about summary refs log tree commit diff
path: root/compiler/rustc_trait_selection/src
AgeCommit message (Collapse)AuthorLines
2021-12-04Use IntoIterator for array impl everywhere.Mara Bos-6/+2
2021-12-04Rollup merge of #90519 - estebank:issue-84003, r=petrochenkovMatthias Krüger-3/+3
Keep spans for generics in `#[derive(_)]` desugaring Keep the spans for generics coming from a `derive`d Item, so that errors and suggestions have better detail. Fix #84003.
2021-12-03Annotate `derive`d spans and move span suggestion codeEsteban Kuber-3/+3
* Annotate `derive`d spans from the user's code with the appropciate context * Add `Span::can_be_used_for_suggestion` to query if the underlying span at the users' code
2021-12-03Revert "Auto merge of #91354 - fee1-dead:const_env, r=spastorino"Santiago Pastorino-157/+231
This reverts commit 18bb8c61a975fff6424cda831ace5b0404277145, reversing changes made to d9baa361902b172be716f96619b909f340802dea.
2021-12-02Auto merge of #91469 - matthiaskrgr:rollup-xom3j55, r=matthiaskrgrbors-1/+5
Rollup of 12 pull requests Successful merges: - #89954 (Fix legacy_const_generic doc arguments display) - #91321 (Handle placeholder regions in NLL type outlive constraints) - #91329 (Fix incorrect usage of `EvaluatedToOk` when evaluating `TypeOutlives`) - #91364 (Improve error message for incorrect field accesses through raw pointers) - #91387 (Clarify and tidy up explanation of E0038) - #91410 (Move `#![feature(const_precise_live_drops)]` checks earlier in the pipeline) - #91435 (Improve diagnostic for missing half of binary operator in `if` condition) - #91444 (disable tests in Miri that take too long) - #91457 (Add additional test from rust issue number 91068) - #91460 (Document how `last_os_error` should be used) - #91464 (Document file path case sensitivity) - #91466 (Improve the comments in `Symbol::interner`.) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-12-02Rollup merge of #91329 - Aaron1011:modulo-regions-test, r=jackh726Matthias Krüger-1/+5
Fix incorrect usage of `EvaluatedToOk` when evaluating `TypeOutlives` A global predicate is not guarnatenteed to outlive all regions. If the predicate involves late-bound regions, then it may fail to outlive other regions (e.g. `for<'b> &'b bool: 'static` does not hold) We now only produce `EvaluatedToOk` when a global predicate has no late-bound regions - in that case, the ony region that can be present in the type is 'static
2021-12-02Auto merge of #91318 - eggyal:reduce-boilerplate-around-infallible-folders, ↵bors-119/+101
r=jackh726 Reduce boilerplate around infallible folders Further to https://github.com/rust-lang/rust/pull/91230#issuecomment-981059666 r? `@jackh726`
2021-12-02Rename TypeFolderFallible to FallibleTypeFolderAlan Egerton-2/+2
2021-12-02Reduce boilerplate around infallible foldersAlan Egerton-119/+101
2021-12-02Auto merge of #91455 - matthiaskrgr:rollup-gix2hy6, r=matthiaskrgrbors-3/+1
Rollup of 4 iffy pull requests Successful merges: - #89234 (Disallow non-c-like but "fieldless" ADTs from being casted to integer if they use arbitrary enum discriminant) - #91045 (Issue 90702 fix: Stop treating some crate loading failures as fatal errors) - #91394 (Bump stage0 compiler) - #91411 (Enable svh tests on msvc) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-12-02Rollup merge of #91394 - Mark-Simulacrum:bump-stage0, r=pietroalbiniMatthias Krüger-3/+1
Bump stage0 compiler r? `@pietroalbini` (or anyone else)
2021-12-02Auto merge of #91354 - fee1-dead:const_env, r=spastorinobors-232/+157
Cleanup: Eliminate ConstnessAnd This is almost a behaviour-free change and purely a refactoring. "almost" because we appear to be using the wrong ParamEnv somewhere already, and this is now exposed by failing a test using the unstable `~const` feature. We most definitely need to review all `without_const` and at some point should probably get rid of many of them by using `TraitPredicate` instead of `TraitRef`. This is a continuation of https://github.com/rust-lang/rust/pull/90274. r? `@oli-obk` cc `@spastorino` `@ecstatic-morse`
2021-12-01TODO => FIXMEDeadbeef-1/+1
2021-12-01Cache with consistent env and boundDeadbeef-8/+18
2021-12-01Rollup merge of #90985 - camsteffen:diag-name-usage, r=jackh726Matthias Krüger-6/+6
Use `get_diagnostic_name` more
2021-11-30re-format with new rustfmtMark Rousskov-3/+1
2021-11-29Reformat everythingDeadbeef-4/+1
2021-11-29Completely remove ConstnessAndOli Scherer-12/+10
2021-11-29Avoid storing the ImplPolarity and Constness next to a TraitRef and use ↵Oli Scherer-43/+51
TraitPredicate instead
2021-11-29Replace `ConstnessAnd<TraitRef>` with `TraitPredicate` which conveys the ↵Oli Scherer-65/+44
same information
2021-11-29Prefer TraitPredicate over ConstnessAnd<TraitRef>Oli Scherer-24/+9
2021-11-29Use the constness from the param env instead of having a separate dimension ↵Oli Scherer-75/+4
for it This breaks a ~const test that will be fixed in a follow up commit of this PR
2021-11-29Add constness to ParamEnvOli Scherer-7/+26
This now causes a lot of queries to be executed twice, as reveal_all forces NotConst
2021-11-28Fix incorrect usage of `EvaluatedToOk` when evaluating `TypeOutlives`Aaron Hill-1/+5
A global predicate is not guarnatenteed to outlive all regions. If the predicate involves late-bound regions, then it may fail to outlive other regions (e.g. `for<'b> &'b bool: 'static` does not hold) We now only produce `EvaluatedToOk` when a global predicate has no late-bound regions - in that case, the ony region that can be present in the type is 'static
2021-11-28Auto merge of #91230 - eggyal:fallible-type-fold, r=jackh726bors-171/+163
Make `TypeFolder::fold_*` return `Result` Implements rust-lang/compiler-team#432. Initially this is just a rebase of `@LeSeulArtichaut's` work in #85469 (abandoned; see https://github.com/rust-lang/rust/pull/85485#issuecomment-908781112). At that time, it caused a regression in performance that required some further exploration... with this rebased PR bors can hopefully report some perf analysis from which we can investigate further (if the regression is indeed still present). r? `@jackh726` cc `@nikomatsakis`
2021-11-27Only check for errors in predicate when skipping impl assemblyAaron Hill-1/+4
Prior to PR #91205, checking for errors in the overall obligation would check checking the `ParamEnv`, due to an incorrect `super_visit_with` impl. With this bug fixed, we will now bail out of impl candidate assembly if the `ParamEnv` contains any error types. In practice, this appears to be overly conservative - when an error occurs early in compilation, we end up giving up early for some predicates that we could have successfully evaluated without overflow. By only checking for errors in the predicate itself, we avoid causing additional spurious 'type annotations needed' errors after a 'real' error has already occurred. With this PR, the diagnostic changes caused by PR #91205 are reverted.
2021-11-26Use `TypeFolder::Error` for `FullTypeResolver` and `QueryNormalizer`LeSeulArtichaut-76/+41
Co-authored-by: Alan Egerton <eggyal@gmail.com>
2021-11-26Unwrap the results of type foldersLeSeulArtichaut-17/+23
Co-authored-by: Alan Egerton <eggyal@gmail.com>
2021-11-26Adapt `TypeFolder` implementors to return a `Result`LeSeulArtichaut-83/+104
Co-authored-by: Alan Egerton <eggyal@gmail.com>
2021-11-24Add impl polarity to fieldsDeadbeef-26/+27
2021-11-24Allow more cases to match ~const Drop.Deadbeef-32/+48
2021-11-22Use `derive_default_enum` in the compilerJacob Pratt-10/+7
2021-11-21Simplify for loop desugarCameron Steffen-4/+3
2021-11-20Do not mention associated items when they introduce an obligationEsteban Kuber-9/+3
2021-11-20Point at source of trait bound obligations in more placesEsteban Kuber-7/+19
Be more thorough in using `ItemObligation` and `BindingObligation` when evaluating obligations so that we can point at trait bounds that introduced unfulfilled obligations. We no longer incorrectly point at unrelated trait bounds (`substs-ppaux.verbose.stderr`). In particular, we now point at trait bounds on method calls. We no longer point at "obvious" obligation sources (we no longer have a note pointing at `Trait` saying "required by a bound in `Trait`", like in `associated-types-no-suitable-supertrait*`). Address part of #89418.
2021-11-18rustc: Remove `#[rustc_synthetic]`Vadim Petrochenkov-3/+4
This function parameter attribute was introduced in https://github.com/rust-lang/rust/pull/44866 as an intermediate step in implementing `impl Trait`, it's not necessary or used anywhere by itself.
2021-11-17Rollup merge of #90884 - Nilstrieb:fix-span-trivial-trait-bound, r=estebankMatthias Krüger-1/+2
Fix span for non-satisfied trivial trait bounds The spans for "trait bound not satisfied" errors in trivial trait bounds referenced the entire item (fn, impl, struct) before. Now they only reference the obligation itself (`String: Copy`) Address #90869
2021-11-16Use get_diagnostic_name moreCameron Steffen-6/+6
2021-11-16Rollup merge of #90819 - JakobDegen:issue-90804, r=petrochenkovYuki Okushi-38/+21
Fixes incorrect handling of TraitRefs when emitting suggestions. Closes #90804 , although there were more issues here that were hidden by the thing that caused this ICE. Underlying problem was that substitutions were being thrown out, which not only leads to an ICE but also incorrect diagnostics. On top of that, in some cases the self types from the root obligations were being mixed in with those from derived obligations. This makes a couple diagnostics arguable worse ("`B<C>` does not implement `Copy`" instead of "`C` does not implement `Copy`") but the worse diagnostics are at least still correct and that downside is in my opinion clearly outweighed by the benefits of fixing the ICE and unambiguously wrong diagnostics.
2021-11-15refactor is_param_boundTaylor Yu-8/+2
2021-11-15check where clause before suggesting unsizedTaylor Yu-0/+19
2021-11-14Fix span for non-satisfied trivial trait boundsNilstrieb-1/+2
The spans for "trait bound not satisfied" errors in trivial trait bounds referenced the entire item (fn, impl, struct) before. Now they only reference the obligation itself (`String: Copy`) Address #90869
2021-11-13Fix handling of substitutions and binders when deciding whether to suggest ↵Jakob Degen-38/+21
references When suggesting references, substitutions were being forgotten and some types were misused. This led to at least one ICE and other incorrectly emitted diagnostics. This has been fixed; in some cases this leads to diagnostics changing, and tests have been adjusted.
2021-11-11Use `associated_item_def_ids` moreMatthew Jasper-7/+1
2021-11-11Auto merge of #90648 - matthewjasper:assoc-item-cleanup, r=cjgillotbors-11/+4
Assoc item cleanup This removes some fields from ObligationCauseCode Split out of #90639
2021-11-10don't inline `report_overlap_conflict`lcnr-0/+5
2021-11-10no overlap errors after failing the orphan checklcnr-2/+6
2021-11-09Auto merge of #90734 - matthiaskrgr:rollup-e1euotp, r=matthiaskrgrbors-3/+3
Rollup of 7 pull requests Successful merges: - #89561 (Type inference for inline consts) - #90035 (implement rfc-2528 type_changing-struct-update) - #90613 (Allow to run a specific rustdoc-js* test) - #90683 (Make `compiler-docs` only control the default instead of being a hard off-switch) - #90685 (x.py: remove fixme by deleting code) - #90701 (Record more artifact sizes during self-profiling.) - #90723 (Better document `Box` and `alloc::alloc::box_free` connection) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-11-09Rollup merge of #89561 - nbdd0121:const_typeck, r=nikomatsakisMatthias Krüger-3/+3
Type inference for inline consts Fixes #78132 Fixes #78174 Fixes #81857 Fixes #89964 Perform type checking/inference of inline consts in the same context as the outer def, similar to what is currently done to closure. Doing so would require `closure_base_def_id` of the inline const to return the outer def, and since `closure_base_def_id` can be called on non-local crate (and thus have no HIR available), a new `DefKind` is created for inline consts. The type of the generated anon const can capture lifetime of outer def, so we couldn't just use the typeck result as the type of the inline const's def. Closure has a similar issue, and it uses extra type params `CK, CS, U` to capture closure kind, input/output signature and upvars. I use a similar approach for inline consts, letting it have an extra type param `R`, and then `typeof(InlineConst<[paremt generics], R>)` would just be `R`. In borrowck region requirements are also propagated to the outer MIR body just like it's currently done for closure. With this PR, inline consts in expression position are quitely usable now; however the usage in pattern position is still incomplete -- since those does not remain in the MIR borrowck couldn't verify the lifetime there. I have left an ignored test as a FIXME. Some disucssions can be found on [this Zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/260443-project-const-generics/topic/inline.20consts.20typeck). cc `````@spastorino````` `````@lcnr````` r? `````@nikomatsakis````` `````@rustbot````` label A-inference F-inline_const T-compiler
2021-11-09Auto merge of #86041 - bstrie:unmagic-array-copy, r=jackh726bors-7/+4
Replace Copy/Clone compiler magic on arrays with library impls With const generics the compiler no longer needs to fake these impls.