mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-25 19:35:06 +00:00
recover from missing type annotation
This commit is contained in:
parent
244ee65bbe
commit
049f0a6d2c
2 changed files with 20 additions and 0 deletions
|
@ -2556,6 +2556,20 @@ fn f() {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn infer_missing_type() {
|
||||||
|
check_types(
|
||||||
|
r#"
|
||||||
|
struct S;
|
||||||
|
|
||||||
|
fn f() {
|
||||||
|
let s: = S;
|
||||||
|
//^ S
|
||||||
|
}
|
||||||
|
"#,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn infer_type_alias_variant() {
|
fn infer_type_alias_variant() {
|
||||||
check_infer(
|
check_infer(
|
||||||
|
|
|
@ -57,6 +57,12 @@ fn type_with_bounds_cond(p: &mut Parser, allow_bounds: bool) {
|
||||||
pub(super) fn ascription(p: &mut Parser) {
|
pub(super) fn ascription(p: &mut Parser) {
|
||||||
assert!(p.at(T![:]));
|
assert!(p.at(T![:]));
|
||||||
p.bump(T![:]);
|
p.bump(T![:]);
|
||||||
|
if p.at(T![=]) {
|
||||||
|
// recover from `let x: = expr;`, `const X: = expr;` and similars
|
||||||
|
// hopefully no type starts with `=`
|
||||||
|
p.error("missing type");
|
||||||
|
return;
|
||||||
|
}
|
||||||
type_(p);
|
type_(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue