about summary refs log tree commit diff
path: root/src/librustc/traits
AgeCommit message (Collapse)AuthorLines
2018-11-25Auto merge of #55906 - nnethercote:rm-OpenSnapshot-CommittedSnapshot, ↵bors-9/+5
r=nikomatsakis Clean up and streamline snapshot data structures These commits clean up the snapshot structures a bit, so they are more consistent with each other and with the `ena` crate. They also remove the `OpenSnapshot` and `CommittedSnapshot` entries in the undo log, just like I did for the `ena` crate in https://github.com/rust-lang-nursery/ena/pull/14. This PR in combination with that `ena` PR reduces instruction counts by up to 6% on benchmarks. r? @nikomatsakis. Note that this isn't quite ready for landing, because the `ena` dependency in the first commit needs to be updated once https://github.com/rust-lang-nursery/ena/pull/14 lands. But otherwise it should be good.
2018-11-25Make `commit` and `rollback_to` methods take ownership of the snapshots.Nicholas Nethercote-3/+3
Because they shouldn't be reused. This provides consistency with the `ena` crate.
2018-11-25Remove `insert_noop`.Nicholas Nethercote-6/+2
Because it's as useless as its name suggests. This commit also renames `UndoLog::Noop` as `UndoLog::Purged`, because (a) that's a more descriptive name and (b) it matches the name used in similar code in `librustc/infer/region_constraints/mod.rs`.
2018-11-24Move `BoundTy` debruijn index to the `TyKind` enum variantscalexm-4/+4
2018-11-24Instantiate all bound vars universallyscalexm-6/+6
2018-11-24Rename some occurences of `skol` to `placeholder`scalexm-3/+3
2018-11-24Introduce `TyKind::Placeholder` variantscalexm-2/+6
2018-11-22Rollup merge of #55980 - csmoe:issue-55891, r=estebankGuillaume Gomez-1/+15
Suggest on closure args count mismatching with pipe span Closes #55891 r? @estebank
2018-11-19Rollup merge of #56027 - Xanewok:docs-backtick, r=QuietMisdreavusPietro Albini-1/+1
docs: Add missing backtick in object_safety.rs docs Closes #56019. r? @bjorn3
2018-11-17docs: Add missing backtick in object_safety.rs docsIgor Matuszewski-1/+1
Closes #56019.
2018-11-17reserve whitespaces between prefix and pipecsmoe-1/+1
2018-11-16improve debug output related to bound calculationNiko Matsakis-1/+6
2018-11-15lint based on closure pipe spancsmoe-1/+15
2018-11-15Auto merge of #55974 - pietroalbini:rollup, r=pietroalbinibors-4/+5
Rollup of 17 pull requests Successful merges: - #55182 (Redox: Update to new changes) - #55211 (Add BufWriter::buffer method) - #55507 (Add link to std::mem::size_of to size_of intrinsic documentation) - #55530 (Speed up String::from_utf16) - #55556 (Use `Mmap` to open the rmeta file.) - #55622 (NetBSD: link libstd with librt in addition to libpthread) - #55750 (Make `NodeId` and `HirLocalId` `newtype_index`) - #55778 (Wrap some query results in `Lrc`.) - #55781 (More precise spans for temps and their drops) - #55785 (Add mem::forget_unsized() for forgetting unsized values) - #55852 (Rewrite `...` as `..=` as a `MachineApplicable` 2018 idiom lint) - #55865 (Unix RwLock: avoid racy access to write_locked) - #55901 (fix various typos in doc comments) - #55926 (Change sidebar selector to fix compatibility with docs.rs) - #55930 (A handful of hir tweaks) - #55932 (core/char: Speed up `to_digit()` for `radix <= 10`) - #55956 (add tests for some fixed ICEs) Failed merges: r? @ghost
2018-11-15Rollup merge of #55901 - euclio:speling, r=petrochenkovPietro Albini-1/+1
fix various typos in doc comments
2018-11-15Rollup merge of #55778 - nnethercote:LrcPreds, r=eddybPietro Albini-3/+4
Wrap some query results in `Lrc`. So that the frequent clones in `try_get` are cheaper.
2018-11-15Auto merge of #54906 - qnighy:fix-issue-50452, r=nikomatsakisbors-8/+19
Reattach all grandchildren when constructing specialization graph. Specialization graphs are constructed by incrementally adding impls in the order of declaration. If the impl being added has its specializations in the graph already, they should be reattached under the impl. However, the current implementation only reattaches the one found first. Therefore, in the following specialization graph, ``` Tr1 | I3 / \ I1 I2 ``` If `I1`, `I2`, and `I3` are declared in this order, the compiler mistakenly constructs the following graph: ``` Tr1 / \ I3 I2 | I1 ``` This patch fixes the reattach procedure to include all specializing grandchildren-to-be. Fixes #50452.
2018-11-14Wrap some query results in `Lrc`.Nicholas Nethercote-3/+4
So that the frequent clones in `try_get` are cheaper. Fixes #54274.
2018-11-13fix various typos in doc commentsAndy Russell-1/+1
2018-11-13Auto merge of #55356 - Aaron1011:fix/rustdoc-negative-auto, r=nikomatsakisbors-1/+16
Check for negative impls when finding auto traits Fixes #55321 When AutoTraitFinder begins examining a type, it checks for an explicit negative impl. However, it wasn't checking for negative impls found when calling 'select' on predicates found from nested obligations. This commit makes AutoTraitFinder check for negative impls whenever it makes a call to 'select'. If a negative impl is found, it immediately bails out. Normal users of SelectioContext don't need to worry about this, since they stop as soon as an Unimplemented error is encountered. However, we add predicates to our ParamEnv when we encounter this error, so we need to handle negative impls specially (so that we don't try adding them to our ParamEnv).
2018-11-13Instantiate all bound vars existentiallyscalexm-2/+3
2018-11-13Reorder code in `rustc::traits::structural_impls`scalexm-340/+340
2018-11-13Bypass ppaux for `Outlives` predicatesscalexm-4/+34
2018-11-13Pretty print quantified goals and clausesscalexm-5/+144
2018-11-12Avoid the Box in `TyCtxt::associated_items`.Niko Matsakis-1/+1
This reduces instruction counts on packed_simd by 2%.
2018-11-11Rollup merge of #55745 - nnethercote:outlives_components-SmallVec, ↵Pietro Albini-1/+3
r=matthewjasper Convert `outlives_components`' return value to a `SmallVec` outparam. This avoids some allocations, reducing instruction counts by 1% on a couple of benchmarks.
2018-11-11Rollup merge of #55687 - alexreg:fix-24010, r=scalexmPietro Albini-6/+3
Take supertraits into account when calculating associated types Fixes #24010 and #23856. Applies to trait aliases too. As a by-product, this PR also makes repeated bindings of the same associated item in the same definition a hard error. This was previously a warning with a note about it becoming a hard error in the future. See #50589 for more info. I talked about this with @nikomatsakis recently, but only very superficially, so this shouldn't stop anyone from assigning it to themself to review and r+. N.B. The "WIP" commits represent imperfect attempts to solve the problem just for trait objects, but I've left them in for reference for the sake of whomever is reviewing this. CC @carllerche @theemathas @durka @mbrubeck
2018-11-10Auto merge of #55717 - oli-obk:rustdoc_overflow, r=pnkfelixbors-1/+1
Bubble up an overflow error so that rustdoc can ignore it fixes #54524 Idk how to write a test for this, other than trying to minimize the entire diesel crate. If desirable I will do that. Note that there are many other such overflow errors hiding out there. Should we try to proactively eliminate them or do we just whack-a-mole them? cc @GuillaumeGomez r? @nikomatsakis
2018-11-08Rollup merge of #55736 - estebank:elide-anon-lt, r=petrochenkovMark Rousskov-1/+4
Elide anon lifetimes in conflicting impl note Fix #54690.
2018-11-08Fix typo in commentvarkor-1/+1
Co-Authored-By: Aaron1011 <aa1ronham@gmail.com>
2018-11-08Use `SmallVec` outparams in several functions.Nicholas Nethercote-1/+3
This avoids some allocations, reducing instruction counts by 1% on a couple of benchmarks.
2018-11-07Added error for duplicate bindings of associated type.Alexander Regueiro-5/+2
2018-11-07Look at projections from supertraits when constructing trait objects.Alexander Regueiro-1/+1
2018-11-07Rollup merge of #55734 - teresy:shorthand-fields, r=davidtwcokennytm-2/+2
refactor: use shorthand fields refactor: use shorthand for single fields everywhere (excluding tests).
2018-11-07Rollup merge of #55501 - nnethercote:DoCompleted, r=pnkfelixkennytm-3/+4
Make `process_obligations`' computation of `completed` optional. It's only used in tests. This reduces instruction counts on several benchmarks by 0.5--1%.
2018-11-07Rollup merge of #55453 - Aaron1011:fix/rustdoc-lifetime, r=pnkfelixkennytm-9/+33
Choose predicates without inference variables over those with them Fixes #54705 When constructing synthetic auto trait impls, we may come across multiple predicates involving the same type, trait, and substitutions. Since we can only display one of these, we pick the one with the 'most strict' lifetime paramters. This ensures that the impl we render the user is actually valid (that is, a struct matching that impl will actually implement the auto trait in question). This commit exapnds the definition of 'more strict' to take into account inference variables. We always choose a predicate without inference variables over a predicate with inference variables.
2018-11-06Elide anon lifetimes in conflicting impl noteEsteban Küber-1/+4
2018-11-06refactor: use shorthand fieldsteresy-2/+2
2018-11-06Bubble up an overflow error so that rustdoc can ignore itOliver Scherer-1/+1
2018-11-04rustc_target: pass contexts by reference, not value.Eduard-Mihai Burtescu-1/+1
2018-11-03Auto merge of #55101 - alexreg:trait-aliases, r=nikomatsakisbors-60/+175
Implement trait aliases (RFC 1733) Extends groundwork done in https://github.com/rust-lang/rust/pull/45047, and fully implements https://github.com/rust-lang/rfcs/pull/1733. CC @durka @nikomatsakis
2018-11-03Rename `Binder::no_late_bound_regions` to `Binder::no_bound_vars`scalexm-11/+11
2018-11-03Shift both late bound regions and bound typesscalexm-13/+13
2018-11-03Move `BoundTy` to `ty::TyKind`scalexm-5/+6
2018-11-03Extended elaboration for trait aliases to include arbitrary bounds.Alexander Regueiro-6/+6
2018-11-03Added support for trait aliases as bounds.Alexander Regueiro-57/+172
2018-11-03Auto merge of #54383 - mikeyhew:custom-receivers-object-safety, r=nikomatsakisbors-35/+263
Take 2: Implement object-safety and dynamic dispatch for arbitrary_self_types This replaces #50173. Over the months that that PR was open, we made a lot of changes to the way this was going to be implemented, and the long, meandering comment thread and commit history would have been confusing to people reading it in the future. So I decided to package everything up with new, straighforward commits and open a new PR. Here are the main points. Please read the commit messages for details. - To simplify codegen, we only support receivers that have the ABI of a pointer. That means they are builtin pointer types, or newtypes thereof. - We introduce a new trait: `DispatchFromDyn<T>`, similar to `CoerceUnsized<T>`. `DispatchFromDyn` has extra requirements that `CoerceUnsized` does not: when you implement `DispatchFromDyn` for a struct, there cannot be any extra fields besides the field being coerced and `PhantomData` fields. This ensures that the struct's ABI is the same as a pointer. - For a method's receiver (e.g. `self: Rc<Self>`) to be object-safe, it needs to have the following property: - let `DynReceiver` be the receiver when `Self = dyn Trait` - let `ConcreteReceiver` be the receiver when `Self = T`, where `T` is some unknown `Sized` type that implements `Trait`, and is the erased type of the trait object. - `ConcreteReceiver` must implement `DispatchFromDyn<DynReceiver>` In the case of `Rc<Self>`, this requires `Rc<T>: DispatchFromDyn<Rc<dyn Trait>>` These rules are explained more thoroughly in the doc comment on `receiver_is_dispatchable` in object_safety.rs. r? @nikomatsakis and @eddyb cc @arielb1 @cramertj @withoutboats Special thanks to @nikomatsakis for getting me un-stuck when implementing the object-safety checks, and @eddyb for helping with the codegen parts. EDIT 2018-11-01: updated because CoerceSized has been replaced with DispatchFromDyn
2018-11-02Auto merge of #55305 - nikomatsakis:universes-refactor-3, r=scalexmbors-31/+25
universes refactor 3 Some more refactorings from my universe branch. These are getting a bit more "invasive" -- they start to plumb the universe information through the canonicalization process. As of yet though I don't **believe** this branch changes our behavior in any notable way, though I'm marking the branch as `WIP` to give myself a chance to verify this. r? @scalexm
2018-11-01Remove this check for object-safety during selection of trait object candidatesMichael Hewson-11/+0
I don't really understand what it's for, but see the comment here: https://github.com/rust-lang/rust/pull/50173#discussion_r204222336 where arielb1 said > Does this check do anything these days? I think `$0: Trait` is always considered ambiguous and nikomatsakis agreed we may be able to get rid of it
2018-11-01add `U: Trait` to the param env during DispatchFromDyn checkMichael Hewson-27/+40
also updated the doc on `receiver_is_dispatchable` to reflect current state of the implementation