From be6fc6aca26b7de1f69102a56689dac8b66e38f5 Mon Sep 17 00:00:00 2001 From: kennytm Date: Fri, 31 May 2019 20:02:07 +0800 Subject: [PATCH 01/11] Stabilize copy_within --- src/libcore/slice/mod.rs | 3 +-- src/libcore/tests/lib.rs | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/libcore/slice/mod.rs b/src/libcore/slice/mod.rs index 0e782bef39dd8..44ff3696b8dae 100644 --- a/src/libcore/slice/mod.rs +++ b/src/libcore/slice/mod.rs @@ -2146,14 +2146,13 @@ impl [T] { /// Copying four bytes within a slice: /// /// ``` - /// # #![feature(copy_within)] /// let mut bytes = *b"Hello, World!"; /// /// bytes.copy_within(1..5, 8); /// /// assert_eq!(&bytes, b"Hello, Wello!"); /// ``` - #[unstable(feature = "copy_within", issue = "54236")] + #[stable(feature = "copy_within", since = "1.37.0")] pub fn copy_within>(&mut self, src: R, dest: usize) where T: Copy, diff --git a/src/libcore/tests/lib.rs b/src/libcore/tests/lib.rs index c617596aba801..d789c22053a55 100644 --- a/src/libcore/tests/lib.rs +++ b/src/libcore/tests/lib.rs @@ -29,7 +29,6 @@ #![feature(inner_deref)] #![feature(slice_internals)] #![feature(slice_partition_dedup)] -#![feature(copy_within)] #![feature(int_error_matching)] #![feature(const_fn)] #![warn(rust_2018_idioms)] From aac9bc5ffac941b5880ad269076169b752a1c7e9 Mon Sep 17 00:00:00 2001 From: kennytm Date: Sun, 2 Jun 2019 23:30:18 +0800 Subject: [PATCH 02/11] copy_within: replace element access by pointer arithmetic to avoid UB This ensures we won't accidentally read *src or *dest even when count = 0. --- src/libcore/slice/mod.rs | 4 ++-- src/libcore/tests/slice.rs | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/libcore/slice/mod.rs b/src/libcore/slice/mod.rs index 44ff3696b8dae..231082e5a1756 100644 --- a/src/libcore/slice/mod.rs +++ b/src/libcore/slice/mod.rs @@ -2177,8 +2177,8 @@ impl [T] { assert!(dest <= self.len() - count, "dest is out of bounds"); unsafe { ptr::copy( - self.get_unchecked(src_start), - self.get_unchecked_mut(dest), + self.as_ptr().add(src_start), + self.as_mut_ptr().add(dest), count, ); } diff --git a/src/libcore/tests/slice.rs b/src/libcore/tests/slice.rs index 9710f019f4e4d..4017572959222 100644 --- a/src/libcore/tests/slice.rs +++ b/src/libcore/tests/slice.rs @@ -1512,6 +1512,13 @@ fn test_copy_within() { let mut bytes = *b"Hello, World!"; bytes.copy_within(.., 0); assert_eq!(&bytes, b"Hello, World!"); + + // Ensure that copying at the end of slice won't cause UB. + let mut bytes = *b"Hello, World!"; + bytes.copy_within(13..13, 5); + assert_eq!(&bytes, b"Hello, World!"); + bytes.copy_within(5..5, 13); + assert_eq!(&bytes, b"Hello, World!"); } #[test] @@ -1536,6 +1543,13 @@ fn test_copy_within_panics_src_inverted() { // 2 is greater than 1, so this range is invalid. bytes.copy_within(2..1, 0); } +#[test] +#[should_panic(expected = "attempted to index slice up to maximum usize")] +fn test_copy_within_panics_src_out_of_bounds() { + let mut bytes = *b"Hello, World!"; + // 2 is greater than 1, so this range is invalid. + bytes.copy_within(usize::max_value()..=usize::max_value(), 0); +} #[test] fn test_is_sorted() { From 427f1a49f677395fbc4415f2917207fb7e4bc061 Mon Sep 17 00:00:00 2001 From: kennytm Date: Tue, 4 Jun 2019 00:27:28 +0800 Subject: [PATCH 03/11] Update src/libcore/tests/slice.rs Co-Authored-By: Jack O'Connor --- src/libcore/tests/slice.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcore/tests/slice.rs b/src/libcore/tests/slice.rs index 4017572959222..eaa799fa96ee2 100644 --- a/src/libcore/tests/slice.rs +++ b/src/libcore/tests/slice.rs @@ -1547,7 +1547,7 @@ fn test_copy_within_panics_src_inverted() { #[should_panic(expected = "attempted to index slice up to maximum usize")] fn test_copy_within_panics_src_out_of_bounds() { let mut bytes = *b"Hello, World!"; - // 2 is greater than 1, so this range is invalid. + // an inclusive range ending at usize::max_value() would make src_end overflow bytes.copy_within(usize::max_value()..=usize::max_value(), 0); } From 1fa50b3ab809ec63b8b44a9f8a3a78b6d5ba41e3 Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Mon, 27 May 2019 09:07:47 +0000 Subject: [PATCH 04/11] Stabilize Option::xor --- src/libcore/option.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/libcore/option.rs b/src/libcore/option.rs index 6b7f491effb30..7f1b53a1b8bfc 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -725,8 +725,6 @@ impl Option { /// # Examples /// /// ``` - /// #![feature(option_xor)] - /// /// let x = Some(2); /// let y: Option = None; /// assert_eq!(x.xor(y), Some(2)); @@ -744,7 +742,7 @@ impl Option { /// assert_eq!(x.xor(y), None); /// ``` #[inline] - #[unstable(feature = "option_xor", issue = "50512")] + #[stable(feature = "option_xor", since = "1.37.0")] pub fn xor(self, optb: Option) -> Option { match (self, optb) { (Some(a), None) => Some(a), From 493d1b473a271e3fc8d332c6bf8e24930a7be597 Mon Sep 17 00:00:00 2001 From: Jonathan Behrens Date: Sat, 8 Jun 2019 19:21:38 -0400 Subject: [PATCH 05/11] Include frame pointer for bare metal RISC-V targets --- src/librustc_target/spec/riscv32imac_unknown_none_elf.rs | 1 + src/librustc_target/spec/riscv32imc_unknown_none_elf.rs | 1 + src/librustc_target/spec/riscv64gc_unknown_none_elf.rs | 1 + src/librustc_target/spec/riscv64imac_unknown_none_elf.rs | 1 + 4 files changed, 4 insertions(+) diff --git a/src/librustc_target/spec/riscv32imac_unknown_none_elf.rs b/src/librustc_target/spec/riscv32imac_unknown_none_elf.rs index 5064393d31135..8a97a09bb60aa 100644 --- a/src/librustc_target/spec/riscv32imac_unknown_none_elf.rs +++ b/src/librustc_target/spec/riscv32imac_unknown_none_elf.rs @@ -25,6 +25,7 @@ pub fn target() -> TargetResult { relocation_model: "static".to_string(), emit_debug_gdb_scripts: false, abi_blacklist: super::riscv_base::abi_blacklist(), + eliminate_frame_pointer: false, .. Default::default() }, }) diff --git a/src/librustc_target/spec/riscv32imc_unknown_none_elf.rs b/src/librustc_target/spec/riscv32imc_unknown_none_elf.rs index 31e74c5920cf9..647d33e3ffeee 100644 --- a/src/librustc_target/spec/riscv32imc_unknown_none_elf.rs +++ b/src/librustc_target/spec/riscv32imc_unknown_none_elf.rs @@ -26,6 +26,7 @@ pub fn target() -> TargetResult { relocation_model: "static".to_string(), emit_debug_gdb_scripts: false, abi_blacklist: super::riscv_base::abi_blacklist(), + eliminate_frame_pointer: false, .. Default::default() }, }) diff --git a/src/librustc_target/spec/riscv64gc_unknown_none_elf.rs b/src/librustc_target/spec/riscv64gc_unknown_none_elf.rs index 2d4070c786fed..a5c13fa28e2ce 100644 --- a/src/librustc_target/spec/riscv64gc_unknown_none_elf.rs +++ b/src/librustc_target/spec/riscv64gc_unknown_none_elf.rs @@ -25,6 +25,7 @@ pub fn target() -> TargetResult { relocation_model: "static".to_string(), emit_debug_gdb_scripts: false, abi_blacklist: super::riscv_base::abi_blacklist(), + eliminate_frame_pointer: false, .. Default::default() }, }) diff --git a/src/librustc_target/spec/riscv64imac_unknown_none_elf.rs b/src/librustc_target/spec/riscv64imac_unknown_none_elf.rs index f2e152c741e02..237d615ffcc4b 100644 --- a/src/librustc_target/spec/riscv64imac_unknown_none_elf.rs +++ b/src/librustc_target/spec/riscv64imac_unknown_none_elf.rs @@ -25,6 +25,7 @@ pub fn target() -> TargetResult { relocation_model: "static".to_string(), emit_debug_gdb_scripts: false, abi_blacklist: super::riscv_base::abi_blacklist(), + eliminate_frame_pointer: false, .. Default::default() }, }) From 4f3cd3ca07f9583d503ad9b260a8d397ebf10055 Mon Sep 17 00:00:00 2001 From: Tyler Mandry Date: Tue, 11 Jun 2019 14:21:03 -0700 Subject: [PATCH 06/11] Fix x.py install Make sure we look for save analysis in the right place. Fixes #61703. --- src/bootstrap/install.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/bootstrap/install.rs b/src/bootstrap/install.rs index 0047be4d5951b..557586709c612 100644 --- a/src/bootstrap/install.rs +++ b/src/bootstrap/install.rs @@ -251,7 +251,10 @@ install!((self, builder, _config), }; Analysis, "analysis", Self::should_build(_config), only_hosts: false, { builder.ensure(dist::Analysis { - compiler: self.compiler, + // Find the actual compiler (handling the full bootstrap option) which + // produced the save-analysis data because that data isn't copied + // through the sysroot uplifting. + compiler: builder.compiler_for(builder.top_stage, builder.config.build, self.target), target: self.target }); install_analysis(builder, self.compiler.stage, self.target); From e7b5586cd67b88d5733fd9bc2179d3b3e8829d0a Mon Sep 17 00:00:00 2001 From: Marc-Antoine Perennou Date: Wed, 5 Jun 2019 15:41:44 +0200 Subject: [PATCH 07/11] rustbuild: fix libtest_stamp Signed-off-by: Marc-Antoine Perennou --- src/bootstrap/builder.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index 2281a45e014a9..cd0a93b01150c 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -787,7 +787,7 @@ impl<'a> Builder<'a> { let libtest_stamp = match cmd { "check" | "clippy" | "fix" => check::libtest_stamp(self, cmp, target), - _ => compile::libstd_stamp(self, cmp, target), + _ => compile::libtest_stamp(self, cmp, target), }; let librustc_stamp = match cmd { From 2cd516c1c3bb4faf40338becc014cd570ad19461 Mon Sep 17 00:00:00 2001 From: Pietro Albini Date: Wed, 12 Jun 2019 11:08:17 +0200 Subject: [PATCH 08/11] ci: fix ci stats upload condition The condition I suggested in #61632 was not correct and it errors out while evaluating. This fixes the condition. Example of a failure: https://dev.azure.com/rust-lang/rust/_build/results?buildId=543 --- .azure-pipelines/steps/run.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.azure-pipelines/steps/run.yml b/.azure-pipelines/steps/run.yml index 4875e2c6754a4..14372d47df8c3 100644 --- a/.azure-pipelines/steps/run.yml +++ b/.azure-pipelines/steps/run.yml @@ -155,6 +155,6 @@ steps: - bash: aws s3 cp --acl public-read cpu-usage.csv s3://$DEPLOY_BUCKET/rustc-builds/$BUILD_SOURCEVERSION/cpu-$SYSTEM_JOBNAME.csv env: AWS_SECRET_ACCESS_KEY: $(AWS_SECRET_ACCESS_KEY) - condition: contains(variables, 'AWS_SECRET_ACCESS_KEY') + condition: variables['AWS_SECRET_ACCESS_KEY'] continueOnError: true displayName: Upload CPU usage statistics From b8f1491f6e9bfb509d66e646e3ba8efb64394e5d Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Thu, 13 Jun 2019 00:37:30 +0900 Subject: [PATCH 09/11] Fix typos --- src/librustc/error_codes.rs | 2 +- src/test/ui/explain.stdout | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/librustc/error_codes.rs b/src/librustc/error_codes.rs index 6243e911bd5fd..65821d8dd8379 100644 --- a/src/librustc/error_codes.rs +++ b/src/librustc/error_codes.rs @@ -1883,7 +1883,7 @@ This pattern should be rewritten. There are a few possible ways to do this: # } ``` -The same applies to transmutes to `*mut fn()`, which were observedin practice. +The same applies to transmutes to `*mut fn()`, which were observed in practice. Note though that use of this type is generally incorrect. The intention is typically to describe a function pointer, but just `fn()` alone suffices for that. `*mut fn()` is a pointer to a fn pointer. diff --git a/src/test/ui/explain.stdout b/src/test/ui/explain.stdout index 411cdfb335b34..9ea56271f593f 100644 --- a/src/test/ui/explain.stdout +++ b/src/test/ui/explain.stdout @@ -53,7 +53,7 @@ This pattern should be rewritten. There are a few possible ways to do this: let f: extern "C" fn(*mut i32) = transmute(foo as usize); // works too ``` -The same applies to transmutes to `*mut fn()`, which were observedin practice. +The same applies to transmutes to `*mut fn()`, which were observed in practice. Note though that use of this type is generally incorrect. The intention is typically to describe a function pointer, but just `fn()` alone suffices for that. `*mut fn()` is a pointer to a fn pointer. From eb09daa762c37c743584ec3b5c05a2d181960ced Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Fri, 7 Jun 2019 18:29:48 +0300 Subject: [PATCH 10/11] Hygienize macros in the standard library --- src/liballoc/macros.rs | 2 +- src/libcore/macros.rs | 22 ++++++++--------- src/libstd/macros.rs | 16 ++++++------- src/test/ui/hygiene/no_implicit_prelude.rs | 2 +- .../ui/hygiene/no_implicit_prelude.stderr | 6 ++--- .../local-modularized-tricky-fail-1.rs | 1 - .../local-modularized-tricky-fail-1.stderr | 24 ++----------------- 7 files changed, 26 insertions(+), 47 deletions(-) diff --git a/src/liballoc/macros.rs b/src/liballoc/macros.rs index dd128e096f952..250c419c531f8 100644 --- a/src/liballoc/macros.rs +++ b/src/liballoc/macros.rs @@ -42,7 +42,7 @@ macro_rules! vec { ($($x:expr),*) => ( <[_]>::into_vec(box [$($x),*]) ); - ($($x:expr,)*) => (vec![$($x),*]) + ($($x:expr,)*) => ($crate::vec![$($x),*]) } // HACK(japaric): with cfg(test) the inherent `[T]::into_vec` method, which is diff --git a/src/libcore/macros.rs b/src/libcore/macros.rs index 9dfa09cf8a512..8b44025f91f5e 100644 --- a/src/libcore/macros.rs +++ b/src/libcore/macros.rs @@ -6,13 +6,13 @@ #[stable(feature = "core", since = "1.6.0")] macro_rules! panic { () => ( - panic!("explicit panic") + $crate::panic!("explicit panic") ); ($msg:expr) => ({ $crate::panicking::panic(&($msg, file!(), line!(), __rust_unstable_column!())) }); ($msg:expr,) => ( - panic!($msg) + $crate::panic!($msg) ); ($fmt:expr, $($arg:tt)+) => ({ $crate::panicking::panic_fmt(format_args!($fmt, $($arg)*), @@ -58,7 +58,7 @@ macro_rules! assert_eq { } }); ($left:expr, $right:expr,) => ({ - assert_eq!($left, $right) + $crate::assert_eq!($left, $right) }); ($left:expr, $right:expr, $($arg:tt)+) => ({ match (&($left), &($right)) { @@ -115,7 +115,7 @@ macro_rules! assert_ne { } }); ($left:expr, $right:expr,) => { - assert_ne!($left, $right) + $crate::assert_ne!($left, $right) }; ($left:expr, $right:expr, $($arg:tt)+) => ({ match (&($left), &($right)) { @@ -208,7 +208,7 @@ macro_rules! debug_assert { #[macro_export] #[stable(feature = "rust1", since = "1.0.0")] macro_rules! debug_assert_eq { - ($($arg:tt)*) => (if cfg!(debug_assertions) { assert_eq!($($arg)*); }) + ($($arg:tt)*) => (if cfg!(debug_assertions) { $crate::assert_eq!($($arg)*); }) } /// Asserts that two expressions are not equal to each other. @@ -235,7 +235,7 @@ macro_rules! debug_assert_eq { #[macro_export] #[stable(feature = "assert_ne", since = "1.13.0")] macro_rules! debug_assert_ne { - ($($arg:tt)*) => (if cfg!(debug_assertions) { assert_ne!($($arg)*); }) + ($($arg:tt)*) => (if cfg!(debug_assertions) { $crate::assert_ne!($($arg)*); }) } /// Unwraps a result or propagates its error. @@ -310,7 +310,7 @@ macro_rules! r#try { return $crate::result::Result::Err($crate::convert::From::from(err)) } }); - ($expr:expr,) => (r#try!($expr)); + ($expr:expr,) => ($crate::r#try!($expr)); } /// Writes formatted data into a buffer. @@ -425,10 +425,10 @@ macro_rules! write { #[allow_internal_unstable(format_args_nl)] macro_rules! writeln { ($dst:expr) => ( - write!($dst, "\n") + $crate::write!($dst, "\n") ); ($dst:expr,) => ( - writeln!($dst) + $crate::writeln!($dst) ); ($dst:expr, $($arg:tt)*) => ( $dst.write_fmt(format_args_nl!($($arg)*)) @@ -494,10 +494,10 @@ macro_rules! unreachable { panic!("internal error: entered unreachable code") }); ($msg:expr) => ({ - unreachable!("{}", $msg) + $crate::unreachable!("{}", $msg) }); ($msg:expr,) => ({ - unreachable!($msg) + $crate::unreachable!($msg) }); ($fmt:expr, $($arg:tt)*) => ({ panic!(concat!("internal error: entered unreachable code: ", $fmt), $($arg)*) diff --git a/src/libstd/macros.rs b/src/libstd/macros.rs index ef7179f0b6f90..ef1b549d1dcf4 100644 --- a/src/libstd/macros.rs +++ b/src/libstd/macros.rs @@ -56,13 +56,13 @@ #[allow_internal_unstable(__rust_unstable_column, libstd_sys_internals)] macro_rules! panic { () => ({ - panic!("explicit panic") + $crate::panic!("explicit panic") }); ($msg:expr) => ({ $crate::rt::begin_panic($msg, &(file!(), line!(), __rust_unstable_column!())) }); ($msg:expr,) => ({ - panic!($msg) + $crate::panic!($msg) }); ($fmt:expr, $($arg:tt)+) => ({ $crate::rt::begin_panic_fmt(&format_args!($fmt, $($arg)+), @@ -145,7 +145,7 @@ macro_rules! print { #[stable(feature = "rust1", since = "1.0.0")] #[allow_internal_unstable(print_internals, format_args_nl)] macro_rules! println { - () => (print!("\n")); + () => ($crate::print!("\n")); ($($arg:tt)*) => ({ $crate::io::_print(format_args_nl!($($arg)*)); }) @@ -204,7 +204,7 @@ macro_rules! eprint { #[stable(feature = "eprint", since = "1.19.0")] #[allow_internal_unstable(print_internals, format_args_nl)] macro_rules! eprintln { - () => (eprint!("\n")); + () => ($crate::eprint!("\n")); ($($arg:tt)*) => ({ $crate::io::_eprint(format_args_nl!($($arg)*)); }) @@ -337,23 +337,23 @@ macro_rules! eprintln { #[stable(feature = "dbg_macro", since = "1.32.0")] macro_rules! dbg { () => { - eprintln!("[{}:{}]", file!(), line!()); + $crate::eprintln!("[{}:{}]", file!(), line!()); }; ($val:expr) => { // Use of `match` here is intentional because it affects the lifetimes // of temporaries - https://stackoverflow.com/a/48732525/1063961 match $val { tmp => { - eprintln!("[{}:{}] {} = {:#?}", + $crate::eprintln!("[{}:{}] {} = {:#?}", file!(), line!(), stringify!($val), &tmp); tmp } } }; // Trailing comma with single argument is ignored - ($val:expr,) => { dbg!($val) }; + ($val:expr,) => { $crate::dbg!($val) }; ($($val:expr),+ $(,)?) => { - ($(dbg!($val)),+,) + ($($crate::dbg!($val)),+,) }; } diff --git a/src/test/ui/hygiene/no_implicit_prelude.rs b/src/test/ui/hygiene/no_implicit_prelude.rs index 1cd05f4d44c5e..890c8307543f3 100644 --- a/src/test/ui/hygiene/no_implicit_prelude.rs +++ b/src/test/ui/hygiene/no_implicit_prelude.rs @@ -13,7 +13,7 @@ mod bar { } fn f() { ::foo::m!(); - println!(); //~ ERROR cannot find macro `print!` in this scope + assert_eq!(0, 0); //~ ERROR cannot find macro `panic!` in this scope } } diff --git a/src/test/ui/hygiene/no_implicit_prelude.stderr b/src/test/ui/hygiene/no_implicit_prelude.stderr index dcb213f809a9d..737b375ed8971 100644 --- a/src/test/ui/hygiene/no_implicit_prelude.stderr +++ b/src/test/ui/hygiene/no_implicit_prelude.stderr @@ -7,11 +7,11 @@ LL | fn f() { ::bar::m!(); } LL | Vec::new(); | ^^^ use of undeclared type or module `Vec` -error: cannot find macro `print!` in this scope +error: cannot find macro `panic!` in this scope --> $DIR/no_implicit_prelude.rs:16:9 | -LL | println!(); - | ^^^^^^^^^^^ +LL | assert_eq!(0, 0); + | ^^^^^^^^^^^^^^^^^ | = help: have you added the `#[macro_use]` on the module/import? = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) diff --git a/src/test/ui/imports/local-modularized-tricky-fail-1.rs b/src/test/ui/imports/local-modularized-tricky-fail-1.rs index d1cb6b07d750c..29e9b8ec841f5 100644 --- a/src/test/ui/imports/local-modularized-tricky-fail-1.rs +++ b/src/test/ui/imports/local-modularized-tricky-fail-1.rs @@ -33,7 +33,6 @@ mod inner2 { fn main() { panic!(); //~ ERROR `panic` is ambiguous - //~| ERROR `panic` is ambiguous } mod inner3 { diff --git a/src/test/ui/imports/local-modularized-tricky-fail-1.stderr b/src/test/ui/imports/local-modularized-tricky-fail-1.stderr index d7ae8e6d505d5..13d3227d8b38f 100644 --- a/src/test/ui/imports/local-modularized-tricky-fail-1.stderr +++ b/src/test/ui/imports/local-modularized-tricky-fail-1.stderr @@ -22,7 +22,7 @@ LL | use inner1::*; = help: consider adding an explicit import of `exported` to disambiguate error[E0659]: `include` is ambiguous (macro-expanded name vs less macro-expanded name from outer scope during import/macro resolution) - --> $DIR/local-modularized-tricky-fail-1.rs:47:1 + --> $DIR/local-modularized-tricky-fail-1.rs:46:1 | LL | include!(); | ^^^^^^^ ambiguous name @@ -59,26 +59,6 @@ LL | define_panic!(); | ---------------- in this macro invocation = help: use `crate::panic` to refer to this macro unambiguously -error[E0659]: `panic` is ambiguous (macro-expanded name vs less macro-expanded name from outer scope during import/macro resolution) - --> $DIR/local-modularized-tricky-fail-1.rs:35:5 - | -LL | panic!(); - | ^^^^^^^^^ ambiguous name - | - = note: `panic` could refer to a macro from prelude -note: `panic` could also refer to the macro defined here - --> $DIR/local-modularized-tricky-fail-1.rs:11:5 - | -LL | / macro_rules! panic { -LL | | () => () -LL | | } - | |_____^ -... -LL | define_panic!(); - | ---------------- in this macro invocation - = help: use `crate::panic` to refer to this macro unambiguously - = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) - -error: aborting due to 4 previous errors +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0659`. From 7c8644dc23679f28635da946803db9a879856460 Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Wed, 12 Jun 2019 19:04:35 +0000 Subject: [PATCH 11/11] Add an alias for x86_64-sun-solaris target tuple --- src/librustc_target/spec/mod.rs | 18 ++++++++++-------- src/tools/build-manifest/src/main.rs | 1 + 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/librustc_target/spec/mod.rs b/src/librustc_target/spec/mod.rs index 844edbb946a51..42ba49ba2b8db 100644 --- a/src/librustc_target/spec/mod.rs +++ b/src/librustc_target/spec/mod.rs @@ -268,16 +268,16 @@ pub type LinkArgs = BTreeMap>; pub type TargetResult = Result; macro_rules! supported_targets { - ( $(($triple:expr, $module:ident),)+ ) => ( - $(mod $module;)* + ( $(($( $triple:literal, )+ $module:ident ),)+ ) => { + $(mod $module;)+ /// List of supported targets - const TARGETS: &[&str] = &[$($triple),*]; + const TARGETS: &[&str] = &[$($($triple),+),+]; fn load_specific(target: &str) -> Result { match target { $( - $triple => { + $($triple)|+ => { let mut t = $module::target() .map_err(LoadTargetError::Other)?; t.options.is_builtin = true; @@ -307,7 +307,7 @@ macro_rules! supported_targets { mod test_json_encode_decode { use serialize::json::ToJson; use super::Target; - $(use super::$module;)* + $(use super::$module;)+ $( #[test] @@ -322,9 +322,9 @@ macro_rules! supported_targets { assert_eq!(original, parsed); }); } - )* + )+ } - ) + }; } supported_targets! { @@ -426,7 +426,9 @@ supported_targets! { ("armv7r-none-eabi", armv7r_none_eabi), ("armv7r-none-eabihf", armv7r_none_eabihf), - ("x86_64-sun-solaris", x86_64_sun_solaris), + // `x86_64-pc-solaris` is an alias for `x86_64_sun_solaris` for backwards compatibility reasons. + // (See .) + ("x86_64-sun-solaris", "x86_64-pc-solaris", x86_64_sun_solaris), ("sparcv9-sun-solaris", sparcv9_sun_solaris), ("x86_64-pc-windows-gnu", x86_64_pc_windows_gnu), diff --git a/src/tools/build-manifest/src/main.rs b/src/tools/build-manifest/src/main.rs index 5efd51b65c14a..b6e087c3844fa 100644 --- a/src/tools/build-manifest/src/main.rs +++ b/src/tools/build-manifest/src/main.rs @@ -118,6 +118,7 @@ static TARGETS: &[&str] = &[ "x86_64-pc-windows-msvc", "x86_64-rumprun-netbsd", "x86_64-sun-solaris", + "x86_64-pc-solaris", "x86_64-unknown-cloudabi", "x86_64-unknown-freebsd", "x86_64-unknown-linux-gnu",