Repository navigation
Closed
Closed
Copy link
Labels
A-associated-itemsArea: Associated items (types, constants & functions)Area: Associated items (types, constants & functions)A-higher-rankedArea: Higher-ranked things (e.g., lifetimes, types, trait bounds aka HRTBs)Area: Higher-ranked things (e.g., lifetimes, types, trait bounds aka HRTBs)A-lazy-normalizationArea: Lazy normalization (tracking issue: #60471)Area: Lazy normalization (tracking issue: #60471)A-lifetimesArea: Lifetimes / regionsArea: Lifetimes / regionsA-type-systemArea: Type systemArea: Type systemC-bugCategory: This is a bug.Category: This is a bug.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.Call for participation: An issue has been fixed and does not reproduce, but no test has been added.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-typesRelevant to the types team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.
Description
trait MyFrom<T> {}
impl<T> MyFrom<T> for T {}
trait MyInto<T> {}
impl<T, U> MyInto<U> for T where U: MyFrom<T> {}
trait A<'self_> {
type T;
}
trait B: for<'self_> A<'self_> {
//type U: for<'self_> MyFrom<<Self as A<'self_>>::T>; // <-- this won't compile
type U: for<'self_> MyInto<<Self as A<'self_>>::T>; // <-- but this will
}
struct M;
impl<'self_> A<'self_> for M {
type T = usize;
}
impl B for M {
type U = usize;
}
fn main() {}This could've been written with MyInto written as Into and similarly for MyFrom/From. It was written this way only to make explicit the necessity of one blanket impl for satisfying the other.
I'm guessing that extensional equality is not judged, even though it is possible to make such a judgment and such a judgment must be made to compile code that compiles today. <Self as A<'self_>>::T on line 12 ought to be equated to usize (which must be detected at some other point in time else line 13 wouldn't be able to compile).
EDIT: Playing around a bit, it looks more and more like it's all about the HKL bounds...
Reacted by Michael Benfield, Charles Samborski, Felipe S. S. Schneider and Andrew Hlynskyi
Reacted by Felipe S. S. Schneider and Andrew Hlynskyi
Metadata
Metadata
Assignees
Labels
A-associated-itemsArea: Associated items (types, constants & functions)Area: Associated items (types, constants & functions)A-higher-rankedArea: Higher-ranked things (e.g., lifetimes, types, trait bounds aka HRTBs)Area: Higher-ranked things (e.g., lifetimes, types, trait bounds aka HRTBs)A-lazy-normalizationArea: Lazy normalization (tracking issue: #60471)Area: Lazy normalization (tracking issue: #60471)A-lifetimesArea: Lifetimes / regionsArea: Lifetimes / regionsA-type-systemArea: Type systemArea: Type systemC-bugCategory: This is a bug.Category: This is a bug.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.Call for participation: An issue has been fixed and does not reproduce, but no test has been added.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-typesRelevant to the types team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.
Activity
[-]Trait A having blanket impl dependence on trait B may be satisfied, but trait B may not[/-][+]A trait having blanket impl dependence on a 2nd trait may be satisfied, but the 2nd trait may not[/+][-]A trait having blanket impl dependence on a 2nd trait may be satisfied, but the 2nd trait may not[/-][+]HKL bounds on associated types causes types that would otherwise be judged equivalent to not be[/+]soltanmm commentedon Dec 30, 2015
HRTBs (I've been using the wrong nomenclature the whole time!) make projections sad.
Very likely a dupe of #28994.
[-]HKL bounds on associated types causes types that would otherwise be judged equivalent to not be[/-][+]Associated type projections don't play well with HRTBs and normalization[/+]eddyb commentedon Jan 1, 2016
cc @nikomatsakis
arielb1 commentedon Jan 2, 2016
Known issue.
soltanmm commentedon Jan 16, 2016
@arielb1 (or @nikomatsakis? Still a bit unclear on y'all's role separation)
What's the expected overall approach to fixing this issue? Even if you don't expect a newcomer to handle it, I'd like to know anyway. :-D
nikomatsakis commentedon Jan 16, 2016
@soltanmm actually, I'm not entirely sure. There are a serious of refactorings that I have in mind for the type system / trait resolver, and I've been figuring that after those are done, I would come back to revisit some of these issues, if they still occur, but it may be worth digging into this example (or #28994) in detail. Honestly it's not all fresh in my mind.
The refactorings I am thinking of are, first, lazy normalization (as described in this discuss thread), which may indeed help here, though I've not thought it through very deeply. Second, I'd like to generally rework how the trait checker is working to make it easier to extend the environment as you go -- the current setup, where the set of assumptions etc is semi-fixed when the inference context is created -- makes it hard to "descend through" a binder like
forand then do trait resolutions and normalizations within that context.soltanmm commentedon Jan 18, 2016
So, potentially w.r.t. lazy normalization, I've been playing with another bit of code (trying to shrink it a bit):
From reading the debug logs, it seems that when checking the well-formed-ness of
impl A for S, upon normalizingS::Btousize, and registering andselecting on the implied<usize as Hkt<'a>>::Output: Clone, the compiler has no idea that<usize as Hkt<'a>>::Output == usizeand never normalizes to it either. Is this a situation in which the compiler might have assumed that everything was already normalized the best it could be and thus gave up?An aside: does lazy normalization have something to do with this asterisk in
project.rs?Mark-Simulacrum commentedon May 6, 2017
Is this #30867? It looks similar, but uncertain.
dylanede commentedon Apr 20, 2018
What's the state of this now? I fairly frequently run into problems with associated types involved with HRTBs not projecting/unifying.
9 remaining items
demurgos commentedon Mar 19, 2020
I think this issue is related to an error I encountered when trying to use the
Iterabletrait example from the Generic Associated Types RFC (RFC 1598).The trait is defined as follow:
I implemented it for a vector of booleans:
Playground
I believe this should compile, but it errors.
See full error
It does not recognize that
&booland<BoolVec as Iterable>::Item<'_>are the same.vandenheuvel commentedon Jul 22, 2020
@demurgos You example compiles now.
fmease commentedon Sep 24, 2024
Triage: The original issue seems to have been fixed, the example from the issue description compiles just fine now.
Auto merge of rust-lang#131355 - clubby789:old-tests, r=<try>
Rollup merge of rust-lang#131355 - clubby789:old-tests, r=jieyouxu
Unrolled build for rust-lang#131355