Skip to content

Commit 7b13c62

Browse files
committedJan 2, 2022
Auto merge of #92482 - matthiaskrgr:rollup-uso1zi0, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - #84083 (Clarify the guarantees that ThreadId does and doesn't make.) - #91593 (Remove unnecessary bounds for some Hash{Map,Set} methods) - #92297 (Reduce compile time of rustbuild) - #92332 (Add test for where clause order) - #92438 (Enforce formatting for rustc_codegen_cranelift) - #92463 (Remove pronunciation guide from Vec<T>) - #92468 (Emit an error for `--cfg=)`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents dd3ac41 + 2004a51 commit 7b13c62

File tree

19 files changed

+398
-380
lines changed

19 files changed

+398
-380
lines changed
 

‎Cargo.lock

-24
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,7 @@ dependencies = [
175175
"filetime",
176176
"getopts",
177177
"ignore",
178-
"lazy_static",
179178
"libc",
180-
"merge",
181179
"num_cpus",
182180
"once_cell",
183181
"opener",
@@ -2221,28 +2219,6 @@ dependencies = [
22212219
"autocfg",
22222220
]
22232221

2224-
[[package]]
2225-
name = "merge"
2226-
version = "0.1.0"
2227-
source = "registry+https://github.com/rust-lang/crates.io-index"
2228-
checksum = "10bbef93abb1da61525bbc45eeaff6473a41907d19f8f9aa5168d214e10693e9"
2229-
dependencies = [
2230-
"merge_derive",
2231-
"num-traits",
2232-
]
2233-
2234-
[[package]]
2235-
name = "merge_derive"
2236-
version = "0.1.0"
2237-
source = "registry+https://github.com/rust-lang/crates.io-index"
2238-
checksum = "209d075476da2e63b4b29e72a2ef627b840589588e71400a25e3565c4f849d07"
2239-
dependencies = [
2240-
"proc-macro-error",
2241-
"proc-macro2",
2242-
"quote",
2243-
"syn",
2244-
]
2245-
22462222
[[package]]
22472223
name = "minifier"
22482224
version = "0.0.41"

‎compiler/rustc_interface/src/interface.rs

+19-19
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use rustc_errors::registry::Registry;
1111
use rustc_errors::{ErrorReported, Handler};
1212
use rustc_lint::LintStore;
1313
use rustc_middle::ty;
14-
use rustc_parse::new_parser_from_source_str;
14+
use rustc_parse::maybe_new_parser_from_source_str;
1515
use rustc_query_impl::QueryCtxt;
1616
use rustc_session::config::{self, ErrorOutputType, Input, OutputFilenames};
1717
use rustc_session::early_error;
@@ -91,7 +91,6 @@ pub fn parse_cfgspecs(cfgspecs: Vec<String>) -> FxHashSet<(String, Option<String
9191
s
9292
)));
9393
let filename = FileName::cfg_spec_source_code(&s);
94-
let mut parser = new_parser_from_source_str(&sess, filename, s.to_string());
9594

