about summary refs log tree commit diff
path: root/compiler/rustc_middle/src/traits
AgeCommit message (Collapse)AuthorLines
2022-01-07Add query to avoid name comparison in `leaf_def`Matthew Jasper-29/+16
2021-12-23Auto merge of #92167 - pierwill:chalk-update, r=jackh726bors-30/+31
Update chalk to 0.75.0 - Compute flags in `intern_ty` - Remove `tracing-serde` from `PERMITTED_DEPENDENCIES` - Bump `tracing-tree` to 0.2.0 - Bump `tracing-subscriber` to 0.3.3
2021-12-22Update chalk to 0.75.0pierwill-30/+31
- Compute flags in `intern_ty` - Remove tracing-serde from PERMITTED_DEPENDENCIES - Disable `tracing-full` feature in `chalk-solve` - Bump tracing-tree to 0.2.0
2021-12-20Eliminate `ObligationCauseData`.Nicholas Nethercote-42/+40
This makes `Obligation` two words bigger, but avoids allocating a lot of the time. I previously tried this in #73983 and it didn't help much, but local timings look more promising now.
2021-12-15Remove `in_band_lifetimes` from `rustc_middle`Aaron Hill-3/+3
See #91867 This was mostly straightforward. In several places, I take advantage of the fact that lifetimes are non-hygenic: a macro declares the 'tcx' lifetime, which is then used in types passed in as macro arguments.
2021-12-13Keep info on pre-desugaring expression for better "incorrect `.await`" ↵Esteban Kuber-1/+1
suggestion Keep the `HirId` of `.await`ed expressions so in the case of a `fn` call on on a sync `fn`, we can suggest maybe turning it into an `async fn`.
2021-12-13Reduce verbosity for `?` on non-`Try` expressionsEsteban Kuber-0/+2
2021-12-13Reduce verbosity when calling `for`-loop on non-`Iterator` expressionEsteban Kuber-0/+2
2021-12-13When `.await` is called on a non-`Future` expression, suggest removalEsteban Kuber-0/+2
Keep track of the origin of a `T: Future` obligation when caused by an `.await` expression. Address #66731.
2021-12-12Revert "Auto merge of #91491 - spastorino:revert-91354, r=oli-obk"Deadbeef-8/+6
This reverts commit ff2439b7b9bafcfdff86b7847128014699df8442, reversing changes made to 2a9e0831d6603d87220cedd1b1293e2eb82ef55c.
2021-12-09Remove redundant [..]sest31-9/+9
2021-12-03Revert "Auto merge of #91354 - fee1-dead:const_env, r=spastorino"Santiago Pastorino-6/+8
This reverts commit 18bb8c61a975fff6424cda831ace5b0404277145, reversing changes made to d9baa361902b172be716f96619b909f340802dea.
2021-11-29Fix toolsDeadbeef-2/+2
2021-11-29Avoid storing the ImplPolarity and Constness next to a TraitRef and use ↵Oli Scherer-1/+1
TraitPredicate instead
2021-11-29Replace `ConstnessAnd<TraitRef>` with `TraitPredicate` which conveys the ↵Oli Scherer-4/+2
same information
2021-11-29Prefer TraitPredicate over ConstnessAnd<TraitRef>Oli Scherer-1/+1
2021-11-23Add supertraits method to rustc_middleMichael Goulet-0/+50
2021-11-14Simplify ObligationCauseData hash to skip ObligationCauseCodeThe8472-1/+10
selection deduplicates obligations through a hashset at some point, computing the hashes for ObligationCauseCode appears to dominate the hashing cost. bodyid + span + discriminant hash hopefully will sufficiently unique unique enough.
2021-11-07Remove some fields from `ObligationCauseCode`Matthew Jasper-2/+0
2021-10-24Point at overlapping impls when type annotations are neededEsteban Kuber-0/+12
2021-10-20Make EvaluationCache consider polarity as cache's keySantiago Pastorino-2/+4
2021-10-20Consider negative polarity on overlap checkSantiago Pastorino-2/+2
2021-10-10Fix spelling: Cannonical -> CanonicalJohn Kugelman-2/+2
2021-10-05Issue 89275 fix and testTom Farmer-4/+11
Issue 89275 fix and test Fix librustdoc OverflowError usage rust tidy run Issue 89275 fix and test
2021-10-03Remove re-export.Camille GILLOT-1/+1
2021-10-01Rollup merge of #88963 - fee1-dead:const-iterator, r=oli-obkManish Goregaokar-1/+3
Coerce const FnDefs to implement const Fn traits You can now pass a FnDef to a function expecting `F` where `F: ~const FnTrait`. r? ``@oli-obk`` ``@rustbot`` label T-compiler F-const_trait_impl
2021-09-21use indexmap instead of hashmaplcnr-13/+3
2021-09-21renamelcnr-4/+4
2021-09-18Auto merge of #89000 - Mark-Simulacrum:no-new-lrc, r=petrochenkovbors-1/+1
Reuse existing shared Lrc for MatchImpl parent This is a small performance win for the hot path, which helps to address this regression: https://github.com/rust-lang/rust/pull/87244#issuecomment-883635813.
2021-09-16Auto merge of #88719 - estebank:point-at-arg-for-obligation, r=nagisabors-4/+14
Point at argument instead of call for their obligations When an obligation is introduced by a specific `fn` argument, point at the argument instead of the `fn` call if the obligation fails to be fulfilled. Move the information about pointing at the call argument expression in an unmet obligation span from the `FulfillmentError` to a new `ObligationCauseCode`. When giving an error about an obligation introduced by a function call that an argument doesn't fulfill, and that argument is a block, add a span_label pointing at the innermost tail expression. Current output: ``` error[E0425]: cannot find value `x` in this scope --> f10.rs:4:14 | 4 | Some(x * 2) | ^ not found in this scope error[E0277]: expected a `FnOnce<({integer},)>` closure, found `Option<_>` --> f10.rs:2:31 | 2 | let p = Some(45).and_then({ | ______________________--------_^ | | | | | required by a bound introduced by this call 3 | | |x| println!("doubling {}", x); 4 | | Some(x * 2) | | ----------- 5 | | }); | |_____^ expected an `FnOnce<({integer},)>` closure, found `Option<_>` | = help: the trait `FnOnce<({integer},)>` is not implemented for `Option<_>` ``` Previous output: ``` error[E0425]: cannot find value `x` in this scope --> f10.rs:4:14 | 4 | Some(x * 2) | ^ not found in this scope error[E0277]: expected a `FnOnce<({integer},)>` closure, found `Option<_>` --> f10.rs:2:22 | 2 | let p = Some(45).and_then({ | ^^^^^^^^ expected an `FnOnce<({integer},)>` closure, found `Option<_>` | = help: the trait `FnOnce<({integer},)>` is not implemented for `Option<_>` ``` Partially address #27300. Will require rebasing on top of #88546.
2021-09-16Refactor `FulfillmentError` to track less dataEsteban Kuber-4/+14
Move the information about pointing at the call argument expression in an unmet obligation span from the `FulfillmentError` to a new `ObligationCauseCode`.
2021-09-15Reuse existing shared Lrc for MatchImpl parentMark Rousskov-1/+1
This is hopefully a small performance win for the hot path.
2021-09-15Move object safety suggestions to the end of the errorEsteban Kuber-2/+2
2021-09-15Coerce const FnDefs to implement const Fn traitsDeadbeef-1/+3
2021-09-15Auto merge of #88558 - fee1-dead:const-drop, r=oli-obkbors-2/+19
Const drop The changes are pretty primitive at this point. But at least it works. ^-^ Problems with the current change that I can think of now: - [x] `~const Drop` shouldn't change anything in the non-const world. - [x] types that do not have drop glues shouldn't fail to satisfy `~const Drop` in const contexts. `struct S { a: u8, b: u16 }` This might not fail for `needs_non_const_drop`, but it will fail in `rustc_trait_selection`. - [x] The current change accepts types that have `const Drop` impls but have non-const `Drop` glue. Fixes #88424. Significant Changes: - `~const Drop` is no longer treated as a normal trait bound. In non-const contexts, this bound has no effect, but in const contexts, this restricts the input type and all of its transitive fields to either a) have a `const Drop` impl or b) can be trivially dropped (i.e. no drop glue) - `T: ~const Drop` will not be linted like `T: Drop`. - Instead of recursing and iterating through the type in `rustc_mir::transform::check_consts`, we use the trait system to special case `~const Drop`. See [`rustc_trait_selection::...::candidate_assembly#assemble_const_drop_candidates`](https://github.com/fee1-dead/rust/blob/const-drop/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs#L817) and others. Changes not related to `const Drop`ping and/or changes that are insignificant: - `Node.constness_for_typeck` no longer returns `hir::Constness::Const` for type aliases in traits. This was previously used to hack how we determine default bound constness for items. But because we now use an explicit opt-in, it is no longer needed. - Removed `is_const_impl_raw` query. We have `impl_constness`, and the only existing use of that query uses `HirId`, which means we can just operate it with hir. - `ty::Destructor` now has a field `constness`, which represents the constness of the destructor. r? `@oli-obk`
2021-09-09fmtDeadbeef-1/+1
2021-09-09Const drop selection candidatesDeadbeef-2/+19
2021-09-09rename mir -> thir around abstract constsEllen-1/+1
2021-08-30Enforce diverging let...elseCameron Steffen-0/+3
2021-08-27Add `ty::BoundConstness`Deadbeef-2/+1
2021-08-22Fix typos “a”→“an”Frank Steffahn-2/+2
2021-08-21Auto merge of #88135 - crlf0710:trait_upcasting_part_3, r=nikomatsakisbors-2/+46
Trait upcasting coercion (part 3) By using separate candidates for each possible choice, this fixes type-checking issues in previous commits. r? `@nikomatsakis`
2021-08-20Require a box expression's type to be SizedAnton Golov-0/+2
2021-08-18Fold `vtable_trait_upcasting_coercion_new_vptr_slot` logic into obligation ↵Charles Lew-2/+41
processing.
2021-08-18Properly generate multiple candidates for trait upcasting coercion.Charles Lew-0/+5
2021-08-13Make selection and evaluation caches use constnessDeadbeef-2/+2
2021-07-20Support HIR wf checking for function signaturesAaron Hill-6/+28
During function type-checking, we normalize any associated types in the function signature (argument types + return type), and then create WF obligations for each of the normalized types. The HIR wf code does not currently support this case, so any errors that we get have imprecise spans. This commit extends `ObligationCauseCode::WellFormed` to support recording a function parameter, allowing us to get the corresponding HIR type if an error occurs. Function typechecking is modified to pass this information during signature normalization and WF checking. The resulting code is fairly verbose, due to the fact that we can no longer normalize the entire signature with a single function call. As part of the refactoring, we now perform HIR-based WF checking for several other 'typed items' (statics, consts, and inherent impls). As a result, WF and projection errors in a function signature now have a precise span, which points directly at the responsible type. If a function signature is constructed via a macro, this will allow the error message to point at the code 'most responsible' for the error (e.g. a user-supplied macro argument).
2021-07-19Better diagnostics when mismatched types due to implict static lifetimejackh726-0/+3
2021-07-16Add initial implementation of HIR-based WF checking for diagnosticsAaron Hill-5/+12
During well-formed checking, we walk through all types 'nested' in generic arguments. For example, WF-checking `Option<MyStruct<u8>>` will cause us to check `MyStruct<u8>` and `u8`. However, this is done on a `rustc_middle::ty::Ty`, which has no span information. As a result, any errors that occur will have a very general span (e.g. the definintion of an associated item). This becomes a problem when macros are involved. In general, an associated type like `type MyType = Option<MyStruct<u8>>;` may have completely different spans for each nested type in the HIR. Using the span of the entire associated item might end up pointing to a macro invocation, even though a user-provided span is available in one of the nested types. This PR adds a framework for HIR-based well formed checking. This check is only run during error reporting, and is used to obtain a more precise span for an existing error. This is accomplished by individually checking each 'nested' type in the HIR for the type, allowing us to find the most-specific type (and span) that produces a given error. The majority of the changes are to the error-reporting code. However, some of the general trait code is modified to pass through more information. Since this has no soundness implications, I've implemented a minimal version to begin with, which can be extended over time. In particular, this only works for HIR items with a corresponding `DefId` (e.g. it will not work for WF-checking performed within function bodies).
2021-07-09Revert the revert of renaming traits::VTable to ImplSourcePaul Trojahn-3/+3
As #72114 and #73055 were merged so closely together I think this accidentally happened while rebasing