about summary refs log tree commit diff
path: root/src/librustc_traits
AgeCommit message (Collapse)AuthorLines
2018-07-21Convert implied_outlives_bounds to a queryTyler Mandry-0/+187
2018-07-18Auto merge of #52342 - nnethercote:CanonicalVar, r=nikomatsakisbors-5/+5
Avoid most allocations in `Canonicalizer`. Extra allocations are a significant cost of NLL, and the most common ones come from within `Canonicalizer`. In particular, `canonical_var()` contains this code: indices .entry(kind) .or_insert_with(|| { let cvar1 = variables.push(info); let cvar2 = var_values.push(kind); assert_eq!(cvar1, cvar2); cvar1 }) .clone() `variables` and `var_values` are `Vec`s. `indices` is a `HashMap` used to track what elements have been inserted into `var_values`. If `kind` hasn't been seen before, `indices`, `variables` and `var_values` all get a new element. (The number of elements in each container is always the same.) This results in lots of allocations. In practice, most of the time these containers only end up holding a few elements. This PR changes them to avoid heap allocations in the common case, by changing the `Vec`s to `SmallVec`s and only using `indices` once enough elements are present. (When the number of elements is small, a direct linear search of `var_values` is as good or better than a hashmap lookup.) The changes to `variables` are straightforward and contained within `Canonicalizer`. The changes to `indices` are more complex but also contained within `Canonicalizer`. The changes to `var_values` are more intrusive because they require defining a new type `SmallCanonicalVarValues` -- which is to `CanonicalVarValues` as `SmallVec` is to `Vec -- and passing stack-allocated values of that type in from outside. All this speeds up a number of NLL "check" builds, the best by 2%. r? @nikomatsakis
2018-07-17Avoid most allocations in `Canonicalizer`.Nicholas Nethercote-5/+5
Extra allocations are a significant cost of NLL, and the most common ones come from within `Canonicalizer`. In particular, `canonical_var()` contains this code: indices .entry(kind) .or_insert_with(|| { let cvar1 = variables.push(info); let cvar2 = var_values.push(kind); assert_eq!(cvar1, cvar2); cvar1 }) .clone() `variables` and `var_values` are `Vec`s. `indices` is a `HashMap` used to track what elements have been inserted into `var_values`. If `kind` hasn't been seen before, `indices`, `variables` and `var_values` all get a new element. (The number of elements in each container is always the same.) This results in lots of allocations. In practice, most of the time these containers only end up holding a few elements. This PR changes them to avoid heap allocations in the common case, by changing the `Vec`s to `SmallVec`s and only using `indices` once enough elements are present. (When the number of elements is small, a direct linear search of `var_values` is as good or better than a hashmap lookup.) The changes to `variables` are straightforward and contained within `Canonicalizer`. The changes to `indices` are more complex but also contained within `Canonicalizer`. The changes to `var_values` are more intrusive because they require defining a new type `SmallCanonicalVarValues` -- which is to `CanonicalVarValues` as `SmallVec` is to `Vec -- and passing stack-allocated values of that type in from outside. All this speeds up a number of NLL "check" builds, the best by 2%.
2018-07-12Deny bare trait objects in the rest of rustljedrz-0/+2
2018-07-09Change wordingscalexm-20/+22
2018-07-07extend where clausescsmoe-15/+18
2018-07-06refactorcsmoe-35/+32
2018-07-05merge wellformed(wc)scsmoe-25/+17
2018-07-05split IntoWellFormedGoalcsmoe-4/+4
2018-07-05wellformed wccsmoe-22/+80
2018-07-02introduce `predicates_defined_on` for traitsNiko Matsakis-4/+2
This new query returns only the predicates *directly defined* on an item (in contrast to the more common `predicates_of`, which returns the predicates that must be proven to reference an item). These two sets are almost always identical except for traits, where `predicates_of` includes an artificial `Self: Trait<...>` predicate (basically saying that you cannot use a trait item without proving that the trait is implemented for the type parameters). This new query is only used in chalk lowering, where this artificial `Self: Trait` predicate is problematic. We encode it in metadata but only where needed since it is kind of repetitive with existing information. Co-authored-by: Tyler Mandry <tmandry@gmail.com>
2018-07-02use `ty::TraitRef::identity` where possibleNiko Matsakis-5/+1
Co-authored-by: Tyler Mandry <tmandry@gmail.com>
2018-06-28Use `Ident`s for associated item definitions in HIRVadim Petrochenkov-1/+1
Remove emulation of hygiene with gensyms
2018-06-28Use `Ident`s for associated type bindings in HIRVadim Petrochenkov-1/+1
2018-06-27rustfmt various filesNiko Matsakis-1/+2
2018-06-27change the `enter_canonical_trait_query` method to give a fulfill cxNiko Matsakis-29/+29
2018-06-27pull out `ParamEnvAnd` and remove `QueryKey`Niko Matsakis-22/+15
2018-06-27move into `provide` methodsNiko Matsakis-29/+73
2018-06-27merge all the `type_op_foo` modules into one as they are so trivialNiko Matsakis-111/+62
2018-06-27use query boiler plate for `normalize_projection_ty` tooNiko Matsakis-27/+33
2018-06-27use query boilerplate for prove-predicate -- slightly inefficientNiko Matsakis-11/+17
This requires us to allocate a single entry vector we didn't use to allocate. I doubt this makes a difference in practice, as this only occurs for cache misses.
2018-06-27use query boilerplate for subtypeNiko Matsakis-14/+14
2018-06-27use query boilerplate for `normalize`Niko Matsakis-20/+16
2018-06-27extract out query boilerplate and use for `Eq`Niko Matsakis-14/+5
2018-06-26introduce `Normalizable` trait for things directly normalizableNiko Matsakis-0/+73
2018-06-26convert `prove_predicate` into a queryNiko Matsakis-0/+34
2018-06-26make `Subtype` a true queryNiko Matsakis-0/+37
2018-06-26make `Eq` a true queryNiko Matsakis-0/+37
2018-06-26remove `Canonicalization` trait, which serves no purposeNiko Matsakis-14/+1
2018-06-26move `make_query_response` into method on infcxNiko Matsakis-137/+18
2018-06-22Auto merge of #51433 - scalexm:finish-rules, r=nikomatsakisbors-81/+167
[chalkify] Small refactoring and WF/FromEnv rules for types r? @nikomatsakis
2018-06-14rustc: rename ty::maps to ty::query.Eduard-Mihai Burtescu-1/+1
2018-06-07Add rules for type well-formednessscalexm-4/+74
2018-06-04Refactor the chalkify lowering processscalexm-81/+97
2018-06-01Update recursion limitsJohn Kåre Alsaker-0/+2
2018-05-31Register outlives predicates from queries the right way around.Matthew Jasper-5/+7
2018-05-24pacify the mercilous tidyNiko Matsakis-0/+10
2018-05-24implement the chalk traits, albeit with many placeholdersNiko Matsakis-1/+521
2018-05-21rustc: use intern_* instead of mk_* where possible.Eduard-Mihai Burtescu-4/+4
2018-05-17Rollup merge of #50818 - nnethercote:faster-normalize, r=nikomatsakisMark Simulacrum-6/+4
Speed up `opt_normalize_projection_type` `opt_normalize_projection_type` is hot in the serde and futures benchmarks in rustc-perf. These two patches speed up the execution of most runs for them by 2--4%.
2018-05-17Avoid allocations in `opt_normalize_projection_type`.Nicholas Nethercote-6/+4
This patch changes `opt_normalize_project_type` so it appends obligations to a given obligations vector, instead of returning a new obligations vector. This change avoids lots of allocations. In the most extreme case, for a clean "Check" build of serde it reduces the total number of allocations by 20%.
2018-05-15Clean up dropck_outlives PhantomData handlingvarkor-7/+4
2018-05-15Add mk_param_from_defvarkor-3/+8
2018-05-15Pull common parameters into GenericParamDefvarkor-6/+4
This leads to a lot of simplifications, as most code doesn't actually need to know about the specific lifetime/type data; rather, it's concerned with properties like name, index and def_id.
2018-05-15Inline get_typevarkor-2/+6
2018-05-15Refactor to address commentsvarkor-6/+1
2018-05-15Generalise more cases of explicit iteration of specific kindsvarkor-2/+7
2018-05-15Fix generics type parameter handling in mirivarkor-1/+2
2018-05-08Store the GeneratorInterior in the new GeneratorSubstsJohn Kåre Alsaker-1/+1
2018-05-08Store generator movability outside GeneratorInteriorJohn Kåre Alsaker-1/+1