fix ICE
This commit is contained in:
parent
15d770400e
commit
f63c2f80e5
@ -814,11 +814,6 @@ https://doc.rust-lang.org/reference/types.html#trait-objects");
|
||||
report_unexpected_def(def);
|
||||
return self.tcx.types.err;
|
||||
}
|
||||
// Replace constructor type with constructed type for tuple struct patterns.
|
||||
let pat_ty = pat_ty.fn_sig(tcx).output();
|
||||
let pat_ty = pat_ty.no_bound_vars().expect("expected fn type");
|
||||
|
||||
self.demand_eqtype(pat.span, expected, pat_ty);
|
||||
|
||||
let variant = match def {
|
||||
Def::Err => {
|
||||
@ -836,6 +831,13 @@ https://doc.rust-lang.org/reference/types.html#trait-objects");
|
||||
}
|
||||
_ => bug!("unexpected pattern definition: {:?}", def)
|
||||
};
|
||||
|
||||
// Replace constructor type with constructed type for tuple struct patterns.
|
||||
let pat_ty = pat_ty.fn_sig(tcx).output();
|
||||
let pat_ty = pat_ty.no_bound_vars().expect("expected fn type");
|
||||
|
||||
self.demand_eqtype(pat.span, expected, pat_ty);
|
||||
|
||||
// Type check subpatterns.
|
||||
if subpats.len() == variant.fields.len() ||
|
||||
subpats.len() < variant.fields.len() && ddpos.is_some() {
|
||||
|
12
src/test/ui/match/match-fn-call.rs
Normal file
12
src/test/ui/match/match-fn-call.rs
Normal file
@ -0,0 +1,12 @@
|
||||
use std::path::Path;
|
||||
|
||||
fn main() {
|
||||
let path = Path::new("foo");
|
||||
match path {
|
||||
Path::new("foo") => println!("foo"),
|
||||
//~^ ERROR expected tuple struct/variant
|
||||
Path::new("bar") => println!("bar"),
|
||||
//~^ ERROR expected tuple struct/variant
|
||||
_ => (),
|
||||
}
|
||||
}
|
15
src/test/ui/match/match-fn-call.stderr
Normal file
15
src/test/ui/match/match-fn-call.stderr
Normal file
@ -0,0 +1,15 @@
|
||||
error[E0164]: expected tuple struct/variant, found method `<Path>::new`
|
||||
--> $DIR/match-fn-call.rs:6:9
|
||||
|
|
||||
LL | Path::new("foo") => println!("foo"),
|
||||
| ^^^^^^^^^^^^^^^^ not a tuple variant or struct
|
||||
|
||||
error[E0164]: expected tuple struct/variant, found method `<Path>::new`
|
||||
--> $DIR/match-fn-call.rs:8:9
|
||||
|
|
||||
LL | Path::new("bar") => println!("bar"),
|
||||
| ^^^^^^^^^^^^^^^^ not a tuple variant or struct
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0164`.
|
Loading…
x
Reference in New Issue
Block a user