Skip to content

Commit

Permalink
Add missing primary label
Browse files Browse the repository at this point in the history
  • Loading branch information
estebank committed Aug 10, 2020
1 parent 6c0755a commit 54f1b43
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 7 deletions.
6 changes: 5 additions & 1 deletion src/librustc_resolve/late/diagnostics.rs
Expand Up @@ -532,6 +532,7 @@ impl<'a> LateResolutionVisitor<'a, '_, '_> {
}),
) if followed_by_brace => {
if let Some(sp) = closing_brace {
err.span_label(span, fallback_label);
err.multipart_suggestion(
"surround the struct literal with parentheses",
vec![
Expand Down Expand Up @@ -595,12 +596,15 @@ impl<'a> LateResolutionVisitor<'a, '_, '_> {
applicability,
);
}
_ => {}
_ => {
err.span_label(span, fallback_label);
}
}
};

match (res, source) {
(Res::Def(DefKind::Macro(MacroKind::Bang), _), _) => {
err.span_label(span, fallback_label);
err.span_suggestion_verbose(
span.shrink_to_hi(),
"use `!` to invoke the macro",
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/error-codes/E0423.stderr
Expand Up @@ -51,7 +51,7 @@ error[E0423]: expected value, found struct `T`
--> $DIR/E0423.rs:14:8
|
LL | if T {} == T {} { println!("Ok"); }
| ^
| ^ not a value
|
help: surround the struct literal with parentheses
|
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/hygiene/rustc-macro-transparency.stderr
Expand Up @@ -8,7 +8,7 @@ error[E0423]: expected value, found macro `semitransparent`
--> $DIR/rustc-macro-transparency.rs:29:5
|
LL | semitransparent;
| ^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^ not a value
|
help: use `!` to invoke the macro
|
Expand All @@ -19,7 +19,7 @@ error[E0423]: expected value, found macro `opaque`
--> $DIR/rustc-macro-transparency.rs:30:5
|
LL | opaque;
| ^^^^^^
| ^^^^^^ not a value
|
help: use `!` to invoke the macro
|
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/resolve/resolve-hint-macro.stderr
Expand Up @@ -2,7 +2,7 @@ error[E0423]: expected function, found macro `assert`
--> $DIR/resolve-hint-macro.rs:2:5
|
LL | assert(true);
| ^^^^^^
| ^^^^^^ not a function
|
help: use `!` to invoke the macro
|
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/struct-literal-variant-in-if.stderr
Expand Up @@ -46,7 +46,7 @@ error[E0423]: expected value, found struct variant `E::V`
--> $DIR/struct-literal-variant-in-if.rs:10:13
|
LL | if x == E::V { field } {}
| ^^^^
| ^^^^ not a value
|
help: surround the struct literal with parentheses
|
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/try-block/try-block-in-edition2015.stderr
Expand Up @@ -11,7 +11,7 @@ error[E0574]: expected struct, variant or union type, found macro `try`
--> $DIR/try-block-in-edition2015.rs:4:33
|
LL | let try_result: Option<_> = try {
| ^^^
| ^^^ not a struct, variant or union type
|
= note: if you want the `try` keyword, you need to be in the 2018 edition
help: use `!` to invoke the macro
Expand Down

0 comments on commit 54f1b43

Please sign in to comment.