about summary refs log tree commit diff
path: root/src/librustc/traits
AgeCommit message (Collapse)AuthorLines
2018-06-07Inline `process_obligation`.Nicholas Nethercote-0/+4
It's very hot, and this speeds things up.
2018-06-07Inline and remove `process_predicate`.Nicholas Nethercote-242/+235
Because it has a single callsite. This patch is large but trivial, doing the minimal amount of work (mostly `self.` insertions) necessary.
2018-06-07Simplify `process_obligation`.Nicholas Nethercote-9/+12
`process_predicates` returns a `Result<Option<Vec<PredicateObligation>>>`. `process_obligation` calls it and then fiddles with the output (using `map`, `map`, `into_iter`, `collect`) to produce a a `Result<Option<Vec<PendingPredicateObligation>>>`. This function is sufficiently hot that the fiddling is expensive. It's much better for `process_predicate` to directly return a `Result<Option<Vec<PendingPredicateObligation>>>` because `Ok(None)` accounts for ~90% of the results, and `Ok(vec![])` accounts for another ~5%.
2018-06-05Properly report transitive errorsOliver Schneider-2/+1
2018-06-05Refactor the const eval diagnostic APIOliver Schneider-3/+6
2018-06-04Refactor the chalkify lowering processscalexm-47/+102
2018-06-02Fix typos of 'ambiguous'Jon Purdy-5/+5
2018-05-31change `PointerKind::Implicit` to a noteNiko Matsakis-6/+25
`PointerKind` is included in `LoanPath` and hence forms part of the equality check; this led to having two unequal paths that both represent `*x`, depending on whether the `*` was inserted automatically or explicitly. Bad mojo. The `note` field, in contrast, is intended more-or-less primarily for this purpose of adding extra data.
2018-05-28Auto merge of #50724 - zackmdavis:applicability_rush, r=Manishearthbors-13/+22
add suggestion applicabilities to librustc and libsyntax A down payment on #50723. Interested in feedback on whether my `MaybeIncorrect` vs. `MachineApplicable` judgement calls are well-calibrated (and that we have a consensus on what this means). r? @Manishearth cc @killercup @estebank
2018-05-26Use `Ident`s for fields in HIRVadim Petrochenkov-1/+1
2018-05-24implement the chalk traits, albeit with many placeholdersNiko Matsakis-145/+275
2018-05-23Rollup merge of #50932 - nnethercote:seen-Predicates, r=eddybkennytm-3/+18
Optimize seen Predicate filtering. This speeds up a few rustc-perf benchmark runs, most notably ones involving 'coercions', the best by 2%.
2018-05-22Auto merge of #50876 - matthewjasper:rollback-trivial-bounds, r=nikomatsakisbors-0/+5
Filter global bounds from ParamEnv again. This PR adds back the filtering of global bounds from ParamEnv as a temporary solution for #50825. <details> Long term, the fix seems like it should be changing the priority in `candidate_should_be_dropped_in_favor_of` so that (global) where clauses aren't considered as highly. https://github.com/rust-lang/rust/blob/a722296b6ec17fecd3f16a7d3f9232b83e5de800/src/librustc/traits/select.rs#L2017-L2022 </details> r? @nikomatsakis
2018-05-21rustc: move TypeParamDef's fields into GenericParamDefKind::Type.Eduard-Mihai Burtescu-3/+3
2018-05-21rustc: don't call Kind::from directly, use .into() instead.Eduard-Mihai Burtescu-2/+2
2018-05-21rustc: make mk_substs_trait take &[Kind] instead of &[Ty].Eduard-Mihai Burtescu-18/+14
2018-05-21Optimize seen Predicate filtering.Nicholas Nethercote-3/+18
This speeds up a few rustc-perf benchmark runs, most notably ones involving 'coercions', the best by 2%.
2018-05-20suggestion applicabilities for libsyntax and librustc, run-rustfix testsZack M. Davis-13/+22
Consider this a down payment on #50723. To recap, an `Applicability` enum was recently (#50204) added, to convey to Rustfix and other tools whether we think it's OK for them to blindly apply the suggestion, or whether to prompt a human for guidance (because the suggestion might contain placeholders that we can't infer, or because we think it has a sufficiently high probability of being wrong even though it's— presumably—right often enough to be worth emitting in the first place). When a suggestion is marked as `MaybeIncorrect`, we try to use comments to indicate precisely why (although there are a few places where we just say `// speculative` because the present author's subjective judgement balked at the idea that the suggestion has no false positives). The `run-rustfix` directive is opporunistically set on some relevant UI tests (and a couple tests that were in the `test/ui/suggestions` directory, even if the suggestions didn't originate in librustc or libsyntax). This is less trivial than it sounds, because a surprising number of test files aren't equipped to be tested as fixed even when they contain successfully fixable errors, because, e.g., there are more, not-directly-related errors after fixing. Some test files need an attribute or underscore to avoid unused warnings tripping up the "fixed code is still producing diagnostics" check despite the fixes being correct; this is an interesting contrast-to/inconsistency-with the behavior of UI tests (which secretly pass `-A unused`), a behavior which we probably ought to resolve one way or the other (filed issue #50926). A few suggestion labels are reworded (e.g., to avoid phrasing it as a question, which which is discouraged by the style guidelines listed in `.span_suggestion`'s doc-comment).
2018-05-18Filter global bounds from ParamEnv again.Matthew Jasper-0/+5
2018-05-17Rollup merge of #50818 - nnethercote:faster-normalize, r=nikomatsakisMark Simulacrum-72/+108
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-17Rename trans to codegen everywhere.Irina Popa-16/+16
2018-05-17Avoid allocations in `opt_normalize_projection_type`.Nicholas Nethercote-71/+90
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-17Avoid repeated HashMap lookups in `opt_normalize_projection_type`.Nicholas Nethercote-1/+18
There is a hot path through `opt_normalize_projection_type`: - `try_start` does a cache lookup (#1). - The result is a `NormalizedTy`. - There are no unresolved type vars, so we call `complete`. - `complete` does *another* cache lookup (#2), then calls `SnapshotMap::insert`. - `insert` does *another* cache lookup (#3), inserting the same value that's already in the cache. This patch optimizes this hot path by introducing `complete_normalized`, for use when the value is known in advance to be a `NormalizedTy`. It always avoids lookup #2. Furthermore, if the `NormalizedTy`'s obligations are empty (the common case), we know that lookup #3 would be a no-op, so we avoid it, while inserting a Noop into the `SnapshotMap`'s undo log.
2018-05-16Auto merge of #48557 - matthewjasper:allow-trvial-bounds, r=nikomatsakisbors-47/+41
Implement RFC 2056 trivial constraints in where clauses This is an implementation of the new behaviour for #48214. Tests are mostly updated to show the effects of this. Feature gate hasn't been added yet. Some things that are worth noting and are maybe not want we want * `&mut T: Copy` doesn't allow as much as someone might expect because there is often an implicit reborrow. * ~There isn't a check that a where clause is well-formed any more, so `where Vec<str>: Debug` is now allowed (without a `str: Sized` bound).~ r? @nikomatsakis
2018-05-15Auto merge of #48523 - varkor:generics-ty-generalisations, r=nikomatsakisbors-24/+41
The Great Generics Generalisation: Ty Edition Part of the generic parameter refactoring effort, split off from https://github.com/rust-lang/rust/pull/48149. Contains the `ty`-relative refactoring. r? @eddyb
2018-05-15Make is_global true for latebound regionsMatthew Jasper-1/+1
2018-05-15Add mk_param_from_defvarkor-1/+1
2018-05-15Use Kind instead of UnpackedKind in Substs methodsvarkor-5/+3
2018-05-15Refactor Substs methods on generic parametersvarkor-6/+12
2018-05-15Clean up generic param handlingvarkor-4/+3
2018-05-15Review refactoringvarkor-6/+7
2018-05-15Rename param_counts to own_countsvarkor-1/+1
2018-05-15Lift pure_wrt_drop to GenericParamDefvarkor-3/+3
2018-05-15Refactor generic params loopsvarkor-16/+18
2018-05-15Pull common parameters into GenericParamDefvarkor-14/+16
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-10/+15
2018-05-15Refactor to address commentsvarkor-2/+1
2018-05-15Use GenericParamCount instead of FxHashMapvarkor-2/+2
2018-05-15Eliminate ty::Generics::types()varkor-4/+8
And with one final incanation, the specific kind iterators were banished from ty::Generics, never to be seen again!
2018-05-15Generalise more cases of explicit iteration of specific kindsvarkor-4/+4
2018-05-15Generalise cases of explicit iteration of specific kindsvarkor-8/+9
2018-05-15Prefer iterator to vecvarkor-5/+5
2018-05-15Consolidate ty::Genericsvarkor-4/+4
2018-05-15Rollup merge of #50712 - leodasvacas:improve-eager-resolution-error-message, ↵Guillaume Gomez-5/+5
r=estebank Improve eager type resolution error message This PR improves the span of eager resolution type errors referring to indexing and field access to use the base span rather than the whole expression. Also a "note: type must be known at this point" is added where in the past we emitted the "type must be known at this context" error, so that early failures can be differentiated and will hopefully be less surprising. Fixes #50692 (or at least does the best we can for the moment) r? @estebank
2018-05-15Feature gate trivial boundsMatthew Jasper-0/+12
2018-05-15Implement RFC 2056 - trivial constraintsMatthew Jasper-46/+28
2018-05-13Improve eager type resolution error messageleonardo.yvens-5/+5
This PR improves the span of eager resolution type errors referring to indexing and field access to use the base span rather than the whole expression. Also a note "Type must be known at this point." is added to where we at some point in the past emitted the "type must be known at this context" error, so that early failures can be differentiated and will hopefully be less surprising. Fixes #50692 (or at least does the best we can for the moment) r? @estebank
2018-05-12Better error reporting in Copy deriveleonardo.yvens-33/+4
In Copy derive, report all fulfillment erros when present and do not report errors for types tainted with `TyErr`. Also report all fields which are not Copy rather than just the first. Also refactored `fn fully_normalize`, removing the not very useful helper function along with a FIXME to the closed issue #26721 that's looks out of context now.
2018-05-10Auto merge of #50395 - Zoxc:small-tys, r=michaelwoeristerbors-25/+25
Optimize layout of TypeVariants This makes references to `Slice` use thin pointers by storing the slice length in the slice itself. `GeneratorInterior` is replaced by storing the movability of generators in `TyGenerator` and the interior witness is stored in `GeneratorSubsts` (which is just a wrapper around `&'tcx Substs`, like `ClosureSubsts`). Finally the fields of `TypeAndMut` is stored inline in `TyRef`. These changes combine to reduce `TypeVariants` from 48 bytes to 24 bytes on x86_64. r? @michaelwoerister
2018-05-09Auto merge of #49834 - Zoxc:sync-trait-cache, r=nikomatsakisbors-10/+17
Make SelectionCache and EvaluationCache thread-safe Split out from https://github.com/rust-lang/rust/pull/49558 r? @nikomatsakis