Skip to content

Commit 3623bcc

Browse files
committed
Auto merge of #65565 - tmandry:rollup-s8n9bie, r=tmandry
Rollup of 17 pull requests Successful merges: - #65016 (Always inline `mem::{size_of,align_of}` in debug builds) - #65197 (Prepare `MutVisitor`s to handle interned projections) - #65201 (Disable Go and OCaml bindings when building LLVM) - #65364 (Collect occurrences of empty blocks for mismatched braces diagnostic) - #65417 (Add more coherence tests) - #65434 (Add long error explanation for E0577) - #65455 (Avoid unnecessary `TokenTree` to `TokenStream` conversions) - #65472 (Use a sharded dep node to dep node index map) - #65480 (Speed up `LexicalResolve::expansion()`) - #65496 (properly document panics in div_euclid and rem_euclid) - #65508 (add option to ping llvm ice-breakers to triagebot) - #65511 (save-analysis: Nest tables when processing impl block definitions) - #65513 (reorder fmt docs for more clarity) - #65532 (doc: make BitSet intro more short) - #65540 (show up some extra info when t!() fails) - #65549 (Fix left/right shift typo in wrapping rotate docs) - #65552 (Clarify diagnostics when using `~` as a unary op) Failed merges: - #65471 (Add long error explanation for E0578) r? @ghost
2 parents 518deda + 12d1f86 commit 3623bcc

File tree

57 files changed

+1021
-278
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+1021
-278
lines changed

src/bootstrap/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1126,7 +1126,7 @@ impl Build {
11261126
}
11271127

11281128
let mut paths = Vec::new();
1129-
let contents = t!(fs::read(stamp));
1129+
let contents = t!(fs::read(stamp), &stamp);
11301130
// This is the method we use for extracting paths from the stamp file passed to us. See
11311131
// run_cargo for more information (in compile.rs).
11321132
for part in contents.split(|b| *b == 0) {

src/bootstrap/native.rs

+1-9
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ impl Step for Llvm {
157157
.define("WITH_POLLY", "OFF")
158158
.define("LLVM_ENABLE_TERMINFO", "OFF")
159159
.define("LLVM_ENABLE_LIBEDIT", "OFF")
160+
.define("LLVM_ENABLE_BINDINGS", "OFF")
160161
.define("LLVM_ENABLE_Z3_SOLVER", "OFF")
161162
.define("LLVM_PARALLEL_COMPILE_JOBS", builder.jobs().to_string())
162163
.define("LLVM_TARGET_ARCH", target.split('-').next().unwrap())
@@ -169,15 +170,6 @@ impl Step for Llvm {
169170
}
170171
}
171172

172-
// By default, LLVM will automatically find OCaml and, if it finds it,
173-
// install the LLVM bindings in LLVM_OCAML_INSTALL_PATH, which defaults
174-
// to /usr/bin/ocaml.
175-
// This causes problem for non-root builds of Rust. Side-step the issue
176-
// by setting LLVM_OCAML_INSTALL_PATH to a relative path, so it installs
177-
// in the prefix.
178-
cfg.define("LLVM_OCAML_INSTALL_PATH",
179-
env::var_os("LLVM_OCAML_INSTALL_PATH").unwrap_or_else(|| "usr/lib/ocaml".into()));
180-
181173
let want_lldb = builder.config.lldb_enabled && !self.emscripten;
182174

183175
// This setting makes the LLVM tools link to the dynamic LLVM library,

src/build_helper/lib.rs

+7
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@ macro_rules! t {
2121
Err(e) => panic!("{} failed with {}", stringify!($e), e),
2222
}
2323
};
24+
// it can show extra info in the second parameter
25+
($e:expr, $extra:expr) => {
26+
match $e {
27+
Ok(e) => e,
28+
Err(e) => panic!("{} failed with {} ({:?})", stringify!($e), e, $extra),
29+
}
30+
};
2431
}
2532

2633
// Because Cargo adds the compiler's dylib path to our library search path, llvm-config may

src/liballoc/fmt.rs

