about summary refs log tree commit diff
path: root/compiler/rustc_trait_selection
AgeCommit message (Collapse)AuthorLines
2023-12-15Remove an unneeded allocationArthur Carcano-1/+1
2023-12-15unify query canonicalization modeAli MJ Al-Nasrawy-16/+5
2023-12-14Unconditionally register alias-relate in projection goalMichael Goulet-11/+23
2023-12-14reviewlcnr-1/+1
2023-12-14consistently use "next solver" instead of "new solver"lcnr-13/+13
2023-12-14update use of feature flagslcnr-14/+13
2023-12-14rename `-Ztrait-solver` to `-Znext-solver`lcnr-37/+36
2023-12-14Auto merge of #117749 - aliemjay:perf-canon-cache, r=lcnrbors-4/+4
cache param env canonicalization Canonicalize ParamEnv only once and store it. Then whenever we try to canonicalize `ParamEnvAnd<'tcx, T>` we only have to canonicalize `T` and then merge the results. Prelimiary results show ~3-4% savings in diesel and serde benchmarks. Best to review commits individually. Some commits have a short description. Initial implementation had a soundness bug (https://github.com/rust-lang/rust/pull/117749#issuecomment-1840453387) due to cache invalidation: - When canonicalizing `Ty<'?0>` we first try to resolve region variables in the current InferCtxt which may have a constraint `?0 == 'static`. This means that we register `Ty<'?0> => Canonical<Ty<'static>>` in the cache, which is obviously incorrect in another inference context. - This is fixed by not doing region resolution when canonicalizing the query *input* (vs. response), which is the only place where ParamEnv is used, and then in a later commit we *statically* guard against any form of inference variable resolution of the cached canonical ParamEnv's. r? `@ghost`
2023-12-13Tweak `short_ty_string` to reduce number of filesEsteban Küber-28/+36
When shortening types and writing them to disk, make `short_ty_string` capable of reusing the same file, instead of writing a file per shortened type.
2023-12-13global param_env canonicalization cacheAli MJ Al-Nasrawy-4/+4
2023-12-13Auto merge of #118500 - ZetaNumbers:tcx_hir_refactor, r=petrochenkovbors-32/+30
Move some methods from `tcx.hir()` to `tcx` https://github.com/rust-lang/rust/pull/118256#issuecomment-1826442834 Renamed: - find -> opt_hir_node - get -> hir_node - find_by_def_id -> opt_hir_node_by_def_id - get_by_def_id -> hir_node_by_def_id
2023-12-12Rollup merge of #118889 - matthiaskrgr:compl_2023_2, r=WaffleLapkinJubilee-3/+2
more clippy::complexity fixes redundant_guards redundant_slicing filter_next needless_borrowed_reference useless_format
2023-12-12Rollup merge of #118885 - matthiaskrgr:compl_2023, r=compiler-errorsJubilee-1/+1
clippy::complexity fixes filter_map_identity needless_bool search_is_some unit_arg map_identity needless_question_mark derivable_impls
2023-12-12more clippy::complexity fixesMatthias Krüger-3/+2
redundant_guards redundant_slicing filter_next needless_borrowed_reference useless_format
2023-12-12clippy::complexity fixesMatthias Krüger-1/+1
filter_map_identity needless_bool search_is_some unit_arg map_identity needless_question_mark derivable_impls
2023-12-12Auto merge of #118881 - matthiaskrgr:rollup-0rl3tir, r=matthiaskrgrbors-13/+23
Rollup of 9 pull requests Successful merges: - #116740 (dont ICE when ConstKind::Expr for is_const_evaluatable) - #117914 (On borrow return type, suggest borrowing from arg or owned return type) - #117927 (Clarify how to choose a FutureIncompatibilityReason variant.) - #118855 (Improve an error involving attribute values.) - #118856 (rustdoc-search: clean up parser) - #118865 (rustc_codegen_llvm: Enforce `rustc::potential_query_instability` lint) - #118866 (llvm-wrapper: adapt for LLVM API change) - #118868 (Correctly gate the parsing of match arms without body) - #118877 (tests: CGU tests require build-pass, not check-pass (remove FIXME)) r? `@ghost` `@rustbot` modify labels: rollup
2023-12-12Rollup merge of #116740 - ↵Matthias Krüger-13/+23
lenko-d:const_evaluatable_failed_for_non_unevaluated_const, r=BoxyUwU dont ICE when ConstKind::Expr for is_const_evaluatable The problem is that we are not handling ConstKind::Expr inside report_not_const_evaluatable_error Fixes [#114151]
2023-12-12Move some methods from `tcx.hir()` to `tcx`zetanumbers-32/+30
Renamings: - find -> opt_hir_node - get -> hir_node - find_by_def_id -> opt_hir_node_by_def_id - get_by_def_id -> hir_node_by_def_id Fix rebase changes using removed methods Use `tcx.hir_node_by_def_id()` whenever possible in compiler Fix clippy errors Fix compiler Apply suggestions from code review Co-authored-by: Vadim Petrochenkov <vadim.petrochenkov@gmail.com> Add FIXME for `tcx.hir()` returned type about its removal Simplify with with `tcx.hir_node_by_def_id`
2023-12-12refactor writeback: emit normalization errors with new solverlcnr-5/+4
2023-12-11Auto merge of #118661 - fee1-dead-contrib:restore-const-partialEq, ↵bors-2/+5
r=compiler-errors Restore `const PartialEq` And thus fixes a number of tests. There is a bug that still needs to be fixed, so WIP for now. r? `@compiler-errors`
2023-12-10fix host param for `PartialEq`Deadbeef-2/+5
2023-12-10remove redundant importssurechen-2/+0
detects redundant imports that can be eliminated. for #117772 : In order to facilitate review and modification, split the checking code and removing redundant imports code into two PR.
2023-12-09report_not_const_evaluatable_error to avoid ICEing on ConstKind::ExprLenko Donchev-13/+23
2023-12-09Rollup merge of #118762 - compiler-errors:gen-nits, r=eholkJubilee-3/+2
Some more minor `async gen`-related nits Tiny tweaks found after `async gen` pr landed r? eholk
2023-12-08Rollup merge of #118736 - aliemjay:revert-ice-on-ambig, r=compiler-errorsMatthias Krüger-12/+4
temporarily revert "ice on ambguity in mir typeck" Reverts #116530 as a temporary measure to fix #117577. That issue should be ultimately fixed by checking WF of type annotations prior to normalization, which is implemented in #104098 but this PR is intended to be backported to beta. r? ``@compiler-errors`` (the reviewer of the reverted PR)
2023-12-08Rollup merge of #117586 - compiler-errors:the-canonicalizer, r=lcnrMatthias Krüger-430/+2
Uplift the (new solver) canonicalizer into `rustc_next_trait_solver` Uplifts the new trait solver's canonicalizer into a new crate called `rustc_next_trait_solver`. The crate name is literally a bikeshed-avoidance name, so let's not block this PR on that -- renames are welcome later. There are a host of other changes that were required to make this possible: * Expose a `ConstTy` trait to get the `Interner::Ty` from a `Interner::Const`. * Expose some constructor methods to construct `Bound` variants. These are currently methods defined on the interner themselves, but they could be pulled into traits later. * Expose a `IntoKind` trait to turn a `Ty`/`Const`/`Region` into their corresponding `*Kind`s. * Some minor tweaks to other APIs in `rustc_type_ir`. The canonicalizer code itself is best reviewed **with whitespace ignored.** r? ``@lcnr``
2023-12-08More nitsMichael Goulet-3/+2
2023-12-08Uplift canonicalizer into new trait solver crateMichael Goulet-430/+2
2023-12-08Implement `async gen` blocksMichael Goulet-4/+232
2023-12-08Auto merge of #118689 - compiler-errors:const-drop, r=fee1-deadbors-10/+21
Fix const drop checking Fixes confirmation of `~const Destruct` and const drops. r? fee1-dead
2023-12-08temporarily revert "ice on ambguity in mir typeck"Ali MJ Al-Nasrawy-12/+4
Reverts #116530
2023-12-08Auto merge of #118725 - lcnr:normalizes-to-projection-split-3, r=BoxyUwUbors-76/+102
split `NormalizesTo` out of `Projection` 3 third attempt at #112658. Rebasing #116262 is very annoying, so I am doing it again from scratch. We should now be able to merge it without regressing anything as we handle occurs check failures involving aliases correctly since #117088. see https://hackmd.io/ktEL8knTSYmtdfrMMnA-Hg fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/1 r? `@compiler-errors`
2023-12-08implement and use `NormalizesTo`lcnr-67/+73
2023-12-07Rollup merge of #118686 - compiler-errors:object-safety, r=lcnrMatthias Krüger-10/+7
Only check principal trait ref for object safety It should make things a bit faster, in case we end up registering a bunch of object safety preds. r? ```@ghost```
2023-12-07add unused `NormalizesTo` predicatelcnr-10/+30
2023-12-07Fix const drop checkingMichael Goulet-10/+21
2023-12-07Auto merge of #118685 - compiler-errors:stack-dependent, r=lcnrbors-4/+4
`EvaluatedToUnknown` -> `EvaluatedToAmbigStackDependent`, `EvaluatedToRecur` -> `EvaluatedToErrStackDependent` Less confusing names, since the only difference between them and their parallel `EvalutedTo..` is that they are stack dependent. r? lcnr
2023-12-07Auto merge of #118684 - compiler-errors:yeet-poly-gen-sig, r=spastorinobors-65/+59
Remove `PolyGenSig` since it's always a dummy binder Coroutines are never polymorphic in their signature. This cleans up a FIXME in the code: ``` /// Returns the "coroutine signature", which consists of its yield /// and return types. /// /// N.B., some bits of the code prefers to see this wrapped in a /// binder, but it never contains bound regions. Probably this /// function should be removed. ```
2023-12-06Only check principal trait ref for object safetyMichael Goulet-10/+7
2023-12-06EvaluatedToUnknown -> EvaluatedToAmbigStackDependent, EvaluatedToRecur -> ↵Michael Goulet-4/+4
EvaluatedToErrStackDependent
2023-12-06Yeet PolyGenSigMichael Goulet-65/+59
2023-12-06Rollup merge of #116496 - estebank:question-method-chain-context, ↵Matthias Krüger-3/+232
r=compiler-errors Provide context when `?` can't be called because of `Result<_, E>` When a method chain ending in `?` causes an E0277 because the expression's `Result::Err` variant doesn't have a type that can be converted to the `Result<_, E>` type parameter in the return type, provide additional context of which parts of the chain can and can't support the `?` operator. ``` error[E0277]: `?` couldn't convert the error to `String` --> $DIR/question-mark-result-err-mismatch.rs:27:25 | LL | fn bar() -> Result<(), String> { | ------------------ expected `String` because of this LL | let x = foo(); | ----- this has type `Result<_, String>` ... LL | .map_err(|_| ())?; | ---------------^ the trait `From<()>` is not implemented for `String` | | | this can't be annotated with `?` because it has type `Result<_, ()>` | = note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait = help: the following other types implement trait `From<T>`: <String as From<char>> <String as From<Box<str>>> <String as From<Cow<'a, str>>> <String as From<&str>> <String as From<&mut str>> <String as From<&String>> = note: required for `Result<(), String>` to implement `FromResidual<Result<Infallible, ()>>` ``` Fix #72124.
2023-12-05Reduce verbosity of errorEsteban Küber-16/+21
2023-12-05Detect incorrect `;` in `Option::ok_or_else` and `Result::map_err`Esteban Küber-3/+67
Fix #72124.
2023-12-05Point at fewer methods in the chain, only those that change the E typeEsteban Küber-29/+47
2023-12-05Provide context when `?` can't be called because of `Result<_, E>`Esteban Küber-1/+143
When a method chain ending in `?` causes an E0277 because the expression's `Result::Err` variant doesn't have a type that can be converted to the `Result<_, E>` type parameter in the return type, provide additional context of which parts of the chain can and can't support the `?` operator. ``` error[E0277]: `?` couldn't convert the error to `String` --> $DIR/question-mark-result-err-mismatch.rs:28:25 | LL | fn bar() -> Result<(), String> { | ------------------ expected `String` because of this LL | let x = foo(); | ----- this can be annotated with `?` because it has type `Result<String, String>` LL | let one = x LL | .map(|s| ()) | ----------- this can be annotated with `?` because it has type `Result<(), String>` LL | .map_err(|_| ())?; | ---------------^ the trait `From<()>` is not implemented for `String` | | | this can't be annotated with `?` because it has type `Result<(), ()>` | = note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait = help: the following other types implement trait `From<T>`: <String as From<char>> <String as From<Box<str>>> <String as From<Cow<'a, str>>> <String as From<&str>> <String as From<&mut str>> <String as From<&String>> = note: required for `Result<(), String>` to implement `FromResidual<Result<Infallible, ()>>` ``` Fix #72124.
2023-12-05Rollup merge of #118346 - compiler-errors:deeply-normalize-for-diagnostic, ↵Michael Goulet-5/+57
r=lcnr Add `deeply_normalize_for_diagnostics`, use it in coherence r? lcnr Normalize trait refs used for coherence error reporting with `-Ztrait-solver=next-coherence`. Two things: 1. I said before that we can't add this to `TyErrCtxt` because we compute `OverlapResult`s even if there are no diagnostics being emitted, e.g. for a reservation impl. 2. I didn't want to add this to an `InferCtxtExt` trait because I felt it was unnecessary. I don't particularly care about the API though.
2023-12-05Add moreMichael Goulet-5/+5
2023-12-05Add print_trait_sugaredMichael Goulet-11/+4
2023-12-05Continue folding if deep normalizer failsMichael Goulet-14/+40