about summary refs log tree commit diff
path: root/src/librustc/traits
AgeCommit message (Collapse)AuthorLines
2019-06-11rustc: deny(unused_lifetimes).Eduard-Mihai Burtescu-8/+8
2019-06-09Use Symbol for named arguments in fmt_macrosMark Rousskov-33/+33
2019-06-09Make a few methods privateMark Rousskov-2/+2
2019-06-06Auto merge of #57428 - alexreg:associated_type_bounds, r=nikomatsakis,Centrilbors-23/+22
Implementation of RFC 2289 (associated_type_bounds) This PR implements the [`asociated_type_bounds` feature](https://github.com/rust-lang/rfcs/blob/master/text/2289-associated-type-bounds.md). Associated type bounds are implemented in: - function/method arguments and return types - structs, enums, unions - associated items in traits - type aliases - type parameter defaults - trait objects - let bindings CC @nikomatsakis @centril
2019-06-05Implemented for function bounds, type bounds, and named existential types.Alexander Regueiro-2/+1
2019-06-05Aggregation of drive-by cosmetic changes.Alexander Regueiro-21/+21
2019-06-05Refactor `TypeVariableOrigin` into `TypeVariableOrigin` and ↵varkor-5/+18
`TypeVariableOriginKind`
2019-06-03Don't canonicalize `'static` in normalizeMatthew Jasper-1/+3
2019-05-31Add more information in ConstEvalFailure errorvarkor-2/+5
2019-05-30Auto merge of #61253 - nnethercote:avoid-hygiene_data-lookups, r=petrochenkovbors-1/+1
Avoid `hygiene_data` lookups These commits mostly introduce compound operations that allow two close adjacent `hygiene_data` lookups to be combined. r? @petrochenkov
2019-05-29Introduce and use `SyntaxContext::outer_expn_info()`.Nicholas Nethercote-1/+1
It reduces two `hygiene_data` accesses to one on some hot paths.
2019-05-28Rename `OpportunisticTypeResolver` to `OpportunisticVarResolver`varkor-35/+35
2019-05-28Resolve consts in OpportunisticTypeResolvervarkor-1/+1
2019-05-26Rename "Associated*" to "Assoc*"Andrew Xu-31/+31
We are going to uniform the terminology of all associated items. Methods that may or may not have `self` are called "associated functions". Because `AssociatedFn` is a bit long, we rename `Associated` to `Assoc`.
2019-05-25Don't use `ty::Const` without immediately interningOliver Scherer-4/+2
2019-05-24Tweak macro parse errors when reaching EOF during macro call parseEsteban Küber-12/+12
- Add detail on origin of current parser when reaching EOF and stop saying "found <eof>" and point at the end of macro calls - Handle empty `cfg_attr` attribute - Reword empty `derive` attribute error
2019-05-22Rollup merge of #60773 - Aaron1011:fix/rustdoc-project-all, r=eddybMazdak Farrokhzad-17/+68
Always try to project predicates when finding auto traits in rustdoc Fixes #60726 Previous, AutoTraitFinder would only try to project predicates when the predicate type contained an inference variable. When finding auto traits, we only project to try to unify inference variables - we don't otherwise learn any new information about the required bounds. However, this lead to failing to properly generate a negative auto trait impl (indicating that a type never implements a certain auto trait) in the following unusual scenario: In almost all cases, a type has an (implicit) negative impl of an auto trait due some other type having an explicit *negative* impl of that auto trait. For example: struct MyType<T> { field: *const T } has an implicit 'impl<T> !Send for MyType<T>', due to the explicit negative impl (in libcore) 'impl<T: ?Sized> !Send for *const T'. However, as exposed by the 'abi_stable' crate, this isn't always the case. This minimzed example shows how a type can never implement 'Send', due to a projection error: ``` pub struct True; pub struct False; pub trait MyTrait { type Project; } pub struct MyStruct<T> { field: T } impl MyTrait for u8 { type Project = False; } unsafe impl<T> Send for MyStruct<T> where T: MyTrait<Project=True> {} pub struct Wrapper { inner: MyStruct<u8> } ``` In this example, `<u8 as MyTrait>::Project == True' must hold for 'MyStruct<u8>: Send' to hold. However, '<u8 as MyTrait>::Project == False' holds instead To properly account for this unusual case, we need to call 'poly_project_and_unify' on *all* predicates, not just those with inference variables. This ensures that we catch the projection error that occurs above, and don't incorrectly determine that 'Wrapper: Send' holds.
2019-05-22Auto merge of #59445 - alexreg:ban-multi-trait-objects-via-aliases, r=oli-obkbors-89/+230
Ban multi-trait objects via trait aliases Obviously, multi-trait objects are not normally supported, so they should not be supported via trait aliases. This has been factored out from the previous PR https://github.com/rust-lang/rust/pull/55994 (see point 1). r? @Centril CC @nikomatsakis ------------------ ### RELNOTES: We now allow `dyn Send + fmt::Debug` with equivalent semantics to `dyn fmt::Debug + Send`. That is, the order of the mentioned traits does not matter wrt. principal/not-principal traits. This is a small change that might deserve a mention in the blog post because it is a language change but most likely not. See https://github.com/rust-lang/rust/blob/ce2ee305f9165c037ecddddb5792588a15ff6c37/src/test/ui/traits/wf-trait-object-reverse-order.rs. // @Centril
2019-05-21Remove impls for `InternedString`/string equality.Nicholas Nethercote-5/+5
`Symbol` received the same treatment in #60630. Also, we can derive `PartialEq` for `InternedString`.
2019-05-20Addressed more points raised in review.Alexander Regueiro-42/+28
2019-05-20Addressed more points raised in review.Alexander Regueiro-54/+42
2019-05-20Addressed points raised in review.Alexander Regueiro-11/+22
2019-05-20Fixed detection of multiple non-auto traits.Alexander Regueiro-69/+135
2019-05-20Addressed review points.Alexander Regueiro-26/+21
2019-05-20Ban multi-trait objects via trait aliases.Alexander Regueiro-62/+159
2019-05-20Accumulation of various drive-by cosmetic changes.Alexander Regueiro-8/+6
2019-05-20Introduce `InternedString::intern`.Nicholas Nethercote-12/+7
`InternedString::intern(x)` is preferable to `Symbol::intern(x).as_interned_str()`, because the former involves one call to `with_interner` while the latter involves two. The case within InternedString::decode() is particularly hot, and this change reduces the number of `with_interner` calls by up to 13%.
2019-05-19Rollup merge of #60934 - fabric-and-ink:defindex_with_newtype_macro, ↵Mazdak Farrokhzad-1/+1
r=petrochenkov Declare DefIndex with the newtype_index macro See #60666
2019-05-19Rollup merge of #60924 - estebank:try-msg, r=petrochenkovMazdak Farrokhzad-3/+6
Explain that ? converts the error type using From Fix #60917.
2019-05-18Declare DefIndex with the newtype_index macroFabian Drinck-1/+1
2019-05-18Auto merge of #60910 - nnethercote:avoid-some-unnecessary-interning, ↵bors-1/+1
r=petrochenkov Avoid some unnecessary interning r? @petrochenkov
2019-05-17Auto merge of #49799 - hdhoang:46205_deny_incoherent_fundamental_impls, ↵bors-19/+24
r=nikomatsakis lint: convert incoherent_fundamental_impls into hard error *Summary for affected authors:* If your crate depends on one of the following crates, please upgrade to a newer version: - gtk-rs: upgrade to at least 0.4 - rusqlite: upgrade to at least 0.14 - nalgebra: upgrade to at least 0.15, or the last patch version of 0.14 - spade: upgrade or refresh the Cargo.lock file to use version 1.7 - imageproc: upgrade to at least 0.16 (newer versions no longer use nalgebra) implement #46205 r? @nikomatsakis
2019-05-17Explain that ? converts the error type using FromEsteban Küber-3/+6
2019-05-17Change `rustc::util::common::FN_OUTPUT_NAME` to a `Symbol`.Nicholas Nethercote-1/+1
2019-05-14Rollup merge of #60444 - nikomatsakis:issue-60010-cycle-error-investigation, ↵Mazdak Farrokhzad-2/+53
r=pnkfelix forego caching for all participants in cycles, apart from root node This is a targeted fix for #60010, which uncovered a pretty bad failure of our caching strategy in the face of coinductive cycles. The problem is explained in the comment in the PR on the new field, `in_cycle`, but I'll reproduce it here: > Starts out as false -- if, during evaluation, we encounter a > cycle, then we will set this flag to true for all participants > in the cycle (apart from the "head" node). These participants > will then forego caching their results. This is not the most > efficient solution, but it addresses #60010. The problem we > are trying to prevent: > > - If you have `A: AutoTrait` requires `B: AutoTrait` and `C: NonAutoTrait` > - `B: AutoTrait` requires `A: AutoTrait` (coinductive cycle, ok) > - `C: NonAutoTrait` requires `A: AutoTrait` (non-coinductive cycle, not ok) > > you don't want to cache that `B: AutoTrait` or `A: AutoTrait` > is `EvaluatedToOk`; this is because they were only considered > ok on the premise that if `A: AutoTrait` held, but we indeed > encountered a problem (later on) with `A: AutoTrait. So we > currently set a flag on the stack node for `B: AutoTrait` (as > well as the second instance of `A: AutoTrait`) to supress > caching. > > This is a simple, targeted fix. The correct fix requires > deeper changes, but would permit more caching: we could > basically defer caching until we have fully evaluated the > tree, and then cache the entire tree at once. I'm not sure what the impact of this fix will be in terms of existing crates or performance: we were accepting incorrect code before, so there will perhaps be some regressions, and we are now caching less. As the comment above notes, we could do a lot better than this fix, but that would involve more invasive rewrites. I thought it best to start with something simple. r? @pnkfelix -- but let's do crater/perf run cc @arielb1
2019-05-13modify commentFelix S Klock II-2/+7
modify the comment on `in_cycle` to reflect changes requested by ariel and myself.
2019-05-13Always try to project predicates when finding auto traits in rustdocAaron Hill-17/+68
Fixes #60726 Previous, AutoTraitFinder would only try to project predicates when the predicate type contained an inference variable. When finding auto traits, we only project to try to unify inference variables - we don't otherwise learn any new information about the required bounds. However, this lead to failing to properly generate a negative auto trait impl (indicating that a type never implements a certain auto trait) in the following unusual scenario: In almost all cases, a type has an (implicit) negative impl of an auto trait due some other type having an explicit *negative* impl of that auto trait. For example: struct MyType<T> { field: *const T } has an implicit 'impl<T> !Send for MyType<T>', due to the explicit negative impl (in libcore) 'impl<T: ?Sized> !Send for *const T'. However, as exposed by the 'abi_stable' crate, this isn't always the case. This minimzed example shows how a type can never implement 'Send', due to a projection error: ``` pub struct True; pub struct False; pub trait MyTrait { type Project; } pub struct MyStruct<T> { field: T } impl MyTrait for u8 { type Project = False; } unsafe impl<T> Send for MyStruct<T> where T: MyTrait<Project=True> {} pub struct Wrapper { inner: MyStruct<u8> } ``` In this example, `<u8 as MyTrait>::Project == True' must hold for 'MyStruct<u8>: Send' to hold. However, '<u8 as MyTrait>::Project == False' holds instead To properly account for this unusual case, we need to call 'poly_project_and_unify' on *all* predicates, not just those with inference variables. This ensures that we catch the projection error that occurs above, and don't incorrectly determine that 'Wrapper: Send' holds.
2019-05-13Remove the equality operation between `Symbol` and strings.Nicholas Nethercote-2/+3
And also the equality between `Path` and strings, because `Path` is made up of `Symbol`s.
2019-05-13Pass a `Symbol` to `check_name`, `emit_feature_err`, and related functions.Nicholas Nethercote-11/+12
2019-05-09Rollup merge of #60647 - petrochenkov:nospace, r=michaelwoeristerMazdak Farrokhzad-3/+1
cleanup: Remove `DefIndexAddressSpace` The scheme with two address spaces for `DefIndex` was needed in the past, but apparently not needed anymore (after removing `DefId`s from locals and `HirId`-ification).
2019-05-09cleanup: Remove `DefIndexAddressSpace`Vadim Petrochenkov-3/+1
2019-05-08Use `delay_span_bug` for "Failed to unify obligation"Esteban Küber-5/+10
2019-05-06Rename `ParamTy::idx` to `ParamTy::index`varkor-3/+3
2019-05-01Create ShallowResolvervarkor-18/+16
Co-Authored-By: Gabriel Smith <yodaldevoid@users.noreply.github.com>
2019-05-01Rename mk_infer to mk_ty_inferGabriel Smith-2/+2
Signed-off-by: Gabriel Smith <ga29smith@gmail.com>
2019-05-01Rename *shallow_resolve to *shallow_resolve_typevarkor-14/+14
Co-Authored-By: Gabriel Smith <yodaldevoid@users.noreply.github.com>
2019-05-01forego caching for all participants in cycles, apart from root nodeNiko Matsakis-2/+48
2019-05-01Auto merge of #60137 - eddyb:rustdoc-rm-def-ctor-hax, r=petrochenkovbors-62/+26
rustdoc: remove def_ctor hack. ~~No longer necessary since we have `describe_def`.~~ Turns out `def_ctor` was used in conjunction with abusing `tcx.type_of(def_id)` working on both type definitions and `impl`s (specifically, of builtin types), but also reimplementing a lot of the logic that `Clean` already provides on `Ty` / `ty::TraitRef`. The first commit now does the minimal refactor to keep it working, while the second commit contains the rest of the refactor I started (parts of which I'm not sure we need to keep).
2019-05-01Auto merge of #60195 - varkor:commontypes-to-common, r=eddybbors-3/+3
Split `CommonTypes` into `CommonTypes` and `CommonLifetimes` The so-called "`CommonTypes`" contains more than just types. r? @eddyb
2019-04-30Rollup merge of #60344 - Aaron1011:fix/tower-hyper, r=eddybMazdak Farrokhzad-1/+1
Don't try to render auto-trait bounds with any inference variables Previously, we checked if the target of a projection type was itself an inference variable. However, for Rustdoc rendering purposes, there's no distinction between an inference variable ('_') and a type containing one (e.g. (MyStruct<u8, _>)) - we don't want to render either of them. Fixes #60269 Due to the complexity of the original bug, which spans three different crates (hyper, tower-hyper, and tower), I have been unable to create a minimized reproduction for the issue.