about summary refs log tree commit diff
path: root/src/librustc/traits/auto_trait.rs
AgeCommit message (Collapse)AuthorLines
2020-02-16Move librustc/{traits,infer} to librustc_infer.Camille GILLOT-837/+0
2020-02-13Constness -> enum Const { Yes(Span), No }Mazdak Farrokhzad-2/+1
Same idea for `Unsafety` & use new span for better diagnostics.
2020-02-10Reduce the number of `RefCell`s in `InferCtxt`.Nicholas Nethercote-3/+13
`InferCtxt` contains six structures within `RefCell`s. Every time we create and dispose of (commit or rollback) a snapshot we have to `borrow_mut` each one of them. This commit moves the six structures under a single `RefCell`, which gives significant speed-ups by reducing the number of `borrow_mut` calls. To avoid runtime errors I had to reduce the lifetimes of dynamic borrows in a couple of places.
2020-02-05Move rustc::traits datatypes to module traits::types.Camille GILLOT-0/+1
2020-01-27don't clone types that are copy, round two.Matthias Krüger-1/+1
2020-01-20Add `constness` field to `ty::Predicate::Trait`Dylan MacKenzie-3/+6
2019-12-22Format the worldMark Rousskov-104/+81
2019-11-26Fix spelling typosBrian Wignall-3/+3
2019-11-21Applied suggestions from code review.Alexander Regueiro-63/+64
2019-11-21Aggregation of drive-by cosmetic changes.Alexander Regueiro-64/+65
2019-09-26Auto merge of #62661 - arielb1:never-reserve, r=nikomatsakisbors-1/+1
reserve `impl<T> From<!> for T` this is necessary for never-type stabilization. cc #57012 #35121 I think we wanted a crater run for this @nikomatsakis? r? @nikomatsakis
2019-09-25Rename `sty` to `kind`varkor-2/+2
2019-09-24resolve the rustc_reservation_impl attribute in 1 placeAriel Ben-Yehuda-1/+1
2019-06-14Unify all uses of 'gcx and 'tcx.Eduard-Mihai Burtescu-30/+24
2019-06-12rustc: replace `TyCtxt<'tcx, 'gcx, 'tcx>` with `TyCtxt<'gcx, 'tcx>`.Eduard-Mihai Burtescu-4/+4
2019-06-12rustc: replace `TyCtxt<'a, 'gcx, 'tcx>` with `TyCtxt<'tcx, 'gcx, 'tcx>`.Eduard-Mihai Burtescu-7/+7
2019-06-11rustc: deny(unused_lifetimes).Eduard-Mihai Burtescu-1/+1
2019-05-28Rename `OpportunisticTypeResolver` to `OpportunisticVarResolver`varkor-3/+3
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-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-1/+1
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.
2019-04-30rustdoc: refactor(?) synthetic impl building.Eduard-Mihai Burtescu-56/+23
2019-04-30rustdoc: remove def_ctor hack.Eduard-Mihai Burtescu-12/+9
2019-04-28Fix lint findings in librustcflip1995-4/+4
2019-04-27Don't try to render auto-trait bounds with any inference variablesAaron Hill-1/+1
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.
2019-04-25Update existing usagesvarkor-1/+1
2019-02-27rename Substs to InternalSubstscsmoe-1/+1
Change-Id: I3fa00e999a2ee4eb72db1fdf53a8633b49176a18
2019-02-21introduce a dummy leak check and invoke it in all the right placesNiko Matsakis-1/+7
This set of diffs was produced by combing through b68fad670bb3612cac26e50751e4fd9150e59977 and seeing where the `leak_check` used to be invoked and how.
2019-02-13HirId-ify hir::BodyIdljedrz-3/+3
2019-02-10rustc: doc commentsAlexander Regueiro-1/+1
2019-02-05move librustc to 2018Mark Mansi-4/+4
2019-01-02universe transitionNiko Matsakis-7/+1
Remove the leak-check and its associated machinery. Replace with making the solver aware of universes.
2018-12-27Add a def-id in `ty::ParamEnv`scalexm-1/+6
2018-12-27Auto merge of #56838 - Aaron1011:fix/rustdoc-infer-unify, r=nikomatsakisbors-2/+2
Call poly_project_and_unify_type on types that contain inference types Commit f57247c48cb59 (Ensure that Rusdoc discovers all necessary auto trait bounds) added a check to ensure that we only attempt to unify a projection predicatre with inference variables. However, the check it added was too strict - instead of checking that a type *contains* an inference variable (e.g. '&_', 'MyType<_>'), it required the type to *be* an inference variable (i.e. only '_' would match). This commit relaxes the check to use 'ty.has_infer_types', ensuring that we perform unification wherever possible. Fixes #56822
2018-12-25Remove licensesMark Rousskov-10/+0
2018-12-14Call poly_project_and_unify_type on types that contain inference typesAaron Hill-2/+2
Commit f57247c48cb59 (Ensure that Rusdoc discovers all necessary auto trait bounds) added a check to ensure that we only attempt to unify a projection predicatre with inference variables. However, the check it added was too strict - instead of checking that a type *contains* an inference variable (e.g. '&_', 'MyType<_>'), it required the type to *be* an inference variable (i.e. only '_' would match). This commit relaxes the check to use 'ty.has_infer_types', ensuring that we perform unification wherever possible. Fixes #56822
2018-12-07Various minor/cosmetic improvements to codeAlexander Regueiro-5/+5
2018-11-28Filter out self-referential projection predicatesAaron Hill-1/+26
If we end up with a projection predicate that equates a type with itself (e.g. <T as MyType>::Value == <T as MyType>::Value), we can run into issues if we try to add it to our ParamEnv.
2018-11-28Check all substitution parameters for inference variablesAaron Hill-3/+8
2018-11-28Ensure that Rusdoc discovers all necessary auto trait boundsAaron Hill-17/+51
Fixes #50159 This commit makes several improvements to AutoTraitFinder: * Call infcx.resolve_type_vars_if_possible before processing new predicates. This ensures that we eliminate inference variables wherever possible. * Process all nested obligations we get from a vtable, not just ones with depth=1. * The 'depth=1' check was a hack to work around issues processing certain predicates. The other changes in this commit allow us to properly process all predicates that we encounter, so the check is no longer necessary, * Ensure that we only display predicates *without* inference variables to the user, and only attempt to unify predicates that *have* an inference variable as their type. Additionally, the internal helper method is_of_param now operates directly on a type, rather than taking a Substs. This allows us to use the 'self_ty' method, rather than directly dealing with Substs.
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-08Fix typo in commentvarkor-1/+1
Co-Authored-By: Aaron1011 <aa1ronham@gmail.com>
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-03Rename `Binder::no_late_bound_regions` to `Binder::no_bound_vars`scalexm-2/+2
2018-10-28Choose predicates without inference variables over those with themAaron Hill-9/+33
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-10-25Fix tidy errorAaron Hill-1/+3
2018-10-25Check for negative impls when finding auto traitsAaron Hill-1/+14
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-10-20Auto merge of #55014 - ljedrz:lazyboye_unwraps, r=matthewjasperbors-2/+2
Prefer unwrap_or_else to unwrap_or in case of function calls/allocations The contents of `unwrap_or` are evaluated eagerly, so it's not a good pick in case of function calls and allocations. This PR also changes a few `unwrap_or`s with `unwrap_or_default`. An added bonus is that in some cases this change also reveals if the object it's called on is an `Option` or a `Result` (based on whether the closure takes an argument).
2018-10-19Deprecate the `FxHashMap()` and `FxHashSet()` constructor function hackOliver Scherer-4/+4