-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problem with self
when inheriting generic traits.
#4183
Comments
If this can be fixed this would allow us define
|
@catamorphism (nag nag) |
I did a search for "mismatched types: expecting", and it seems to be pointing to librustc/middle/typeck/check/_match.rs. Dunno if that's of any help. |
There also seems to be one at librustc/middle/typeck/check/mod.rs
|
I think this is failing because typeck isn't applying substs properly when checking the inherited trait. If I comment out the |
Cheers, the help is most appreciated. |
So far I've figured out that the I don't understand the code well enough to know what to do, though; still digging. |
After talking to @nikomatsakis , I think this will be easier to fix after fixing #4678, so I'm going to consider this blocked on #4678. |
Referencing this pull: #4910 |
I am doing some refactoring so as to make object types and the rest sound and correctly implemented. This is needed to prepare for my rewritten and expanded borrow checker. I have a feeling this refactoring will solve this issue, or at least make it much clearer what's going on. |
Not critical for 0.6; de-milestoning. |
…e with a bare function store (which is not in fact a kind of value) but rather ty::TraitRef. Removes many uses of fail!() and other telltale signs of type-semantic mismatch. cc rust-lang#4183 (not a fix, but related)
…e with a bare function store (which is not in fact a kind of value) but rather ty::TraitRef. Removes many uses of fail!() and other telltale signs of type-semantic mismatch. cc rust-lang#4183 (not a fix, but related)
Just a progress report: I've got the fix for this almost done...a couple of tests failing though so not quite there. |
|
…mber of ways. - In a TraitRef, use the self type consistently to refer to the Self type: - trait ref in `impl Trait<A,B,C> for S` has a self type of `S`. - trait ref in `A:Trait` has the self type `A` - trait ref associated with a trait decl has self type `Self` - trait ref associated with a supertype has self type `Self` - trait ref in an object type `@Trait` has no self type - Rewrite `each_bound_traits_and_supertraits` to perform substitutions as it goes, and thus yield a series of trait refs that are always in the same 'namespace' as the type parameter bound given as input. Before, we left this to the caller, but this doesn't work because the caller lacks adequare information to perform the type substitutions correctly. - For provided methods, substitute the generics involved in the provided method correctly. - Introduce TypeParameterDef, which tracks the bounds declared on a type parameter and brings them together with the def_id and (in the future) other information (maybe even the parameter's name!). - Introduce Subst trait, which helps to cleanup a lot of the repetitive code involved with doing type substitution. - Introduce Repr trait, which makes debug printouts far more convenient. Fixes rust-lang#4183. Needed for rust-lang#5656.
…komatsakis Cleanup substitutions and treatment of generics around traits in a number of ways - In a TraitRef, use the self type consistently to refer to the Self type: - trait ref in `impl Trait<A,B,C> for S` has a self type of `S`. - trait ref in `A:Trait` has the self type `A` - trait ref associated with a trait decl has self type `Self` - trait ref associated with a supertype has self type `Self` - trait ref in an object type `@Trait` has no self type - Rewrite `each_bound_traits_and_supertraits` to perform substitutions as it goes, and thus yield a series of trait refs that are always in the same 'namespace' as the type parameter bound given as input. Before, we left this to the caller, but this doesn't work because the caller lacks adequare information to perform the type substitutions correctly. - For provided methods, substitute the generics involved in the provided method correctly. - Introduce TypeParameterDef, which tracks the bounds declared on a type parameter and brings them together with the def_id and (in the future) other information (maybe even the parameter's name!). - Introduce Subst trait, which helps to cleanup a lot of the repetitive code involved with doing type substitution. - Introduce Repr trait, which makes debug printouts far more convenient. Fixes #4183. Needed for #5656. r? @catamorphism
I think we can close this one now. Everything seems to be in order. :) |
Update: changed to capitalized
Self
Update: Use
FuzzyEq
trait fromstd::cmp
The text was updated successfully, but these errors were encountered: