-
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.
Allow constraining opaque types during auto trait casting
- Loading branch information
Showing
5 changed files
with
30 additions
and
32 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 was deleted.
Oops, something went wrong.
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,18 @@ | ||
//! Show an uninformative diagnostic that we could possibly improve in the future | ||
trait Trait<T> {} | ||
|
||
impl<T, U> Trait<T> for U {} | ||
|
||
fn hello() -> &'static (dyn Trait<impl Sized> + Send) { | ||
//~^ ERROR: type annotations needed | ||
if false { | ||
let x = hello(); | ||
let _: &'static dyn Trait<()> = &x; | ||
//^ Note the extra `&`, paired with the blanket impl causing | ||
// `impl Sized` to never get a hidden type registered. | ||
} | ||
todo!() | ||
} | ||
|
||
fn main() {} |
9 changes: 9 additions & 0 deletions
9
tests/ui/impl-trait/trait_upcasting_reference_mismatch.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,9 @@ | ||
error[E0282]: type annotations needed | ||
--> $DIR/trait_upcasting_reference_mismatch.rs:7:35 | ||
| | ||
LL | fn hello() -> &'static (dyn Trait<impl Sized> + Send) { | ||
| ^^^^^^^^^^ cannot infer type | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0282`. |