Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Differentiate different defining uses of taits when they reference di…
…stinct generic parameters
- Loading branch information
1 parent
e386373
commit 9e547b4
Showing
3 changed files
with
38 additions
and
10 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
16 changes: 16 additions & 0 deletions
16
src/test/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn.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,16 @@ | ||
// https://github.com/rust-lang/rust/issues/73481 | ||
// This test used to cause unsoundness, since one of the two possible | ||
// resolutions was chosen at random instead of erroring due to conflicts. | ||
|
||
#![feature(min_type_alias_impl_trait)] | ||
|
||
type X<A, B> = impl Into<&'static A>; | ||
//~^ ERROR the trait bound `&'static B: From<&A>` is not satisfied | ||
|
||
fn f<A, B: 'static>(a: &'static A, b: B) -> (X<A, B>, X<B, A>) { | ||
(a, a) | ||
} | ||
|
||
fn main() { | ||
println!("{}", <X<_, _> as Into<&String>>::into(f(&[1isize, 2, 3], String::new()).1)); | ||
} |
15 changes: 15 additions & 0 deletions
15
src/test/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn.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,15 @@ | ||
error[E0277]: the trait bound `&'static B: From<&A>` is not satisfied | ||
--> $DIR/multiple-def-uses-in-one-fn.rs:7:16 | ||
| | ||
LL | type X<A, B> = impl Into<&'static A>; | ||
| ^^^^^^^^^^^^^^^^^^^^^ the trait `From<&A>` is not implemented for `&'static B` | ||
| | ||
= note: required because of the requirements on the impl of `Into<&'static B>` for `&A` | ||
help: consider introducing a `where` bound, but there might be an alternative better way to express this requirement | ||
| | ||
LL | fn f<A, B: 'static>(a: &'static A, b: B) -> (X<A, B>, X<B, A>) where &'static B: From<&A> { | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0277`. |