Skip to content

Commit 6c2a952

Browse files
committed
Highlight whole expression for E0599
1 parent 64165aa commit 6c2a952

File tree

4 files changed

+31
-15
lines changed

4 files changed

+31
-15
lines changed

compiler/rustc_hir_typeck/src/method/suggest.rs

+3
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
333333
rcvr_ty.prefix_string(self.tcx),
334334
ty_str_reported,
335335
);
336+
if tcx.sess.source_map().is_multiline(sugg_span) {
337+
err.span_label(sugg_span.with_hi(span.lo()), "");
338+
}
336339
let ty_str = if short_ty_str.len() < ty_str.len() && ty_str.len() > 10 {
337340
short_ty_str
338341
} else {

src/tools/compiletest/src/runtest.rs

+7-6
Original file line numberDiff line numberDiff line change
@@ -1432,12 +1432,13 @@ impl<'test> TestCx<'test> {
14321432
expect_help: bool,
14331433
expect_note: bool,
14341434
) -> bool {
1435-
match actual_error.kind {
1436-
Some(ErrorKind::Help) => expect_help,
1437-
Some(ErrorKind::Note) => expect_note,
1438-
Some(ErrorKind::Error) | Some(ErrorKind::Warning) => true,
1439-
Some(ErrorKind::Suggestion) | None => false,
1440-
}
1435+
!actual_error.msg.is_empty()
1436+
&& match actual_error.kind {
1437+
Some(ErrorKind::Help) => expect_help,
1438+
Some(ErrorKind::Note) => expect_note,
1439+
Some(ErrorKind::Error) | Some(ErrorKind::Warning) => true,
1440+
Some(ErrorKind::Suggestion) | None => false,
1441+
}
14411442
}
14421443

14431444
fn should_emit_metadata(&self, pm: Option<PassMode>) -> Emit {

tests/ui/methods/method-call-err-msg.stderr

+10-7
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,17 @@ LL | .two(0, /* isize */);
4848
error[E0599]: `Foo` is not an iterator
4949
--> $DIR/method-call-err-msg.rs:19:7
5050
|
51-
LL | pub struct Foo;
52-
| --------------
53-
| |
54-
| method `take` not found for this struct
55-
| doesn't satisfy `Foo: Iterator`
51+
LL | pub struct Foo;
52+
| --------------
53+
| |
54+
| method `take` not found for this struct
55+
| doesn't satisfy `Foo: Iterator`
5656
...
57-
LL | .take()
58-
| ^^^^ `Foo` is not an iterator
57+
LL | / y.zero()
58+
LL | | .take()
59+
| | -^^^^ `Foo` is not an iterator
60+
| |______|
61+
|
5962
|
6063
= note: the following trait bounds were not satisfied:
6164
`Foo: Iterator`

tests/ui/typeck/issue-31173.stderr

+11-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,17 @@ note: required by a bound in `cloned`
2424
error[E0599]: the method `collect` exists for struct `Cloned<TakeWhile<&mut IntoIter<u8>, [[email protected]:7:21]>>`, but its trait bounds were not satisfied
2525
--> $DIR/issue-31173.rs:12:10
2626
|
27-
LL | .collect();
28-
| ^^^^^^^ method cannot be called due to unsatisfied trait bounds
27+
LL | let temp: Vec<u8> = it
28+
| _________________________-
29+
LL | | .take_while(|&x| {
30+
LL | | found_e = true;
31+
LL | | false
32+
LL | | })
33+
LL | | .cloned()
34+
LL | | .collect();
35+
| | -^^^^^^^ method cannot be called due to unsatisfied trait bounds
36+
| |_________|
37+
|
2938
--> $SRC_DIR/core/src/iter/adapters/take_while.rs:LL:COL
3039
|
3140
= note: doesn't satisfy `<_ as Iterator>::Item = &_`

0 commit comments

Comments
 (0)