+67-44
Original file line numberDiff line numberDiff line change
@@ -86,27 +86,74 @@
8686
//! parameters (corresponding to `format_spec` in the syntax above). These
8787
//! parameters affect the string representation of what's being formatted.
8888
//!
89+
//! ## Width
90+
//!
91+
//! ```
92+
//! // All of these print "Hello x !"
93+
//! println!("Hello {:5}!", "x");
94+
//! println!("Hello {:1$}!", "x", 5);
95+
//! println!("Hello {1:0$}!", 5, "x");
96+
//! println!("Hello {:width$}!", "x", width = 5);
97+
//! ```
98+
//!
99+
//! This is a parameter for the "minimum width" that the format should take up.
100+
//! If the value's string does not fill up this many characters, then the
101+
//! padding specified by fill/alignment will be used to take up the required
102+
//! space (see below).
103+
//!
104+
//! The value for the width can also be provided as a [`usize`] in the list of
105+
//! parameters by adding a postfix `$`, indicating that the second argument is
106+
//! a [`usize`] specifying the width.
107+
//!
108+
//! Referring to an argument with the dollar syntax does not affect the "next
109+
//! argument" counter, so it's usually a good idea to refer to arguments by
110+
//! position, or use named arguments.
111+
//!
89112
//! ## Fill/Alignment
90113
//!
91-
//! The fill character is provided normally in conjunction with the
92-
//! [`width`](#width)
93-
//! parameter. This indicates that if the value being formatted is smaller than
94-
//! `width` some extra characters will be printed around it. The extra
95-
//! characters are specified by `fill`, and the alignment can be one of the
96-
//! following options:
114+
//! ```
115+
//! assert_eq!(format!("Hello {:<5}!", "x"), "Hello x !");
116+
//! assert_eq!(format!("Hello {:-<5}!", "x"), "Hello x----!");
117+
//! assert_eq!(format!("Hello {:^5}!", "x"), "Hello x !");
118+
//! assert_eq!(format!("Hello {:>5}!", "x"), "Hello x!");
119+
//! ```
97120
//!
98-
//! * `<` - the argument is left-aligned in `width` columns
99-
//! * `^` - the argument is center-aligned in `width` columns
100-
//! * `>` - the argument is right-aligned in `width` columns
121+
//! The optional fill character and alignment is provided normally in conjunction with the
122+
//! [`width`](#width) parameter. It must be defined before `width`, right after the `:`.
123+
//! This indicates that if the value being formatted is smaller than
124+
//! `width` some extra characters will be printed around it.
125+
//! Filling comes in the following variants for different alignments:
126+
//!
127+
//! * `[fill]<` - the argument is left-aligned in `width` columns
128+
//! * `[fill]^` - the argument is center-aligned in `width` columns
129+
//! * `[fill]>` - the argument is right-aligned in `width` columns
130+
//!
131+
//! The default [fill/alignment](#fillalignment) for non-numerics is a space and
132+
//! left-aligned. The
133+
//! defaults for numeric formatters is also a space but with right-alignment. If
134+
//! the `0` flag (see below) is specified for numerics, then the implicit fill character is
135+
//! `0`.
101136
//!
102137
//! Note that alignment may not be implemented by some types. In particular, it
103138
//! is not generally implemented for the `Debug` trait. A good way to ensure
104-
//! padding is applied is to format your input, then use this resulting string
105-
//! to pad your output.
139+
//! padding is applied is to format your input, then pad this resulting string
140+
//! to obtain your output:
141+
//!
142+
//! ```
143+
//! println!("Hello {:^15}!", format!("{:?}", Some("hi"))); // => "Hello Some("hi") !"
144+
//! ```
106145
//!
107146
//! ## Sign/`#`/`0`
108147
//!
109-
//! These can all be interpreted as flags for a particular formatter.
148+
//! ```
149+
//! assert_eq!(format!("Hello {:+}!", 5), "Hello +5!");
150+
//! assert_eq!(format!("{:#x}!", 27), "0x1b!");
151+
//! assert_eq!(format!("Hello {:05}!", 5), "Hello 00005!");
152+
//! assert_eq!(format!("Hello {:05}!", -5), "Hello -0005!");
153+
//! assert_eq!(format!("{:#010x}!", 27), "0x0000001b!");
154+
//! ```
155+
//!
156+
//! These are all flags altering the behavior of the formatter.
110157
//!
111158
//! * `+` - This is intended for numeric types and indicates that the sign
112159
//! should always be printed. Positive signs are never printed by
@@ -121,44 +168,15 @@
121168
//! * `#X` - precedes the argument with a `0x`
122169
//! * `#b` - precedes the argument with a `0b`
123170
//! * `#o` - precedes the argument with a `0o`
124-
//! * `0` - This is used to indicate for integer formats that the padding should
171+
//! * `0` - This is used to indicate for integer formats that the padding to `width` should
125172
//! both be done with a `0` character as well as be sign-aware. A format
126173
//! like `{:08}` would yield `00000001` for the integer `1`, while the
127174
//! same format would yield `-0000001` for the integer `-1`. Notice that
128175
//! the negative version has one fewer zero than the positive version.
129176
//! Note that padding zeroes are always placed after the sign (if any)
130177
//! and before the digits. When used together with the `#` flag, a similar
131178
//! rule applies: padding zeroes are inserted after the prefix but before
132-
//! the digits.
133-
//!
134-
//! ## Width
135-
//!
136-
//! This is a parameter for the "minimum width" that the format should take up.
137-
//! If the value's string does not fill up this many characters, then the
138-
//! padding specified by fill/alignment will be used to take up the required
139-
//! space.
140-
//!
141-
//! The default [fill/alignment](#fillalignment) for non-numerics is a space and
142-
//! left-aligned. The
143-
//! defaults for numeric formatters is also a space but with right-alignment. If
144-
//! the `0` flag is specified for numerics, then the implicit fill character is
145-
//! `0`.
146-
//!
147-
//! The value for the width can also be provided as a [`usize`] in the list of
148-
//! parameters by using the dollar syntax indicating that the second argument is
149-
//! a [`usize`] specifying the width, for example:
150-
//!
151-
//! ```
152-
//! // All of these print "Hello x !"
153-
//! println!("Hello {:5}!", "x");
154-
//! println!("Hello {:1$}!", "x", 5);
155-
//! println!("Hello {1:0$}!", 5, "x");
156-
//! println!("Hello {:width$}!", "x", width = 5);
157-
//! ```
158-
//!
159-
//! Referring to an argument with the dollar syntax does not affect the "next
160-
//! argument" counter, so it's usually a good idea to refer to arguments by
161-
//! position, or use named arguments.
179+
//! the digits. The prefix is included in the total width.
162180
//!
163181
//! ## Precision
164182
//!
@@ -235,9 +253,14 @@
235253
//! them with the same character. For example, the `{` character is escaped with
236254
//! `{{` and the `}` character is escaped with `}}`.
237255
//!
256+
//! ```
257+
//! assert_eq!(format!("Hello {{}}"), "Hello {}");
258+
//! assert_eq!(format!("{{ Hello"), "{ Hello");
259+
//! ```
260+
//!
238261
//! # Syntax
239262
//!
240-
//! To summarize, you can find the full grammar of format strings.
263+
//! To summarize, here you can find the full grammar of format strings.
241264
//! The syntax for the formatting language used is drawn from other languages,
242265
//! so it should not be too alien. Arguments are formatted with Python-like
243266
//! syntax, meaning that arguments are surrounded by `{}` instead of the C-like