9695
macro_rules! error {
9796
($reason: expr) => {
@@ -102,26 +101,27 @@ pub fn parse_cfgspecs(cfgspecs: Vec<String>) -> FxHashSet<(String, Option<String
102101
};
103102
}
104103

105-
match &mut parser.parse_meta_item() {
106-
Ok(meta_item) if parser.token == token::Eof => {
107-
if meta_item.path.segments.len() != 1 {
108-
error!("argument key must be an identifier");
109-
}
110-
match &meta_item.kind {
111-
MetaItemKind::List(..) => {
112-
error!(r#"expected `key` or `key="value"`"#);
113-
}
114-
MetaItemKind::NameValue(lit) if !lit.kind.is_str() => {
115-
error!("argument value must be a string");
104+
match maybe_new_parser_from_source_str(&sess, filename, s.to_string()) {
105+
Ok(mut parser) => match &mut parser.parse_meta_item() {
106+
Ok(meta_item) if parser.token == token::Eof => {
107+
if meta_item.path.segments.len() != 1 {
108+
error!("argument key must be an identifier");
116109
}
117-
MetaItemKind::NameValue(..) | MetaItemKind::Word => {
118-
let ident = meta_item.ident().expect("multi-segment cfg key");
119-
return (ident.name, meta_item.value_str());
110+
match &meta_item.kind {
111+
MetaItemKind::List(..) => {}
112+
MetaItemKind::NameValue(lit) if !lit.kind.is_str() => {
113+
error!("argument value must be a string");
114+
}
115+
MetaItemKind::NameValue(..) | MetaItemKind::Word => {
116+
let ident = meta_item.ident().expect("multi-segment cfg key");
117+
return (ident.name, meta_item.value_str());
118+
}
120119
}
121120
}
122-
}
123-
Ok(..) => {}
124-
Err(err) => err.cancel(),
121+
Ok(..) => {}
122+
Err(err) => err.cancel(),
123+
},
124+
Err(errs) => errs.into_iter().for_each(|mut err| err.cancel()),
125125
}
126126

127127
error!(r#"expected `key` or `key="value"`"#);

‎library/alloc/src/vec/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ use self::spec_extend::SpecExtend;
148148
#[cfg(not(no_global_oom_handling))]
149149
mod spec_extend;
150150

151-
/// A contiguous growable array type, written as `Vec<T>` and pronounced 'vector'.
151+
/// A contiguous growable array type, written as `Vec<T>`, short for 'vector'.
152152
///
153153
/// # Examples
154154
///

‎library/std/src/collections/hash/map.rs

+77-77
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,33 @@ impl<K, V, S> HashMap<K, V, S> {
349349
Keys { inner: self.iter() }
350350
}
351351

352+
/// Creates a consuming iterator visiting all the keys in arbitrary order.
353+
/// The map cannot be used after calling this.
354+
/// The iterator element type is `K`.
355+
///
356+
/// # Examples
357+
///
358+
/// ```
359+
/// use std::collections::HashMap;
360+
///
361+
/// let map = HashMap::from([
362+
/// ("a", 1),
363+
/// ("b", 2),
364+
/// ("c", 3),
365+
/// ]);
366+
///
367+
/// let mut vec: Vec<&str> = map.into_keys().collect();
368+
/// // The `IntoKeys` iterator produces keys in arbitrary order, so the
369+
/// // keys must be sorted to test them against a sorted array.
370+
/// vec.sort_unstable();
371+
/// assert_eq!(vec, ["a", "b", "c"]);
372+
/// ```
373+
#[inline]
374+
#[stable(feature = "map_into_keys_values", since = "1.54.0")]
375+
pub fn into_keys(self) -> IntoKeys<K, V> {
376+
IntoKeys { inner: self.into_iter() }
377+
}
378+
352379
/// An iterator visiting all values in arbitrary order.
353380
/// The iterator element type is `&'a V`.
354381
///
@@ -399,6 +426,33 @@ impl<K, V, S> HashMap<K, V, S> {
399426
ValuesMut { inner: self.iter_mut() }
400427
}
401428

429+
/// Creates a consuming iterator visiting all the values in arbitrary order.
430+
/// The map cannot be used after calling this.
431+
/// The iterator element type is `V`.
432+
///
433+
/// # Examples
434+
///
435+
/// ```
436+
/// use std::collections::HashMap;
437+
///
438+
/// let map = HashMap::from([
439+
/// ("a", 1),
440+
/// ("b", 2),
441+
/// ("c", 3),
442+
/// ]);
443+
///
444+
/// let mut vec: Vec<i32> = map.into_values().collect();
445+
/// // The `IntoValues` iterator produces values in arbitrary order, so
446+
/// // the values must be sorted to test them against a sorted array.
447+
/// vec.sort_unstable();
448+
/// assert_eq!(vec, [1, 2, 3]);
449+
/// ```
450+
#[inline]
451+
#[stable(feature = "map_into_keys_values", since = "1.54.0")]
452+
pub fn into_values(self) -> IntoValues<K, V> {
453+
IntoValues { inner: self.into_iter() }
454+
}
455+
402456
/// An iterator visiting all key-value pairs in arbitrary order.
403457
/// The iterator element type is `(&'a K, &'a V)`.
404458
///
@@ -555,6 +609,29 @@ impl<K, V, S> HashMap<K, V, S> {
555609
DrainFilter { base: self.base.drain_filter(pred) }
556610
}
557611

612+
/// Retains only the elements specified by the predicate.
613+
///
614+
/// In other words, remove all pairs `(k, v)` such that `f(&k, &mut v)` returns `false`.
615+
/// The elements are visited in unsorted (and unspecified) order.
616+
///
617+
/// # Examples
618+
///
619+
/// ```
620+
/// use std::collections::HashMap;
621+
///
622+
/// let mut map: HashMap<i32, i32> = (0..8).map(|x| (x, x*10)).collect();
623+
/// map.retain(|&k, _| k % 2 == 0);
624+
/// assert_eq!(map.len(), 4);
625+
/// ```
626+
#[inline]
627+
#[stable(feature = "retain_hash_collection", since = "1.18.0")]
628+
pub fn retain<F>(&mut self, f: F)
629+
where
630+
F: FnMut(&K, &mut V) -> bool,
631+
{
632+
self.base.retain(f)
633+
}
634+
558635
/// Clears the map, removing all key-value pairs. Keeps the allocated memory
559636
/// for reuse.
560637
///
@@ -937,83 +1014,6 @@ where
9371014
{
9381015
self.base.remove_entry(k)
9391016
}
940-
941-
/// Retains only the elements specified by the predicate.
942-
///
943-
/// In other words, remove all pairs `(k, v)` such that `f(&k, &mut v)` returns `false`.
944-
/// The elements are visited in unsorted (and unspecified) order.
945-
///
946-
/// # Examples
947-
///
948-
/// ```
949-
/// use std::collections::HashMap;
950-
///
951-
/// let mut map: HashMap<i32, i32> = (0..8).map(|x| (x, x*10)).collect();
952-
/// map.retain(|&k, _| k % 2 == 0);
953-
/// assert_eq!(map.len(), 4);
954-
/// ```
955-
#[inline]
956-
#[stable(feature = "retain_hash_collection", since = "1.18.0")]
957-
pub fn retain<F>(&mut self, f: F)
958-
where
959-
F: FnMut(&K, &mut V) -> bool,
960-
{
961-
self.base.retain(f)
962-
}
963-
964-
/// Creates a consuming iterator visiting all the keys in arbitrary order.
965-
/// The map cannot be used after calling this.
966-
/// The iterator element type is `K`.
967-
///
968-
/// # Examples
969-
///
970-
/// ```
971-
/// use std::collections::HashMap;
972-
///
973-
/// let map = HashMap::from([
974-
/// ("a", 1),
975-
/// ("b", 2),
976-
/// ("c", 3),
977-
/// ]);
978-
///
979-
/// let mut vec: Vec<&str> = map.into_keys().collect();
980-
/// // The `IntoKeys` iterator produces keys in arbitrary order, so the
981-
/// // keys must be sorted to test them against a sorted array.
982-
/// vec.sort_unstable();
983-
/// assert_eq!(vec, ["a", "b", "c"]);
984-
/// ```
985-
#[inline]
986-
#[stable(feature = "map_into_keys_values", since = "1.54.0")]
987-
pub fn into_keys(self) -> IntoKeys<K, V> {
988-
IntoKeys { inner: self.into_iter() }
989-
}
990-
991-
/// Creates a consuming iterator visiting all the values in arbitrary order.
992-
/// The map cannot be used after calling this.
993-
/// The iterator element type is `V`.
994-
///
995-
/// # Examples
996-
///
997-
/// ```
998-
/// use std::collections::HashMap;
999-
///
1000-
/// let map = HashMap::from([
1001-
/// ("a", 1),
1002-
/// ("b", 2),
1003-
/// ("c", 3),
1004-
/// ]);
1005-
///
1006-
/// let mut vec: Vec<i32> = map.into_values().collect();
1007-
/// // The `IntoValues` iterator produces values in arbitrary order, so
1008-
/// // the values must be sorted to test them against a sorted array.
1009-
/// vec.sort_unstable();
1010-
/// assert_eq!(vec, [1, 2, 3]);
1011-
/// ```
1012-
#[inline]
1013-
#[stable(feature = "map_into_keys_values", since = "1.54.0")]
1014-
pub fn into_values(self) -> IntoValues<K, V> {
1015-
IntoValues { inner: self.into_iter() }
1016-
}
10171017
}
10181018

10191019
impl<K, V, S> HashMap<K, V, S>

‎library/std/src/collections/hash/set.rs

+22-22
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,28 @@ impl<T, S> HashSet<T, S> {
290290
DrainFilter { base: self.base.drain_filter(pred) }
291291
}
292292

293+
/// Retains only the elements specified by the predicate.
294+
///
295+
/// In other words, remove all elements `e` such that `f(&e)` returns `false`.
296+
/// The elements are visited in unsorted (and unspecified) order.
297+
///
298+
/// # Examples
299+
///
300+
/// ```
301+
/// use std::collections::HashSet;
302+
///
303+
/// let mut set = HashSet::from([1, 2, 3, 4, 5, 6]);
304+
/// set.retain(|&k| k % 2 == 0);
305+
/// assert_eq!(set.len(), 3);
306+
/// ```
307+
#[stable(feature = "retain_hash_collection", since = "1.18.0")]
308+
pub fn retain<F>(&mut self, f: F)
309+
where
310+
F: FnMut(&T) -> bool,
311+
{
312+
self.base.retain(f)
313+
}
314+
293315
/// Clears the set, removing all values.
294316
///
295317
/// # Examples
@@ -906,28 +928,6 @@ where
906928
{
907929
self.base.take(value)
908930
}
909-
910-
/// Retains only the elements specified by the predicate.
911-
///
912-
/// In other words, remove all elements `e` such that `f(&e)` returns `false`.
913-
/// The elements are visited in unsorted (and unspecified) order.
914-
///
915-
/// # Examples
916-
///
917-
/// ```
918-
/// use std::collections::HashSet;
919-
///
920-
/// let mut set = HashSet::from([1, 2, 3, 4, 5, 6]);
921-
/// set.retain(|&k| k % 2 == 0);
922-
/// assert_eq!(set.len(), 3);
923-
/// ```
924-
#[stable(feature = "retain_hash_collection", since = "1.18.0")]
925-
pub fn retain<F>(&mut self, f: F)
926-
where
927-
F: FnMut(&T) -> bool,
928-
{
929-
self.base.retain(f)
930-
}
931931
}
932932

933933
#[stable(feature = "rust1", since = "1.0.0")]

‎library/std/src/thread/mod.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -972,10 +972,13 @@ pub fn park_timeout(dur: Duration) {
972972

973973
/// A unique identifier for a running thread.
974974
///
975-
/// A `ThreadId` is an opaque object that has a unique value for each thread
976-
/// that creates one. `ThreadId`s are not guaranteed to correspond to a thread's
977-
/// system-designated identifier. A `ThreadId` can be retrieved from the [`id`]
978-
/// method on a [`Thread`].
975+
/// A `ThreadId` is an opaque object that uniquely identifies each thread
976+
/// created during the lifetime of a process. `ThreadId`s are guaranteed not to
977+
/// be reused, even when a thread terminates. `ThreadId`s are under the control
978+
/// of Rust's standard library and there may not be any relationship between
979+
/// `ThreadId` and the underlying platform's notion of a thread identifier --
980+
/// the two concepts cannot, therefore, be used interchangeably. A `ThreadId`
981+
/// can be retrieved from the [`id`] method on a [`Thread`].
979982
///
980983
/// # Examples
981984
///

‎rustfmt.toml

+5-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ ignore = [
1919
"library/backtrace",
2020
"library/portable-simd",
2121
"library/stdarch",
22-
"compiler/rustc_codegen_cranelift",
2322
"compiler/rustc_codegen_gcc",
2423
"src/doc/book",
2524
"src/doc/edition-guide",
@@ -36,4 +35,9 @@ ignore = [
3635
"src/tools/rust-analyzer",
3736
"src/tools/rustfmt",
3837
"src/tools/rust-installer",
38+
39+
# these are ignored by a standard cargo fmt run
40+
"compiler/rustc_codegen_cranelift/y.rs", # running rustfmt breaks this file
41+
"compiler/rustc_codegen_cranelift/example",
42+
"compiler/rustc_codegen_cranelift/scripts",
3943
]

‎src/bootstrap/Cargo.toml

-2
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,9 @@ libc = "0.2"
4444
serde = { version = "1.0.8", features = ["derive"] }
4545
serde_json = "1.0.2"
4646
toml = "0.5"
47-
lazy_static = "1.3.0"
4847
time = "0.1"
4948
ignore = "0.4.10"
5049
opener = "0.5"
51-
merge = "0.1.0"
5250
once_cell = "1.7.2"
5351

5452
[target.'cfg(windows)'.dependencies.winapi]

0 commit comments

Comments
 (0)
Please sign in to comment.