Add a regression test for #44692

Add a test for the issue resolved by removing `resolve_macro_path`

Add a test making sure that extern prelude entries introduced from an opaque macro are not visible anywhere, even it that macro

Fix test output after rebase
This commit is contained in:
Vadim Petrochenkov 2019-07-08 21:58:42 +03:00
parent 7b74d72d9a
commit e86e5cb38f
7 changed files with 128 additions and 1 deletions

View File

@ -0,0 +1,15 @@
// force-host
// no-prefer-dynamic
#![crate_type = "proc-macro"]
extern crate proc_macro;
use proc_macro::*;
#[proc_macro_derive(NoMarker)]
pub fn f(input: TokenStream) -> TokenStream {
if input.to_string().contains("rustc_copy_clone_marker") {
panic!("found `#[rustc_copy_clone_marker]`");
}
TokenStream::new()
}

View File

@ -0,0 +1,16 @@
// Test that `#[rustc_copy_clone_marker]` is not injected when a user-defined derive shadows
// a built-in derive in non-trivial scope (e.g. in a nested module).
// check-pass
// aux-build:derive-marker-tricky.rs
extern crate derive_marker_tricky;
mod m {
use derive_marker_tricky::NoMarker as Copy;
#[derive(Copy)]
struct S;
}
fn main() {}

View File

@ -0,0 +1,28 @@
#![feature(decl_macro)]
macro a() {
extern crate core as my_core;
mod v {
// Early resolution.
use my_core; //~ ERROR unresolved import `my_core`
}
mod u {
// Late resolution.
fn f() { my_core::mem::drop(0); }
//~^ ERROR failed to resolve: use of undeclared type or module `my_core`
}
}
a!();
mod v {
// Early resolution.
use my_core; //~ ERROR unresolved import `my_core`
}
mod u {
// Late resolution.
fn f() { my_core::mem::drop(0); }
//~^ ERROR failed to resolve: use of undeclared type or module `my_core`
}
fn main() {}

View File

@ -0,0 +1,37 @@
error[E0432]: unresolved import `my_core`
--> $DIR/extern-prelude-from-opaque-fail.rs:20:9
|
LL | use my_core;
| ^^^^^^^
| |
| no `my_core` in the root
| help: a similar name exists in the module: `my_core`
error[E0432]: unresolved import `my_core`
--> $DIR/extern-prelude-from-opaque-fail.rs:7:13
|
LL | use my_core;
| ^^^^^^^ no `my_core` in the root
...
LL | a!();
| ----- in this macro invocation
error[E0433]: failed to resolve: use of undeclared type or module `my_core`
--> $DIR/extern-prelude-from-opaque-fail.rs:11:18
|
LL | fn f() { my_core::mem::drop(0); }
| ^^^^^^^ use of undeclared type or module `my_core`
...
LL | a!();
| ----- in this macro invocation
error[E0433]: failed to resolve: use of undeclared type or module `my_core`
--> $DIR/extern-prelude-from-opaque-fail.rs:24:14
|
LL | fn f() { my_core::mem::drop(0); }
| ^^^^^^^ use of undeclared type or module `my_core`
error: aborting due to 4 previous errors
Some errors have detailed explanations: E0432, E0433.
For more information about an error, try `rustc --explain E0432`.

View File

@ -0,0 +1,14 @@
// Regression test for the issue #44692
macro_rules! hang { () => {
{ //~ ERROR format argument must be a string literal
#[derive(Clone)]
struct S;
""
}
}}
fn main() {
format_args!(hang!());
}

View File

@ -0,0 +1,17 @@
error: format argument must be a string literal
--> $DIR/derive-in-eager-expansion-hang.rs:4:5
|
LL | / {
LL | | #[derive(Clone)]
LL | | struct S;
LL | |
LL | | ""
LL | | }
| |_____^
help: you might be missing a string literal to format with
|
LL | format_args!("{}", hang!());
| ^^^^^
error: aborting due to previous error

View File

@ -83,7 +83,7 @@ LL | #[my_macro]
| ^^^^^^^^
|
= note: for more information, see https://github.com/rust-lang/rust/issues/29642
= help: add #![feature(custom_attribute)] to the crate attributes to enable
= help: add `#![feature(custom_attribute)]` to the crate attributes to enable
error: can't use a procedural macro from the same crate that defines it
--> $DIR/macro-namespace-reserved-2.rs:39:3