src/libcore/mem/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ pub fn forget_unsized<T: ?Sized>(t: T) {
236236
/// ```
237237
///
238238
/// [alignment]: ./fn.align_of.html
239-
#[inline]
239+
#[inline(always)]
240240
#[stable(feature = "rust1", since = "1.0.0")]
241241
#[rustc_promotable]
242242
pub const fn size_of<T>() -> usize {
@@ -328,7 +328,7 @@ pub fn min_align_of_val<T: ?Sized>(val: &T) -> usize {
328328
///
329329
/// assert_eq!(4, mem::align_of::<i32>());
330330
/// ```
331-
#[inline]
331+
#[inline(always)]
332332
#[stable(feature = "rust1", since = "1.0.0")]
333333
#[rustc_promotable]
334334
pub const fn align_of<T>() -> usize {

src/libcore/num/mod.rs

+10-2
Original file line numberDiff line numberDiff line change
@@ -1864,7 +1864,7 @@ if `self < 0`, this is equal to round towards +/- infinity.
18641864
18651865
# Panics
18661866
1867-
This function will panic if `rhs` is 0.
1867+
This function will panic if `rhs` is 0 or the division results in overflow.
18681868
18691869
# Examples
18701870
@@ -1903,7 +1903,7 @@ This is done as if by the Euclidean division algorithm -- given
19031903
19041904
# Panics
19051905
1906-
This function will panic if `rhs` is 0.
1906+
This function will panic if `rhs` is 0 or the division results in overflow.
19071907
19081908
# Examples
19091909
@@ -3694,6 +3694,10 @@ Since, for the positive integers, all common
36943694
definitions of division are equal, this
36953695
is exactly equal to `self / rhs`.
36963696
3697+
# Panics
3698+
3699+
This function will panic if `rhs` is 0.
3700+
36973701
# Examples
36983702
36993703
Basic usage:
@@ -3719,6 +3723,10 @@ Since, for the positive integers, all common
37193723
definitions of division are equal, this
37203724
is exactly equal to `self % rhs`.
37213725
3726+
# Panics
3727+
3728+
This function will panic if `rhs` is 0.
3729+
37223730
# Examples
37233731
37243732
Basic usage:

src/libcore/num/wrapping.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ assert_eq!(n.trailing_zeros(), 3);
437437
/// wrapping the truncated bits to the end of the resulting
438438
/// integer.
439439
///
440-
/// Please note this isn't the same operation as the `>>` shifting
440+
/// Please note this isn't the same operation as the `<<` shifting
441441
/// operator!
442442
///
443443
/// # Examples
@@ -463,7 +463,7 @@ assert_eq!(n.trailing_zeros(), 3);
463463
/// wrapping the truncated bits to the beginning of the resulting
464464
/// integer.
465465
///
466-
/// Please note this isn't the same operation as the `<<` shifting
466+
/// Please note this isn't the same operation as the `>>` shifting
467467
/// operator!
468468
///
469469
/// # Examples

src/librustc/dep_graph/graph.rs

+21-8
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet};
44
use rustc_index::vec::{Idx, IndexVec};
55
use smallvec::SmallVec;
66
use rustc_data_structures::sync::{Lrc, Lock, AtomicU32, AtomicU64, Ordering};
7+
use rustc_data_structures::sharded::{self, Sharded};
78
use std::sync::atomic::Ordering::SeqCst;
89
use std::env;
910
use std::hash::Hash;
@@ -381,7 +382,7 @@ impl DepGraph {
381382
#[inline]
382383
pub fn read(&self, v: DepNode) {
383384
if let Some(ref data) = self.data {
384-
let map = data.current.node_to_node_index.lock();
385+
let map = data.current.node_to_node_index.get_shard_by_value(&v).lock();
385386
if let Some(dep_node_index) = map.get(&v).copied() {
386387
std::mem::drop(map);
387388
data.read_index(dep_node_index);
@@ -405,6 +406,7 @@ impl DepGraph {
405406
.unwrap()
406407
.current
407408
.node_to_node_index
409+
.get_shard_by_value(dep_node)
408410
.lock()
409411
.get(dep_node)
410412
.cloned()
@@ -414,7 +416,11 @@ impl DepGraph {
414416
#[inline]
415417
pub fn dep_node_exists(&self, dep_node: &DepNode) -> bool {
416418
if let Some(ref data) = self.data {
417-
data.current.node_to_node_index.lock().contains_key(dep_node)
419+
data.current
420+
.node_to_node_index
421+
.get_shard_by_value(&dep_node)
422+
.lock()
423+
.contains_key(dep_node)
418424
} else {
419425
false
420426
}
@@ -595,7 +601,11 @@ impl DepGraph {
595601

596602
#[cfg(not(parallel_compiler))]
597603
{
598-
debug_assert!(!data.current.node_to_node_index.lock().contains_key(dep_node));
604+
debug_assert!(!data.current
605+
.node_to_node_index
606+
.get_shard_by_value(dep_node)
607+
.lock()
608+
.contains_key(dep_node));
599609
debug_assert!(data.colors.get(prev_dep_node_index).is_none());
600610
}
601611

@@ -927,7 +937,7 @@ struct DepNodeData {
927937
/// acquire the lock on `data.`
928938
pub(super) struct CurrentDepGraph {
929939
data: Lock<IndexVec<DepNodeIndex, DepNodeData>>,
930-
node_to_node_index: Lock<FxHashMap<DepNode, DepNodeIndex>>,
940+
node_to_node_index: Sharded<FxHashMap<DepNode, DepNodeIndex>>,
931941

932942
/// Used to trap when a specific edge is added to the graph.
933943
/// This is used for debug purposes and is only active with `debug_assertions`.
@@ -985,8 +995,8 @@ impl CurrentDepGraph {
985995

986996
CurrentDepGraph {
987997
data: Lock::new(IndexVec::with_capacity(new_node_count_estimate)),
988-
node_to_node_index: Lock::new(FxHashMap::with_capacity_and_hasher(
989-
new_node_count_estimate,
998+
node_to_node_index: Sharded::new(|| FxHashMap::with_capacity_and_hasher(
999+
new_node_count_estimate / sharded::SHARDS,
9901000
Default::default(),
9911001
)),
9921002
anon_id_seed: stable_hasher.finish(),
@@ -1035,7 +1045,10 @@ impl CurrentDepGraph {
10351045
edges: SmallVec<[DepNodeIndex; 8]>,
10361046
fingerprint: Fingerprint
10371047
) -> DepNodeIndex {
1038-
debug_assert!(!self.node_to_node_index.lock().contains_key(&dep_node));
1048+
debug_assert!(!self.node_to_node_index
1049+
.get_shard_by_value(&dep_node)
1050+
.lock()
1051+
.contains_key(&dep_node));
10391052
self.intern_node(dep_node, edges, fingerprint)
10401053
}
10411054

@@ -1045,7 +1058,7 @@ impl CurrentDepGraph {
10451058
edges: SmallVec<[DepNodeIndex; 8]>,
10461059
fingerprint: Fingerprint
10471060
) -> DepNodeIndex {
1048-
match self.node_to_node_index.lock().entry(dep_node) {
1061+
match self.node_to_node_index.get_shard_by_value(&dep_node).lock().entry(dep_node) {
10491062
Entry::Occupied(entry) => *entry.get(),
10501063
Entry::Vacant(entry) => {
10511064
let mut data = self.data.lock();

0 commit comments

Comments
 (0)