about summary refs log tree commit diff
path: root/compiler/rustc_trait_selection
AgeCommit message (Collapse)AuthorLines
2021-09-18Auto merge of #88994 - Aaron1011:intercrate-caching, r=jackh726bors-0/+16
Disable the evaluation cache when in intercrate mode It's possible to use the same `InferCtxt` with both an intercrate and non-intercrate `SelectionContext`. However, the local (inferctxt) evaluation cache is not aware of this distinction, so this kind of `InferCtxt` re-use will pollute the cache wth bad results. This commit avoids the issue by disabling the evaluation cache entirely during intercrate mode.
2021-09-18Auto merge of #88980 - tmiasko:instrument-debug, r=oli-obkbors-2/+2
Use explicit log level in tracing instrument macro Specify a log level in tracing instrument macro explicitly. Additionally reduce the used log level from a default info level to a debug level (all of those appear to be developer oriented logs, so there should be no need to include them in release builds).
2021-09-17Auto merge of #88962 - fee1-dead:const-drop, r=oli-obkbors-0/+1
inline(always) on check_recursion_limit r? `@oli-obk` #88558 caused a regression, this PR adds `#[inline(always)]` to `check_recursion_limit`, a possible suspect of that regression.
2021-09-17Add another case of fallback to () avoid breakageMark Rousskov-2/+96
This adds src/test/ui/never_type/fallback-closure-ret.rs as a test case which showcases the failure mode fixed by this commit.
2021-09-17Auto merge of #88945 - Aaron1011:no-projection-completion, ↵bors-10/+2
r=wesleywiser,jackh726 Remove concept of 'completion' from the projection cache Fixes #88910 When we initially store a `NormalizedTy` in the projection cache, we discard all obligations that we can (while ensuring that we don't cause any issues with incremental compilation). Marking a projection cache entry as 'completed' discards all obligations associated with it. This can only cause problems, since any obligations stored in the cache are there for a reason (e.g. they evaluate to `EvaluatedToOkModuloRegions`). This commit removes `complete` and `complete_normalized` entirely.
2021-09-17Rollup merge of #88911 - FabianWolff:issue-88653, r=petrochenkovYuki Okushi-14/+24
Improve error message for type mismatch in generator arguments Fixes #88653. The code example given there is invalid because the `Generator` trait (unlike the `Fn` traits) does not take the generator arguments in tupled-up form (because there can only be one argument, from my understanding). Hence, the type error in the example in #88653 is correct, because the given generator takes a `bool` argument, whereas the function's return type talks about a generator with a `(bool,)` argument. The error message is both confusing and wrong, though: It is wrong because it displays the wrong "expected signature", and it is confusing because both the "expected" and "found" notes point at the same span. With my changes, I get the following, more helpful output: ``` error[E0631]: type mismatch in generator arguments --> test.rs:5:22 | 5 | fn foo(bar: bool) -> impl Generator<(bool,)> { | ^^^^^^^^^^^^^^^^^^^^^^^ expected signature of `fn((bool,)) -> _` 6 | |bar| { | ----- found signature of `fn(bool) -> _` ```
2021-09-16Auto merge of #88719 - estebank:point-at-arg-for-obligation, r=nagisabors-37/+81
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-16Rollup merge of #88875 - notriddle:notriddle/cleanup-unused-trait-selection, ↵Manish Goregaokar-3/+0
r=Mark-Simulacrum cleanup(rustc_trait_selection): remove vestigial code from rustc_on_unimplemented This isn't allowed by the validator, and seems to be unused. When it was added in ed10a3faae1fd1176b2edf4a61438e0542c103b9, it was used on `Sized`, and that usage is gone.
2021-09-16Fix rebaseEsteban Kuber-12/+12
2021-09-16Remove unnecessary labelEsteban Kuber-9/+14
2021-09-16fix `clone` callEsteban Kuber-2/+2
2021-09-16Account for blocks in argumentsEsteban Kuber-2/+22
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.
2021-09-16Point at call span that introduced obligation for the argEsteban Kuber-1/+11
2021-09-16Refactor `FulfillmentError` to track less dataEsteban Kuber-34/+43
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-15Remove ToPolyTraitRef impl for TraitRefjackh726-11/+11
2021-09-15Remove ToPredicate impls that use Binder::dummyjackh726-25/+35
2021-09-15Disable the evaluation cache when in intercrate modeAaron Hill-0/+16
It's possible to use the same `InferCtxt` with both an intercrate and non-intercrate `SelectionContext`. However, the local (inferctxt) evaluation cache is not aware of this distinction, so this kind of `InferCtxt` re-use will pollute the cache wth bad results. This commit avoids the issue by disabling the evaluation cache entirely during intercrate mode.
2021-09-15Use explicit log level in tracing instrument macroTomasz Miąsko-2/+2
Specify a log level in tracing instrument macro explicitly. Additionally reduce the used log level from a default info level to a debug level (all of those appear to be developer oriented logs, so there should be no need to include them in release builds).
2021-09-15Coerce const FnDefs to implement const Fn traitsDeadbeef-9/+16
2021-09-15inline(always) on check_recursion_limitDeadbeef-0/+1
2021-09-15Auto merge of #88558 - fee1-dead:const-drop, r=oli-obkbors-37/+170
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-14Remove concept of 'completion' from the projection cacheAaron Hill-10/+2
Fixes #88910 When we initially store a `NormalizedTy` in the projection cache, we discard all obligations that we can (while ensuring that we don't cause any issues with incremental compilation). Marking a projection cache entry as 'completed' discards all obligations associated with it. This can only cause problems, since any obligations stored in the cache are there for a reason (e.g. they evaluate to `EvaluatedToOkModuloRegions`). This commit removes `complete` and `complete_normalized` entirely.
2021-09-13Rollup merge of #88851 - fee1-dead:dup-bound, r=oli-obkGuillaume Gomez-2/+3
Fix duplicate bounds for const_trait_impl Fixes #88383. Compare the constness of the candidates before winnowing and removing a `~const` `BoundCandidate`.
2021-09-13Improve error message for type mismatch in generator argumentsFabian Wolff-14/+24
2021-09-12Auto merge of #88881 - Manishearth:rollup-alohfwx, r=Manishearthbors-267/+176
Rollup of 7 pull requests Successful merges: - #88336 ( Detect stricter constraints on gats where clauses in impls vs trait) - #88677 (rustc: Remove local variable IDs from `Export`s) - #88699 (Remove extra unshallow from cherry-pick checker) - #88709 (generic_const_exprs: use thir for abstract consts instead of mir) - #88711 (Rework DepthFirstSearch API) - #88810 (rustdoc: Cleanup `clean` part 1) - #88813 (explicitly link to external `ena` docs) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-09-12Rollup merge of #88709 - BoxyUwU:thir-abstract-const, r=lcnrManish Goregaokar-267/+176
generic_const_exprs: use thir for abstract consts instead of mir Changes `AbstractConst` building to use `thir` instead of `mir` so that there's less chance of consts unifying when they shouldn't because lowering to mir dropped information (see `abstract-consts-as-cast-5.rs` test) r? `@lcnr`
2021-09-12Auto merge of #88771 - jackh726:wf_tys_set, r=nikomatsakisbors-3/+4
Use FxHashSet instead of Vec for well formed tys Trying to recover perf from #88312 r? `@ghost`
2021-09-11cleanup(rustc_trait_selection): remove vestigial code from ↵Michael Howell-3/+0
rustc_on_unimplemented This isn't allowed by the validator, and seems to be unused. When it was added in ed10a3faae1fd1176b2edf4a61438e0542c103b9, it was used on `Sized`, and that usage is gone.
2021-09-11Rollup merge of #88849 - matthiaskrgr:clony_on_copy, r=petrochenkovJubilee-8/+8
don't clone types that are Copy (clippy::clone_on_copy)
2021-09-11Auto merge of #88327 - bonega:scalar_refactor, r=eddybbors-2/+2
`WrappingRange` (#88242) follow-up (`is_full_for`, `Scalar: Copy`, etc.) Some changes related to feedback during #88242 r? `@RalfJung`
2021-09-11Fix duplicate bounds for const_trait_implDeadbeef-2/+3
2021-09-11don't clone types that are Copy (clippy::clone_on_copy)Matthias Krüger-8/+8
2021-09-10Rollup merge of #88578 - ↵Manish Goregaokar-4/+13
notriddle:notriddle/suggest-add-reference-to-for-loop-iter, r=nagisa fix(rustc): suggest `items` be borrowed in `for i in items[x..]` Fixes #87994
2021-09-09Use FxHashSet instead of Vec for well formed tysjackh726-3/+4
2021-09-09add test for builtin types N + N unifying with fn callEllen-3/+10
2021-09-09Make `abi::Abi` `Copy` and remove a *lot* of refsAndreas Liljeqvist-2/+2
fix fix Remove more refs and clones fix more fix
2021-09-09Use trait select logic instead of queryDeadbeef-18/+34
2021-09-09fmtDeadbeef-19/+18
2021-09-09Const drop selection candidatesDeadbeef-20/+138
2021-09-09fmtEllen-1/+3
2021-09-09resolve `from_hir_call` FIXMEEllen-1/+0
2021-09-09add a `CastKind` to `Node::Cast`Ellen-8/+11
2021-09-09nitsEllen-20/+19
2021-09-09remove commentEllen-1/+1
2021-09-09rename mir -> thir around abstract constsEllen-15/+15
2021-09-09remove debug stmtsEllen-2/+1
2021-09-09remove `WorkNode`Ellen-51/+10
2021-09-09handle `ExprKind::NeverToAny`Ellen-2/+1
2021-09-09dont build abstract const for monomorphic constsEllen-1/+30