Tweak labels
This commit is contained in:
parent
8ba1a97e37
commit
b1a6c32660
3 changed files with 8 additions and 7 deletions
|
@ -3289,8 +3289,7 @@ impl<'a> Resolver<'a> {
|
||||||
let line_sp = cm.lookup_char_pos(sp.hi()).line;
|
let line_sp = cm.lookup_char_pos(sp.hi()).line;
|
||||||
let line_base_sp = cm.lookup_char_pos(base_span.lo()).line;
|
let line_base_sp = cm.lookup_char_pos(base_span.lo()).line;
|
||||||
if snippet == ":" {
|
if snippet == ":" {
|
||||||
err.span_label(base_span,
|
let mut show_label = true;
|
||||||
"expecting a type here because of type ascription");
|
|
||||||
if line_sp != line_base_sp {
|
if line_sp != line_base_sp {
|
||||||
err.span_suggestion_short(
|
err.span_suggestion_short(
|
||||||
sp,
|
sp,
|
||||||
|
@ -3312,6 +3311,7 @@ impl<'a> Resolver<'a> {
|
||||||
"::".to_string(),
|
"::".to_string(),
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
|
show_label = false;
|
||||||
}
|
}
|
||||||
if let Ok(base_snippet) = base_snippet {
|
if let Ok(base_snippet) = base_snippet {
|
||||||
err.span_suggestion(
|
err.span_suggestion(
|
||||||
|
@ -3320,8 +3320,13 @@ impl<'a> Resolver<'a> {
|
||||||
format!("let {}", base_snippet),
|
format!("let {}", base_snippet),
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
|
show_label = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if show_label {
|
||||||
|
err.span_label(base_span,
|
||||||
|
"expecting a type here because of type ascription");
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
} else if !snippet.trim().is_empty() {
|
} else if !snippet.trim().is_empty() {
|
||||||
debug!("tried to find type ascription `:` token, couldn't find it");
|
debug!("tried to find type ascription `:` token, couldn't find it");
|
||||||
|
|
|
@ -5,7 +5,6 @@ LL | temp: i32 = fun(5i32);
|
||||||
| ^^^^
|
| ^^^^
|
||||||
| |
|
| |
|
||||||
| not found in this scope
|
| not found in this scope
|
||||||
| expecting a type here because of type ascription
|
|
||||||
| help: maybe you meant to write an assignment here: `let temp`
|
| help: maybe you meant to write an assignment here: `let temp`
|
||||||
|
|
||||||
error[E0425]: cannot find value `temp` in this scope
|
error[E0425]: cannot find value `temp` in this scope
|
||||||
|
|
|
@ -8,10 +8,7 @@ error[E0423]: expected value, found module `std`
|
||||||
--> $DIR/type-ascription-instead-of-path.rs:2:5
|
--> $DIR/type-ascription-instead-of-path.rs:2:5
|
||||||
|
|
|
|
||||||
LL | std:io::stdin();
|
LL | std:io::stdin();
|
||||||
| ^^^
|
| ^^^ not a value
|
||||||
| |
|
|
||||||
| not a value
|
|
||||||
| expecting a type here because of type ascription
|
|
||||||
help: maybe you meant to write a path separator here
|
help: maybe you meant to write a path separator here
|
||||||
|
|
|
|
||||||
LL | std::io::stdin();
|
LL | std::io::stdin();
|
||||||
|
|
Loading…
Reference in a new issue