Skip to content

Commit 2cf736f

Browse files
committed
Auto merge of #57577 - Centril:rollup, r=Centril
Rollup of 4 pull requests Successful merges: - #57004 (Make `TokenStream` less recursive.) - #57102 (NLL: Add union justifications to conflicting borrows.) - #57337 (rustc: Place wasm linker args first instead of last) - #57549 (Add #[must_use] message to Iterator and Future) Failed merges: r? @ghost
2 parents 1c561d9 + e2311b3 commit 2cf736f

28 files changed

+601
-579
lines changed

src/libcore/future/future.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use task::{Poll, LocalWaker};
2323
///
2424
/// When using a future, you generally won't call `poll` directly, but instead
2525
/// `await!` the value.
26-
#[must_use]
26+
#[must_use = "futures do nothing unless polled"]
2727
pub trait Future {
2828
/// The result of the `Future`.
2929
type Output;

src/libcore/iter/iterator.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ fn _assert_is_object_safe(_: &dyn Iterator<Item=()>) {}
8888
message="`{Self}` is not an iterator"
8989
)]
9090
#[doc(spotlight)]
91-
#[must_use]
91+
#[must_use = "iterators are lazy and do nothing unless consumed"]
9292
pub trait Iterator {
9393
/// The type of the elements being iterated over.
9494
#[stable(feature = "rust1", since = "1.0.0")]

src/libcore/iter/mod.rs

+22-22
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@
243243
//! using it. The compiler will warn us about this kind of behavior:
244244
//!
245245
//! ```text
246-
//! warning: unused result that must be used: iterator adaptors are lazy and
246+
//! warning: unused result that must be used: iterators are lazy and
247247
//! do nothing unless consumed
248248
//! ```
249249
//!
@@ -404,7 +404,7 @@ impl<R: Try> LoopState<R::Ok, R> {
404404
/// [`rev`]: trait.Iterator.html#method.rev
405405
/// [`Iterator`]: trait.Iterator.html
406406
#[derive(Clone, Debug)]
407-
#[must_use = "iterator adaptors are lazy and do nothing unless consumed"]
407+
#[must_use = "iterators are lazy and do nothing unless consumed"]
408408
#[stable(feature = "rust1", since = "1.0.0")]
409409
pub struct Rev<T> {
410410
iter: T
@@ -505,7 +505,7 @@ unsafe impl<I> TrustedLen for Rev<I>
505505
/// [`copied`]: trait.Iterator.html#method.copied
506506
/// [`Iterator`]: trait.Iterator.html
507507
#[unstable(feature = "iter_copied", issue = "57127")]
508-
#[must_use = "iterator adaptors are lazy and do nothing unless consumed"]
508+
#[must_use = "iterators are lazy and do nothing unless consumed"]
509509
#[derive(Clone, Debug)]
510510
pub struct Copied<I> {
511511
it: I,
@@ -605,7 +605,7 @@ unsafe impl<'a, I, T: 'a> TrustedLen for Copied<I>
605605
/// [`cloned`]: trait.Iterator.html#method.cloned
606606
/// [`Iterator`]: trait.Iterator.html
607607
#[stable(feature = "iter_cloned", since = "1.1.0")]
608-
#[must_use = "iterator adaptors are lazy and do nothing unless consumed"]
608+
#[must_use = "iterators are lazy and do nothing unless consumed"]
609609
#[derive(Clone, Debug)]
610610
pub struct Cloned<I> {
611611
it: I,
@@ -717,7 +717,7 @@ unsafe impl<'a, I, T: 'a> TrustedLen for Cloned<I>
717717
/// [`cycle`]: trait.Iterator.html#method.cycle
718718
/// [`Iterator`]: trait.Iterator.html
719719
#[derive(Clone, Debug)]
720-
#[must_use = "iterator adaptors are lazy and do nothing unless consumed"]
720+
#[must_use = "iterators are lazy and do nothing unless consumed"]
721721
#[stable(feature = "rust1", since = "1.0.0")]
722722
pub struct Cycle<I> {
723723
orig: I,
@@ -757,7 +757,7 @@ impl<I> FusedIterator for Cycle<I> where I: Clone + Iterator {}
757757
///
758758
/// [`step_by`]: trait.Iterator.html#method.step_by
759759
/// [`Iterator`]: trait.Iterator.html
760-
#[must_use = "iterator adaptors are lazy and do nothing unless consumed"]
760+
#[must_use = "iterators are lazy and do nothing unless consumed"]
761761
#[stable(feature = "iterator_step_by", since = "1.28.0")]
762762
#[derive(Clone, Debug)]
763763
pub struct StepBy<I> {
@@ -849,7 +849,7 @@ impl<I> ExactSizeIterator for StepBy<I> where I: ExactSizeIterator {}
849849
/// [`chain`]: trait.Iterator.html#method.chain
850850
/// [`Iterator`]: trait.Iterator.html
851851
#[derive(Clone, Debug)]
852-
#[must_use = "iterator adaptors are lazy and do nothing unless consumed"]
852+
#[must_use = "iterators are lazy and do nothing unless consumed"]
853853
#[stable(feature = "rust1", since = "1.0.0")]
854854
pub struct Chain<A, B> {
855855
a: A,
@@ -1100,7 +1100,7 @@ unsafe impl<A, B> TrustedLen for Chain<A, B>
11001100
/// [`zip`]: trait.Iterator.html#method.zip
11011101
/// [`Iterator`]: trait.Iterator.html
11021102
#[derive(Clone, Debug)]
1103-
#[must_use = "iterator adaptors are lazy and do nothing unless consumed"]
1103+
#[must_use = "iterators are lazy and do nothing unless consumed"]
11041104
#[stable(feature = "rust1", since = "1.0.0")]
11051105
pub struct Zip<A, B> {
11061106
a: A,
@@ -1400,7 +1400,7 @@ unsafe impl<A, B> TrustedLen for Zip<A, B>
14001400
/// println!("{:?}", pair);
14011401
/// }
14021402
/// ```
1403-
#[must_use = "iterator adaptors are lazy and do nothing unless consumed"]
1403+
#[must_use = "iterators are lazy and do nothing unless consumed"]
14041404
#[stable(feature = "rust1", since = "1.0.0")]
14051405
#[derive(Clone)]
14061406
pub struct Map<I, F> {
@@ -1511,7 +1511,7 @@ unsafe impl<B, I, F> TrustedRandomAccess for Map<I, F>
15111511
///
15121512
/// [`filter`]: trait.Iterator.html#method.filter
15131513
/// [`Iterator`]: trait.Iterator.html
1514-
#[must_use = "iterator adaptors are lazy and do nothing unless consumed"]
1514+
#[must_use = "iterators are lazy and do nothing unless consumed"]
15151515
#[stable(feature = "rust1", since = "1.0.0")]
15161516
#[derive(Clone)]
15171517
pub struct Filter<I, P> {
@@ -1643,7 +1643,7 @@ impl<I: FusedIterator, P> FusedIterator for Filter<I, P>
16431643
///
16441644
/// [`filter_map`]: trait.Iterator.html#method.filter_map
16451645
/// [`Iterator`]: trait.Iterator.html
1646-
#[must_use = "iterator adaptors are lazy and do nothing unless consumed"]
1646+
#[must_use = "iterators are lazy and do nothing unless consumed"]
16471647
#[stable(feature = "rust1", since = "1.0.0")]
16481648
#[derive(Clone)]
16491649
pub struct FilterMap<I, F> {
@@ -1754,7 +1754,7 @@ impl<B, I: FusedIterator, F> FusedIterator for FilterMap<I, F>
17541754
/// [`enumerate`]: trait.Iterator.html#method.enumerate
17551755
/// [`Iterator`]: trait.Iterator.html
17561756
#[derive(Clone, Debug)]
1757-
#[must_use = "iterator adaptors are lazy and do nothing unless consumed"]
1757+
#[must_use = "iterators are lazy and do nothing unless consumed"]
17581758
#[stable(feature = "rust1", since = "1.0.0")]
17591759
pub struct Enumerate<I> {
17601760
iter: I,
@@ -1915,7 +1915,7 @@ unsafe impl<I> TrustedLen for Enumerate<I>
19151915
/// [`peekable`]: trait.Iterator.html#method.peekable
19161916
/// [`Iterator`]: trait.Iterator.html
19171917
#[derive(Clone, Debug)]
1918-
#[must_use = "iterator adaptors are lazy and do nothing unless consumed"]
1918+
#[must_use = "iterators are lazy and do nothing unless consumed"]
19191919
#[stable(feature = "rust1", since = "1.0.0")]
19201920
pub struct Peekable<I: Iterator> {
19211921
iter: I,
@@ -2066,7 +2066,7 @@ impl<I: Iterator> Peekable<I> {
20662066
///
20672067
/// [`skip_while`]: trait.Iterator.html#method.skip_while
20682068
/// [`Iterator`]: trait.Iterator.html
2069-
#[must_use = "iterator adaptors are lazy and do nothing unless consumed"]
2069+
#[must_use = "iterators are lazy and do nothing unless consumed"]
20702070
#[stable(feature = "rust1", since = "1.0.0")]
20712071
#[derive(Clone)]
20722072
pub struct SkipWhile<I, P> {
@@ -2149,7 +2149,7 @@ impl<I, P> FusedIterator for SkipWhile<I, P>
21492149
///
21502150
/// [`take_while`]: trait.Iterator.html#method.take_while
21512151
/// [`Iterator`]: trait.Iterator.html
2152-
#[must_use = "iterator adaptors are lazy and do nothing unless consumed"]
2152+
#[must_use = "iterators are lazy and do nothing unless consumed"]
21532153
#[stable(feature = "rust1", since = "1.0.0")]
21542154
#[derive(Clone)]
21552155
pub struct TakeWhile<I, P> {
@@ -2233,7 +2233,7 @@ impl<I, P> FusedIterator for TakeWhile<I, P>
22332233
/// [`skip`]: trait.Iterator.html#method.skip
22342234
/// [`Iterator`]: trait.Iterator.html
22352235
#[derive(Clone, Debug)]
2236-
#[must_use = "iterator adaptors are lazy and do nothing unless consumed"]
2236+
#[must_use = "iterators are lazy and do nothing unless consumed"]
22372237
#[stable(feature = "rust1", since = "1.0.0")]
22382238
pub struct Skip<I> {
22392239
iter: I,
@@ -2371,7 +2371,7 @@ impl<I> FusedIterator for Skip<I> where I: FusedIterator {}
23712371
/// [`take`]: trait.Iterator.html#method.take
23722372
/// [`Iterator`]: trait.Iterator.html
23732373
#[derive(Clone, Debug)]
2374-
#[must_use = "iterator adaptors are lazy and do nothing unless consumed"]
2374+
#[must_use = "iterators are lazy and do nothing unless consumed"]
23752375
#[stable(feature = "rust1", since = "1.0.0")]
23762376
pub struct Take<I> {
23772377
iter: I,
@@ -2458,7 +2458,7 @@ unsafe impl<I: TrustedLen> TrustedLen for Take<I> {}
24582458
///
24592459
/// [`scan`]: trait.Iterator.html#method.scan
24602460
/// [`Iterator`]: trait.Iterator.html
2461-
#[must_use = "iterator adaptors are lazy and do nothing unless consumed"]
2461+
#[must_use = "iterators are lazy and do nothing unless consumed"]
24622462
#[stable(feature = "rust1", since = "1.0.0")]
24632463
#[derive(Clone)]
24642464
pub struct Scan<I, St, F> {
@@ -2518,7 +2518,7 @@ impl<B, I, St, F> Iterator for Scan<I, St, F> where
25182518
///
25192519
/// [`flat_map`]: trait.Iterator.html#method.flat_map
25202520
/// [`Iterator`]: trait.Iterator.html
2521-
#[must_use = "iterator adaptors are lazy and do nothing unless consumed"]
2521+
#[must_use = "iterators are lazy and do nothing unless consumed"]
25222522
#[stable(feature = "rust1", since = "1.0.0")]
25232523
pub struct FlatMap<I, U: IntoIterator, F> {
25242524
inner: FlattenCompat<Map<I, F>, <U as IntoIterator>::IntoIter>
@@ -2603,7 +2603,7 @@ impl<I, U, F> FusedIterator for FlatMap<I, U, F>
26032603
///
26042604
/// [`flatten`]: trait.Iterator.html#method.flatten
26052605
/// [`Iterator`]: trait.Iterator.html
2606-
#[must_use = "iterator adaptors are lazy and do nothing unless consumed"]
2606+
#[must_use = "iterators are lazy and do nothing unless consumed"]
26072607
#[stable(feature = "iterator_flatten", since = "1.29.0")]
26082608
pub struct Flatten<I: Iterator>
26092609
where I::Item: IntoIterator {
@@ -2832,7 +2832,7 @@ impl<I, U> DoubleEndedIterator for FlattenCompat<I, U>
28322832
/// [`fuse`]: trait.Iterator.html#method.fuse
28332833
/// [`Iterator`]: trait.Iterator.html
28342834
#[derive(Clone, Debug)]
2835-
#[must_use = "iterator adaptors are lazy and do nothing unless consumed"]
2835+
#[must_use = "iterators are lazy and do nothing unless consumed"]
28362836
#[stable(feature = "rust1", since = "1.0.0")]
28372837
pub struct Fuse<I> {
28382838
iter: I,
@@ -3056,7 +3056,7 @@ impl<I> ExactSizeIterator for Fuse<I> where I: ExactSizeIterator {
30563056
///
30573057
/// [`inspect`]: trait.Iterator.html#method.inspect
30583058
/// [`Iterator`]: trait.Iterator.html
3059-
#[must_use = "iterator adaptors are lazy and do nothing unless consumed"]
3059+
#[must_use = "iterators are lazy and do nothing unless consumed"]
30603060
#[stable(feature = "rust1", since = "1.0.0")]
30613061
#[derive(Clone)]
30623062
pub struct Inspect<I, F> {

src/librustc_borrowck/borrowck/check_loans.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -557,12 +557,8 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> {
557557
if new_loan.loan_path.has_fork(&old_loan.loan_path) && common.is_some() {
558558
let nl = self.bccx.loan_path_to_string(&common.unwrap());
559559
let ol = nl.clone();
560-
let new_loan_msg = format!(" (via `{}`)",
561-
self.bccx.loan_path_to_string(
562-
&new_loan.loan_path));
563-
let old_loan_msg = format!(" (via `{}`)",
564-
self.bccx.loan_path_to_string(
565-
&old_loan.loan_path));
560+
let new_loan_msg = self.bccx.loan_path_to_string(&new_loan.loan_path);
561+
let old_loan_msg = self.bccx.loan_path_to_string(&old_loan.loan_path);
566562
(nl, ol, new_loan_msg, old_loan_msg)
567563
} else {
568564
(self.bccx.loan_path_to_string(&new_loan.loan_path),

src/librustc_codegen_ssa/back/linker.rs

+62-60
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,7 @@ impl LinkerInfo {
8181
}
8282

8383
LinkerFlavor::Lld(LldFlavor::Wasm) => {
84-
Box::new(WasmLd {
85-
cmd,
86-
sess,
87-
info: self
88-
}) as Box<dyn Linker>
84+
Box::new(WasmLd::new(cmd, sess, self)) as Box<dyn Linker>
8985
}
9086
}
9187
}
@@ -876,6 +872,67 @@ pub struct WasmLd<'a> {
876872
info: &'a LinkerInfo,
877873
}
878874

875+
impl<'a> WasmLd<'a> {
876+
fn new(mut cmd: Command, sess: &'a Session, info: &'a LinkerInfo) -> WasmLd<'a> {
877+
// There have been reports in the wild (rustwasm/wasm-bindgen#119) of
878+
// using threads causing weird hangs and bugs. Disable it entirely as
879+
// this isn't yet the bottleneck of compilation at all anyway.
880+
cmd.arg("--no-threads");
881+
882+
// By default LLD only gives us one page of stack (64k) which is a
883+
// little small. Default to a larger stack closer to other PC platforms
884+
// (1MB) and users can always inject their own link-args to override this.
885+
cmd.arg("-z").arg("stack-size=1048576");
886+
887+
// By default LLD's memory layout is:
888+
//
889+
// 1. First, a blank page
890+
// 2. Next, all static data
891+
// 3. Finally, the main stack (which grows down)
892+
//
893+
// This has the unfortunate consequence that on stack overflows you
894+
// corrupt static data and can cause some exceedingly weird bugs. To
895+
// help detect this a little sooner we instead request that the stack is
896+
// placed before static data.
897+
//
898+
// This means that we'll generate slightly larger binaries as references
899+
// to static data will take more bytes in the ULEB128 encoding, but
900+
// stack overflow will be guaranteed to trap as it underflows instead of
901+
// corrupting static data.
902+
cmd.arg("--stack-first");
903+
904+
// FIXME we probably shouldn't pass this but instead pass an explicit
905+
// whitelist of symbols we'll allow to be undefined. Unfortunately
906+
// though we can't handle symbols like `log10` that LLVM injects at a
907+
// super late date without actually parsing object files. For now let's
908+
// stick to this and hopefully fix it before stabilization happens.
909+
cmd.arg("--allow-undefined");
910+
911+
// For now we just never have an entry symbol
912+
cmd.arg("--no-entry");
913+
914+
// Make the default table accessible
915+
cmd.arg("--export-table");
916+
917+
// Rust code should never have warnings, and warnings are often
918+
// indicative of bugs, let's prevent them.
919+
cmd.arg("--fatal-warnings");
920+
921+
// The symbol visibility story is a bit in flux right now with LLD.
922+
// It's... not entirely clear to me what's going on, but this looks to
923+
// make everything work when `export_symbols` isn't otherwise called for
924+
// things like executables.
925+
cmd.arg("--export-dynamic");
926+
927+
// LLD only implements C++-like demangling, which doesn't match our own
928+
// mangling scheme. Tell LLD to not demangle anything and leave it up to
929+
// us to demangle these symbols later.
930+
cmd.arg("--no-demangle");
931+
932+
WasmLd { cmd, sess, info }
933+
}
934+
}
935+
879936
impl<'a> Linker for WasmLd<'a> {
880937
fn link_dylib(&mut self, lib: &str) {
881938
self.cmd.arg("-l").arg(lib);
@@ -982,61 +1039,6 @@ impl<'a> Linker for WasmLd<'a> {
9821039
}
9831040

9841041
fn finalize(&mut self) -> Command {
985-
// There have been reports in the wild (rustwasm/wasm-bindgen#119) of
986-
// using threads causing weird hangs and bugs. Disable it entirely as
987-
// this isn't yet the bottleneck of compilation at all anyway.
988-
self.cmd.arg("--no-threads");
989-
990-
// By default LLD only gives us one page of stack (64k) which is a
991-
// little small. Default to a larger stack closer to other PC platforms
992-
// (1MB) and users can always inject their own link-args to override this.
993-
self.cmd.arg("-z").arg("stack-size=1048576");
994-
995-
// By default LLD's memory layout is:
996-
//
997-
// 1. First, a blank page
998-
// 2. Next, all static data
999-
// 3. Finally, the main stack (which grows down)
1000-
//
1001-
// This has the unfortunate consequence that on stack overflows you
1002-
// corrupt static data and can cause some exceedingly weird bugs. To
1003-
// help detect this a little sooner we instead request that the stack is
1004-
// placed before static data.
1005-
//
1006-
// This means that we'll generate slightly larger binaries as references
1007-
// to static data will take more bytes in the ULEB128 encoding, but
1008-
// stack overflow will be guaranteed to trap as it underflows instead of
1009-
// corrupting static data.
1010-
self.cmd.arg("--stack-first");
1011-
1012-
// FIXME we probably shouldn't pass this but instead pass an explicit
1013-
// whitelist of symbols we'll allow to be undefined. Unfortunately
1014-
// though we can't handle symbols like `log10` that LLVM injects at a
1015-
// super late date without actually parsing object files. For now let's
1016-
// stick to this and hopefully fix it before stabilization happens.
1017-
self.cmd.arg("--allow-undefined");
1018-
1019-
// For now we just never have an entry symbol
1020-
self.cmd.arg("--no-entry");
1021-
1022-
// Make the default table accessible
1023-
self.cmd.arg("--export-table");
1024-
1025-
// Rust code should never have warnings, and warnings are often
1026-
// indicative of bugs, let's prevent them.
1027-
self.cmd.arg("--fatal-warnings");
1028-
1029-
// The symbol visibility story is a bit in flux right now with LLD.
1030-
// It's... not entirely clear to me what's going on, but this looks to
1031-
// make everything work when `export_symbols` isn't otherwise called for
1032-
// things like executables.
1033-
self.cmd.arg("--export-dynamic");
1034-
1035-
// LLD only implements C++-like demangling, which doesn't match our own
1036-
// mangling scheme. Tell LLD to not demangle anything and leave it up to
1037-
// us to demangle these symbols later.
1038-
self.cmd.arg("--no-demangle");
1039-
10401042
::std::mem::replace(&mut self.cmd, Command::new(""))
10411043
}
10421044

0 commit comments

Comments
 (0)