Improve error message for missing angle brackets in [_]::method

This commit is contained in:
Fabian Wolff 2021-10-01 23:03:28 +02:00
parent ed937594d3
commit d92c683933
3 changed files with 17 additions and 0 deletions

View File

@ -1211,6 +1211,8 @@ impl Expr {
}
}
ExprKind::Underscore => TyKind::Infer,
// This expression doesn't look like a type syntactically.
_ => return None,
};

View File

@ -0,0 +1,7 @@
// Regression test for #89388.
fn main() {
let option: Option<&[u8]> = Some(b"...");
let _ = option.map([_]::to_vec);
//~^ ERROR: missing angle brackets in associated item path
}

View File

@ -0,0 +1,8 @@
error: missing angle brackets in associated item path
--> $DIR/issue-89388.rs:5:24
|
LL | let _ = option.map([_]::to_vec);
| ^^^^^^^^^^^ help: try: `<[_]>::to_vec`
error: aborting due to previous error