-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #115629 - compiler-errors:sugg-deref-unsize, r=oli-obk
Don't suggest dereferencing to unsized type Rudimentary check that the self type is Sized. I don't really like any of this diagnostics code -- it's really messy and also really prone to false positives and negatives, but oh well. Fixes #115569
- Loading branch information
Showing
23 changed files
with
61 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
tests/ui/traits/suggest-dereferences/dont-suggest-unsize-deref.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
fn use_iterator<I>(itr: I) | ||
where | ||
I: IntoIterator<Item = i32>, | ||
{ | ||
} | ||
|
||
fn pass_iterator<I>(i: &dyn IntoIterator<Item = i32, IntoIter = I>) | ||
where | ||
I: Iterator<Item = i32>, | ||
{ | ||
use_iterator(i); | ||
//~^ ERROR `&dyn IntoIterator<IntoIter = I, Item = i32>` is not an iterator | ||
} | ||
|
||
fn main() {} |
22 changes: 22 additions & 0 deletions
22
tests/ui/traits/suggest-dereferences/dont-suggest-unsize-deref.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
error[E0277]: `&dyn IntoIterator<IntoIter = I, Item = i32>` is not an iterator | ||
--> $DIR/dont-suggest-unsize-deref.rs:11:18 | ||
| | ||
LL | use_iterator(i); | ||
| ------------ ^ `&dyn IntoIterator<IntoIter = I, Item = i32>` is not an iterator | ||
| | | ||
| required by a bound introduced by this call | ||
| | ||
= help: the trait `Iterator` is not implemented for `&dyn IntoIterator<IntoIter = I, Item = i32>` | ||
= note: required for `&dyn IntoIterator<IntoIter = I, Item = i32>` to implement `IntoIterator` | ||
note: required by a bound in `use_iterator` | ||
--> $DIR/dont-suggest-unsize-deref.rs:3:8 | ||
| | ||
LL | fn use_iterator<I>(itr: I) | ||
| ------------ required by a bound in this function | ||
LL | where | ||
LL | I: IntoIterator<Item = i32>, | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `use_iterator` | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0277`. |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.