From 651d289405b9d48005a3e6a14f0f76a792d60c5f Mon Sep 17 00:00:00 2001 From: Smitty Date: Sat, 6 Feb 2021 19:17:14 -0500 Subject: [PATCH 01/18] Add note about encoding when null bytes found --- compiler/rustc_parse/src/lexer/mod.rs | 3 +++ src/test/ui/parser/issue-66473.stderr | Bin 2660 -> 5180 bytes src/test/ui/parser/issue-68629.stderr | Bin 1441 -> 1819 bytes src/test/ui/parser/issue-68730.stderr | Bin 966 -> 1218 bytes 4 files changed, 3 insertions(+) diff --git a/compiler/rustc_parse/src/lexer/mod.rs b/compiler/rustc_parse/src/lexer/mod.rs index 4a638ec3f8020..bb63dbd5303a3 100644 --- a/compiler/rustc_parse/src/lexer/mod.rs +++ b/compiler/rustc_parse/src/lexer/mod.rs @@ -268,6 +268,9 @@ impl<'a> StringReader<'a> { // tokens like `<<` from `rustc_lexer`, and then add fancier error recovery to it, // as there will be less overall work to do this way. let token = unicode_chars::check_for_substitution(self, start, c, &mut err); + if c == '\x00' { + err.help("source files must be encoded in UTF-8, unexpected null bytes might occur when the wrong text encoding is used"); + } err.emit(); token? } diff --git a/src/test/ui/parser/issue-66473.stderr b/src/test/ui/parser/issue-66473.stderr index b370b125cfefda4f82cbb4866fec528b1465a2ef..25f462d3dca98b14c5cc32ca326f3292438b1cef 100644 GIT binary patch literal 5180 zcmd^@%}T>S6h^y_&rtY8myLGXB&`8mi6C?(x>8Eova7aoaLl{2cV$PxTKx&8)w3rYN@nBxsUiZxbT=xRUm)AF^nNo(_ zAn-cv6RAQkY~`zXb$UI#;^^bO_TwtnfxhF=&Th@^z1o#~6?@8W=SXQf3!#LOF=3QV zN#W5bjUj<}ED}nPaopWrx!p!S2wKc2*7-|rrc(@`_44~{oaSSRVD(GLQ>C~q`oyt18b6YtV!CnCh3_qNm{vj>%!J*>p+fhA@SEw%m;EwN;qfAGJ!j)Qtouhj~Cs^&I!6)&G;<>J+< mJfMDAcNNBOEv^PbA@$N|C5Cbth?a+$q^C?6g~H+~$N2;tYx|1; delta 143 zcmdm^@kC_8&55~AlV>t&fv9FCFqO*;rovgklp`yc(q;owqU_p0m6JF?KZ4Q xcaRHAt>Fe!(|N#D6EB#`xbBOU_S8 zO;O0qQwR-l)3wl1D9uZ)C`e5%0Se}o=Hw_ORhEF%XQpSADC8$6mli3MXQbvSlw_nT zlo#dar7M)AR+K=@$prE;ixo&TEIRY=WC&QD2A zQOL|w2n})5wa`&0%}cE)NKGyQ3g(sOSW7Acfxq~+W6rb696fvU!DK} delta 23 dcmX@ad5nER>f{ql%9Gg`U4gXAW?rVPOaN)z2nPTF From a9bb3fbd86c89ac85d4cc21ae4f17e1001825aba Mon Sep 17 00:00:00 2001 From: Smitty Date: Sun, 7 Feb 2021 10:05:43 -0500 Subject: [PATCH 02/18] Add tests for new UTF-16 behavior --- src/test/ui/parser/utf16-be-without-bom.rs | Bin 0 -> 125 bytes src/test/ui/parser/utf16-be-without-bom.stderr | Bin 0 -> 3485 bytes src/test/ui/parser/utf16-le-without-bom.rs | Bin 0 -> 126 bytes src/test/ui/parser/utf16-le-without-bom.stderr | Bin 0 -> 3448 bytes 4 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 src/test/ui/parser/utf16-be-without-bom.rs create mode 100644 src/test/ui/parser/utf16-be-without-bom.stderr create mode 100644 src/test/ui/parser/utf16-le-without-bom.rs create mode 100644 src/test/ui/parser/utf16-le-without-bom.stderr diff --git a/src/test/ui/parser/utf16-be-without-bom.rs b/src/test/ui/parser/utf16-be-without-bom.rs new file mode 100644 index 0000000000000000000000000000000000000000..22aa19717873a58a19379fb56c99177e018ecf06 GIT binary patch literal 125 zcmZX~!3x4a3`Nnb=PO=!6_nY}*JQ96km5^;DGK7hTi5RHg;Ogm!sD{_Oba&bTpTI!WlysILyEjtToZ06Qk`+Ys)U!0&^=V0)XPsz?;TTe`q`~Z|SAbkr4;41|h;qh2oriN8)wwQkm z?`)Cqj`T&1%OBKz)o1DiH@%z;0uM;7a!2>gCWr}hCnL~{8qH^obUW{$FEQ~Cs4^wk literal 0 HcmV?d00001 diff --git a/src/test/ui/parser/utf16-le-without-bom.stderr b/src/test/ui/parser/utf16-le-without-bom.stderr new file mode 100644 index 0000000000000000000000000000000000000000..857cc085b2e818ffbc2288e36950741cef4df03a GIT binary patch literal 3448 zcmds)&r8EF7>0B1U-1ea6joj593!A75rmyYZzA2=uWMMBjQp^ZZU4L3CSxaEz=P!0 zl$Z84H#+h79J; zSWE~c3sq7HA@Tb1m<~IBOj<6eu>PfVO@qm&-R8x#_Cpti(`ajwur;C8N={*EY4_g| zekBZ?p)yJ6#SQ^$lo2*8esdlwB7cN(vdGx$og1l`Vh()?3#y3k}vNH9!>xN literal 0 HcmV?d00001 From c6cb014ad650f7b46c357d40f469c116cc752575 Mon Sep 17 00:00:00 2001 From: Smitty Date: Sun, 7 Feb 2021 11:02:53 -0500 Subject: [PATCH 03/18] Clarify error message wording --- compiler/rustc_parse/src/lexer/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_parse/src/lexer/mod.rs b/compiler/rustc_parse/src/lexer/mod.rs index bb63dbd5303a3..4bf870eb7ce7e 100644 --- a/compiler/rustc_parse/src/lexer/mod.rs +++ b/compiler/rustc_parse/src/lexer/mod.rs @@ -269,7 +269,7 @@ impl<'a> StringReader<'a> { // as there will be less overall work to do this way. let token = unicode_chars::check_for_substitution(self, start, c, &mut err); if c == '\x00' { - err.help("source files must be encoded in UTF-8, unexpected null bytes might occur when the wrong text encoding is used"); + err.help("source files must contain UTF-8 encoded text, unexpected null bytes might occur when a different encoding is used"); } err.emit(); token? From ed8c68644c9a352f61c3b4591b6fc18653e2ffc2 Mon Sep 17 00:00:00 2001 From: Smitty Date: Sun, 7 Feb 2021 11:11:38 -0500 Subject: [PATCH 04/18] Bless tests with new error wording --- src/test/ui/parser/issue-66473.stderr | Bin 5180 -> 5260 bytes src/test/ui/parser/issue-68629.stderr | Bin 1819 -> 1831 bytes src/test/ui/parser/issue-68730.stderr | Bin 1218 -> 1226 bytes .../ui/parser/utf16-be-without-bom.stderr | Bin 3485 -> 3537 bytes .../ui/parser/utf16-le-without-bom.stderr | Bin 3448 -> 3500 bytes 5 files changed, 0 insertions(+), 0 deletions(-) diff --git a/src/test/ui/parser/issue-66473.stderr b/src/test/ui/parser/issue-66473.stderr index 25f462d3dca98b14c5cc32ca326f3292438b1cef..8a16d7f955129811997464d47c4e10238db77340 100644 GIT binary patch literal 5260 zcmd^@%}&BV6h>LsXCV2EE~zrm7Hpy`V`9R}=t@Hh?JYFm44EInsC!?|ce0d(R1MID z3uU_KqLbd+@21H;IV7c!Aq<~zG3QWvAT>k^EhfZ6JeZfZ*L`yU*S)~;<@L>Jrj#K! z2)s`FM5@pWTlpzoon8;GIQn?6{kV#Apzk=evs-g}uXg2L#W&@*bBt*^3!#LOF(J*S zr0{5zMl84$E~H|1F%`25s+e6=)!H+vV#zj-;eT-^2lb#{s}-14&5`UXUfy!$;?=5e zH86fy-YMUT|9>L#!}1RKv+>q$N^n}ry67;1kcjT122x>of+&dcA8M1c^TVp#=VEiO pmGLVNsbBVHg+W|Pu)$DBy|iPApS6h^y_&rtY8myLGXB&`8mi6C?(x>8Eova7aoaLl{2cV$PxTKx&8)w3rYN@nBxsUiZxbT=xRUm)AF^nNo(_ zAn-cv6RAQkY~`zXb$UI#;^^bO_TwtnfxhF=&Th@^z1o#~6?@8W=SXQf3!#LOF=3QV zN#W5bjUj<}ED}nPaopWrx!p!S2wKc2*7-|rrc(@`_44~{oaSSRVD(GLQ>C~q`oyt18b6YtV!CnCh3_qNm{vj>%!J*>p+fhA@SEw%m;EwN;qfAGJ!j)Qtouhj~Cs^&I!6)&G;<>J+< mJfMDAcNNBOEv^PbA@$N|C5Cbth?a+$q^C?6g~H+~$N2;tYx|1; diff --git a/src/test/ui/parser/issue-68629.stderr b/src/test/ui/parser/issue-68629.stderr index 034c714f3d66f157aabf818ede719e864e5a43f0..19c9ef30f9049537fca85864287462c8f875eee4 100644 GIT binary patch delta 154 zcmbQux14W-6QfjeeqKppW}ZT5h?}m3LTX-eeoAVJLP=^x$z*wEO|C?Rl+3iW)S}e9 Z$puWIlOHg;lcZw~Nvfqc7cj481^~NuGxGod delta 146 zcmZ3^H=A#R6QgiaszPdBa(+r`ib7_dLTHGauEk_MW=-Cbj8uj4qWrvcg_6{Y$%)L; YlUFe|lBC*d@>wQ#;&g0IWIo0W0F`qu#sB~S diff --git a/src/test/ui/parser/issue-68730.stderr b/src/test/ui/parser/issue-68730.stderr index ff683bf8be773b10c05684f0befce1d2ba6beb1d..8602abacabd325988d4f2b8a9116d85688365341 100644 GIT binary patch delta 101 zcmX@ad5UvFyHs+1UP)qRozbZFZAZlrE(0l(T82 zW@p;u!#wk2SSO*wC*7&|_o24PlQB{yqpkHu@|;cHVM`jz2_sQ3ensz9Pv4aa2HQ6nS0@&??6b3NHNJ=YT>q l47ehV@ypKpu2NP?+f9jS9QlTZY>2t0PpO>2w$7L&`2q8pTI!WlysILyEjtToZ06Qk`+Ys)U!0&^=V0)XPsz?;TTe`q`~Z|SAQ|7}~+WvQ^t(2~`11@BC zNq9--+{NKt(pqT_C#O;^B#bSzg{ooIlqAQSTXi=Hkf!%Ie|UPncDBw2X-nxs*hV>< zj@9f+8{X$VKZbQO8exr^Nd`7!1rz@2f?fK%72B}g2=Kli_49XVsGV~d<#b7?MN0-V zXDmu3Z6PFHUmnvTNS3Oi3YM0(<4;S=IhEEwkgjbp{EyAY4+79*V;_dF#|EEugXp8f53rrrTy)CILYx<6072%9 zGJ!Dv#TY>^P=Zlr5Ng6GLkQMkd@0=W>}VzUUiJUerhn)RO47FCxzgI!ZGN%93X-Zn-6 literal 3448 zcmds)&r8EF7>0B1U-1ea6joj593!A75rmyYZzA2=uWMMBjQp^ZZU4L3CSxaEz=P!0 zl$Z84H#+h79J; zSWE~c3sq7HA@Tb1m<~IBOj<6eu>PfVO@qm&-R8x#_Cpti(`ajwur;C8N={*EY4_g| zekBZ?p)yJ6#SQ^$lo2*8esdlwB7cN(vdGx$og1l`Vh()?3#y3k}vNH9!>xN From bff4e937ab1aeb5961371391e67f71137ee96e0d Mon Sep 17 00:00:00 2001 From: Ivan Tham Date: Mon, 22 Feb 2021 18:48:32 +0800 Subject: [PATCH 05/18] Add missing "see its documentation for more" stdio StdoutLock and StderrLock does not have example, it would be better to leave "see its documentation for more" like iter docs. --- library/std/src/io/stdio.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/std/src/io/stdio.rs b/library/std/src/io/stdio.rs index d1f9049c8fabb..1e72c9e0611ea 100644 --- a/library/std/src/io/stdio.rs +++ b/library/std/src/io/stdio.rs @@ -497,7 +497,7 @@ pub struct Stdout { /// A locked reference to the [`Stdout`] handle. /// /// This handle implements the [`Write`] trait, and is constructed via -/// the [`Stdout::lock`] method. +/// the [`Stdout::lock`] method. See its documentation for more. /// /// ### Note: Windows Portability Consideration /// When operating in a console, the Windows implementation of this stream does not support @@ -711,7 +711,7 @@ pub struct Stderr { /// A locked reference to the [`Stderr`] handle. /// /// This handle implements the [`Write`] trait and is constructed via -/// the [`Stderr::lock`] method. +/// the [`Stderr::lock`] method. See its documentation for more. /// /// ### Note: Windows Portability Consideration /// When operating in a console, the Windows implementation of this stream does not support From c0c44360112e4574954c8016c59847a3f651bdaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Sinan=20A=C4=9Facan?= Date: Mon, 22 Feb 2021 16:55:20 +0300 Subject: [PATCH 06/18] Remove a redundant macro Turn the macro into a function. Also remove unused 'span' argument. --- .../rustc_typeck/src/check/method/suggest.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/compiler/rustc_typeck/src/check/method/suggest.rs b/compiler/rustc_typeck/src/check/method/suggest.rs index 721e8ec54f05f..e6c551ff4d41b 100644 --- a/compiler/rustc_typeck/src/check/method/suggest.rs +++ b/compiler/rustc_typeck/src/check/method/suggest.rs @@ -517,21 +517,21 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } if self.is_fn_ty(&rcvr_ty, span) { - macro_rules! report_function { - ($span:expr, $name:expr) => { - err.note(&format!( - "`{}` is a function, perhaps you wish to call it", - $name - )); - }; + fn report_function( + err: &mut DiagnosticBuilder<'_>, + name: T, + ) { + err.note( + &format!("`{}` is a function, perhaps you wish to call it", name,), + ); } if let SelfSource::MethodCall(expr) = source { if let Ok(expr_string) = tcx.sess.source_map().span_to_snippet(expr.span) { - report_function!(expr.span, expr_string); + report_function(&mut err, expr_string); } else if let ExprKind::Path(QPath::Resolved(_, ref path)) = expr.kind { if let Some(segment) = path.segments.last() { - report_function!(expr.span, segment.ident); + report_function(&mut err, segment.ident); } } } From 55626eda08cb309503c9425fc52770a7831fab7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Mi=C4=85sko?= Date: Wed, 24 Feb 2021 00:00:00 +0000 Subject: [PATCH 07/18] Use log level to control partitioning debug output --- .../src/monomorphize/partitioning/mod.rs | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/compiler/rustc_mir/src/monomorphize/partitioning/mod.rs b/compiler/rustc_mir/src/monomorphize/partitioning/mod.rs index b9fcd32250dcf..b68a8104fba72 100644 --- a/compiler/rustc_mir/src/monomorphize/partitioning/mod.rs +++ b/compiler/rustc_mir/src/monomorphize/partitioning/mod.rs @@ -239,17 +239,22 @@ where I: Iterator>, 'tcx: 'a, { - if cfg!(debug_assertions) { - debug!("{}", label); + let dump = move || { + use std::fmt::Write; + + let s = &mut String::new(); + let _ = writeln!(s, "{}", label); for cgu in cgus { - debug!("CodegenUnit {} estimated size {} :", cgu.name(), cgu.size_estimate()); + let _ = + writeln!(s, "CodegenUnit {} estimated size {} :", cgu.name(), cgu.size_estimate()); for (mono_item, linkage) in cgu.items() { let symbol_name = mono_item.symbol_name(tcx).name; let symbol_hash_start = symbol_name.rfind('h'); let symbol_hash = symbol_hash_start.map_or("", |i| &symbol_name[i..]); - debug!( + let _ = writeln!( + s, " - {} [{:?}] [{}] estimated size {}", mono_item, linkage, @@ -258,9 +263,13 @@ where ); } - debug!(""); + let _ = writeln!(s, ""); } - } + + std::mem::take(s) + }; + + debug!("{}", dump()); } #[inline(never)] // give this a place in the profiler From e130e9cf7787ef83f9cada14b7a2579b09c6a558 Mon Sep 17 00:00:00 2001 From: Wesley Wiser Date: Thu, 25 Feb 2021 18:25:38 -0500 Subject: [PATCH 08/18] Update measureme dependency to the latest version This version adds the ability to use `rdpmc` hardware-based performance counters instead of wall-clock time for measuring duration. This also introduces a dependency on the `perf-event-open-sys` crate on Linux which is used when using hardware counters. --- Cargo.lock | 16 ++++++++++++++-- compiler/rustc_codegen_llvm/Cargo.toml | 2 +- compiler/rustc_data_structures/Cargo.toml | 2 +- compiler/rustc_middle/Cargo.toml | 2 +- src/tools/tidy/src/deps.rs | 1 + 5 files changed, 18 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c1011c0f479cb..357e66654e07c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2080,11 +2080,14 @@ dependencies = [ [[package]] name = "measureme" -version = "9.0.0" +version = "9.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22bf8d885d073610aee20e7fa205c4341ed32a761dbde96da5fd96301a8d3e82" +checksum = "4a98e07fe802486895addb2b5467f33f205e82c426bfaf350f5d8109b137767c" dependencies = [ + "log", + "memmap", "parking_lot", + "perf-event-open-sys", "rustc-hash", "smallvec 1.6.1", ] @@ -2481,6 +2484,15 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" +[[package]] +name = "perf-event-open-sys" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce9bedf5da2c234fdf2391ede2b90fabf585355f33100689bc364a3ea558561a" +dependencies = [ + "libc", +] + [[package]] name = "pest" version = "2.1.3" diff --git a/compiler/rustc_codegen_llvm/Cargo.toml b/compiler/rustc_codegen_llvm/Cargo.toml index ebbb852f21cc8..6dad087a31ba2 100644 --- a/compiler/rustc_codegen_llvm/Cargo.toml +++ b/compiler/rustc_codegen_llvm/Cargo.toml @@ -11,7 +11,7 @@ doctest = false [dependencies] bitflags = "1.0" libc = "0.2" -measureme = "9.0.0" +measureme = "9.1.0" snap = "1" tracing = "0.1" rustc_middle = { path = "../rustc_middle" } diff --git a/compiler/rustc_data_structures/Cargo.toml b/compiler/rustc_data_structures/Cargo.toml index e3476517de583..818c43642566c 100644 --- a/compiler/rustc_data_structures/Cargo.toml +++ b/compiler/rustc_data_structures/Cargo.toml @@ -25,7 +25,7 @@ rustc-hash = "1.1.0" smallvec = { version = "1.6.1", features = ["union", "may_dangle"] } rustc_index = { path = "../rustc_index", package = "rustc_index" } bitflags = "1.2.1" -measureme = "9.0.0" +measureme = "9.1.0" libc = "0.2" stacker = "0.1.12" tempfile = "3.0.5" diff --git a/compiler/rustc_middle/Cargo.toml b/compiler/rustc_middle/Cargo.toml index 7de398a1898e5..0674233165501 100644 --- a/compiler/rustc_middle/Cargo.toml +++ b/compiler/rustc_middle/Cargo.toml @@ -28,6 +28,6 @@ rustc_ast = { path = "../rustc_ast" } rustc_span = { path = "../rustc_span" } chalk-ir = "0.55.0" smallvec = { version = "1.6.1", features = ["union", "may_dangle"] } -measureme = "9.0.0" +measureme = "9.1.0" rustc_session = { path = "../rustc_session" } rustc_type_ir = { path = "../rustc_type_ir" } diff --git a/src/tools/tidy/src/deps.rs b/src/tools/tidy/src/deps.rs index f127086724fc6..c1395f37aa8eb 100644 --- a/src/tools/tidy/src/deps.rs +++ b/src/tools/tidy/src/deps.rs @@ -131,6 +131,7 @@ const PERMITTED_DEPENDENCIES: &[&str] = &[ "parking_lot", "parking_lot_core", "pathdiff", + "perf-event-open-sys", "pkg-config", "polonius-engine", "ppv-lite86", From c7091f5a07fa665344d0ebafae5480f54337ef88 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Fri, 26 Feb 2021 11:01:23 +0100 Subject: [PATCH 09/18] Link crtbegin/crtend on musl to terminate .eh_frame For some targets, rustc uses a "CRT fallback", where it links CRT object files it ships instead of letting the host compiler link them. On musl, rustc currently links crt1, crti and crtn (provided by libc), but does not link crtbegin and crtend (provided by libgcc). In particular, crtend is responsible for terminating the .eh_frame section. Lack of terminator may result in segfaults during unwinding, as reported in #47551 and encountered by the LLVM 12 update in #81451. This patch links crtbegin and crtend for musl as well, following the table at the top of crt_objects.rs. --- compiler/rustc_target/src/spec/crt_objects.rs | 21 ++++++++++++------- src/bootstrap/compile.rs | 6 ++++++ 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/compiler/rustc_target/src/spec/crt_objects.rs b/compiler/rustc_target/src/spec/crt_objects.rs index 32da16a2d8ca8..51a48147e6b62 100644 --- a/compiler/rustc_target/src/spec/crt_objects.rs +++ b/compiler/rustc_target/src/spec/crt_objects.rs @@ -64,17 +64,24 @@ pub(super) fn all(obj: &str) -> CrtObjects { pub(super) fn pre_musl_fallback() -> CrtObjects { new(&[ - (LinkOutputKind::DynamicNoPicExe, &["crt1.o", "crti.o"]), - (LinkOutputKind::DynamicPicExe, &["Scrt1.o", "crti.o"]), - (LinkOutputKind::StaticNoPicExe, &["crt1.o", "crti.o"]), - (LinkOutputKind::StaticPicExe, &["rcrt1.o", "crti.o"]), - (LinkOutputKind::DynamicDylib, &["crti.o"]), - (LinkOutputKind::StaticDylib, &["crti.o"]), + (LinkOutputKind::DynamicNoPicExe, &["crt1.o", "crti.o", "crtbegin.o"]), + (LinkOutputKind::DynamicPicExe, &["Scrt1.o", "crti.o", "crtbeginS.o"]), + (LinkOutputKind::StaticNoPicExe, &["crt1.o", "crti.o", "crtbegin.o"]), + (LinkOutputKind::StaticPicExe, &["rcrt1.o", "crti.o", "crtbeginS.o"]), + (LinkOutputKind::DynamicDylib, &["crti.o", "crtbeginS.o"]), + (LinkOutputKind::StaticDylib, &["crti.o", "crtbeginS.o"]), ]) } pub(super) fn post_musl_fallback() -> CrtObjects { - all("crtn.o") + new(&[ + (LinkOutputKind::DynamicNoPicExe, &["crtend.o", "crtn.o"]), + (LinkOutputKind::DynamicPicExe, &["crtendS.o", "crtn.o"]), + (LinkOutputKind::StaticNoPicExe, &["crtend.o", "crtn.o"]), + (LinkOutputKind::StaticPicExe, &["crtendS.o", "crtn.o"]), + (LinkOutputKind::DynamicDylib, &["crtendS.o", "crtn.o"]), + (LinkOutputKind::StaticDylib, &["crtendS.o", "crtn.o"]), + ]) } pub(super) fn pre_mingw_fallback() -> CrtObjects { diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs index 7d5e3d05b11fa..859e38dc34647 100644 --- a/src/bootstrap/compile.rs +++ b/src/bootstrap/compile.rs @@ -189,6 +189,12 @@ fn copy_self_contained_objects( DependencyType::TargetSelfContained, ); } + for &obj in &["crtbegin.o", "crtbeginS.o", "crtend.o", "crtendS.o"] { + let src = compiler_file(builder, builder.cc(target), target, obj); + let target = libdir_self_contained.join(obj); + builder.copy(&src, &target); + target_deps.push((target, DependencyType::TargetSelfContained)); + } } else if target.ends_with("-wasi") { let srcdir = builder.wasi_root(target).unwrap().join("lib/wasm32-wasi"); for &obj in &["crt1.o", "crt1-reactor.o"] { From dd502cb3436756ecb32a3024e7cd9d855348227c Mon Sep 17 00:00:00 2001 From: Trevor Spiteri Date: Fri, 26 Feb 2021 19:03:44 +0100 Subject: [PATCH 10/18] doc: cube root, not cubic root Like we say square root, not quadratic root. --- library/std/src/f32.rs | 2 +- library/std/src/f64.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/library/std/src/f32.rs b/library/std/src/f32.rs index f51b2c2462166..c16d27fa1f58c 100644 --- a/library/std/src/f32.rs +++ b/library/std/src/f32.rs @@ -503,7 +503,7 @@ impl f32 { unsafe { cmath::fdimf(self, other) } } - /// Returns the cubic root of a number. + /// Returns the cube root of a number. /// /// # Examples /// diff --git a/library/std/src/f64.rs b/library/std/src/f64.rs index 8c41e4486865c..4c95df5ffe04a 100644 --- a/library/std/src/f64.rs +++ b/library/std/src/f64.rs @@ -505,7 +505,7 @@ impl f64 { unsafe { cmath::fdim(self, other) } } - /// Returns the cubic root of a number. + /// Returns the cube root of a number. /// /// # Examples /// From 5661fe3fa9e19715d5532d002341098e52fa0c76 Mon Sep 17 00:00:00 2001 From: Lucas De Angelis Date: Fri, 26 Feb 2021 22:09:39 +0100 Subject: [PATCH 11/18] Fix intra-doc handling of `Self` in enum Fixes #82209 --- src/librustdoc/passes/collect_intra_doc_links.rs | 3 +++ src/test/rustdoc/issue-82209.rs | 8 ++++++++ 2 files changed, 11 insertions(+) create mode 100644 src/test/rustdoc/issue-82209.rs diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs index 6d9e3d0b9eab0..2e1197b3fe7b6 100644 --- a/src/librustdoc/passes/collect_intra_doc_links.rs +++ b/src/librustdoc/passes/collect_intra_doc_links.rs @@ -838,6 +838,9 @@ impl<'a, 'tcx> DocFolder for LinkCollector<'a, 'tcx> { debug!("looking for the `Self` type"); let self_id = if item.is_fake() { None + // Checking if the item is a field in a variant in an enum + } else if (matches!(self.cx.tcx.def_kind(item.def_id), DefKind::Field) && matches!(self.cx.tcx.def_kind(self.cx.tcx.parent(item.def_id).unwrap()), DefKind::Variant)) { + self.cx.tcx.parent(item.def_id).and_then(|item_id| self.cx.tcx.parent(item_id)) } else if matches!( self.cx.tcx.def_kind(item.def_id), DefKind::AssocConst diff --git a/src/test/rustdoc/issue-82209.rs b/src/test/rustdoc/issue-82209.rs new file mode 100644 index 0000000000000..72a585a705eef --- /dev/null +++ b/src/test/rustdoc/issue-82209.rs @@ -0,0 +1,8 @@ +#![deny(broken_intra_doc_links)] +pub enum Foo { + Bar { + abc: i32, + /// [Self::Bar::abc] + xyz: i32, + }, +} From d95b7b31c7e55e4c10dece4b41b5602f450e776e Mon Sep 17 00:00:00 2001 From: Lucas De Angelis Date: Fri, 26 Feb 2021 22:48:53 +0100 Subject: [PATCH 12/18] Fix formatting --- src/librustdoc/passes/collect_intra_doc_links.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs index 2e1197b3fe7b6..5d7df80663cad 100644 --- a/src/librustdoc/passes/collect_intra_doc_links.rs +++ b/src/librustdoc/passes/collect_intra_doc_links.rs @@ -839,7 +839,12 @@ impl<'a, 'tcx> DocFolder for LinkCollector<'a, 'tcx> { let self_id = if item.is_fake() { None // Checking if the item is a field in a variant in an enum - } else if (matches!(self.cx.tcx.def_kind(item.def_id), DefKind::Field) && matches!(self.cx.tcx.def_kind(self.cx.tcx.parent(item.def_id).unwrap()), DefKind::Variant)) { + } else if (matches!(self.cx.tcx.def_kind(item.def_id), DefKind::Field) + && matches!( + self.cx.tcx.def_kind(self.cx.tcx.parent(item.def_id).unwrap()), + DefKind::Variant + )) + { self.cx.tcx.parent(item.def_id).and_then(|item_id| self.cx.tcx.parent(item_id)) } else if matches!( self.cx.tcx.def_kind(item.def_id), From 02cc85065ed0595ea0894770cfd6e6a9316ad256 Mon Sep 17 00:00:00 2001 From: Lucas De Angelis Date: Fri, 26 Feb 2021 23:48:45 +0100 Subject: [PATCH 13/18] Update src/librustdoc/passes/collect_intra_doc_links.rs Co-authored-by: Joshua Nelson --- src/librustdoc/passes/collect_intra_doc_links.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs index 5d7df80663cad..c047f8729adc1 100644 --- a/src/librustdoc/passes/collect_intra_doc_links.rs +++ b/src/librustdoc/passes/collect_intra_doc_links.rs @@ -838,7 +838,7 @@ impl<'a, 'tcx> DocFolder for LinkCollector<'a, 'tcx> { debug!("looking for the `Self` type"); let self_id = if item.is_fake() { None - // Checking if the item is a field in a variant in an enum + // Checking if the item is a field in an enum variant } else if (matches!(self.cx.tcx.def_kind(item.def_id), DefKind::Field) && matches!( self.cx.tcx.def_kind(self.cx.tcx.parent(item.def_id).unwrap()), From 5835f6defa96e488ceb537e666b0ba92b85b6fdb Mon Sep 17 00:00:00 2001 From: Lucas De Angelis Date: Sat, 27 Feb 2021 01:08:05 +0100 Subject: [PATCH 14/18] Move test file, add test of generated link --- src/test/rustdoc/{ => intra-doc}/issue-82209.rs | 3 +++ 1 file changed, 3 insertions(+) rename src/test/rustdoc/{ => intra-doc}/issue-82209.rs (55%) diff --git a/src/test/rustdoc/issue-82209.rs b/src/test/rustdoc/intra-doc/issue-82209.rs similarity index 55% rename from src/test/rustdoc/issue-82209.rs rename to src/test/rustdoc/intra-doc/issue-82209.rs index 72a585a705eef..76618cdce4cd2 100644 --- a/src/test/rustdoc/issue-82209.rs +++ b/src/test/rustdoc/intra-doc/issue-82209.rs @@ -1,3 +1,4 @@ +#![crate_name = "foo"] #![deny(broken_intra_doc_links)] pub enum Foo { Bar { @@ -6,3 +7,5 @@ pub enum Foo { xyz: i32, }, } + +// @has foo/enum.Foo.html '//a/@href' '../foo/enum.Foo.html#variant.Bar.field.abc' From e026e18e3fe7c19e7072cac86b9e9296d551ab5b Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Sat, 27 Feb 2021 12:37:05 +0200 Subject: [PATCH 15/18] Add ARIA role to sidebar toggle in Rustdoc This indicates that the div is an interactive element, and makes the sidebar toggle "clickable" in assistive technologies. Fixes #82582 --- src/librustdoc/html/layout.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustdoc/html/layout.rs b/src/librustdoc/html/layout.rs index e5a686bd07d07..73c106f5ae032 100644 --- a/src/librustdoc/html/layout.rs +++ b/src/librustdoc/html/layout.rs @@ -75,7 +75,7 @@ crate fn render( \ {before_content}\ \ From d94b4e81e4ce8bc21c192ed928f33991ffe78365 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 27 Feb 2021 19:07:19 +0300 Subject: [PATCH 16/18] clarify RW lock's priority gotcha In particular, the following program works on Linux, but deadlocks on mac: use std::{ sync::{Arc, RwLock}, thread, time::Duration, }; fn main() { let lock = Arc::new(RwLock::new(())); let r1 = thread::spawn({ let lock = Arc::clone(&lock); move || { let _rg = lock.read(); eprintln!("r1/1"); sleep(1000); let _rg = lock.read(); eprintln!("r1/2"); sleep(5000); } }); sleep(100); let w = thread::spawn({ let lock = Arc::clone(&lock); move || { let _wg = lock.write(); eprintln!("w"); } }); sleep(100); let r2 = thread::spawn({ let lock = Arc::clone(&lock); move || { let _rg = lock.read(); eprintln!("r2"); sleep(2000); } }); r1.join().unwrap(); r2.join().unwrap(); w.join().unwrap(); } fn sleep(ms: u64) { std::thread::sleep(Duration::from_millis(ms)) } --- library/std/src/sync/rwlock.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/library/std/src/sync/rwlock.rs b/library/std/src/sync/rwlock.rs index d967779ce361d..4e706b270963b 100644 --- a/library/std/src/sync/rwlock.rs +++ b/library/std/src/sync/rwlock.rs @@ -23,7 +23,9 @@ use crate::sys_common::rwlock as sys; /// /// The priority policy of the lock is dependent on the underlying operating /// system's implementation, and this type does not guarantee that any -/// particular policy will be used. +/// particular policy will be used. In particular, a writer which is waiting to +/// acquire the lock in `write` might or might not block future calls to +/// `read`. /// /// The type parameter `T` represents the data that this lock protects. It is /// required that `T` satisfies [`Send`] to be shared across threads and From 261c952ba66f130096edf530fae50bd0640e09e4 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 27 Feb 2021 19:44:17 +0300 Subject: [PATCH 17/18] Update library/std/src/sync/rwlock.rs Co-authored-by: Steven Fackler --- library/std/src/sync/rwlock.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/std/src/sync/rwlock.rs b/library/std/src/sync/rwlock.rs index 4e706b270963b..0298f59228cbe 100644 --- a/library/std/src/sync/rwlock.rs +++ b/library/std/src/sync/rwlock.rs @@ -24,7 +24,7 @@ use crate::sys_common::rwlock as sys; /// The priority policy of the lock is dependent on the underlying operating /// system's implementation, and this type does not guarantee that any /// particular policy will be used. In particular, a writer which is waiting to -/// acquire the lock in `write` might or might not block future calls to +/// acquire the lock in `write` might or might not block concurrent calls to /// `read`. /// /// The type parameter `T` represents the data that this lock protects. It is From 632a89529a6a951b83f805f4e1bb07d127b4e69c Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 27 Feb 2021 21:01:02 +0100 Subject: [PATCH 18/18] Add a getter for Frame.loc This is necessary for Priroda. --- compiler/rustc_mir/src/interpret/eval_context.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/compiler/rustc_mir/src/interpret/eval_context.rs b/compiler/rustc_mir/src/interpret/eval_context.rs index 1ba87358b1c3d..6b796eb372199 100644 --- a/compiler/rustc_mir/src/interpret/eval_context.rs +++ b/compiler/rustc_mir/src/interpret/eval_context.rs @@ -226,6 +226,16 @@ impl<'mir, 'tcx, Tag> Frame<'mir, 'tcx, Tag> { } impl<'mir, 'tcx, Tag, Extra> Frame<'mir, 'tcx, Tag, Extra> { + /// Get the current location within the Frame. + /// + /// If this is `Err`, we are not currently executing any particular statement in + /// this frame (can happen e.g. during frame initialization, and during unwinding on + /// frames without cleanup code). + /// We basically abuse `Result` as `Either`. + pub fn current_loc(&self) -> Result { + self.loc + } + /// Return the `SourceInfo` of the current instruction. pub fn current_source_info(&self) -> Option<&mir::SourceInfo> { self.loc.ok().map(|loc| self.body.source_info(loc))