Skip to content

Add non-regression test for #144168 #144189

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 21, 2025
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
27 changes: 27 additions & 0 deletions tests/ui/resolve/underscore-bindings-disambiguators.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Regression test for issue #144168 where some `_` bindings were incorrectly only allowed once per
// module, failing with "error[E0428]: the name `_` is defined multiple times".

// This weird/complex setup is reduced from `zerocopy-0.8.25` where the issue was encountered.

#![crate_type = "lib"]

macro_rules! impl_for_transmute_from {
() => {
const _: () = {};
};
}

mod impls {
use super::*;
impl_for_transmute_from!();
impl_for_transmute_from!();
const _: () = todo!(); //~ ERROR: evaluation panicked
const _: () = todo!(); //~ ERROR: evaluation panicked
const _: () = todo!(); //~ ERROR: evaluation panicked
const _: () = todo!(); //~ ERROR: evaluation panicked
const _: () = todo!(); //~ ERROR: evaluation panicked
}
use X as Y; //~ ERROR: unresolved import
use Z as W; //~ ERROR: unresolved import

const _: () = todo!(); //~ ERROR: evaluation panicked
70 changes: 70 additions & 0 deletions tests/ui/resolve/underscore-bindings-disambiguators.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
error[E0432]: unresolved import `X`
--> $DIR/underscore-bindings-disambiguators.rs:24:5
|
LL | use X as Y;
| -^^^^^
| |
| no `X` in the root
| help: a similar name exists in the module: `_`

error[E0432]: unresolved import `Z`
--> $DIR/underscore-bindings-disambiguators.rs:25:5
|
LL | use Z as W;
| -^^^^^
| |
| no `Z` in the root
| help: a similar name exists in the module: `_`

error[E0080]: evaluation panicked: not yet implemented
--> $DIR/underscore-bindings-disambiguators.rs:18:19
|
LL | const _: () = todo!();
| ^^^^^^^ evaluation of `impls::_` failed here
|
= note: this error originates in the macro `todo` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0080]: evaluation panicked: not yet implemented
--> $DIR/underscore-bindings-disambiguators.rs:19:19
|
LL | const _: () = todo!();
| ^^^^^^^ evaluation of `impls::_` failed here
|
= note: this error originates in the macro `todo` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0080]: evaluation panicked: not yet implemented
--> $DIR/underscore-bindings-disambiguators.rs:20:19
|
LL | const _: () = todo!();
| ^^^^^^^ evaluation of `impls::_` failed here
|
= note: this error originates in the macro `todo` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0080]: evaluation panicked: not yet implemented
--> $DIR/underscore-bindings-disambiguators.rs:21:19
|
LL | const _: () = todo!();
| ^^^^^^^ evaluation of `impls::_` failed here
|
= note: this error originates in the macro `todo` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0080]: evaluation panicked: not yet implemented
--> $DIR/underscore-bindings-disambiguators.rs:22:19
|
LL | const _: () = todo!();
| ^^^^^^^ evaluation of `impls::_` failed here
|
= note: this error originates in the macro `todo` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0080]: evaluation panicked: not yet implemented
--> $DIR/underscore-bindings-disambiguators.rs:27:15
|
LL | const _: () = todo!();
| ^^^^^^^ evaluation of `_` failed here
|
= note: this error originates in the macro `todo` (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to 8 previous errors

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