Skip to content

Commit

Permalink
Don't add message that will never be shown to users
Browse files Browse the repository at this point in the history
It will still be used in json, as seen by the ui test changes
  • Loading branch information
oli-obk committed Nov 11, 2022
1 parent 014f7f4 commit 21ce587
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2445,12 +2445,12 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
(Ok(l), Ok(r)) => l.line == r.line,
_ => true,
};
if !ident.span.overlaps(span) && !same_line {
if !ident.span.is_dummy() && !ident.span.overlaps(span) && !same_line {
multispan.push_span_label(ident.span, "required by a bound in this");
}
}
let descr = format!("required by a bound in `{}`", item_name);
if span != DUMMY_SP {
if !span.is_dummy() {
let msg = format!("required by this bound in `{}`", item_name);
multispan.push_span_label(span, msg);
err.span_note(multispan, &descr);
Expand Down
1 change: 0 additions & 1 deletion src/test/ui/iterators/collect-into-array.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
fn main() {
//~^ NOTE required by a bound in this
let whatever: [u32; 10] = (0..10).collect();
//~^ ERROR an array of type `[u32; 10]` cannot be built directly from an iterator
//~| NOTE try collecting into a `Vec<{integer}>`, then using `.try_into()`
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/iterators/collect-into-array.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0277]: an array of type `[u32; 10]` cannot be built directly from an iterator
--> $DIR/collect-into-array.rs:3:31
--> $DIR/collect-into-array.rs:2:31
|
LL | let whatever: [u32; 10] = (0..10).collect();
| ^^^^^^^ ------- required by a bound introduced by this call
Expand Down
2 changes: 0 additions & 2 deletions src/test/ui/iterators/collect-into-slice.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
fn process_slice(data: &[i32]) {
//~^ NOTE required by a bound in this
//~| NOTE required by a bound in this
todo!()
}

Expand Down
6 changes: 3 additions & 3 deletions src/test/ui/iterators/collect-into-slice.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0277]: the size for values of type `[i32]` cannot be known at compilation time
--> $DIR/collect-into-slice.rs:8:9
--> $DIR/collect-into-slice.rs:6:9
|
LL | let some_generated_vec = (0..10).collect();
| ^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
Expand All @@ -9,7 +9,7 @@ LL | let some_generated_vec = (0..10).collect();
= help: unsized locals are gated as an unstable feature

error[E0277]: the size for values of type `[i32]` cannot be known at compilation time
--> $DIR/collect-into-slice.rs:8:38
--> $DIR/collect-into-slice.rs:6:38
|
LL | let some_generated_vec = (0..10).collect();
| ^^^^^^^ doesn't have a size known at compile-time
Expand All @@ -22,7 +22,7 @@ LL | fn collect<B: FromIterator<Self::Item>>(self) -> B
| ^ required by this bound in `collect`

error[E0277]: a slice of type `[i32]` cannot be built since `[i32]` has no definite size
--> $DIR/collect-into-slice.rs:8:30
--> $DIR/collect-into-slice.rs:6:30
|
LL | let some_generated_vec = (0..10).collect();
| ^^^^^^^ ------- required by a bound introduced by this call
Expand Down

0 comments on commit 21ce587

Please sign in to comment.