-
Notifications
You must be signed in to change notification settings - Fork 12.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't suggest
#[doc(hidden)]
methods
- Loading branch information
Showing
3 changed files
with
38 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// #107983 - testing that `__iterator_get_unchecked` isn't suggested | ||
// HELP included so that compiletest errors on the bad suggestion | ||
pub fn i_can_has_iterator() -> impl Iterator<Item = u32> { | ||
//~^ ERROR expected `Box<dyn Iterator>` | ||
//~| HELP consider constraining the associated type | ||
Box::new(1..=10) as Box<dyn Iterator> | ||
//~^ ERROR the value of the associated type `Item` | ||
//~| HELP specify the associated type | ||
} | ||
|
||
fn main() {} |
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,24 @@ | ||
error[E0191]: the value of the associated type `Item` (from trait `Iterator`) must be specified | ||
--> $DIR/trait-hidden-method.rs:6:33 | ||
| | ||
LL | Box::new(1..=10) as Box<dyn Iterator> | ||
| ^^^^^^^^ help: specify the associated type: `Iterator<Item = Type>` | ||
|
||
error[E0271]: expected `Box<dyn Iterator>` to be an iterator that yields `u32`, but it yields `<dyn Iterator as Iterator>::Item` | ||
--> $DIR/trait-hidden-method.rs:3:32 | ||
| | ||
LL | pub fn i_can_has_iterator() -> impl Iterator<Item = u32> { | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ expected associated type, found `u32` | ||
... | ||
LL | Box::new(1..=10) as Box<dyn Iterator> | ||
| ------------------------------------- return type was inferred to be `Box<dyn Iterator>` here | ||
| | ||
= note: expected associated type `<dyn Iterator as Iterator>::Item` | ||
found type `u32` | ||
= help: consider constraining the associated type `<dyn Iterator as Iterator>::Item` to `u32` or calling a method that returns `<dyn Iterator as Iterator>::Item` | ||
= note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
Some errors have detailed explanations: E0191, E0271. | ||
For more information about an error, try `rustc --explain E0191`. |