summary refs log tree commit diff
path: root/compiler/rustc_trait_selection/src
AgeCommit message (Collapse)AuthorLines
2023-05-27Don't use outlives type op outside of MIR typeckMichael Goulet-14/+23
2023-05-27Uplift complex type ops back into typeck so we can call them locallyMichael Goulet-17/+558
2023-05-27Perform MIR type ops locally in new solverMichael Goulet-1/+94
2023-05-27Rollup merge of #111987 - lcnr:alias-relate-coherence, r=BoxyUwUMatthias Krüger-9/+25
do not prefer substs relate during coherence r? ```@compiler-errors```
2023-05-26remove unnecessary `.ok()` callslcnr-6/+14
2023-05-26do not prefer substs relate during coherencelcnr-3/+11
2023-05-25Fallible<_> -> Result<_, NoSolution>Michael Goulet-38/+41
2023-05-25Use ErrorGuaranteed more in MIR type opsMichael Goulet-21/+39
2023-05-25Match on both reveal and solver mode at the same timeMichael Goulet-41/+38
2023-05-25Add InferCtxt::register_hidden_type_in_new_solverMichael Goulet-40/+24
2023-05-25Strongly prefer alias and param-env boundsMichael Goulet-5/+9
2023-05-25Pre-populate MIR with opaques, prefer subst-relate candidateMichael Goulet-28/+25
2023-05-25Check that opaque is a defining use, prefer pre-defined opaquesMichael Goulet-14/+91
2023-05-25Prepopulate opaques in canonical inputMichael Goulet-77/+170
2023-05-25Move DefiningAnchorMichael Goulet-1/+2
2023-05-25Pull out logic from #111131, plus some new logic in ↵Michael Goulet-6/+60
EvalCtxt::normalize_opaque_type Co-authored-by: lcnr <rust@lcnr.de>
2023-05-24Rollup merge of #111912 - WaffleLapkin:is_some_and_in_the_compiler, ↵Manish Goregaokar-7/+7
r=petrochenkov Use `Option::is_some_and` and `Result::is_ok_and` in the compiler `.is_some_and(..)`/`.is_ok_and(..)` replace `.map_or(false, ..)` and `.map(..).unwrap_or(false)`, making the code more readable. This PR is a sibling of https://github.com/rust-lang/rust/pull/111873#issuecomment-1561316515
2023-05-24Use ObligationCtxt in custom type opsMichael Goulet-27/+27
2023-05-24Use `Option::is_some_and` and `Result::is_ok_and` in the compilerMaybe Waffle-7/+7
2023-05-24Rollup merge of #111880 - compiler-errors:pointer-like-param-env, r=jackh726Matthias Krüger-10/+16
Don't ICE when computing PointerLike trait when region vars are in param-env Fixes #111877
2023-05-23Don't ICE when computing PointerLike trait when region vars are in param-envMichael Goulet-10/+16
2023-05-23Rollup merge of #111704 - compiler-errors:sized-return-cleanup, r=oli-obkDylan DPC-230/+49
Remove return type sized check hack from hir typeck Remove a bunch of special-cased suggestions when someone returns `-> dyn Trait` that checks for type equality, etc. This was a pretty complex piece of code that also relied on a hack in hir typeck (see changes to `compiler/rustc_hir_typeck/src/check.rs`), and I'm not convinced that it's necessary to maintain, when all we really need to tell the user is that they should return `-> impl Trait` or `-> Box<dyn Trait>`, depending on their specific use-case. This is necessary because we may need to move the "return type is sized" check from hir typeck to wfcheck, which does not have access to typeck results. This is a prerequisite for that, and I'm fairly confident that the diagnostics "regressions" here are not a big deal.
2023-05-23Auto merge of #110204 - compiler-errors:new-solver-hir-typeck-hacks, r=lcnrbors-0/+57
Deal with unnormalized projections when structurally resolving types with new solver 1. Normalize types in `structurally_resolved_type` when the new solver is enabled 2. Normalize built-in autoderef targets in `Autoderef` when the new solver is enabled 3. Normalize-erasing-regions in `resolve_type` in writeback This is motivated by the UI test provided, which currently fails with: ``` error[E0609]: no field `x` on type `<usize as SliceIndex<[Foo]>>::Output` --> <source>:9:11 | 9 | xs[0].x = 1; | ^ ``` I'm pretty happy with the approach in (1.) and (2.) and think we'll inevitably need something like this in the long-term, but (3.) seems like a hack to me. It's a *lot* of work to add tons of new calls to every user of these typeck results though (mir build, late lints, etc). Happy to discuss further. r? `@lcnr`
2023-05-22Structurally normalize in the new solverMichael Goulet-0/+57
2023-05-22Auto merge of #111848 - Dylan-DPC:rollup-7jqydzg, r=Dylan-DPCbors-0/+8
Rollup of 6 pull requests Successful merges: - #111501 (MIR drive-by cleanups) - #111609 (Mark internal functions and traits unsafe to reflect preconditions) - #111612 (Give better error when collecting into `&[T]`) - #111756 (Rename `{drop,forget}_{copy,ref}` lints to more consistent naming) - #111843 (move lcnr to only review types stuff) - #111844 (Migrate GUI colors test to original CSS color format) r? `@ghost` `@rustbot` modify labels: rollup
2023-05-23Rollup merge of #111612 - ChayimFriedman2:collect-into-slice-ref, r=petrochenkovDylan DPC-0/+8
Give better error when collecting into `&[T]` The detection of slice reference of `{integral}` in `rustc_on_unimplemented` is hacky, but a proper solution requires changing `FmtPrinter` to add a parameter to print integers as `{integral}` and I didn't want to change it just for `rustc_on_unimplemented`. I can do that if requested, though. I'm open to better wording; this is the best I could come up with.
2023-05-19update recursion depth in `confirm_candidate`lcnr-0/+6
2023-05-19Auto merge of #110100 - compiler-errors:no-infer-pred-must-hold, r=jackh726bors-23/+32
do not allow inference in `predicate_must_hold` (alternative approach) See the FCP description for more info, but tl;dr is that we should not return `EvaluatedToOkModuloRegions` if an obligation may hold only with some choice of inference vars being constrained. Attempts to solve this in the approach laid out by lcnr here: https://github.com/rust-lang/rust/pull/109558#discussion_r1147318134, rather than by eagerly replacing infer vars with placeholders which is a bit too restrictive. r? `@ghost`
2023-05-18Rollup merge of #111695 - fmease:dont-lump-together-alias-tys, r=compiler-errorsDylan DPC-5/+16
Exclude inherent projections from some alias type `match`es Updating (hopefully) all remaining `match`es which I overlooked to update when adding `AliasKind::Inherent` in #109410. Fixes #111399. Sadly the regression test is a clippy test instead of a rustc one as I don't know of another way to test that a trait bound like `Ty::InhProj: Trait` doesn't cause a crash without reaching a cycle error first (this is getting old ^^'). `@rustbot` label F-inherent_associated_types r? `@compiler-errors`
2023-05-18Rollup merge of #111633 - nnethercote:avoid-ref-format, r=WaffleLapkinDylan DPC-1/+1
Avoid `&format("...")` calls in error message code. Some error message cleanups. Best reviewed one commit at a time. r? `@davidtwco`
2023-05-18Simplify suggestion when returning bare dyn traitMichael Goulet-230/+49
2023-05-17Exclude inherent projections from some alias ty matchesLeón Orell Valerian Liehr-5/+16
2023-05-16Rollup merge of #111533 - clubby789:drop-tracking-error, r=oli-obkMatthias Krüger-2/+1
Handle error body in generator layout Fixes #111468 I feel like making this query return `Option<GeneratorLayout>` might be better but had some issues with that approach
2023-05-16Use error term if missing associated item in new solverMichael Goulet-1/+15
2023-05-16Rollup merge of #111602 - tmiasko:erroneous-constant-used, r=oli-obkNilstrieb-4/+4
Suppress "erroneous constant used" for constants tainted by errors When constant evaluation fails because its MIR is tainted by errors, suppress note indicating that erroneous constant was used, since those errors have to be fixed regardless of the constant being used or not. Fixes #110891.
2023-05-16Avoid `&format("...")` calls in error message code.Nicholas Nethercote-1/+1
Error message all end up passing into a function as an `impl Into<{D,Subd}iagnosticMessage>`. If an error message is creatd as `&format("...")` that means we allocate a string (in the `format!` call), then take a reference, and then clone (allocating again) the reference to produce the `{D,Subd}iagnosticMessage`, which is silly. This commit removes the leading `&` from a lot of these cases. This means the original `String` is moved into the `{D,Subd}iagnosticMessage`, avoiding the double allocations. This requires changing some function argument types from `&str` to `String` (when all arguments are `String`) or `impl Into<{D,Subd}iagnosticMessage>` (when some arguments are `String` and some are `&str`).
2023-05-15Give better error when collecting into `&[T]`Chayim Refael Friedman-0/+8
2023-05-15Move expansion of query macros in rustc_middle to rustc_middle::queryJohn Kåre Alsaker-7/+9
2023-05-15Suppress "erroneous constant used" for constants tainted by errorsTomasz Miąsko-4/+4
When constant evaluation fails because its MIR is tainted by errors, suppress note indicating that erroneous constant was used, since those errors have to be fixed regardless of the constant being used or not.
2023-05-13Handle error body when in generator layoutclubby789-2/+1
2023-05-12do not allow inference in `pred_known_to_hold_modulo_regions`Michael Goulet-21/+23
2023-05-12EvaluateToAmbig if evaluate_root_obligation does inferenceMichael Goulet-3/+10
2023-05-12Note base types of coercionMichael Goulet-51/+50
2023-05-11Auto merge of #111029 - Nilstrieb:when-the-errs-are-too-big, r=petrochenkovbors-7/+19
Shrink `SelectionError` a lot `SelectionError` used to be 80 bytes (on 64 bit). That's quite big. Especially because the selection cache contained `Result<_, SelectionError>. The Ok type is only 32 bytes, so the 80 bytes significantly inflate the size of the cache. Most variants of the `SelectionError` seem to be hard errors, only `Unimplemented` shows up in practice (for cranelift-codegen, it occupies 23.4% of all cache entries). We can just box away the biggest variant, `OutputTypeParameterMismatch`, to get the size down to 16 bytes, well within the size of the Ok type inside the cache.
2023-05-09Consolidate the 'match assumption' type methods in GoalKindMichael Goulet-140/+47
2023-05-09Make alias bounds sound in the new solverMichael Goulet-2/+162
2023-05-09Rename `expected_trait_ref` to `self_ty_trait_ref`Nilstrieb-2/+2
This trait ref is derived from the self type and then equated to the trait ref from the obligation. For example, for `fn(): Fn(u32)`, `self_ty_trait_ref` is `Fn()`, which is then equated to `Fn(u32)` (which will fail, causing the obligation to fail).
2023-05-09Shrink `SelectionError` a lotNilstrieb-5/+17
`SelectionError` used to be 80 bytes (on 64 bit). That's quite big. Especially because the selection cache contained `Result<_, SelectionError>. The Ok type is only 32 bytes, so the 80 bytes significantly inflate the size of the cache. Most variants of the `SelectionError` seem to be hard errors, only `Unimplemented` shows up in practice (for cranelift-codegen, it occupies 23.4% of all cache entries). We can just box away the biggest variant, `OutputTypeParameterMismatch`, to get the size down to 16 bytes, well within the size of the Ok type inside the cache.
2023-05-09Rollup merge of #111252 - matthewjasper:min-spec-improvements, r=compiler-errorsDylan DPC-22/+59
Min specialization improvements - Don't allow specialization impls with no items, such implementations are probably not correct and only occur as mistakes in the compiler and standard library - Fix a missing normalization call - Adds spans for lifetime errors from overly general specializations Closes #79457 Closes #109815
2023-05-08Rollup merge of #109410 - fmease:iat-alias-kind-inherent, r=compiler-errorsMichael Goulet-52/+252
Introduce `AliasKind::Inherent` for inherent associated types Allows us to check (possibly generic) inherent associated types for well-formedness. Type inference now also works properly. Follow-up to #105961. Supersedes #108430. Fixes #106722. Fixes #108957. Fixes #109768. Fixes #109789. Fixes #109790. ~Not to be merged before #108860 (`AliasKind::Weak`).~ CC `@jackh726` r? `@compiler-errors` `@rustbot` label T-types F-inherent_associated_types