Tweak unsupported negative trait bounds message
This commit is contained in:
parent
e1be8b0318
commit
9bfb0ef818
6 changed files with 55 additions and 38 deletions
|
@ -366,7 +366,7 @@ impl Diagnostic {
|
||||||
}],
|
}],
|
||||||
}],
|
}],
|
||||||
msg: msg.to_owned(),
|
msg: msg.to_owned(),
|
||||||
style: SuggestionStyle::HideCodeInline,
|
style: SuggestionStyle::HideCodeAlways,
|
||||||
applicability,
|
applicability,
|
||||||
});
|
});
|
||||||
self
|
self
|
||||||
|
|
|
@ -5598,8 +5598,14 @@ impl<'a> Parser<'a> {
|
||||||
|
|
||||||
if !negative_bounds.is_empty() || was_negative {
|
if !negative_bounds.is_empty() || was_negative {
|
||||||
let plural = negative_bounds.len() > 1;
|
let plural = negative_bounds.len() > 1;
|
||||||
let mut err = self.struct_span_err(negative_bounds,
|
let last_span = negative_bounds.last().map(|sp| *sp);
|
||||||
"negative trait bounds are not supported");
|
let mut err = self.struct_span_err(
|
||||||
|
negative_bounds,
|
||||||
|
"negative trait bounds are not supported",
|
||||||
|
);
|
||||||
|
if let Some(sp) = last_span {
|
||||||
|
err.span_label(sp, "negative trait bounds are not supported");
|
||||||
|
}
|
||||||
if let Some(bound_list) = colon_span {
|
if let Some(bound_list) = colon_span {
|
||||||
let bound_list = bound_list.to(self.prev_span);
|
let bound_list = bound_list.to(self.prev_span);
|
||||||
let mut new_bound_list = String::new();
|
let mut new_bound_list = String::new();
|
||||||
|
@ -5612,11 +5618,12 @@ impl<'a> Parser<'a> {
|
||||||
}
|
}
|
||||||
new_bound_list = new_bound_list.replacen(" +", ":", 1);
|
new_bound_list = new_bound_list.replacen(" +", ":", 1);
|
||||||
}
|
}
|
||||||
err.span_suggestion_short(bound_list,
|
err.span_suggestion_hidden(
|
||||||
&format!("remove the trait bound{}",
|
bound_list,
|
||||||
if plural { "s" } else { "" }),
|
&format!("remove the trait bound{}", if plural { "s" } else { "" }),
|
||||||
new_bound_list,
|
new_bound_list,
|
||||||
Applicability::MachineApplicable);
|
Applicability::MachineApplicable,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
err.emit();
|
err.emit();
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,8 @@ error: negative trait bounds are not supported
|
||||||
--> $DIR/issue-58857.rs:4:7
|
--> $DIR/issue-58857.rs:4:7
|
||||||
|
|
|
|
||||||
LL | impl<A: !Valid> Conj<A>{}
|
LL | impl<A: !Valid> Conj<A>{}
|
||||||
| ^^^^^^^^ help: remove the trait bound
|
| ^^^^^^^^ negative trait bounds are not supported
|
||||||
|
= help: remove the trait bound
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,15 @@
|
||||||
// run-rustfix
|
// run-rustfix
|
||||||
|
|
||||||
trait Tr {} //~ ERROR negative trait bounds are not supported
|
trait Tr {}
|
||||||
trait Tr2: SuperA {} //~ ERROR negative trait bounds are not supported
|
//~^ ERROR negative trait bounds are not supported
|
||||||
trait Tr3: SuperB {} //~ ERROR negative trait bounds are not supported
|
trait Tr2: SuperA {}
|
||||||
|
//~^ ERROR negative trait bounds are not supported
|
||||||
|
trait Tr3: SuperB {}
|
||||||
|
//~^ ERROR negative trait bounds are not supported
|
||||||
trait Tr4: SuperB + SuperD {}
|
trait Tr4: SuperB + SuperD {}
|
||||||
|
//~^ ERROR negative trait bounds are not supported
|
||||||
trait Tr5 {}
|
trait Tr5 {}
|
||||||
|
//~^ ERROR negative trait bounds are not supported
|
||||||
|
|
||||||
trait SuperA {}
|
trait SuperA {}
|
||||||
trait SuperB {}
|
trait SuperB {}
|
||||||
|
|
|
@ -1,12 +1,17 @@
|
||||||
// run-rustfix
|
// run-rustfix
|
||||||
|
|
||||||
trait Tr: !SuperA {} //~ ERROR negative trait bounds are not supported
|
trait Tr: !SuperA {}
|
||||||
trait Tr2: SuperA + !SuperB {} //~ ERROR negative trait bounds are not supported
|
//~^ ERROR negative trait bounds are not supported
|
||||||
trait Tr3: !SuperA + SuperB {} //~ ERROR negative trait bounds are not supported
|
trait Tr2: SuperA + !SuperB {}
|
||||||
trait Tr4: !SuperA + SuperB //~ ERROR negative trait bounds are not supported
|
//~^ ERROR negative trait bounds are not supported
|
||||||
|
trait Tr3: !SuperA + SuperB {}
|
||||||
|
//~^ ERROR negative trait bounds are not supported
|
||||||
|
trait Tr4: !SuperA + SuperB
|
||||||
+ !SuperC + SuperD {}
|
+ !SuperC + SuperD {}
|
||||||
trait Tr5: !SuperA //~ ERROR negative trait bounds are not supported
|
//~^ ERROR negative trait bounds are not supported
|
||||||
|
trait Tr5: !SuperA
|
||||||
+ !SuperB {}
|
+ !SuperB {}
|
||||||
|
//~^ ERROR negative trait bounds are not supported
|
||||||
|
|
||||||
trait SuperA {}
|
trait SuperA {}
|
||||||
trait SuperB {}
|
trait SuperB {}
|
||||||
|
|
|
@ -2,41 +2,40 @@ error: negative trait bounds are not supported
|
||||||
--> $DIR/issue-33418.rs:3:9
|
--> $DIR/issue-33418.rs:3:9
|
||||||
|
|
|
|
||||||
LL | trait Tr: !SuperA {}
|
LL | trait Tr: !SuperA {}
|
||||||
| ^^^^^^^^^ help: remove the trait bound
|
| ^^^^^^^^^ negative trait bounds are not supported
|
||||||
|
= help: remove the trait bound
|
||||||
|
|
||||||
error: negative trait bounds are not supported
|
error: negative trait bounds are not supported
|
||||||
--> $DIR/issue-33418.rs:4:19
|
--> $DIR/issue-33418.rs:5:19
|
||||||
|
|
|
|
||||||
LL | trait Tr2: SuperA + !SuperB {}
|
LL | trait Tr2: SuperA + !SuperB {}
|
||||||
| ---------^^^^^^^^^
|
| ^^^^^^^^^ negative trait bounds are not supported
|
||||||
| |
|
= help: remove the trait bound
|
||||||
| help: remove the trait bound
|
|
||||||
|
|
||||||
error: negative trait bounds are not supported
|
error: negative trait bounds are not supported
|
||||||
--> $DIR/issue-33418.rs:5:10
|
--> $DIR/issue-33418.rs:7:10
|
||||||
|
|
|
|
||||||
LL | trait Tr3: !SuperA + SuperB {}
|
LL | trait Tr3: !SuperA + SuperB {}
|
||||||
| ^^^^^^^^^---------
|
| ^^^^^^^^^ negative trait bounds are not supported
|
||||||
| |
|
= help: remove the trait bound
|
||||||
| help: remove the trait bound
|
|
||||||
|
|
||||||
error: negative trait bounds are not supported
|
error: negative trait bounds are not supported
|
||||||
--> $DIR/issue-33418.rs:6:10
|
--> $DIR/issue-33418.rs:9:10
|
||||||
|
|
|
|
||||||
LL | trait Tr4: !SuperA + SuperB
|
LL | trait Tr4: !SuperA + SuperB
|
||||||
| __________-^^^^^^^^
|
| ^^^^^^^^^
|
||||||
LL | | + !SuperC + SuperD {}
|
LL | + !SuperC + SuperD {}
|
||||||
| |_____^^^^^^^^^________- help: remove the trait bounds
|
| ^^^^^^^^^ negative trait bounds are not supported
|
||||||
|
= help: remove the trait bounds
|
||||||
|
|
||||||
error: negative trait bounds are not supported
|
error: negative trait bounds are not supported
|
||||||
--> $DIR/issue-33418.rs:8:10
|
--> $DIR/issue-33418.rs:12:10
|
||||||
|
|
|
|
||||||
LL | trait Tr5: !SuperA
|
LL | trait Tr5: !SuperA
|
||||||
| __________-^^^^^^^^
|
| ^^^^^^^^^
|
||||||
LL | | + !SuperB {}
|
LL | + !SuperB {}
|
||||||
| | ^^^^^^^^-
|
| ^^^^^^^^^ negative trait bounds are not supported
|
||||||
| |_____________|
|
= help: remove the trait bounds
|
||||||
| help: remove the trait bounds
|
|
||||||
|
|
||||||
error: aborting due to 5 previous errors
|
error: aborting due to 5 previous errors
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue