about summary refs log tree commit diff
path: root/compiler/rustc_trait_selection/src
AgeCommit message (Collapse)AuthorLines
2024-07-03Auto merge of #123737 - compiler-errors:alias-wf, r=lcnrbors-9/+3
Check alias args for WF even if they have escaping bound vars #### What This PR stops skipping arguments of aliases if they have escaping bound vars, instead recursing into them and only discarding the resulting obligations referencing bounds vars. #### An example: From the test: ``` trait Trait { type Gat<U: ?Sized>; } fn test<T>(f: for<'a> fn(<&'a T as Trait>::Gat<&'a [str]>)) where for<'a> &'a T: Trait {} //~^ ERROR the size for values of type `[()]` cannot be known at compilation time fn main() {} ``` We now prove that `str: Sized` in order for `&'a [str]` to be well-formed. We were previously unconditionally skipping over `&'a [str]` as it referenced a buond variable. We now recurse into it and instead only discard the `[str]: 'a` obligation because of the escaping bound vars. #### Why? This is a change that improves consistency about proving well-formedness earlier in the pipeline, which is necessary for future work on where-bounds in binders and correctly handling higher-ranked implied bounds. I don't expect this to fix any unsoundness. #### What doesn't it fix? Specifically, this doesn't check projection predicates' components are well-formed, because there are too many regressions: https://github.com/rust-lang/rust/pull/123737#issuecomment-2052198478
2024-07-02Actually report normalization-based type errors correctly for alias-relate ↵Michael Goulet-48/+101
obligations in new solver
2024-07-02Fix spansMichael Goulet-1/+2
2024-07-02Miscellaneous renamingMichael Goulet-3/+3
2024-07-02Rollup merge of #127230 - hattizai:patch01, r=saethlinMatthias Krüger-2/+2
chore: remove duplicate words remove duplicate words in comments to improve readability.
2024-07-02Rollup merge of #127146 - compiler-errors:fast-reject, r=lcnrMatthias Krüger-2/+2
Uplift fast rejection to new solver Self explanatory. r? lcnr
2024-07-02chore: remove duplicate wordshattizai-2/+2
2024-07-01Auto merge of #126996 - oli-obk:do_not_count_errors, r=nnethercotebors-19/+19
Automatically taint InferCtxt when errors are emitted r? `@nnethercote` Basically `InferCtxt::dcx` now returns a `DiagCtxt` that refers back to the `Cell<Option<ErrorGuaranteed>>` of the `InferCtxt` and thus when invoking `Diag::emit`, and the diagnostic is an error, we taint the `InferCtxt` directly. That change on its own has no effect at all, because `InferCtxt` already tracks whether errors have been emitted by recording the global error count when it gets opened, and checking at the end whether the count changed. So I removed that error count check, which had a bit of fallout that I immediately fixed by invoking `InferCtxt::dcx` instead of `TyCtxt::dcx` in a bunch of places. The remaining new errors are because an error was reported in another query, and never bubbled up. I think they are minor enough for this to be ok, and sometimes it actually improves diagnostics, by not silencing useful diagnostics anymore. fixes #126485 (cc `@olafes)` There are more improvements we can do (like tainting in hir ty lowering), but I would rather do that in follow up PRs, because it requires some refactorings.
2024-06-30Uplift fast rejection to new solverMichael Goulet-2/+2
2024-06-29Auto merge of #120639 - fee1-dead-contrib:new-effects-desugaring, r=oli-obkbors-0/+6
Implement new effects desugaring cc `@rust-lang/project-const-traits.` Will write down notes once I have finished. * [x] See if we want `T: Tr` to desugar into `T: Tr, T::Effects: Compat<true>` * [x] Fix ICEs on `type Assoc: ~const Tr` and `type Assoc<T: ~const Tr>` * [ ] add types and traits to minicore test * [ ] update rustc-dev-guide Fixes #119717 Fixes #123664 Fixes #124857 Fixes #126148
2024-06-28implement new effects desugaringDeadbeef-0/+6
2024-06-27Make queries more explicitMichael Goulet-5/+5
2024-06-26Automatically taint InferCtxt when errors are emittedOli Scherer-2/+2
2024-06-26Restrict diagnostic context lifetime of InferCtxt to itself instead of TyCtxtOli Scherer-3/+3
2024-06-26Restrict diagnostic context lifetime of TypeErrCtxt to InferCtxt instead of ↵Oli Scherer-14/+14
TyCtxt
2024-06-25Auto merge of #125610 - oli-obk:define_opaque_types14, r=compiler-errorsbors-4/+4
Allow constraining opaque types during various unsizing casts allows unsizing of tuples, arrays and Adts to constraint opaque types in their generic parameters to concrete types on either side of the unsizing cast. Also allows constraining opaque types during trait object casts that only differ in auto traits or lifetimes. cc #116652
2024-06-25Auto merge of #126813 - compiler-errors:SliceLike, r=lcnrbors-17/+35
Add `SliceLike` to `rustc_type_ir`, use it in the generic solver code (+ some other changes) First, we split out `TraitRef::new_from_args` which takes *just* `ty::GenericArgsRef` from `TraitRef::new` which takes `impl IntoIterator<Item: Into<GenericArg>>`. I will explain in a minute why. Second, we introduce `SliceLike`, which allows us to be generic over `List<T>` and `[T]`. This trait has an `as_slice()` and `into_iter()` method, and some other convenience functions. However, importantly, since types like `I::GenericArgs` now implement `SliceLike` rather than `IntoIter<Item = I::GenericArg>`, we can't use `TraitRef::new` on this directly. That's where `new_from_args` comes in. Finally, we adjust all the code to use these slice operators. Some things get simpler, some things get a bit more annoying since we need to use `as_slice()` in a few places. 🤷 r? lcnr
2024-06-24Split out IntoIterator and non-Iterator constructors for ↵Michael Goulet-17/+35
AliasTy/AliasTerm/TraitRef/projection
2024-06-24Suggest inline const blocks for array initializationPavel Grigorenko-33/+7
2024-06-21Rename a bunch of thingsMichael Goulet-24/+24
2024-06-20Rollup merge of #126717 - nnethercote:rustfmt-use-pre-cleanups, r=jieyouxuMatthias Krüger-0/+2
Clean up some comments near `use` declarations #125443 will reformat all `use` declarations in the repository. There are a few edge cases involving comments on `use` declarations that require care. This PR cleans up some clumsy comment cases, taking us a step closer to #125443 being able to merge. r? ``@lqd``
2024-06-20Rollup merge of #126620 - oli-obk:taint_errors, r=fee1-deadMatthias Krüger-100/+111
Actually taint InferCtxt when a fulfillment error is emitted And avoid checking the global error counter fixes #122044 fixes #123255 fixes #123276 fixes #125799
2024-06-20Add blank lines after module-level `//!` comments.Nicholas Nethercote-0/+2
Most modules have such a blank line, but some don't. Inserting the blank line makes it clearer that the `//!` comments are describing the entire module, rather than the `use` declaration(s) that immediately follows.
2024-06-19Const generic parameters aren't bounds, even if we end up erroring because ↵Oli Scherer-85/+103
of the bound that binds the parameter's type
2024-06-19Allow constraining opaque types during auto trait castingOli Scherer-1/+1
2024-06-19Allow constraining opaque types during unsizingOli Scherer-3/+3
2024-06-19Taint infcx when reporting errorsOli Scherer-15/+8
2024-06-18Auto merge of #126614 - compiler-errors:uplift-next-trait-solver, r=lcnrbors-7313/+479
Uplift next trait solver to `rustc_next_trait_solver` 🎉 There's so many FIXMEs! Sorry! Ideally this merges with the FIXMEs and we track and squash them over the near future. Also, this still doesn't build on anything other than rustc. I still need to fix `feature = "nightly"` in `rustc_type_ir`, and remove and fix all the nightly feature usage in the new trait solver (notably: let-chains). Also, sorry `@lcnr` I know you asked for me to separate the commit where we `mv rustc_trait_selection/solve/... rustc_next_trait_solver/solve/...`, but I had already done all the work by that point. Luckily, `git` understands the file moves so it should still be relatively reviewable. If this is still very difficult to review, then I can do some rebasing magic to try to separate this out. Please let me know! r? lcnr
2024-06-18Remove redundant argument from `subdiagnostic` methodOli Scherer-5/+2
2024-06-18Use a dedicated type instead of a reference for the diagnostic contextOli Scherer-2/+2
This paves the way for tracking more state (e.g. error tainting) in the diagnostic context handle
2024-06-18Fix transmute goalMichael Goulet-1/+27
2024-06-18Fix impl for SolverDelegateMichael Goulet-77/+310
2024-06-18Uplift the new trait solverMichael Goulet-7260/+0
2024-06-18SolverDelegateMichael Goulet-148/+339
2024-06-18Make SearchGraph fully genericMichael Goulet-73/+49
2024-06-16Uplift OpaqueTypeKey too, use it in responseMichael Goulet-9/+3
2024-06-16Uplift ExternalConstraintDataMichael Goulet-15/+27
2024-06-16Make ExternalConstraints just carry outlivesMichael Goulet-18/+22
2024-06-16Stop using AssocKind in new solverMichael Goulet-13/+11
2024-06-16Move InferCtxtSelectExt out of eval_ctxt moduleMichael Goulet-3/+3
2024-06-16Auto merge of #126540 - jhpratt:rollup-fzzz8j3, r=jhprattbors-1/+1
Rollup of 4 pull requests Successful merges: - #125112 (Document behavior of `create_dir_all` wrt. empty path) - #126127 (Spell out other trait diagnostic) - #126309 (unify git command preperation) - #126539 (Update `Arc::try_unwrap()` docs) r? `@ghost` `@rustbot` modify labels: rollup
2024-06-16Rollup merge of #126127 - Alexendoo:other-trait-diag, r=pnkfelixJacob Pratt-1/+1
Spell out other trait diagnostic I recently saw somebody confused about the diagnostic thinking it was suggesting to add an `as` cast. This change is longer but I think it's clearer
2024-06-16Auto merge of #126505 - compiler-errors:no-vtable, r=lcnrbors-170/+100
Only compute vtable information during codegen This PR removes vtable information from the `Object` and `TraitUpcasting` candidate sources in the trait solvers, and defers the computation of relevant information to `Instance::resolve`. This is because vtables really aren't a thing in the trait world -- they're an implementation detail in codegen. Previously it was just easiest to tangle this information together since we were already doing the work of looking at all the supertraits in the trait solver, and specifically because we use traits to represent when it's possible to call a method via a vtable (`Object` candidate) and do upcasting (`Unsize` candidate). but I am somewhat suspicious we're doing a *lot* of extra work, especially in polymorphic contexts, so let's see what perf says.
2024-06-15Rollup merge of #126525 - jieyouxu:traitsel-docs, r=compiler-errorsGuillaume Gomez-2/+2
trait_selection: remove extra words Tiny doc cleanup. Fixes https://github.com/rust-lang/rust/issues/88231.
2024-06-15Rollup merge of #126496 - compiler-errors:more-generics, r=lcnrGuillaume Gomez-143/+151
Make proof tree probing and `Candidate`/`CandidateSource` generic over interner `<TyCtxt<'tcx>>` is ugly, but will become `<I>` when things actually become generic. r? lcnr
2024-06-15Rollup merge of #126404 - compiler-errors:alias-relate-terms, r=lcnrGuillaume Gomez-1/+40
Check that alias-relate terms are WF if reporting an error in alias-relate Check that each of the left/right term is WF when deriving a best error obligation for an alias-relate goal. This will make sure that given `<i32 as NotImplemented>::Assoc = ()` will drill down into `i32: NotImplemented` since we currently treat the projection as rigid. r? lcnr
2024-06-15trait_selection: remove extra words许杰友 Jieyou Xu (Joe)-2/+2
2024-06-15Rollup merge of #126471 - oli-obk:filter_loop, r=compiler-errorsMatthias Krüger-11/+6
Use a consistent way to filter out bounds instead of splitting it into three places just a small cleanup, no logic change. Initially the code had me looking for why anything was special here, only to realize there's nothing interesting going on
2024-06-15Rollup merge of #126354 - compiler-errors:variance, r=lcnrMatthias Krüger-4/+4
Use `Variance` glob imported variants everywhere Fully commit to using the globbed variance. Could be convinced the other way, and change this PR to not use the globbed variants anywhere, but I'd rather we do one or the other. r? lcnr
2024-06-14Only compute vtable information during codegenMichael Goulet-170/+100