Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

in which some labels and notes are upgraded to structured suggestions #48928

Merged
merged 1 commit into from
Mar 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/librustc_typeck/check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3096,10 +3096,10 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
};
}
ty::TyRawPtr(..) => {
err.note(&format!("`{0}` is a native pointer; perhaps you need to deref \
with `(*{0}).{1}`",
self.tcx.hir.node_to_pretty_string(base.id),
field.node));
let base = self.tcx.hir.node_to_pretty_string(base.id);
let msg = format!("`{}` is a native pointer; try dereferencing it", base);
let suggestion = format!("(*{}).{}", base, field.node);
err.span_suggestion(field.span, &msg, suggestion);
}
_ => {}
}
Expand Down
13 changes: 8 additions & 5 deletions src/libsyntax/parse/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2831,9 +2831,10 @@ impl<'a> Parser<'a> {
let (span, e) = self.interpolated_or_expr_span(e)?;
let span_of_tilde = lo;
let mut err = self.diagnostic().struct_span_err(span_of_tilde,
"`~` can not be used as a unary operator");
err.span_label(span_of_tilde, "did you mean `!`?");
err.help("use `!` instead of `~` if you meant to perform bitwise negation");
"`~` cannot be used as a unary operator");
err.span_suggestion_short(span_of_tilde,
"use `!` to perform bitwise negation",
"!".to_owned());
err.emit();
(lo.to(span), self.mk_unary(UnOp::Not, e))
}
Expand Down Expand Up @@ -3389,7 +3390,7 @@ impl<'a> Parser<'a> {
None)?;
if let Err(mut e) = self.expect(&token::OpenDelim(token::Brace)) {
if self.token == token::Token::Semi {
e.span_note(match_span, "did you mean to remove this `match` keyword?");
e.span_suggestion_short(match_span, "try removing this `match`", "".to_owned());
}
return Err(e)
}
Expand Down Expand Up @@ -5361,7 +5362,9 @@ impl<'a> Parser<'a> {
if is_macro_rules {
let mut err = self.diagnostic()
.struct_span_err(sp, "can't qualify macro_rules invocation with `pub`");
err.help("did you mean #[macro_export]?");
err.span_suggestion(sp,
"try exporting the macro",
"#[macro_export]".to_owned());
Err(err)
} else {
let mut err = self.diagnostic()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
// except according to those terms.

fn main() {
let x = ~1; //~ ERROR can not be used as a unary operator
let x = ~1; //~ ERROR cannot be used as a unary operator
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
error: `~` cannot be used as a unary operator
--> $DIR/issue-41679-tilde-bitwise-negation-attempt.rs:12:13
|
LL | let x = ~1; //~ ERROR cannot be used as a unary operator
| ^ help: use `!` to perform bitwise negation

error: aborting due to previous error

10 changes: 0 additions & 10 deletions src/test/ui/did_you_mean/issue-41679.stderr

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

fn main() {
let foo =
match //~ NOTE did you mean to remove this `match` keyword?
match
Some(4).unwrap_or_else(5)
//~^ NOTE expected one of `.`, `?`, `{`, or an operator here
; //~ NOTE unexpected token
Expand Down
13 changes: 13 additions & 0 deletions src/test/ui/did_you_mean/match-refactor-to-expr.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
error: expected one of `.`, `?`, `{`, or an operator, found `;`
--> $DIR/match-refactor-to-expr.rs:18:9
|
LL | match
| ----- help: try removing this `match`
LL | Some(4).unwrap_or_else(5)
| - expected one of `.`, `?`, `{`, or an operator here
LL | //~^ NOTE expected one of `.`, `?`, `{`, or an operator here
LL | ; //~ NOTE unexpected token
| ^ unexpected token

error: aborting due to previous error

Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
// except according to those terms.

#[macro_use] mod bleh {
pub macro_rules! foo { //~ ERROR can't qualify macro_rules invocation with `pub`
//~^ HELP did you mean #[macro_export]?
pub macro_rules! foo { //~ ERROR can't qualify macro_rules invocation
($n:ident) => (
fn $n () -> i32 {
1
Expand Down
8 changes: 8 additions & 0 deletions src/test/ui/did_you_mean/pub-macro-rules.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
error: can't qualify macro_rules invocation with `pub`
--> $DIR/pub-macro-rules.rs:12:5
|
LL | pub macro_rules! foo { //~ ERROR can't qualify macro_rules invocation
| ^^^ help: try exporting the macro: `#[macro_export]`

error: aborting due to previous error

8 changes: 2 additions & 6 deletions src/test/ui/issue-11004.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,13 @@ error[E0609]: no field `x` on type `*mut A`
--> $DIR/issue-11004.rs:17:21
|
LL | let x : i32 = n.x; //~ no field `x` on type `*mut A`
| ^
|
= note: `n` is a native pointer; perhaps you need to deref with `(*n).x`
| ^ help: `n` is a native pointer; try dereferencing it: `(*n).x`

error[E0609]: no field `y` on type `*mut A`
--> $DIR/issue-11004.rs:18:21
|
LL | let y : f64 = n.y; //~ no field `y` on type `*mut A`
| ^
|
= note: `n` is a native pointer; perhaps you need to deref with `(*n).y`
| ^ help: `n` is a native pointer; try dereferencing it: `(*n).y`

error: aborting due to 2 previous errors

Expand Down