Closed
Description
#![feature(marker_trait_attr)]
#[marker]
trait A {}
trait B {}
impl<T: A> B for T {}
impl<T: B> A for T {}
impl A for &str {}
impl<T: A + B> A for (T,) {}
// insert another line break around here and it stops compiling on nightly-2021-04-25
trait TraitWithAssoc {
type Assoc;
}
impl<T: A> TraitWithAssoc for T {
type Assoc = T;
}
// ^^^ vvv these two impls should be overlapping
impl TraitWithAssoc for ((&str,),) {
type Assoc = ((&'static str,),);
}
fn g<T: TraitWithAssoc<Assoc = ((&'static str,),)>>(x: T::Assoc) -> ((&'static str,),) {
x
}
fn j<T: A + B>(
x: (T,),
f: fn(<(T,) as TraitWithAssoc>::Assoc) -> ((&'static str,),),
) -> ((&'static str,),) {
f(x)
}
fn main() {
let y;
{
let hello = "Hello World!".to_owned();
y = j::<(&str,)>(((&hello,),), g::<((&str,),)>).0 .0;
}
println!("{}", y);
}
�0X�
same code with an additional line of whitespace/comments where indicated:
error[E0277]: the trait bound `(&str,): A` is not satisfied
--> src/main.rs:39:26
|
31 | fn j<T: A + B>(x: (T,), f: fn(<(T,) as TraitWithAssoc>::Assoc) -> &'static str) -> &'static str {
| - required by this bound in `j`
...
39 | y = j::<(&str,)>(((&hello,),), g::<((&str,),)>);
| ^^^^^^^^^^^^ the trait `A` is not implemented for `(&str,)`
|
= help: the following implementations were found:
<(T,) as A>
however, the playground seems to behave different from my local nightly here
Tested on
$ rustc +nightly-2021-04-25 --version
rustc 1.53.0-nightly (42816d61e 2021-04-24)
@rustbot label T-compiler requires-nightly F-marker_trait_attr A-traits A-typesystem
and someone please add “I-unsound 💥”
Metadata
Metadata
Assignees
Labels
Area: Incremental compilationArea: Trait systemArea: Type systemCategory: This is a bug.`#![feature(marker_trait_attr)]`Issue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessRelevant to the compiler team, which will review and decide on the PR/issue.This issue requires a nightly compiler in some way.