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

Highlight whole expression for E0599 #108609

Merged
merged 1 commit into from
Mar 2, 2023
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
3 changes: 3 additions & 0 deletions compiler/rustc_hir_typeck/src/method/suggest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
rcvr_ty.prefix_string(self.tcx),
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 {
short_ty_str
} else {
Expand Down
13 changes: 7 additions & 6 deletions src/tools/compiletest/src/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1432,12 +1432,13 @@ impl<'test> TestCx<'test> {
expect_help: bool,
expect_note: bool,
) -> bool {
match actual_error.kind {
Some(ErrorKind::Help) => expect_help,
Some(ErrorKind::Note) => expect_note,
Some(ErrorKind::Error) | Some(ErrorKind::Warning) => true,
Some(ErrorKind::Suggestion) | None => false,
}
!actual_error.msg.is_empty()
&& match actual_error.kind {
Some(ErrorKind::Help) => expect_help,
Some(ErrorKind::Note) => expect_note,
Some(ErrorKind::Error) | Some(ErrorKind::Warning) => true,
Some(ErrorKind::Suggestion) | None => false,
}
}

fn should_emit_metadata(&self, pm: Option<PassMode>) -> Emit {
Expand Down
17 changes: 10 additions & 7 deletions tests/ui/methods/method-call-err-msg.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,17 @@ LL | .two(0, /* isize */);
error[E0599]: `Foo` is not an iterator
--> $DIR/method-call-err-msg.rs:19:7
|
LL | pub struct Foo;
| --------------
| |
| method `take` not found for this struct
| doesn't satisfy `Foo: Iterator`
LL | pub struct Foo;
| --------------
| |
| method `take` not found for this struct
| doesn't satisfy `Foo: Iterator`
...
LL | .take()
| ^^^^ `Foo` is not an iterator
LL | / y.zero()
LL | | .take()
| | -^^^^ `Foo` is not an iterator
| |______|
|
|
= note: the following trait bounds were not satisfied:
`Foo: Iterator`
Expand Down
13 changes: 11 additions & 2 deletions tests/ui/typeck/issue-31173.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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
--> $DIR/issue-31173.rs:12:10
|
LL | .collect();
| ^^^^^^^ method cannot be called due to unsatisfied trait bounds
LL | let temp: Vec<u8> = it
| _________________________-
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
|
= note: doesn't satisfy `<_ as Iterator>::Item = &_`
Expand Down