about summary refs log tree commit diff
path: root/compiler/rustc_trait_selection/src/traits
AgeCommit message (Collapse)AuthorLines
2025-01-23Remove query normalize from dropck outlives type opMichael Goulet-10/+14
2025-01-22Rollup merge of #135816 - BoxyUwU:root_normalizes_to_goal_ice, r=lcnrMatthias Krüger-51/+39
Use `structurally_normalize` instead of manual `normalizes-to` goals in alias relate errors r? `@lcnr` I added `structurally_normalize_term` so that code that is generic over ty or const can use the structurally normalize helpers. See `tests/ui/traits/next-solver/diagnostics/alias_relate_error_uses_structurally_normalize.rs` for a description of the reason for the (now fixed) ICEs
2025-01-22Refactor dyn-compatibility error and suggestionsTaylor Cramer-1/+0
This CL makes a number of small changes to dyn compatibility errors: - "object safety" has been renamed to "dyn-compatibility" throughout - "Convert to enum" suggestions are no longer generated when there exists a type-generic impl of the trait or an impl for `dyn OtherTrait` - Several error messages are reorganized for user readability Additionally, the dyn compatibility error creation code has been split out into functions. cc #132713 cc #133267
2025-01-22Rename `structurally_normalize` to `structurally_normalize_ty`Boxy-4/+4
2025-01-22Use `structurally_normalize` instead of manual `normalizes-to` goalsBoxy-47/+35
2025-01-21Move supertrait_def_ids into the elaborate module like all other fnsMichael Goulet-9/+11
2025-01-21Auto merge of #133830 - compiler-errors:span-key, r=lcnrbors-146/+69
Rework dyn trait lowering to stop being so intertwined with trait alias expansion This PR reworks the trait object lowering code to stop handling trait aliases so funky, and removes the `TraitAliasExpander` in favor of a much simpler design. This refactoring is important for making the code that I'm writing in https://github.com/rust-lang/rust/pull/133397 understandable and easy to maintain, so the diagnostics regressions are IMO inevitable. In the old trait object lowering code, we used to be a bit sloppy with the lists of traits in their unexpanded and expanded forms. This PR largely rewrites this logic to expand the trait aliases *once* and handle them more responsibly throughout afterwards. Please review this with whitespace disabled. r? lcnr
2025-01-18Get rid of `ToPolyTraitRef`Michael Goulet-5/+7
2025-01-18Rollup merge of #135639 - lqd:trivial-builtin-impls, r=lcnrMatthias Krüger-2/+2
new solver: prefer trivial builtin impls As discussed [on zulip](https://rust-lang.zulipchat.com/#narrow/channel/364551-t-types.2Ftrait-system-refactor/topic/needs_help.3A.20trivial.20builtin.20impls), this PR: - adds a new `BuiltinImplSource::Trivial` source, and marks the `Sized` builtin impls as trivial - prefers these trivial builtin impls in `merge_trait_candidates` The comments can likely be wordsmithed a bit better, and I ~stole~ was inspired by the old solver ones. Let me know how you want them improved. When enabling the new solver for tests, 3 UI tests now pass: - `regions/issue-26448-1.rs` and its sibling `regions/issue-26448-2.rs` were rejected by the new solver but accepted by the old one - and `issues/issue-42796.rs` where the old solver emitted some overflow errors in addition to the expected error (For some reason one of these tests is run-pass, but I can take care of that another day) r? lcnr
2025-01-18Auto merge of #135618 - lcnr:coherence-unknown, r=compiler-errorsbors-24/+45
add cache to `AmbiguityCausesVisitor` fixes #135457, alternative to #135524. cc https://rust-lang.zulipchat.com/#narrow/channel/364551-t-types.2Ftrait-system-refactor/topic/new-solver.20hang.20.23135457 r? `@compiler-errors`
2025-01-17new solver: prefer trivial builtin impls over where-clausesRémy Rakic-2/+2
for now, only builtin `Sized` impls are tracked as being `Trivial`
2025-01-17add cache to `AmbiguityCausesVisitor`lcnr-2/+12
2025-01-15Rollup merge of #135498 - compiler-errors:dyn-upcasting-completeness, r=lcnrGuillaume Gomez-1/+13
Prefer lower `TraitUpcasting` candidates in selection Fixes #135463. The underlying cause is this ambiguity, but it's more clear (and manifests as a coercion error, rather than a MIR validation error) when it's written the way I did in the UI test. Sorry this is cursed r? lcnr
2025-01-15avoid running the overlap check twicelcnr-22/+33
2025-01-15Rework trait expansion to happen once explicitlyMichael Goulet-146/+69
2025-01-14Rollup merge of #135466 - compiler-errors:leak-check-impossible, r=lcnrMatthias Krüger-3/+12
Leak check in `impossible_predicates` to avoid monomorphizing impossible instances Fixes #135462 r? lcnr
2025-01-14Prefer lower TraitUpcasting candidatesMichael Goulet-1/+13
2025-01-14Leak check in impossible_predicates to avoid monomorphizing impossible instancesMichael Goulet-3/+12
2025-01-14fix ICE with references to infinite structs in constsLukas Markeffsky-3/+4
2025-01-09Rollup merge of #135269 - estebank:unneeded-into, r=compiler-errorsMatthias Krüger-2/+2
Remove some unnecessary `.into()` calls
2025-01-08Remove some unnecessary `.into()` callsEsteban Küber-2/+2
2025-01-08Implement const Destruct in old solverMichael Goulet-1/+105
2025-01-06Add derived causes for host effect predicatesMichael Goulet-3/+18
2025-01-03Do not project when there are unconstrained impl paramsMichael Goulet-29/+48
2024-12-31Make sure we check the future type is Sized in AsyncFn*Michael Goulet-3/+20
2024-12-27Rollup merge of #134827 - compiler-errors:borrowck-nits, r=lqdDavid Tolnay-2/+1
Some random region tweaks Remove a redundant function and add an assertion that I think is useful
2024-12-27Rollup merge of #134823 - chloefeal:fix, r=tgross35,dtolnayDavid Tolnay-1/+1
Fix typos This PR focuses on correcting typos and improving clarity in documentation files. Thank you.
2024-12-27Fix typoschloefeal-1/+1
Signed-off-by: chloefeal <188809157+chloefeal@users.noreply.github.com>
2024-12-26Make ty::Error implement auto traitsMichael Goulet-1/+3
2024-12-26nit: Remove redundant functionMichael Goulet-2/+1
2024-12-24Auto merge of #134716 - Zalathar:rollup-1h4q8cc, r=Zalatharbors-28/+137
Rollup of 5 pull requests Successful merges: - #134638 (Fix effect predicates from item bounds in old solver) - #134662 (Fix safety docs for `dyn Any + Send {+ Sync}`) - #134689 (core: fix const ptr::swap_nonoverlapping when there are pointers at odd offsets) - #134699 (Belay new reviews for workingjubilee) - #134701 (Correctly note item kind in `NonConstFunctionCall` error message) r? `@ghost` `@rustbot` modify labels: rollup
2024-12-24Rollup merge of #134638 - compiler-errors:fx-item-bounds, r=lcnrStuart Cook-28/+137
Fix effect predicates from item bounds in old solver r? lcnr
2024-12-22Begin to implement type system layer of unsafe bindersMichael Goulet-3/+32
2024-12-22Rollup merge of #134639 - compiler-errors:negative-ambiguity-causes, r=oli-obkMatthias Krüger-9/+13
Make sure we note ambiguity causes on positive/negative impl conflicts Fixes https://github.com/rust-lang/rust/issues/134632 by explaining why the error must be
2024-12-22Make sure we note ambiguity causes on positive/negative impl conflictsMichael Goulet-9/+13
2024-12-22Fix item bounds in old solverMichael Goulet-28/+137
2024-12-21Auto merge of #134501 - lcnr:member-constraints-yeet, r=oli-obkbors-13/+5
handle member constraints directly in the mir type checker cleaner, faster, easier to change going forward :> fixes #109654 r? `@oli-obk` `@compiler-errors`
2024-12-20remove non-borrowck member constraintslcnr-13/+5
2024-12-18chore: fix some typosacceptacross-1/+1
Signed-off-by: acceptacross <csqcqs@gmail.com>
2024-12-18Auto merge of #134243 - nnethercote:re-export-more-rustc_span, r=jieyouxubors-5/+3
Re-export more `rustc_span::symbol` things from `rustc_span`. `rustc_span::symbol` defines some things that are re-exported from `rustc_span`, such as `Symbol` and `sym`. But it doesn't re-export some closely related things such as `Ident` and `kw`. So you can do `use rustc_span::{Symbol, sym}` but you have to do `use rustc_span::symbol::{Ident, kw}`, which is inconsistent for no good reason. This commit re-exports `Ident`, `kw`, and `MacroRulesNormalizedIdent`, and changes many `rustc_span::symbol::` qualifiers to `rustc_span::`. This is a 300+ net line of code reduction, mostly because many files with two `use rustc_span` items can be reduced to one. r? `@jieyouxu`
2024-12-18Re-export more `rustc_span::symbol` things from `rustc_span`.Nicholas Nethercote-5/+3
`rustc_span::symbol` defines some things that are re-exported from `rustc_span`, such as `Symbol` and `sym`. But it doesn't re-export some closely related things such as `Ident` and `kw`. So you can do `use rustc_span::{Symbol, sym}` but you have to do `use rustc_span::symbol::{Ident, kw}`, which is inconsistent for no good reason. This commit re-exports `Ident`, `kw`, and `MacroRulesNormalizedIdent`, and changes many `rustc_span::symbol::` qualifiers in `compiler/` to `rustc_span::`. This is a 200+ net line of code reduction, mostly because many files with two `use rustc_span` items can be reduced to one.
2024-12-17Rollup merge of #133265 - the8472:extract-if-ranges, r=cuviperMatthias Krüger-1/+1
Add a range argument to vec.extract_if tracking issue: #43244 This adds the range argument requested in https://github.com/rust-lang/rust/issues/43244#issuecomment-2486160659
2024-12-17consistently handle global where-boundslcnr-305/+241
2024-12-16update uses of extract_if in the compilerThe 8472-1/+1
2024-12-15Rollup merge of #134285 - oli-obk:push-vwrqsqlwnuxo, r=UrgauStuart Cook-1/+1
Add some convenience helper methods on `hir::Safety` Makes a lot of call sites simpler and should make any refactorings needed for https://github.com/rust-lang/rust/pull/134090#issuecomment-2541332415 simpler, as fewer sites have to be touched in case we end up storing some information in the variants of `hir::Safety`
2024-12-14Add some convenience helper methods on `hir::Safety`Oli Scherer-1/+1
2024-12-14(Re-)Implement impl_trait_in_bindingsMichael Goulet-0/+6
2024-12-14Split UserTypeAnnotation to have a kindMichael Goulet-4/+4
2024-12-13Auto merge of #134122 - oli-obk:push-zqnyznxtpnll, r=petrochenkovbors-1/+3
Move impl constness into impl trait header This PR is kind of the opposite of the rejected https://github.com/rust-lang/rust/pull/134114 Instead of moving more things into the `constness` query, we want to keep them where their corresponding hir nodes are lowered. So I gave this a spin for impls, which have an obvious place to be (the impl trait header). And surprisingly it's also a perf improvement (likely just slightly better query & cache usage). The issue was that removing anything from the `constness` query makes it just return `NotConst`, which is wrong. So I had to change it to `bug!` out if used wrongly, and only then remove the impl blocks from the `constness` query. I think this change is good in general, because it makes using `constness` more robust (as can be seen by how few sites that had to be changed, so it was almost solely used specifically for the purpose of asking for functions' constness). The main thing where this change was not great was in clippy, which was using the `constness` query as a general DefId -> constness map. I added a `DefKind` filter in front of that. If it becomes a more common pattern we can always move that helper into rustc.
2024-12-12Move impl constness into impl trait headerOli Scherer-1/+3