From 7b652d341e9a476658af8a9186972ce73ec38c3c Mon Sep 17 00:00:00 2001 From: Niels Sascha Reedijk Date: Sat, 19 Sep 2020 09:17:53 +0100 Subject: [PATCH 01/19] Haiku: explicitly set CMAKE_SYSTEM_NAME when cross-compiling This resolves issues where the cross-build of LLVM fails because it tries to link to the host's system libraries instead of the target's system libraries. --- src/bootstrap/native.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/bootstrap/native.rs b/src/bootstrap/native.rs index 6bba00ee85e14..37d6fab070b8e 100644 --- a/src/bootstrap/native.rs +++ b/src/bootstrap/native.rs @@ -378,6 +378,8 @@ fn configure_cmake( cfg.define("CMAKE_SYSTEM_NAME", "FreeBSD"); } else if target.contains("windows") { cfg.define("CMAKE_SYSTEM_NAME", "Windows"); + } else if target.contains("haiku") { + cfg.define("CMAKE_SYSTEM_NAME", "Haiku"); } // When cross-compiling we should also set CMAKE_SYSTEM_VERSION, but in // that case like CMake we cannot easily determine system version either. From cc0b718aaa35bfb2a9ca5dd59078ae7e54dbc4bb Mon Sep 17 00:00:00 2001 From: Olivia Crain Date: Thu, 15 Oct 2020 08:40:40 -0500 Subject: [PATCH 02/19] Mark inout asm! operands as used in liveness pass --- compiler/rustc_passes/src/liveness.rs | 2 +- src/test/ui/liveness/liveness-issue-77915.rs | 36 ++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 src/test/ui/liveness/liveness-issue-77915.rs diff --git a/compiler/rustc_passes/src/liveness.rs b/compiler/rustc_passes/src/liveness.rs index ae810b9e79a5f..7288015e17029 100644 --- a/compiler/rustc_passes/src/liveness.rs +++ b/compiler/rustc_passes/src/liveness.rs @@ -1174,7 +1174,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { } } hir::InlineAsmOperand::InOut { expr, .. } => { - succ = self.write_place(expr, succ, ACC_READ | ACC_WRITE); + succ = self.write_place(expr, succ, ACC_READ | ACC_WRITE | ACC_USE); } hir::InlineAsmOperand::SplitInOut { out_expr, .. } => { if let Some(expr) = out_expr { diff --git a/src/test/ui/liveness/liveness-issue-77915.rs b/src/test/ui/liveness/liveness-issue-77915.rs new file mode 100644 index 0000000000000..300e4ad8b0106 --- /dev/null +++ b/src/test/ui/liveness/liveness-issue-77915.rs @@ -0,0 +1,36 @@ +// Ensure inout asm! operands are marked as used by the liveness pass + +// only-x86_64 +// check-pass + +#![feature(asm)] +#![allow(dead_code)] +#![deny(unused_variables)] + +// Tests the single variable inout case +unsafe fn rep_movsb(mut dest: *mut u8, mut src: *const u8, mut n: usize) -> *mut u8 { + while n != 0 { + asm!( + "rep movsb", + inout("rcx") n, + inout("rsi") src, + inout("rdi") dest, + ); + } + dest +} + +// Tests the split inout case +unsafe fn rep_movsb2(mut dest: *mut u8, mut src: *const u8, mut n: usize) -> *mut u8 { + while n != 0 { + asm!( + "rep movsb", + inout("rcx") n, + inout("rsi") src => src, + inout("rdi") dest, + ); + } + dest +} + +fn main() {} From fd193f2d7f7ebed086de9977951cac76211533b0 Mon Sep 17 00:00:00 2001 From: Olivia Crain Date: Sat, 17 Oct 2020 16:36:58 -0500 Subject: [PATCH 03/19] Treat InOut variables like other input variables --- compiler/rustc_passes/src/liveness.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_passes/src/liveness.rs b/compiler/rustc_passes/src/liveness.rs index 7288015e17029..e88b6cb11e5cf 100644 --- a/compiler/rustc_passes/src/liveness.rs +++ b/compiler/rustc_passes/src/liveness.rs @@ -1174,7 +1174,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { } } hir::InlineAsmOperand::InOut { expr, .. } => { - succ = self.write_place(expr, succ, ACC_READ | ACC_WRITE | ACC_USE); + succ = self.write_place(expr, succ, ACC_READ | ACC_WRITE); } hir::InlineAsmOperand::SplitInOut { out_expr, .. } => { if let Some(expr) = out_expr { @@ -1199,7 +1199,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { } } hir::InlineAsmOperand::InOut { expr, .. } => { - succ = self.propagate_through_place_components(expr, succ); + succ = self.propagate_through_expr(expr, succ); } hir::InlineAsmOperand::SplitInOut { in_expr, out_expr, .. } => { if let Some(expr) = out_expr { From 4e2c59a970695b2809a0f68f2ffe415ebdb04913 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sun, 18 Oct 2020 21:54:59 +0200 Subject: [PATCH 04/19] Greatly improve display for small mobile devices screens --- src/librustdoc/html/static/rustdoc.css | 35 ++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/librustdoc/html/static/rustdoc.css b/src/librustdoc/html/static/rustdoc.css index 8c8a00d47bc07..0ab97ab3f6384 100644 --- a/src/librustdoc/html/static/rustdoc.css +++ b/src/librustdoc/html/static/rustdoc.css @@ -1560,6 +1560,41 @@ h4 > .notable-traits { #titles, #titles > div { height: 73px; } + + #main > table:not(.table-display) td { + word-break: break-word; + min-width: 10%; + } + + .search-container > div { + display: block; + width: calc(100% - 37px); + } + + #crate-search { + width: 100%; + border-radius: 4px; + border: 0; + } + + #crate-search + .search-input { + width: calc(100% + 71px); + margin-left: -36px; + } + + #theme-picker, #settings-menu { + padding: 5px; + width: 31px; + height: 31px; + } + + #theme-picker { + margin-top: -2px; + } + + #settings-menu { + top: 7px; + } } h3.notable { From 17c6c5932c8de780fcd1d06aff230e8cc6bca9f8 Mon Sep 17 00:00:00 2001 From: Olivia Crain Date: Sun, 18 Oct 2020 23:51:10 -0500 Subject: [PATCH 05/19] Mark InOut operands as used in RWU table with write_place --- compiler/rustc_passes/src/liveness.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_passes/src/liveness.rs b/compiler/rustc_passes/src/liveness.rs index e88b6cb11e5cf..7288015e17029 100644 --- a/compiler/rustc_passes/src/liveness.rs +++ b/compiler/rustc_passes/src/liveness.rs @@ -1174,7 +1174,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { } } hir::InlineAsmOperand::InOut { expr, .. } => { - succ = self.write_place(expr, succ, ACC_READ | ACC_WRITE); + succ = self.write_place(expr, succ, ACC_READ | ACC_WRITE | ACC_USE); } hir::InlineAsmOperand::SplitInOut { out_expr, .. } => { if let Some(expr) = out_expr { @@ -1199,7 +1199,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { } } hir::InlineAsmOperand::InOut { expr, .. } => { - succ = self.propagate_through_expr(expr, succ); + succ = self.propagate_through_place_components(expr, succ); } hir::InlineAsmOperand::SplitInOut { in_expr, out_expr, .. } => { if let Some(expr) = out_expr { From 8f0bceda13ac871dd452841d3b6aa049f9f649a1 Mon Sep 17 00:00:00 2001 From: Olivia Crain Date: Sun, 18 Oct 2020 23:52:15 -0500 Subject: [PATCH 06/19] Refactor liveness-issue-77915 to liveness-asm and improve tests --- src/test/ui/liveness/liveness-asm.rs | 43 ++++++++++++++++++++ src/test/ui/liveness/liveness-asm.stderr | 23 +++++++++++ src/test/ui/liveness/liveness-issue-77915.rs | 36 ---------------- 3 files changed, 66 insertions(+), 36 deletions(-) create mode 100644 src/test/ui/liveness/liveness-asm.rs create mode 100644 src/test/ui/liveness/liveness-asm.stderr delete mode 100644 src/test/ui/liveness/liveness-issue-77915.rs diff --git a/src/test/ui/liveness/liveness-asm.rs b/src/test/ui/liveness/liveness-asm.rs new file mode 100644 index 0000000000000..e64335a8cc589 --- /dev/null +++ b/src/test/ui/liveness/liveness-asm.rs @@ -0,0 +1,43 @@ +// Ensure inout asm! operands are marked as used by the liveness pass + +// check-pass + +#![feature(asm)] +#![allow(dead_code)] +#![warn(unused_assignments)] +#![warn(unused_variables)] + +// Test the single inout case +unsafe fn f1(mut src: *const u8) { + asm!("/*{0}*/", inout(reg) src); //~ WARN value assigned to `src` is never read +} + +unsafe fn f2(mut src: *const u8) -> *const u8 { + asm!("/*{0}*/", inout(reg) src); + src +} + +// Test the split inout case +unsafe fn f3(mut src: *const u8) { + asm!("/*{0}*/", inout(reg) src => src); //~ WARN value assigned to `src` is never read +} + +unsafe fn f4(mut src: *const u8) -> *const u8 { + asm!("/*{0}*/", inout(reg) src => src); + src +} + +// Tests the use of field projections +struct S { + field: *mut u8, +} + +unsafe fn f5(src: &mut S) { + asm!("/*{0}*/", inout(reg) src.field); +} + +unsafe fn f6(src: &mut S) { + asm!("/*{0}*/", inout(reg) src.field => src.field); +} + +fn main() {} diff --git a/src/test/ui/liveness/liveness-asm.stderr b/src/test/ui/liveness/liveness-asm.stderr new file mode 100644 index 0000000000000..b8c04b5c4429e --- /dev/null +++ b/src/test/ui/liveness/liveness-asm.stderr @@ -0,0 +1,23 @@ +warning: value assigned to `src` is never read + --> $DIR/liveness-asm.rs:12:32 + | +LL | asm!("/*{0}*/", inout(reg) src); + | ^^^ + | +note: the lint level is defined here + --> $DIR/liveness-asm.rs:7:9 + | +LL | #![warn(unused_assignments)] + | ^^^^^^^^^^^^^^^^^^ + = help: maybe it is overwritten before being read? + +warning: value assigned to `src` is never read + --> $DIR/liveness-asm.rs:22:39 + | +LL | asm!("/*{0}*/", inout(reg) src => src); + | ^^^ + | + = help: maybe it is overwritten before being read? + +warning: 2 warnings emitted + diff --git a/src/test/ui/liveness/liveness-issue-77915.rs b/src/test/ui/liveness/liveness-issue-77915.rs deleted file mode 100644 index 300e4ad8b0106..0000000000000 --- a/src/test/ui/liveness/liveness-issue-77915.rs +++ /dev/null @@ -1,36 +0,0 @@ -// Ensure inout asm! operands are marked as used by the liveness pass - -// only-x86_64 -// check-pass - -#![feature(asm)] -#![allow(dead_code)] -#![deny(unused_variables)] - -// Tests the single variable inout case -unsafe fn rep_movsb(mut dest: *mut u8, mut src: *const u8, mut n: usize) -> *mut u8 { - while n != 0 { - asm!( - "rep movsb", - inout("rcx") n, - inout("rsi") src, - inout("rdi") dest, - ); - } - dest -} - -// Tests the split inout case -unsafe fn rep_movsb2(mut dest: *mut u8, mut src: *const u8, mut n: usize) -> *mut u8 { - while n != 0 { - asm!( - "rep movsb", - inout("rcx") n, - inout("rsi") src => src, - inout("rdi") dest, - ); - } - dest -} - -fn main() {} From d80f127a75017dcdc91f4535b26a668976e2cfc7 Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Mon, 19 Oct 2020 23:58:42 +0200 Subject: [PATCH 07/19] Avoid panic_bounds_check in fmt::write. Writing any fmt::Arguments would trigger the inclusion of usize formatting and padding code in the resulting binary, because indexing used in fmt::write would generate code using panic_bounds_check, which prints the index and length. These bounds checks are not necessary, as fmt::Arguments never contains any out-of-bounds indexes. This change replaces them with unsafe get_unchecked, to reduce the amount of generated code, which is especially important for embedded targets. --- library/core/src/fmt/mod.rs | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/library/core/src/fmt/mod.rs b/library/core/src/fmt/mod.rs index 0963c6d6cd7ea..04edf4611ecc3 100644 --- a/library/core/src/fmt/mod.rs +++ b/library/core/src/fmt/mod.rs @@ -1082,7 +1082,9 @@ pub fn write(output: &mut dyn Write, args: Arguments<'_>) -> Result { // a string piece. for (arg, piece) in fmt.iter().zip(args.pieces.iter()) { formatter.buf.write_str(*piece)?; - run(&mut formatter, arg, &args.args)?; + // SAFETY: arg and args.args come from the same Arguments, + // which guarantees the indexes are always within bounds. + unsafe { run(&mut formatter, arg, &args.args) }?; idx += 1; } } @@ -1096,25 +1098,36 @@ pub fn write(output: &mut dyn Write, args: Arguments<'_>) -> Result { Ok(()) } -fn run(fmt: &mut Formatter<'_>, arg: &rt::v1::Argument, args: &[ArgumentV1<'_>]) -> Result { +unsafe fn run(fmt: &mut Formatter<'_>, arg: &rt::v1::Argument, args: &[ArgumentV1<'_>]) -> Result { fmt.fill = arg.format.fill; fmt.align = arg.format.align; fmt.flags = arg.format.flags; - fmt.width = getcount(args, &arg.format.width); - fmt.precision = getcount(args, &arg.format.precision); + // SAFETY: arg and args come from the same Arguments, + // which guarantees the indexes are always within bounds. + unsafe { + fmt.width = getcount(args, &arg.format.width); + fmt.precision = getcount(args, &arg.format.precision); + } // Extract the correct argument - let value = args[arg.position]; + + // SAFETY: arg and args come from the same Arguments, + // which guarantees its index is always within bounds. + let value = unsafe { args.get_unchecked(arg.position) }; // Then actually do some printing (value.formatter)(value.value, fmt) } -fn getcount(args: &[ArgumentV1<'_>], cnt: &rt::v1::Count) -> Option { +unsafe fn getcount(args: &[ArgumentV1<'_>], cnt: &rt::v1::Count) -> Option { match *cnt { rt::v1::Count::Is(n) => Some(n), rt::v1::Count::Implied => None, - rt::v1::Count::Param(i) => args[i].as_usize(), + rt::v1::Count::Param(i) => { + // SAFETY: cnt and args come from the same Arguments, + // which guarantees this index is always within bounds. + unsafe { args.get_unchecked(i).as_usize() } + } } } From c647735f40c402f674917aff0361d4f3be7a24d8 Mon Sep 17 00:00:00 2001 From: est31 Date: Tue, 20 Oct 2020 19:09:50 +0200 Subject: [PATCH 08/19] rustc_lint: remove unused to_string In this instance, we can just pass a &str slice and save an allocation. --- compiler/rustc_lint/src/types.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_lint/src/types.rs b/compiler/rustc_lint/src/types.rs index af14f28ff9f46..9da40dd10f823 100644 --- a/compiler/rustc_lint/src/types.rs +++ b/compiler/rustc_lint/src/types.rs @@ -145,9 +145,9 @@ fn lint_overflowing_range_endpoint<'tcx>( // We need to preserve the literal's suffix, // as it may determine typing information. let suffix = match lit.node { - LitKind::Int(_, LitIntType::Signed(s)) => s.name_str().to_string(), - LitKind::Int(_, LitIntType::Unsigned(s)) => s.name_str().to_string(), - LitKind::Int(_, LitIntType::Unsuffixed) => "".to_string(), + LitKind::Int(_, LitIntType::Signed(s)) => s.name_str(), + LitKind::Int(_, LitIntType::Unsigned(s)) => s.name_str(), + LitKind::Int(_, LitIntType::Unsuffixed) => "", _ => bug!(), }; let suggestion = format!("{}..={}{}", start, lit_val - 1, suffix); From 00d23cf220a46adad99291a33557ce53fbb173ef Mon Sep 17 00:00:00 2001 From: est31 Date: Tue, 20 Oct 2020 19:36:44 +0200 Subject: [PATCH 09/19] Make {u,}int_range functions a bit nicer .into() guarantees safety of the conversion. Furthermore, the minimum value of all uints is known to be 0. --- compiler/rustc_lint/src/types.rs | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/compiler/rustc_lint/src/types.rs b/compiler/rustc_lint/src/types.rs index 9da40dd10f823..b502bd7f7a1bd 100644 --- a/compiler/rustc_lint/src/types.rs +++ b/compiler/rustc_lint/src/types.rs @@ -170,24 +170,25 @@ fn lint_overflowing_range_endpoint<'tcx>( // warnings are consistent between 32- and 64-bit platforms. fn int_ty_range(int_ty: ast::IntTy) -> (i128, i128) { match int_ty { - ast::IntTy::Isize => (i64::MIN as i128, i64::MAX as i128), - ast::IntTy::I8 => (i8::MIN as i64 as i128, i8::MAX as i128), - ast::IntTy::I16 => (i16::MIN as i64 as i128, i16::MAX as i128), - ast::IntTy::I32 => (i32::MIN as i64 as i128, i32::MAX as i128), - ast::IntTy::I64 => (i64::MIN as i128, i64::MAX as i128), - ast::IntTy::I128 => (i128::MIN as i128, i128::MAX), + ast::IntTy::Isize => (i64::MIN.into(), i64::MAX.into()), + ast::IntTy::I8 => (i8::MIN.into(), i8::MAX.into()), + ast::IntTy::I16 => (i16::MIN.into(), i16::MAX.into()), + ast::IntTy::I32 => (i32::MIN.into(), i32::MAX.into()), + ast::IntTy::I64 => (i64::MIN.into(), i64::MAX.into()), + ast::IntTy::I128 => (i128::MIN, i128::MAX), } } fn uint_ty_range(uint_ty: ast::UintTy) -> (u128, u128) { - match uint_ty { - ast::UintTy::Usize => (u64::MIN as u128, u64::MAX as u128), - ast::UintTy::U8 => (u8::MIN as u128, u8::MAX as u128), - ast::UintTy::U16 => (u16::MIN as u128, u16::MAX as u128), - ast::UintTy::U32 => (u32::MIN as u128, u32::MAX as u128), - ast::UintTy::U64 => (u64::MIN as u128, u64::MAX as u128), - ast::UintTy::U128 => (u128::MIN, u128::MAX), - } + let max = match uint_ty { + ast::UintTy::Usize => u64::MAX.into(), + ast::UintTy::U8 => u8::MAX.into(), + ast::UintTy::U16 => u16::MAX.into(), + ast::UintTy::U32 => u32::MAX.into(), + ast::UintTy::U64 => u64::MAX.into(), + ast::UintTy::U128 => u128::MAX, + }; + (0, max) } fn get_bin_hex_repr(cx: &LateContext<'_>, lit: &hir::Lit) -> Option { From fa094044a98dade4ac2dffe1f1e4383b34bb03ff Mon Sep 17 00:00:00 2001 From: bishtpawan Date: Tue, 20 Oct 2020 23:13:21 +0530 Subject: [PATCH 10/19] Fix build failure of rustfmt --- compiler/rustc_mir_build/src/lints.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_mir_build/src/lints.rs b/compiler/rustc_mir_build/src/lints.rs index bdef02a011bac..b588bc1ad837e 100644 --- a/compiler/rustc_mir_build/src/lints.rs +++ b/compiler/rustc_mir_build/src/lints.rs @@ -71,11 +71,12 @@ impl<'mir, 'tcx> Search<'mir, 'tcx> { let func_ty = func.ty(body, tcx); if let ty::FnDef(callee, substs) = *func_ty.kind() { + let normalized_substs = tcx.normalize_erasing_regions(param_env, substs); let (callee, call_substs) = - if let Ok(Some(instance)) = Instance::resolve(tcx, param_env, callee, substs) { + if let Ok(Some(instance)) = Instance::resolve(tcx, param_env, callee, normalized_substs) { (instance.def_id(), instance.substs) } else { - (callee, substs) + (callee, normalized_substs) }; // FIXME(#57965): Make this work across function boundaries From ea24395617745dd0483a7c4114da04b114a7d3d8 Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Tue, 20 Oct 2020 20:20:06 +0200 Subject: [PATCH 11/19] Add debug_asserts for the unsafe indexing in fmt::write. --- library/core/src/fmt/mod.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/library/core/src/fmt/mod.rs b/library/core/src/fmt/mod.rs index 04edf4611ecc3..cc84bf14a33a5 100644 --- a/library/core/src/fmt/mod.rs +++ b/library/core/src/fmt/mod.rs @@ -1110,7 +1110,7 @@ unsafe fn run(fmt: &mut Formatter<'_>, arg: &rt::v1::Argument, args: &[ArgumentV } // Extract the correct argument - + debug_assert!(arg.position < args.len()); // SAFETY: arg and args come from the same Arguments, // which guarantees its index is always within bounds. let value = unsafe { args.get_unchecked(arg.position) }; @@ -1124,6 +1124,7 @@ unsafe fn getcount(args: &[ArgumentV1<'_>], cnt: &rt::v1::Count) -> Option Some(n), rt::v1::Count::Implied => None, rt::v1::Count::Param(i) => { + debug_assert!(i < args.len()); // SAFETY: cnt and args come from the same Arguments, // which guarantees this index is always within bounds. unsafe { args.get_unchecked(i).as_usize() } From 5948e62f3443df626cc803fd3a08bc24e42209e8 Mon Sep 17 00:00:00 2001 From: est31 Date: Tue, 20 Oct 2020 18:38:54 +0200 Subject: [PATCH 12/19] Sync LLVM submodule if it has been initialized Since having enabled the download-ci-llvm option, and having rebased on top of f05b47ccdfa63f8b4b9fb47a9aa92381801d3ff1, I've noticed that I had to update the llvm-project submodule manually if it was checked out. Orignally, the submodule update logic was introduced to reduce the friction for contributors to manage the submodules, or in other words, to prevent getting PRs that have unwanted submodule rollbacks because the contributors didn't run git submodule update. This commit adds logic to ensure there is no inadvertent LLVM submodule rollback in a PR if download-ci-llvm (or llvm-config) is enabled. It will detect whether the llvm-project submodule is initialized, and if so, update it in any case. If it is not initialized, behaviour is kept to not do any update/initialization. An alternative to the chosen implementation would be to not pass the --init command line arg to `git submodule update` for the src/llvm-project submodule. This would show a confusing error message however on all builds with an uninitialized repo. We could pass the --silent param, but we still want it to print something if it is initialized and has to update something. So we just do a manual check for whether the submodule is initialized. --- src/bootstrap/bootstrap.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py index ce37adeb28c93..a14c12a39e5e4 100644 --- a/src/bootstrap/bootstrap.py +++ b/src/bootstrap/bootstrap.py @@ -891,10 +891,15 @@ def update_submodules(self): ).decode(default_encoding).splitlines()] filtered_submodules = [] submodules_names = [] + llvm_checked_out = os.path.exists(os.path.join(self.rust_root, "src/llvm-project/.git")) for module in submodules: if module.endswith("llvm-project"): + # Don't sync the llvm-project submodule either if an external LLVM + # was provided, or if we are downloading LLVM. Also, if the + # submodule has been initialized already, sync it anyways so that + # it doesn't mess up contributor pull requests. if self.get_toml('llvm-config') or self.downloading_llvm(): - if self.get_toml('lld') != 'true': + if self.get_toml('lld') != 'true' and not llvm_checked_out: continue check = self.check_submodule(module, slow_submodules) filtered_submodules.append((module, check)) From 356d5b5b2addd6f34b0d6809635dd08a4712b126 Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Tue, 20 Oct 2020 20:20:31 +0200 Subject: [PATCH 13/19] Add test to check for fmt::write bloat. It checks that fmt::write by itself doesn't pull in any panicking or or display code. --- src/test/run-make/fmt-write-bloat/Makefile | 7 +++++ src/test/run-make/fmt-write-bloat/main.rs | 32 ++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 src/test/run-make/fmt-write-bloat/Makefile create mode 100644 src/test/run-make/fmt-write-bloat/main.rs diff --git a/src/test/run-make/fmt-write-bloat/Makefile b/src/test/run-make/fmt-write-bloat/Makefile new file mode 100644 index 0000000000000..4227adb0d307c --- /dev/null +++ b/src/test/run-make/fmt-write-bloat/Makefile @@ -0,0 +1,7 @@ +-include ../../run-make-fulldeps/tools.mk + +NM=nm + +all: main.rs + $(RUSTC) $< -O + $(NM) $(call RUN_BINFILE,main) | $(CGREP) -v panicking panic_fmt panic_bounds_check pad_integral Display Debug diff --git a/src/test/run-make/fmt-write-bloat/main.rs b/src/test/run-make/fmt-write-bloat/main.rs new file mode 100644 index 0000000000000..e86c48014c3aa --- /dev/null +++ b/src/test/run-make/fmt-write-bloat/main.rs @@ -0,0 +1,32 @@ +#![feature(lang_items)] +#![feature(start)] +#![no_std] + +use core::fmt; +use core::fmt::Write; + +#[link(name = "c")] +extern "C" {} + +struct Dummy; + +impl fmt::Write for Dummy { + #[inline(never)] + fn write_str(&mut self, _: &str) -> fmt::Result { + Ok(()) + } +} + +#[start] +fn main(_: isize, _: *const *const u8) -> isize { + let _ = writeln!(Dummy, "Hello World"); + 0 +} + +#[lang = "eh_personality"] +fn eh_personality() {} + +#[panic_handler] +fn panic(_: &core::panic::PanicInfo) -> ! { + loop {} +} From e852a4abf01f605aa71cd529887c17c4c64f33ed Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Tue, 20 Oct 2020 16:36:46 -0700 Subject: [PATCH 14/19] Update cargo --- Cargo.lock | 15 ++++++++++++++- src/tools/cargo | 2 +- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0d2170a992747..034e7e34eb39e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -310,7 +310,7 @@ dependencies = [ "crypto-hash", "curl", "curl-sys", - "env_logger 0.7.1", + "env_logger 0.8.1", "filetime", "flate2", "fwdansi", @@ -1035,6 +1035,19 @@ dependencies = [ "termcolor", ] +[[package]] +name = "env_logger" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "54532e3223c5af90a6a757c90b5c5521564b07e5e7a958681bcd2afad421cdcd" +dependencies = [ + "atty", + "humantime 2.0.1", + "log", + "regex", + "termcolor", +] + [[package]] name = "error_index_generator" version = "0.0.0" diff --git a/src/tools/cargo b/src/tools/cargo index 79b397d72c557..dd83ae55c871d 160000 --- a/src/tools/cargo +++ b/src/tools/cargo @@ -1 +1 @@ -Subproject commit 79b397d72c557eb6444a2ba0dc00a211a226a35a +Subproject commit dd83ae55c871d94f060524656abab62ec40b4c40 From 3adac0391b543b8563298242aeeba6ade8f72944 Mon Sep 17 00:00:00 2001 From: Wesley Wiser Date: Tue, 20 Oct 2020 20:55:37 -0400 Subject: [PATCH 15/19] Add test case for #77062 Closes #77062 --- src/test/ui/consts/issue-77062-large-zst-array.rs | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 src/test/ui/consts/issue-77062-large-zst-array.rs diff --git a/src/test/ui/consts/issue-77062-large-zst-array.rs b/src/test/ui/consts/issue-77062-large-zst-array.rs new file mode 100644 index 0000000000000..0566b802e75b6 --- /dev/null +++ b/src/test/ui/consts/issue-77062-large-zst-array.rs @@ -0,0 +1,5 @@ +// build-pass + +fn main() { + let _ = &[(); usize::MAX]; +} From 2720b2da18ef9a0cd0b5ec9ebafc09b68e3cfb7a Mon Sep 17 00:00:00 2001 From: Olivia Crain Date: Wed, 21 Oct 2020 00:34:01 -0500 Subject: [PATCH 16/19] Limit liveness-asm tests to x86_64 --- src/test/ui/liveness/liveness-asm.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/test/ui/liveness/liveness-asm.rs b/src/test/ui/liveness/liveness-asm.rs index e64335a8cc589..b51da0e0d8cdd 100644 --- a/src/test/ui/liveness/liveness-asm.rs +++ b/src/test/ui/liveness/liveness-asm.rs @@ -1,5 +1,6 @@ // Ensure inout asm! operands are marked as used by the liveness pass +// only-x86_64 // check-pass #![feature(asm)] From dc29c7a72f63dcad65e5ec3899a0eb114798bdfd Mon Sep 17 00:00:00 2001 From: Olivia Crain Date: Wed, 21 Oct 2020 00:56:22 -0500 Subject: [PATCH 17/19] Bless liveness-asm output --- src/test/ui/liveness/liveness-asm.stderr | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/ui/liveness/liveness-asm.stderr b/src/test/ui/liveness/liveness-asm.stderr index b8c04b5c4429e..f385d7a8065b6 100644 --- a/src/test/ui/liveness/liveness-asm.stderr +++ b/src/test/ui/liveness/liveness-asm.stderr @@ -1,18 +1,18 @@ warning: value assigned to `src` is never read - --> $DIR/liveness-asm.rs:12:32 + --> $DIR/liveness-asm.rs:13:32 | LL | asm!("/*{0}*/", inout(reg) src); | ^^^ | note: the lint level is defined here - --> $DIR/liveness-asm.rs:7:9 + --> $DIR/liveness-asm.rs:8:9 | LL | #![warn(unused_assignments)] | ^^^^^^^^^^^^^^^^^^ = help: maybe it is overwritten before being read? warning: value assigned to `src` is never read - --> $DIR/liveness-asm.rs:22:39 + --> $DIR/liveness-asm.rs:23:39 | LL | asm!("/*{0}*/", inout(reg) src => src); | ^^^ From 7f5847735a85b474d0ce8627665e2015fb2c7b56 Mon Sep 17 00:00:00 2001 From: bishtpawan Date: Wed, 21 Oct 2020 11:42:52 +0530 Subject: [PATCH 18/19] Fix formatting --- compiler/rustc_mir_build/src/lints.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/compiler/rustc_mir_build/src/lints.rs b/compiler/rustc_mir_build/src/lints.rs index b588bc1ad837e..a9620b83124e0 100644 --- a/compiler/rustc_mir_build/src/lints.rs +++ b/compiler/rustc_mir_build/src/lints.rs @@ -72,12 +72,13 @@ impl<'mir, 'tcx> Search<'mir, 'tcx> { let func_ty = func.ty(body, tcx); if let ty::FnDef(callee, substs) = *func_ty.kind() { let normalized_substs = tcx.normalize_erasing_regions(param_env, substs); - let (callee, call_substs) = - if let Ok(Some(instance)) = Instance::resolve(tcx, param_env, callee, normalized_substs) { - (instance.def_id(), instance.substs) - } else { - (callee, normalized_substs) - }; + let (callee, call_substs) = if let Ok(Some(instance)) = + Instance::resolve(tcx, param_env, callee, normalized_substs) + { + (instance.def_id(), instance.substs) + } else { + (callee, normalized_substs) + }; // FIXME(#57965): Make this work across function boundaries From 51de5908c94056f54cd54a1b03c84efea2b40b19 Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Wed, 21 Oct 2020 16:30:41 +0200 Subject: [PATCH 19/19] Add tracking issue number for pin_static_ref. --- library/core/src/pin.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/core/src/pin.rs b/library/core/src/pin.rs index b73cd046e5a65..0b9c733f7fead 100644 --- a/library/core/src/pin.rs +++ b/library/core/src/pin.rs @@ -786,7 +786,7 @@ impl Pin<&'static T> { /// /// This is safe, because `T` is borrowed for the `'static` lifetime, which /// never ends. - #[unstable(feature = "pin_static_ref", issue = "none")] + #[unstable(feature = "pin_static_ref", issue = "78186")] #[rustc_const_unstable(feature = "const_pin", issue = "76654")] pub const fn static_ref(r: &'static T) -> Pin<&'static T> { // SAFETY: The 'static borrow guarantees the data will not be @@ -800,7 +800,7 @@ impl Pin<&'static mut T> { /// /// This is safe, because `T` is borrowed for the `'static` lifetime, which /// never ends. - #[unstable(feature = "pin_static_ref", issue = "none")] + #[unstable(feature = "pin_static_ref", issue = "78186")] #[rustc_const_unstable(feature = "const_pin", issue = "76654")] pub const fn static_mut(r: &'static mut T) -> Pin<&'static mut T> { // SAFETY: The 'static borrow guarantees the data will not be