about summary refs log tree commit diff
path: root/compiler/rustc_trait_selection/src/traits/fulfill.rs
AgeCommit message (Collapse)AuthorLines
2025-07-20Consider param-env for fast pathMichael Goulet-1/+1
2025-07-17Eagerly unify coroutine witness in old solverMichael Goulet-0/+1
2025-07-17Unstall obligations by looking for coroutines in old solverMichael Goulet-7/+32
2025-07-15Implement other logicstiif-0/+3
2025-07-15Add the core logic in old and new solverstiif-1/+10
2025-06-27Auto merge of #142223 - compiler-errors:perf-wf, r=lcnrbors-2/+6
Fast path for WF goals in new solver Hopefully self-explanatory.
2025-06-26Rollup merge of #142927 - compiler-errors:note-find-const, r=BoxyUwUMichael Goulet-1/+1
Add note to `find_const_ty_from_env` Add a note to `find_const_ty_from_env` to explain why it has an `unwrap` which "often" causes ICEs. Also, uplift it into the new trait solver. This avoids needing to go through the interner to call this method which is otherwise an inherent method in the compiler. I can remove this part if desired. r? `@boxyuwu`
2025-06-25Remove some glob imports from the type systemMichael Goulet-2/+4
2025-06-24Apply fast path to old solver tooMichael Goulet-2/+6
2025-06-23Add note to find_const_ty_from_envMichael Goulet-1/+1
2025-05-26RenameMichael Goulet-2/+2
2025-05-26Avoid obligation construction dance with query region constraintsMichael Goulet-2/+2
2025-04-26convert some `GenericArg` to `Term`lcnr-3/+3
2025-04-22Properly drain pending obligations for coroutinesMichael Goulet-1/+1
2025-04-09re-use sized fast pathDavid Wood-1/+5
There's an existing fast path for the `type_op_prove_predicate` predicate, checking for trivially `Sized` types, which can be re-used when evaluating obligations within queries. This should improve performance, particularly in anticipation of new sizedness traits being added which can take advantage of this.
2025-03-31increment depth of nested obligationslcnr-20/+36
2025-02-22Greatly simplify lifetime captures in edition 2024Michael Goulet-4/+3
2025-01-30introduce `ty::Value`Lukas Markeffsky-1/+1
Co-authored-by: FedericoBruzzone <federico.bruzzone.i@gmail.com>
2024-12-02Assert that obligations are empty before deeply normalizingMichael Goulet-0/+4
2024-11-23Auto merge of #133242 - lcnr:questionable-uwu, r=compiler-errors,BoxyUwUbors-4/+2
finish `Reveal` removal After #133212 changed the `TypingMode` to be the only source of truth, this entirely rips out `Reveal`. cc #132279 r? `@compiler-errors`
2024-11-23no more Reveal :(lcnr-4/+2
2024-11-23Remove unnecessary bool from ExpectedFoundMichael Goulet-5/+8
2024-11-12Consolidate type system const evaluation under `traits::evaluate_const`Boxy-22/+30
mew
2024-11-04Remove the trivial constkind importsMichael Goulet-3/+3
2024-11-03Rename the FIXMEs, remove a few that dont matter anymoreMichael Goulet-1/+1
2024-10-29TypingMode :thinking:lcnr-7/+10
2024-10-28Hack out effects support for old solverMichael Goulet-2/+29
2024-10-24Implement const effect predicate in new solverMichael Goulet-1/+9
2024-10-24Remove associated type based effects logicMichael Goulet-1/+0
2024-10-23nightly feature tracking: get rid of the per-feature bool fieldsRalf Jung-1/+1
2024-10-12Swap PredicateObligation to ThinVecGnomedDev-1/+2
2024-10-12Swap Vec<PredicateObligation> to type aliasGnomedDev-21/+33
2024-09-25Compiler: Rename "object safe" to "dyn compatible"León Orell Valerian Liehr-3/+3
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-2/+2
2024-09-02chore: Fix typos in 'compiler' (batch 3)Alexander Cyon-1/+1
2024-08-30Remove `#[macro_use] extern crate tracing` from `rustc_trait_selection`.Nicholas Nethercote-0/+1
2024-07-29Reformat `use` declarations.Nicholas Nethercote-19/+16
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-07-21Move all error reporting into rustc_trait_selectionMichael Goulet-1/+1
2024-07-09Split out overflow handling into its own moduleMichael Goulet-1/+1
2024-07-08Move trait selection error reporting to its own top-level moduleMichael Goulet-1/+1
2024-06-05Fully implement `ConstArgHasType`Boxy-28/+40
2024-06-05Basic removal of `Ty` from places (boring)Boxy-2/+2
2024-06-04Auto merge of #125380 - compiler-errors:wc-obj-safety, r=oli-obkbors-1/+1
Make `WHERE_CLAUSES_OBJECT_SAFETY` a regular object safety violation #### The issue In #50781, we have known about unsound `where` clauses in function arguments: ```rust trait Impossible {} trait Foo { fn impossible(&self) where Self: Impossible; } impl Foo for &() { fn impossible(&self) where Self: Impossible, {} } // `where` clause satisfied for the object, meaning that the function now *looks* callable. impl Impossible for dyn Foo {} fn main() { let x: &dyn Foo = &&(); x.impossible(); } ``` ... which currently segfaults at runtime because we try to call a method in the vtable that doesn't exist. :( #### What did u change This PR removes the `WHERE_CLAUSES_OBJECT_SAFETY` lint and instead makes it a regular object safety violation. I choose to make this into a hard error immediately rather than a `deny` because of the time that has passed since this lint was authored, and the single (1) regression (see below). That means that it's OK to mention `where Self: Trait` where clauses in your trait, but making such a trait into a `dyn Trait` object will report an object safety violation just like `where Self: Sized`, etc. ```rust trait Impossible {} trait Foo { fn impossible(&self) where Self: Impossible; // <~ This definition is valid, just not object-safe. } impl Foo for &() { fn impossible(&self) where Self: Impossible, {} } fn main() { let x: &dyn Foo = &&(); // <~ THIS is where we emit an error. } ``` #### Regressions From a recent crater run, there's only one crate that relies on this behavior: https://github.com/rust-lang/rust/pull/124305#issuecomment-2122381740. The crate looks unmaintained and there seems to be no dependents. #### Further We may later choose to relax this (e.g. when the where clause is implied by the supertraits of the trait or something), but this is not something I propose to do in this FCP. For example, given: ``` trait Tr { fn f(&self) where Self: Blanket; } impl<T: ?Sized> Blanket for T {} ``` Proving that some placeholder `S` implements `S: Blanket` would be sufficient to prove that the same (blanket) impl applies for both `Concerete: Blanket` and `dyn Trait: Blanket`. Repeating here that I don't think we need to implement this behavior right now. ---- r? lcnr
2024-06-03Nits and formattingMichael Goulet-12/+22
2024-06-03check_is_object_safe -> is_object_safeMichael Goulet-1/+1
2024-06-03Add cycle errors to ScrubbedTraitError to remove a couple more calls to ↵Michael Goulet-4/+3
new_with_diagnostics
2024-06-03Opt-in diagnostics reporting to avoid doing extra work in the new solverMichael Goulet-1/+15
2024-06-03Make TraitEngines generic over errorMichael Goulet-23/+28
2024-05-30Auto merge of #125671 - BoxyUwU:remove_const_ty_eq, r=compiler-errorsbors-10/+31
Do not equate `Const`'s ty in `super_combine_const` Fixes #114456 In #125451 we started relating the `Const`'s tys outside of a probe so it was no longer simply an assertion to catch bugs. This was done so that when we _do_ provide a wrongly typed const argument to an item if we wind up relating it with some other instantiation we'll have a `TypeError` we can bubble up and taint the resulting mir allowing const eval to skip evaluation. In this PR I instead change `ConstArgHasType` to correctly handle checking the types of const inference variables. Previously if we had something like `impl<const N: u32> Trait for [(); N]`, when using the impl we would instantiate it with infer vars and then check that `?x: u32` is of type `u32` and succeed. Then later we would infer `?x` to some `Const` of type `usize`. We now stall on `?x` in `ConstArgHasType` until it has a concrete value that we can determine the type of. This allows us to fail using the erroneous implementation of `Trait` which allows us to taint the mir. Long term we intend to remove the `ty` field on `Const` so we would have no way of accessing the `ty` of a const inference variable anyway and would have to do this. I did not fully update `ConstArgHasType` to avoid using the `ty` field as it's not entirely possible right now- we would need to lookup `ConstArgHasType` candidates in the env. --- As for _why_ I think we should do this, relating the types of const's is not necessary for soundness of the type system. Originally this check started off as a plain `==` in `super_relate_consts` and gradually has been growing in complexity as we support more complicated types. It was never actually required to ensure that const arguments are correctly typed for their parameters however. The way we currently check that a const argument has the correct type is a little convoluted and confusing (and will hopefully be less weird as time goes on). Every const argument has an anon const with its return type set to type of the const parameter it is an argument to. When type checking the anon const regular type checking rules require that the expression is the same type as the return type. This effectively ensure that no matter what every const argument _always_ has the correct type. An extra bit of complexity is that during `hir_ty_lowering` we do not represent everything as a `ConstKind::Unevaluated` corresponding to the anon const. For generic parameters i.e. `[(); N]` we simply represent them as `ConstKind::Param` as we do not want `ConstKind::Unevaluated` with generic substs on stable under min const generics. The anon const still gets type checked resulting in errors about type mismatches. Eventually we intend to not create anon consts for all const arguments (for example for `ConstKind::Param`) and instead check that the argument type is correct via `ConstArgHasType` obligations (these effectively also act as a check that the anon consts have the correctly set return type). What this all means is that the the only time we should ever have mismatched types when relating two `Const`s is if we have messed up our logic for ensuring that const arguments are of the correct type. Having this not be an assert is: - Confusing as it may incorrectly lead people to believe this is an important check that is actually required - Opens the possibility for bugs or behaviour reliant on this (unnecessary) check existing --- This PR makes two tests go from pass->ICE (`generic_const_exprs/ice-125520-layout-mismatch-mulwithoverflow.rs` and `tests/crashes/121858.rs`). This is caused by the fact that we evaluate anon consts even if their where clauses do not hold and is a pre-existing issue and only affects `generic_const_exprs`. I am comfortable exposing the brokenness of `generic_const_exprs` more with this PR This PR makes a test go from ICE->pass (`const-generics/issues/issue-105821.rs`). I have no idea why this PR affects that but I believe that ICE is an unrelated issue to do with the fact that under `generic_const_exprs`/`adt_const_params` we do not handle lifetimes in const parameter types correctly. This PR is likely just masking this bug. Note: this PR doesn't re-introduce the assertion that the two consts' tys are equal. I'm not really sure how I feel about this but tbh it has caused more ICEs than its found lately so :woman_shrugging: r? `@oli-obk` `@compiler-errors`
2024-05-29Partially implement `ConstArgHasType`Boxy-10/+31