Rollup merge of #108609 - clubby789:e0599-highlight, r=estebank
Highlight whole expression for E0599 Fixes #108603 This adds a secondary label to highlight the whole expression leading to the error. It also prevents empty labels being recognised as 'unexpected' by compiletest - otherwise, tests with NOTE annotations would pick up empty labels. `@rustbot` label +A-diagnostics
This commit is contained in:
commit
832987bb1e
4 changed files with 31 additions and 15 deletions
|
@ -333,6 +333,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
rcvr_ty.prefix_string(self.tcx),
|
rcvr_ty.prefix_string(self.tcx),
|
||||||
ty_str_reported,
|
ty_str_reported,
|
||||||
);
|
);
|
||||||
|
if tcx.sess.source_map().is_multiline(sugg_span) {
|
||||||
|
err.span_label(sugg_span.with_hi(span.lo()), "");
|
||||||
|
}
|
||||||
let ty_str = if short_ty_str.len() < ty_str.len() && ty_str.len() > 10 {
|
let ty_str = if short_ty_str.len() < ty_str.len() && ty_str.len() > 10 {
|
||||||
short_ty_str
|
short_ty_str
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1432,12 +1432,13 @@ impl<'test> TestCx<'test> {
|
||||||
expect_help: bool,
|
expect_help: bool,
|
||||||
expect_note: bool,
|
expect_note: bool,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
match actual_error.kind {
|
!actual_error.msg.is_empty()
|
||||||
Some(ErrorKind::Help) => expect_help,
|
&& match actual_error.kind {
|
||||||
Some(ErrorKind::Note) => expect_note,
|
Some(ErrorKind::Help) => expect_help,
|
||||||
Some(ErrorKind::Error) | Some(ErrorKind::Warning) => true,
|
Some(ErrorKind::Note) => expect_note,
|
||||||
Some(ErrorKind::Suggestion) | None => false,
|
Some(ErrorKind::Error) | Some(ErrorKind::Warning) => true,
|
||||||
}
|
Some(ErrorKind::Suggestion) | None => false,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn should_emit_metadata(&self, pm: Option<PassMode>) -> Emit {
|
fn should_emit_metadata(&self, pm: Option<PassMode>) -> Emit {
|
||||||
|
|
|
@ -48,14 +48,17 @@ LL | .two(0, /* isize */);
|
||||||
error[E0599]: `Foo` is not an iterator
|
error[E0599]: `Foo` is not an iterator
|
||||||
--> $DIR/method-call-err-msg.rs:19:7
|
--> $DIR/method-call-err-msg.rs:19:7
|
||||||
|
|
|
|
||||||
LL | pub struct Foo;
|
LL | pub struct Foo;
|
||||||
| --------------
|
| --------------
|
||||||
| |
|
| |
|
||||||
| method `take` not found for this struct
|
| method `take` not found for this struct
|
||||||
| doesn't satisfy `Foo: Iterator`
|
| doesn't satisfy `Foo: Iterator`
|
||||||
...
|
...
|
||||||
LL | .take()
|
LL | / y.zero()
|
||||||
| ^^^^ `Foo` is not an iterator
|
LL | | .take()
|
||||||
|
| | -^^^^ `Foo` is not an iterator
|
||||||
|
| |______|
|
||||||
|
|
|
||||||
|
|
|
|
||||||
= note: the following trait bounds were not satisfied:
|
= note: the following trait bounds were not satisfied:
|
||||||
`Foo: Iterator`
|
`Foo: Iterator`
|
||||||
|
|
|
@ -24,8 +24,17 @@ note: required by a bound in `cloned`
|
||||||
error[E0599]: the method `collect` exists for struct `Cloned<TakeWhile<&mut IntoIter<u8>, [closure@issue-31173.rs:7:21]>>`, but its trait bounds were not satisfied
|
error[E0599]: the method `collect` exists for struct `Cloned<TakeWhile<&mut IntoIter<u8>, [closure@issue-31173.rs:7:21]>>`, but its trait bounds were not satisfied
|
||||||
--> $DIR/issue-31173.rs:12:10
|
--> $DIR/issue-31173.rs:12:10
|
||||||
|
|
|
|
||||||
LL | .collect();
|
LL | let temp: Vec<u8> = it
|
||||||
| ^^^^^^^ method cannot be called due to unsatisfied trait bounds
|
| _________________________-
|
||||||
|
LL | | .take_while(|&x| {
|
||||||
|
LL | | found_e = true;
|
||||||
|
LL | | false
|
||||||
|
LL | | })
|
||||||
|
LL | | .cloned()
|
||||||
|
LL | | .collect();
|
||||||
|
| | -^^^^^^^ method cannot be called due to unsatisfied trait bounds
|
||||||
|
| |_________|
|
||||||
|
|
|
||||||
--> $SRC_DIR/core/src/iter/adapters/take_while.rs:LL:COL
|
--> $SRC_DIR/core/src/iter/adapters/take_while.rs:LL:COL
|
||||||
|
|
|
|
||||||
= note: doesn't satisfy `<_ as Iterator>::Item = &_`
|
= note: doesn't satisfy `<_ as Iterator>::Item = &_`
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue