Rollup merge of #95918 - compiler-errors:issue-95878, r=cjgillot
Delay a bug when we see SelfCtor in ref pattern Fixes #95878
This commit is contained in:
commit
91813a7175
@ -1888,6 +1888,15 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
|
||||
// These entities are explicitly allowed to be shadowed by fresh bindings.
|
||||
None
|
||||
}
|
||||
Res::SelfCtor(_) => {
|
||||
// We resolve `Self` in pattern position as an ident sometimes during recovery,
|
||||
// so delay a bug instead of ICEing.
|
||||
self.r.session.delay_span_bug(
|
||||
ident.span,
|
||||
"unexpected `SelfCtor` in pattern, expected identifier"
|
||||
);
|
||||
None
|
||||
}
|
||||
_ => span_bug!(
|
||||
ident.span,
|
||||
"unexpected resolution for an identifier in pattern: {:?}",
|
||||
|
12
src/test/ui/pattern/issue-95878.rs
Normal file
12
src/test/ui/pattern/issue-95878.rs
Normal file
@ -0,0 +1,12 @@
|
||||
struct Foo<'a>(&'a ());
|
||||
|
||||
impl<'a> Foo<'a> {
|
||||
fn spam(&mut self, baz: &mut Vec<u32>) {
|
||||
match 15 {
|
||||
ref Self => (),
|
||||
//~^ ERROR expected identifier, found keyword `Self`
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
8
src/test/ui/pattern/issue-95878.stderr
Normal file
8
src/test/ui/pattern/issue-95878.stderr
Normal file
@ -0,0 +1,8 @@
|
||||
error: expected identifier, found keyword `Self`
|
||||
--> $DIR/issue-95878.rs:6:17
|
||||
|
|
||||
LL | ref Self => (),
|
||||
| ^^^^ expected identifier, found keyword
|
||||
|
||||
error: aborting due to previous error
|
||||
|
Loading…
x
Reference in New Issue
Block a user