about summary refs log tree commit diff
path: root/compiler/rustc_trait_selection/src
AgeCommit message (Collapse)AuthorLines
2023-11-26Avoid need for `{D,Subd}iagnosticMessage` imports.Nicholas Nethercote-1/+0
The `fluent_messages!` macro produces uses of `crate::{D,Subd}iagnosticMessage`, which means that every crate using the macro must have this import: ``` use rustc_errors::{DiagnosticMessage, SubdiagnosticMessage}; ``` This commit changes the macro to instead use `rustc_errors::{D,Subd}iagnosticMessage`, which avoids the need for the imports.
2023-11-25Get rid of infer vars in inherent assoc types selection by using probeSantiago Pastorino-1/+12
2023-11-25Rollup merge of #118199 - compiler-errors:qpath, r=lcnrGuillaume Gomez-2/+1
Remove `HirId` from `QPath::LangItem` Remove `HirId` from `QPath::LangItem`, since there was only *one* use-case (`ObligationCauseCode::AwaitableExpr`), which we can instead recover by walking the HIR tree.
2023-11-25Rollup merge of #117871 - klensy:unused-pub, r=cjgillotGuillaume Gomez-1/+1
remove unused pub fns This removes some unused `pub fn`; also fixes few obsoleted fn names or added fixmes with reminders to update them.
2023-11-25is_{some,ok}_andMichael Goulet-6/+14
2023-11-25Remove HirId from QPath::LangItemMichael Goulet-2/+1
2023-11-25Don't ICE when encountering placeholders in implied bounds computationMichael Goulet-2/+4
2023-11-25Rollup merge of #118259 - spastorino:move-eager-resolver-to-infer, ↵León Orell Valerian Liehr-80/+5
r=compiler-errors Move EagerResolution to rustc_infer::infer::resolve `EagerResolver` fits better in `rustc_infer::infer::resolver`. Started to disentagle #118118 that has a lot of unrelated things. r? `@compiler-errors` `@lcnr`
2023-11-25Auto merge of #118261 - spastorino:fix-placeholder-replacer, r=compiler-errorsbors-4/+18
Make PlaceholderReplacer shallow_resolver and recur when infer vars This makes resolve type and const infer vars resolve. Given: ```rust #![feature(inherent_associated_types)] #![allow(incomplete_features)] struct Foo<T>(T); impl<'a> Foo<fn(&'a ())> { type Assoc = &'a (); } fn bar(_: for<'a> fn(Foo<fn(Foo<fn(&'static ())>::Assoc)>::Assoc)) {} fn main() {} ``` We should normalize `for<'a> fn(Foo<fn(Foo<fn(&'static ())>::Assoc)>::Assoc)` to `for<'0> fn(&'1 ())` with `'1 == '0` and `'0 == 'static` constraints. We have to resolve `'1` to `'static` in the infcx associated to `PlaceholderReplacer`. This is part of https://github.com/rust-lang/rust/pull/118118 but unrelated to that PR. r? `@compiler-errors` `@lcnr`
2023-11-24AmbiguityCause should not eagerly format stringsMichael Goulet-67/+54
2023-11-24Make PlaceholderReplacer shallow_resolver when folding const and ty and ↵Santiago Pastorino-4/+18
recur if contain infer vars
2023-11-24Move EagerResolution to rustc_infer::infer::resolveSantiago Pastorino-80/+5
2023-11-24Rollup merge of #118243 - lcnr:commit-if-ok, r=compiler-errorsMichael Goulet-9/+9
EvalCtxt::commit_if_ok don't inherit nested goals we use it to check whether an alias is rigid, so we want to avoid considering an alias rigid simply because the inference constraints from normalizing it caused another nested goal fail r? `@compiler-errors`
2023-11-24Rollup merge of #118210 - lcnr:intercrate-ambiguity-causes-uwu, ↵Michael Goulet-2/+4
r=compiler-errors intercrate ambiguity causes: ignore candidates which don't apply r? `@compiler-errors`
2023-11-24EvalCtxt::commit_if_ok don't inherit nested goalslcnr-9/+9
2023-11-24Auto merge of #118189 - compiler-errors:cache-flags-for-const, r=nnethercotebors-7/+5
Cache flags for `ty::Const` Not sure if this has been attempted yet, but worth a shot. It does make the code simpler in `rustc_type_ir`, since we can assume that consts have a `flags` method that is no-cost. r? `@ghost`
2023-11-23fix intercrate ambiguity causeslcnr-2/+4
2023-11-23reviewklensy-2/+1
2023-11-23few moreklensy-0/+1
2023-11-22Cache flags for ty::ConstMichael Goulet-7/+5
2023-11-22Auto merge of #118120 - compiler-errors:closure-kind, r=lcnrbors-51/+49
Remove `PredicateKind::ClosureKind` We don't need the `ClosureKind` predicate kind -- instead, `Fn`-family trait goals are left as ambiguous, and we only need to make progress on `FnOnce` projection goals for inference purposes. This is similar to how we do confirmation of `Fn`-family trait and projection goals in the new trait solver, which also doesn't use the `ClosureKind` predicate. Some hacky logic is added in the second commit so that we can keep the error messages the same.
2023-11-22Auto merge of #118133 - Urgau:stabilize_trait_upcasting, r=WaffleLapkinbors-51/+0
Stabilize RFC3324 dyn upcasting coercion This PR stabilize the `trait_upcasting` feature, aka https://github.com/rust-lang/rfcs/pull/3324. The FCP was completed here: https://github.com/rust-lang/rust/issues/65991#issuecomment-1817552398. ~~And also remove the `deref_into_dyn_supertrait` lint which is now handled by dyn upcasting coercion.~~ Heavily inspired by https://github.com/rust-lang/rust/pull/101718 Fixes https://github.com/rust-lang/rust/issues/65991
2023-11-22Stabilize RFC3324 dyn upcasting coercionUrgau-51/+0
Aka trait_upcasting feature. And also adjust the `deref_into_dyn_supertrait` lint.
2023-11-22Replace `no_ord_impl` with `orderable`.Nicholas Nethercote-0/+1
Similar to the previous commit, this replaces `newtype_index`'s opt-out `no_ord_impl` attribute with the opt-in `orderable` attribute.
2023-11-21Fix `clippy::needless_borrow` in the compilerNilstrieb-86/+77
`x clippy compiler -Aclippy::all -Wclippy::needless_borrow --fix`. Then I had to remove a few unnecessary parens and muts that were exposed now.
2023-11-21Restore closure-kind error messagesMichael Goulet-1/+43
2023-11-21Remove ClosureKind predicate kindMichael Goulet-50/+6
2023-11-21Rollup merge of #118115 - spastorino:fix-old-fn-names, r=compiler-errorsNilstrieb-1/+1
Fix occurrences of old fn names in comment and tracing
2023-11-20Fix occurrences of old fn names in comment and tracingSantiago Pastorino-1/+1
2023-11-20Rollup merge of #118089 - lcnr:intercrate-ambig-msg, r=compiler-errorsMatthias Krüger-37/+84
intercrate_ambiguity_causes: handle self ty infer + reservation impls r? `@compiler-errors`
2023-11-20Don't require intercrate mode for negative coherenceMichael Goulet-1/+7
2023-11-20Don't drop region constraints that come from plugging infer regions with ↵Michael Goulet-7/+7
placeholders
2023-11-20handle reservation impls, track impl sourcelcnr-26/+68
2023-11-20self ty infer ambiguity: add proof tree candlcnr-11/+16
2023-11-19Rollup merge of #118000 - compiler-errors:placeholder-ty-outlives, r=aliemjayMichael Goulet-2/+11
Make regionck care about placeholders in outlives components Currently, we don't consider a placeholder type `!T` to be a type component when it comes to processing type-outlives obligations. This means that they are essentially treated like unit values with no sub-components, and always outlive any region. This is problematic for `non_lifetime_binders`, and even more problematic for `with_negative_coherence`, since negative coherence uses placeholders as universals. This PR adds `Component::Placeholder` which acts much like `Component::Param`. This currently causes a regression in some non-lifetime-binders tests because `for<T> T: 'static` doesn't imply itself when processing outlives obligations, so code like this will fail: ``` fn foo() where for<T> T: 'static { foo() //~ fails } ``` Since the where clause doesn't imply itself. This requires making the `MatchAgainstHigherRankedOutlives` relation smarter when it comes to binders. r? types
2023-11-19Rollup merge of #117994 - compiler-errors:throw-away-regions-in-coherence, ↵Michael Goulet-9/+8
r=lcnr Ignore but do not assume region obligations from unifying headers in negative coherence Partly addresses a FIXME that was added in #112875. Just as we can throw away the nested trait/projection obligations from unifying two impl headers, we can also just throw away the region obligations too. I removed part of the FIXME that was incorrect, namely: > Given that the only region constraints we get are involving inference regions in the root, it shouldn't matter, but still sus. This is not true when unifying `fn(A)` and `for<'b> fn(&'b B)` which ends up with placeholder region outlives from non-root universes. I'm pretty sure this is okay, though it would be nice if we were to use them as assumptions. See the `explicit` revision of the test I committed, which still fails. Fixes #117986 r? lcnr, feel free to reassign tho.
2023-11-19Ignore but do not assume region obligations from unifying headers in ↵Michael Goulet-9/+8
negative coherence
2023-11-19Make regionck care about placeholders in outlives componentsMichael Goulet-2/+11
2023-11-18Auto merge of #117742 - ↵bors-13/+97
weiznich:turn_overlapping_diagnostic_options_into_warnings, r=compiler-errors Add some additional warnings for duplicated diagnostic items This commit adds warnings if a user supplies several diagnostic options where we can only apply one of them. We explicitly warn about ignored options here. In addition a small test for these warnings is added. r? `@compiler-errors` For now that's the last PR to improve the warnings generated by misused `#[diagnostic::on_unimplemented]` attributes. I'm not sure what needs to be done next to move this closer to stabilization.
2023-11-17Auto merge of #117944 - lcnr:region-refactor-uwu, r=BoxyUwUbors-9/+11
some additional region refactorings the commits are selfcontained ✨ r? `@BoxyUwU`
2023-11-17Auto merge of #112422 - aliemjay:implied-bounds-placeholders, r=lcnrbors-2/+6
ignore implied bounds with placeholders given the following code: ```rust trait Trait { type Ty<'a> where Self: 'a; } impl<T> Trait for T { type Ty<'a> = () where Self: 'a; } struct Foo<T: Trait>(T) where for<'x> T::Ty<'x>: Sized; ``` when computing the implied bounds from `Foo<X>` we incorrectly get the bound `X: !x` from the normalization of ` for<'x> <X as Trait>::Ty::<'x>: Sized`. This is a a known bug! we shouldn't use the constraints that arise from normalization as implied bounds. See #109628. Ignore these bounds for now. This should prevent later ICEs. Fixes #112250 Fixes #107409
2023-11-17Auto merge of #117278 - lcnr:try-normalize-ty, r=compiler-errorsbors-291/+287
new solver normalization improvements cool beans At the core of this PR is a `try_normalize_ty` which stops for rigid aliases by using `commit_if_ok`. Reworks alias-relate to fully normalize both the lhs and rhs and then equate the resulting rigid (or inference) types. This fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/68 by avoiding the exponential blowup. Also supersedes #116369 by only defining opaque types if the hidden type is rigid. I removed the stability check in `EvalCtxt::evaluate_goal` due to https://github.com/rust-lang/trait-system-refactor-initiative/issues/75. While I personally have opinions on how to fix it, that still requires further t-types/`@nikomatsakis` buy-in, so I removed that for now. Once we've decided on our approach there, we can revert this commit. r? `@compiler-errors`
2023-11-17rename bound region instantiationlcnr-9/+11
- `erase_late_bound_regions` -> `instantiate_bound_regions_with_erased` - `replace_late_bound_regions_X` -> `instantiate_bound_regions_X`
2023-11-17Add some additional warnings for duplicated diagnostic itemsGeorg Semmler-13/+97
This commit adds warnings if a user supplies several diagnostic options where we can only apply one of them. We explicitly warn about ignored options here. In addition a small test for these warnings is added.
2023-11-16ignore implied bounds with placeholdersAli MJ Al-Nasrawy-2/+6
2023-11-15Re-format code with new rustfmtMark Rousskov-33/+53
2023-11-15Bump cfg(bootstrap)sMark Rousskov-3/+3
2023-11-15Auto merge of #117878 - gavinleroy:proper-depth-check, r=lcnrbors-2/+8
Fix depth check in ProofTreeVisitor. The hack to cutoff overflows and cycles in the new trait solver was incorrect. We want to inspect everything with depth [0..10]. This fix exposed a previously unseen bug, which caused the compiler to ICE when invoking `trait_ref` on a non-assoc type projection. I simply added the guard in the `AmbiguityCausesVisitor`, and updated the expected output for the `auto-trait-coherence` test which now includes the extra note: ```text | = note: upstream crates may add a new impl of trait `std::marker::Send` for type `OpaqueType` in future versions ``` r? `@lcnr`
2023-11-14finish `RegionKind` renamelcnr-2/+2
- `ReFree` -> `ReLateParam` - `ReEarlyBound` -> `ReEarlyParam`
2023-11-14Add guard checking for associated types before computing intercrate ↵Gavin Gray-1/+7
ambiguity of projections. Bless test with more specific notes on the ambiguity cause.