about summary refs log tree commit diff
path: root/src/librustc/middle/traits
AgeCommit message (Collapse)AuthorLines
2016-03-27rustc: move cfg, infer, traits and ty from middle to top-level.Eduard Burtescu-8933/+0
2016-03-27rustc: move middle::subst into middle::ty.Eduard Burtescu-7/+7
2016-03-25Drive-by fix for unnecessary `&mut`Niko Matsakis-1/+1
2016-03-24remove ErasedRegions from substitutionsNiko Matsakis-8/+0
This hack has long since outlived its usefulness; the transition to trans passing around full substitutions is basically done. Instead of `ErasedRegions`, just supply substitutions with a suitable number of `'static` entries, and invoke `erase_regions` when needed (the latter of which we already do).
2016-03-22fix alignmentJorge Aparicio-8/+8
2016-03-22try! -> ?Jorge Aparicio-26/+26
Automated conversion using the untry tool [1] and the following command: ``` $ find -name '*.rs' -type f | xargs untry ``` at the root of the Rust repo. [1]: https://github.com/japaric/untry
2016-03-14Fixes after rebaseAaron Turon-11/+15
2016-03-14Introduce ICE when the topmost projection restriction kicks in, as per issue ↵Aaron Turon-4/+29
#32205
2016-03-14Test fixes, added README for testsAaron Turon-5/+12
2016-03-14Fixes after a rebaseAaron Turon-11/+10
2016-03-14Address review commentsAaron Turon-99/+72
2016-03-14Move projection_mode to InferContext rather than SelectionContext to reduce ↵Aaron Turon-140/+109
chance of bugs
2016-03-14Forbid cross-polarity specializationsAaron Turon-0/+6
2016-03-14Add some debugging output for specialization graph assemblyAaron Turon-0/+9
2016-03-14Refactor core specialization and subst translation code to avoidAaron Turon-170/+145
danger of inference variables floating around without their inference context. The main insight here is that, when we are translating substitutions between two impls, *we already know that the more specific impl holds*, so we do not need to add its obligations to the parameter environment. Instead, we can just thread through the inference context we used to show select the more specific impl in the first place.
2016-03-14Add more commentary for subst translationAaron Turon-3/+29
2016-03-14Move specialization graph walks to iterators; make associated typeAaron Turon-519/+863
projection sensitive to "mode" (most importantly, trans vs middle). This commit introduces several pieces of iteration infrastructure in the specialization graph data structure, as well as various helpers for finding the definition of a given item, given its kind and name. In addition, associated type projection is now *mode-sensitive*, with three possible modes: - **Topmost**. This means that projection is only possible if there is a non-`default` definition of the associated type directly on the selected impl. This mode is a bit of a hack: it's used during early coherence checking before we have built the specialization graph (and therefore before we can walk up the specialization parents to find other definitions). Eventually, this should be replaced with a less "staged" construction of the specialization graph. - **AnyFinal**. Projection succeeds for any non-`default` associated type definition, even if it is defined by a parent impl. Used throughout typechecking. - **Any**. Projection always succeeds. Used by trans. The lasting distinction here is between `AnyFinal` and `Any` -- we wish to treat `default` associated types opaquely for typechecking purposes. In addition to the above, the commit includes a few other minor review fixes.
2016-03-14Address basic nits from initial reviewAaron Turon-8/+9
2016-03-14Assorted fixed after rebasingAaron Turon-2/+1
2016-03-14Add some basic comments about how specialization fits into the rest of the ↵Aaron Turon-0/+43
trait machinery
2016-03-14Add feature gateAaron Turon-0/+10
2016-03-14Implement default associated type inheritance.Aaron Turon-31/+43
This commit leverages the specialization graph infrastructure to allow specializing trait implementations to leave off associated types for which their parents have provided defaults. It also modifies the type projection code to avoid projecting associated types unless either (1) all input types are fully known or (2) the available associated type is "final", i.e. not marked `default`. This restriction is required for soundness, due to examples like: ```rust trait Foo { type Assoc; } impl<T> Foo for T { default type Assoc = (); } impl Foo for u8 { type Assoc = String; } fn generic<T>() -> <T as Foo>::Assoc { () //~ ERROR } fn main() { let s: String = generic::<u8>(); println!("{}", s); // bad news } ```
2016-03-14Check for proper use of `default` keyword in specializing impls.Aaron Turon-1/+22
2016-03-14Implement default method inheritance.Aaron Turon-39/+224
This commit leverages the specialization graph infrastructure to allow specializing trait implementations to leave off methods for which their parents have provided defaults. It does not yet check that the `default` keyword is appropriately used in such cases.
2016-03-14Initial incorporation of specialization:Aaron Turon-41/+80
- Rewrites the overlap checker to instead build up a specialization graph, checking for overlap errors in the process. - Use the specialization order during impl selection. This commit does not yet handle associated types correctly, and assumes that all items are `default` and are overridden.
2016-03-14Add specialization module.Aaron Turon-0/+232
The module contains a few important components: - The `specialize` function, which determines whether one impl is a specialization of another. - The `SpecializationGraph`, a per-trait graph recording the specialization tree. The main purpose of the graph is to allow traversals upwards (to less specialized impls) for discovering un-overridden defaults, and for ensuring that overridden items are allowed to be overridden.
2016-03-14Refactor `impl_trait_ref_and_oblig`, making it generally available as a utilityAaron Turon-4/+36
2016-03-14Fix existing comment typo.Aaron Turon-2/+1
2016-03-11Forbid items with the same name being defined in overlapping inherentAaron Turon-12/+9
impl blocks. For example, the following is now correctly illegal: ```rust struct Foo; impl Foo { fn id() {} } impl Foo { fn id() {} } ``` "Overlapping" here is determined the same way it is for traits (and in fact shares the same code path): roughly, there must be some way of substituting any generic types to unify the impls, such that none of the `where` clauses are provably unsatisfiable under such a unification. Closes #22889
2016-03-11Introduce `ImplHeader`Aaron Turon-66/+24
This commit introduces the idea of an "impl header", which consists of everything outside the impl body: the Self type, the trait reference (when applicable), and predicates from `where` clauses. This type is usable with the type folding machinery, making it possible to work with impl headers at a higher and more generic level.
2016-03-09trans: Reify functions & methods to fn ptrs only where necessary.Eduard Burtescu-4/+5
2016-03-09Track fn type and lifetime parameters in TyFnDef.Eduard Burtescu-1/+1
2016-03-09Split TyBareFn into TyFnDef and TyFnPtr.Eli Friedman-4/+16
There's a lot of stuff wrong with the representation of these types: TyFnDef doesn't actually uniquely identify a function, TyFnPtr is used to represent method calls, TyFnDef in the sub-expression of a cast isn't correctly reified, and probably some other stuff I haven't discovered yet. Splitting them seems like the right first step, though.
2016-03-03Rename middle::ty::ctxt to TyCtxtJeffrey Seyfried-48/+48
2016-02-15use stalled_on in all obligation typesAriel Ben-Yehuda-12/+31
this improves typeck performance by 5% (LLVM times are still huge). Basically fixes #25916 (still O(n^2), but the example takes <1s to compile).
2016-02-13Auto merge of #31588 - soltanmm:layer, r=nikomatsakisbors-6/+6
<sup>**context:** moving back to a layered approach to type checking.</sup> It looks like they'd not ended up tightly coupled in the time one was owned by the other. Every instance outside of `FnCtxt.inh` was from an `InferCtxt` created and dropped in the same function body. This conflicts slightly with #30652, but there too it looks like the `FulfillmentContext` is from an `InferCtxt` that is created and dropped within the same function body (across one call to a module-private function). That said, I heard that the PR that originally moved `FulfillmentContext` into `InferCtxt` was big, which leaves me concerned that I'm missing something. r? @nikomatsakis
2016-02-12Autoderef in librustcJonas Schievink-3/+3
2016-02-11[breaking-change] don't glob import/export syntax::abi enum variantsOliver Schneider-2/+2
2016-02-10Update some debug loggingMasood Malekghassemi-6/+6
2016-02-01Use the per-tree state to detect and permit DAGs (but not cyclic graphs)Niko Matsakis-41/+80
2016-02-01Add a notion of "per-tree" stateNiko Matsakis-18/+46
2016-01-21Revamp the fulfillment cache tracking to only cache trait-refs, whichNiko Matsakis-28/+64
was the major use-case, and to update the dep-graph. Other kinds of predicates are now excluded from the cache because there is no easy way to make a good dep-graph node for them, and because they are not believed to be that useful. :) Fixes #30741. (However, the test still gives wrong result for trans, for an independent reason which is fixed in the next commit.)
2016-01-19remove the `SimplifiedType` from the `DepNode` for now, just to keepNiko Matsakis-11/+3
size of `DepNode` smaller and because we are not that fine-grained yet anyhow
2016-01-17add fixme number into codeNiko Matsakis-1/+1
2016-01-16Document `ObligationForest` better.Niko Matsakis-1/+1
2016-01-16Pacify tidy.Niko Matsakis-1/+2
2016-01-16Implement a hacky version of the DAG support we ultimately want, leavingNiko Matsakis-6/+52
a FIXME for later.
2016-01-16Detect cycles and specialize error reporting for Sized. It is importantNiko Matsakis-7/+187
to get the `Sized` error usable, since that hits new users frequently. Further work is needed for the error reporting for non-Sized cycle cases; those currently just fallback to the old path. Also adjust tests.
2016-01-16Permit coinductive match only for purely OIBIT backtraces.Niko Matsakis-11/+38
Better safe than sorry.
2016-01-16Fix bug in new stall checking code, it should consider integer variablesNiko Matsakis-1/+1
too.