Rollup merge of #70006 - petrochenkov:fresh, r=Centril
resolve: Fix two issues in fresh binding disambiguation Prevent fresh bindings from shadowing ambiguity items. Fixes https://github.com/rust-lang/rust/issues/46079 Correctly treat const generic parameters in fresh binding disambiguation. Fixes https://github.com/rust-lang/rust/issues/68853
This commit is contained in:
commit
d986a706bd
9 changed files with 123 additions and 24 deletions
18
src/test/ui/binding/ambiguity-item.rs
Normal file
18
src/test/ui/binding/ambiguity-item.rs
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
// Identifier pattern referring to an ambiguity item is an error (issue #46079).
|
||||
|
||||
mod m {
|
||||
pub fn f() {}
|
||||
}
|
||||
use m::*;
|
||||
|
||||
mod n {
|
||||
pub fn f() {}
|
||||
}
|
||||
use n::*; // OK, no conflict with `use m::*;`
|
||||
|
||||
fn main() {
|
||||
let v = f; //~ ERROR `f` is ambiguous
|
||||
match v {
|
||||
f => {} //~ ERROR `f` is ambiguous
|
||||
}
|
||||
}
|
||||
41
src/test/ui/binding/ambiguity-item.stderr
Normal file
41
src/test/ui/binding/ambiguity-item.stderr
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
error[E0659]: `f` is ambiguous (glob import vs glob import in the same module)
|
||||
--> $DIR/ambiguity-item.rs:14:13
|
||||
|
|
||||
LL | let v = f;
|
||||
| ^ ambiguous name
|
||||
|
|
||||
note: `f` could refer to the function imported here
|
||||
--> $DIR/ambiguity-item.rs:6:5
|
||||
|
|
||||
LL | use m::*;
|
||||
| ^^^^
|
||||
= help: consider adding an explicit import of `f` to disambiguate
|
||||
note: `f` could also refer to the function imported here
|
||||
--> $DIR/ambiguity-item.rs:11:5
|
||||
|
|
||||
LL | use n::*; // OK, no conflict with `use m::*;`
|
||||
| ^^^^
|
||||
= help: consider adding an explicit import of `f` to disambiguate
|
||||
|
||||
error[E0659]: `f` is ambiguous (glob import vs glob import in the same module)
|
||||
--> $DIR/ambiguity-item.rs:16:9
|
||||
|
|
||||
LL | f => {}
|
||||
| ^ ambiguous name
|
||||
|
|
||||
note: `f` could refer to the function imported here
|
||||
--> $DIR/ambiguity-item.rs:6:5
|
||||
|
|
||||
LL | use m::*;
|
||||
| ^^^^
|
||||
= help: consider adding an explicit import of `f` to disambiguate
|
||||
note: `f` could also refer to the function imported here
|
||||
--> $DIR/ambiguity-item.rs:11:5
|
||||
|
|
||||
LL | use n::*; // OK, no conflict with `use m::*;`
|
||||
| ^^^^
|
||||
= help: consider adding an explicit import of `f` to disambiguate
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0659`.
|
||||
12
src/test/ui/binding/const-param.rs
Normal file
12
src/test/ui/binding/const-param.rs
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
// Identifier pattern referring to a const generic parameter is an error (issue #68853).
|
||||
|
||||
#![feature(const_generics)] //~ WARN the feature `const_generics` is incomplete
|
||||
|
||||
fn check<const N: usize>() {
|
||||
match 1 {
|
||||
N => {} //~ ERROR const parameters cannot be referenced in patterns
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
17
src/test/ui/binding/const-param.stderr
Normal file
17
src/test/ui/binding/const-param.stderr
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
warning: the feature `const_generics` is incomplete and may cause the compiler to crash
|
||||
--> $DIR/const-param.rs:3:12
|
||||
|
|
||||
LL | #![feature(const_generics)]
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: `#[warn(incomplete_features)]` on by default
|
||||
|
||||
error[E0158]: const parameters cannot be referenced in patterns
|
||||
--> $DIR/const-param.rs:7:9
|
||||
|
|
||||
LL | N => {}
|
||||
| ^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0158`.
|
||||
Loading…
Add table
Add a link
Reference in a new issue