From 2961b1a60bb3e0758d00f7536df55e43c88fc0a8 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Thu, 20 Jun 2019 00:16:14 +0300 Subject: [PATCH] resolve: Temporarily make `panic` available with `no_implicit_prelude` --- src/librustc_resolve/macros.rs | 3 ++- src/test/ui/hygiene/no_implicit_prelude.rs | 2 +- src/test/ui/hygiene/no_implicit_prelude.stderr | 11 +---------- 3 files changed, 4 insertions(+), 12 deletions(-) diff --git a/src/librustc_resolve/macros.rs b/src/librustc_resolve/macros.rs index 5623016c2e5e7..b886ae1c99510 100644 --- a/src/librustc_resolve/macros.rs +++ b/src/librustc_resolve/macros.rs @@ -673,7 +673,8 @@ impl<'a> Resolver<'a> { } } WhereToResolve::MacroUsePrelude => { - if use_prelude || rust_2015 { + // FIXME: Remove `panic` from here once its uses in std/core are hygienized. + if use_prelude || rust_2015 || ident.name.as_str() == "panic" { match self.macro_use_prelude.get(&ident.name).cloned() { Some(binding) => Ok((binding, Flags::PRELUDE | Flags::MISC_FROM_PRELUDE)), diff --git a/src/test/ui/hygiene/no_implicit_prelude.rs b/src/test/ui/hygiene/no_implicit_prelude.rs index 890c8307543f3..8a4657fdf3df6 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!(); - assert_eq!(0, 0); //~ ERROR cannot find macro `panic!` in this scope + assert_eq!(0, 0); // OK, the inner `panic` is available due to compiler special casing } } diff --git a/src/test/ui/hygiene/no_implicit_prelude.stderr b/src/test/ui/hygiene/no_implicit_prelude.stderr index 737b375ed8971..c38d2a1c5294d 100644 --- a/src/test/ui/hygiene/no_implicit_prelude.stderr +++ b/src/test/ui/hygiene/no_implicit_prelude.stderr @@ -7,15 +7,6 @@ LL | fn f() { ::bar::m!(); } LL | Vec::new(); | ^^^ use of undeclared type or module `Vec` -error: cannot find macro `panic!` in this scope - --> $DIR/no_implicit_prelude.rs:16:9 - | -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) - error[E0599]: no method named `clone` found for type `()` in the current scope --> $DIR/no_implicit_prelude.rs:12:12 | @@ -29,7 +20,7 @@ LL | ().clone() = note: the following trait is implemented but not in scope, perhaps add a `use` for it: `use std::clone::Clone;` -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors Some errors have detailed explanations: E0433, E0599. For more information about an error, try `rustc --explain E0433`.