Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions tests/ui/resolve/decl-macro-use-no-ice.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//@ edition: 2024
#![feature(decl_macro)]

// Regression test for issue <https://github.com/rust-lang/rust/issues/150711>
// The compiler previously ICE'd during identifier resolution
// involving `macro` items and `use` inside a public macro.


mod foo {
macro f() {}

pub macro m() {
use f; //~ ERROR `f` is private, and cannot be re-exported
f!(); //~ ERROR macro import `f` is private
}
}

fn main() {
foo::m!();
}
47 changes: 47 additions & 0 deletions tests/ui/resolve/decl-macro-use-no-ice.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
error[E0364]: `f` is private, and cannot be re-exported
--> $DIR/decl-macro-use-no-ice.rs:13:13
|
LL | use f;
| ^
...
LL | foo::m!();
| --------- in this macro invocation
|
note: consider marking `f` as `pub` in the imported module
--> $DIR/decl-macro-use-no-ice.rs:13:13
|
LL | use f;
| ^
...
LL | foo::m!();
| --------- in this macro invocation
= note: this error originates in the macro `foo::m` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0603]: macro import `f` is private
--> $DIR/decl-macro-use-no-ice.rs:14:9
|
LL | f!();
| ^ private macro import
...
LL | foo::m!();
| --------- in this macro invocation
|
note: the macro import `f` is defined here...
--> $DIR/decl-macro-use-no-ice.rs:13:13
|
LL | use f;
| ^
...
LL | foo::m!();
| --------- in this macro invocation
note: ...and refers to the macro `f` which is defined here
--> $DIR/decl-macro-use-no-ice.rs:10:5
|
LL | macro f() {}
| ^^^^^^^^^
= note: this error originates in the macro `foo::m` (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to 2 previous errors

Some errors have detailed explanations: E0364, E0603.
For more information about an error, try `rustc --explain E0364`.
Loading