Skip to content

Commit b1a6c32

Browse files
committed
Tweak labels
1 parent 8ba1a97 commit b1a6c32

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

src/librustc_resolve/lib.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3289,8 +3289,7 @@ impl<'a> Resolver<'a> {
32893289
let line_sp = cm.lookup_char_pos(sp.hi()).line;
32903290
let line_base_sp = cm.lookup_char_pos(base_span.lo()).line;
32913291
if snippet == ":" {
3292-
err.span_label(base_span,
3293-
"expecting a type here because of type ascription");
3292+
let mut show_label = true;
32943293
if line_sp != line_base_sp {
32953294
err.span_suggestion_short(
32963295
sp,
@@ -3312,6 +3311,7 @@ impl<'a> Resolver<'a> {
33123311
"::".to_string(),
33133312
Applicability::MaybeIncorrect,
33143313
);
3314+
show_label = false;
33153315
}
33163316
if let Ok(base_snippet) = base_snippet {
33173317
err.span_suggestion(
@@ -3320,8 +3320,13 @@ impl<'a> Resolver<'a> {
33203320
format!("let {}", base_snippet),
33213321
Applicability::MaybeIncorrect,
33223322
);
3323+
show_label = false;
33233324
}
33243325
}
3326+
if show_label {
3327+
err.span_label(base_span,
3328+
"expecting a type here because of type ascription");
3329+
}
33253330
break;
33263331
} else if !snippet.trim().is_empty() {
33273332
debug!("tried to find type ascription `:` token, couldn't find it");

src/test/ui/suggestions/type-ascription-instead-of-let.stderr

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ LL | temp: i32 = fun(5i32);
55
| ^^^^
66
| |
77
| not found in this scope
8-
| expecting a type here because of type ascription
98
| help: maybe you meant to write an assignment here: `let temp`
109

1110
error[E0425]: cannot find value `temp` in this scope

src/test/ui/suggestions/type-ascription-instead-of-path.stderr

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,7 @@ error[E0423]: expected value, found module `std`
88
--> $DIR/type-ascription-instead-of-path.rs:2:5
99
|
1010
LL | std:io::stdin();
11-
| ^^^
12-
| |
13-
| not a value
14-
| expecting a type here because of type ascription
11+
| ^^^ not a value
1512
help: maybe you meant to write a path separator here
1613
|
1714
LL | std::io::stdin();

0 commit comments

Comments
 (0)