Differentiate different defining uses of taits when they reference distinct generic parameters
This commit is contained in:
parent
e386373514
commit
9e547b4464
3 changed files with 38 additions and 10 deletions
|
|
@ -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));
|
||||
}
|
||||
|
|
@ -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`.
|
||||
Loading…
Add table
Add a link
Reference in a new issue