about summary refs log tree commit diff
path: root/compiler/rustc_trait_selection/src
AgeCommit message (Collapse)AuthorLines
2025-03-09Rollup merge of #136968 - oli-obk:bye-bye, r=compiler-errorsMatthias Krüger-25/+5
Turn order dependent trait objects future incompat warning into a hard error fixes #56484 r? ``@ghost`` will FCP when we have a crater result
2025-03-09Do not register `Self: AutoTrait` when confirming auto traitMichael Goulet-15/+1
2025-03-08Remove `#![warn(unreachable_pub)]` from all `compiler/` crates.Nicholas Nethercote-1/+0
(Except for `rustc_codegen_cranelift`.) It's no longer necessary now that `unreachable_pub` is in the workspace lints.
2025-03-07compiler: Use size_of from the prelude instead of importedThalia Archibald-1/+1
Use `std::mem::{size_of, size_of_val, align_of, align_of_val}` from the prelude instead of importing or qualifying them. These functions were added to all preludes in Rust 1.80.
2025-03-07Rollup merge of #134797 - spastorino:ergonomic-ref-counting-1, r=nikomatsakisMatthias Krüger-0/+10
Ergonomic ref counting This is an experimental first version of ergonomic ref counting. This first version implements most of the RFC but doesn't implement any of the optimizations. This was left for following iterations. RFC: https://github.com/rust-lang/rfcs/pull/3680 Tracking issue: https://github.com/rust-lang/rust/issues/132290 Project goal: https://github.com/rust-lang/rust-project-goals/issues/107 r? ```@nikomatsakis```
2025-03-06Add UseCloned trait related codeSantiago Pastorino-0/+10
2025-03-06Rollup merge of #137910 - compiler-errors:async-fn-goal-error, r=oli-obkMichael Goulet-54/+70
Improve error message for `AsyncFn` trait failure for RPIT Use a `WellFormedDerived` obligation cause to make sure we can turn an `AsyncFnKindHelper` trait goal into its parent `AsyncFn*` goal, then fix the logic for reporting `AsyncFn*` kind mismatches. Best reviewed without whitespace. Fixes #137905 r? oli-obk
2025-03-06Rollup merge of #137764 - compiler-errors:always-applicable-negative-impl, ↵Michael Goulet-1/+1
r=lcnr Ensure that negative auto impls are always applicable r? lcnr (or reassign if you dont want to review) https://github.com/rust-lang/rust/issues/68318#issuecomment-2689265030
2025-03-06Rollup merge of #137303 - compiler-errors:maybe-forgor, r=cjgillotMichael Goulet-5/+3
Remove `MaybeForgetReturn` suggestion #115196 implemented a suggestion to add a missing `return` when there is an ambiguity error, when that ambiguity error could be constrained by the return type of the function. I initially reviewed it and thought it could be useful; however, looking back at that code now, I feel like it's a bit too much of a hack to be worth keeping around in typeck, especially given how rare it's expected to fire in practice. This is especially true because it depends on `StashKey::MaybeForgetReturn`, which is only stashed when we have *Sized* obligation ambiguity errors. Let's remove it for now. I'd like to note that it's basically impossible to get this suggestion to apply in its current state except for what I'd consider somewhat artificial examples, involving no generic trait bounds. For example, it's not triggered for: ```rust struct W<T>(T); fn bar<T: Default>() -> W<T> { todo!() } fn foo() -> W<i32> { if true { bar(); } W(0) } ``` Nor is it triggered for: ``` fn foo() -> i32 { if true { Default::default(); } 0 } ``` It's basically only triggered iff there's only one ambiguity error on the type, which is `Sized`. Generally, suggesting something that affects control flow is a pretty dramatic suggestion; therefore, both the accuracy and precision of this diagnostic should be pretty high. One other, somewhat unrelated observation is that this might be using stashed diagnostics incorrectly (or at least unnecessarily). Stashed diagnostics are used when error detection is fragmented over several major stages of the compiler, like a parse or resolver error which later can be recovered in typeck. However, this one is a bit different since it is fully handled within typeck -- perhaps that suggests that if this were to be reimplemented, it wouldn't need to be so complicated of an implementation.
2025-03-06Remove the `Option` part of range ends in the HIROli Scherer-1/+1
2025-03-06Avoid having to handle an `Option` in the type systemOli Scherer-6/+2
2025-03-05Rollup merge of #137728 - Darksonn:no-tuple-unsize, r=oli-obk许杰友 Jieyou Xu (Joe)-40/+2
Remove unsizing coercions for tuples See https://github.com/rust-lang/rust/issues/42877#issuecomment-2686010847 and below comments for justification. Tracking issue: #42877 Fixes: #135217
2025-03-05Rollup merge of #137633 - ↵许杰友 Jieyou Xu (Joe)-168/+62
compiler-errors:no-implied-bounds-hack-unless-bevy, r=lcnr Only use implied bounds hack if bevy, and use deeply normalize in implied bounds hack Consolidates the implied bounds computation mode into a single function, which deeply normalizes, and if it's in **compat** mode (for bevy), it extracts outlives bounds from the infcx. Previously, we were using the implied bounds compat mode in two cases: 1. During WF, if it detects `ParamSet` 2. EVERYWHERE ELSE (lol) -- e.g. borrowck, predicate entailment, etc. While I think this is fine, and the net effect was just that we emitted fewer diagnostics, it makes me uncomfortable that all crates were using the supposed "compat" code. Fixes #137767
2025-03-05Rollup merge of #137298 - compiler-errors:mir-wf, r=lcnr许杰友 Jieyou Xu (Joe)-2/+2
Check signature WF when lowering MIR body Alternative to #137233. https://github.com/rust-lang/rust/pull/137233#issuecomment-2667879143 Fixes https://github.com/rust-lang/rust/issues/137186 We do this check in `mir_drops_elaborated_and_const_checked` and not during `mir_promoted` because that may result in borrowck cycles if WF requires looking into an opaque hidden type. This causes some TAIT tests to fail unnecessarily. r? lcnr try-job: test-various
2025-03-05change definitely non-productive cycles to errorlcnr-1/+1
2025-03-04Auto merge of #135186 - camelid:const-path-multi, r=BoxyUwUbors-2/+10
mgca: Lower all const paths as `ConstArgKind::Path` When `#![feature(min_generic_const_args)]` is enabled, we now lower all const paths in generic arg position to `hir::ConstArgKind::Path`. We then lower assoc const paths to `ty::ConstKind::Unevaluated` since we can no longer use the anon const expression lowering machinery. In the process of implementing this, I factored out `hir_ty_lowering` code that is now shared between lowering assoc types and assoc consts. This PR also introduces a `#[type_const]` attribute for trait assoc consts that are allowed as const args. However, we still need to implement code to check that assoc const definitions satisfy `#[type_const]` if present (basically is it a const path or a monomorphic anon const). r? `@BoxyUwU`
2025-03-04Only use implied bounds hack if bevy, and use deeply normalize in implied ↵Michael Goulet-168/+62
bounds hack
2025-03-04Ensure that negative auto impls are always applicableMichael Goulet-1/+1
2025-03-04mgca: Lower all const paths as `ConstArgKind::Path`Noah Lev-2/+10
When `#![feature(min_generic_const_args)]` is enabled, we now lower all const paths in generic arg position to `hir::ConstArgKind::Path`. We then lower assoc const paths to `ty::ConstKind::Unevaluated` since we can no longer use the anon const expression lowering machinery. In the process of implementing this, I factored out `hir_ty_lowering` code that is now shared between lowering assoc types and assoc consts. This PR also introduces a `#[type_const]` attribute for trait assoc consts that are allowed as const args. However, we still need to implement code to check that assoc const definitions satisfy `#[type_const]` if present (basically is it a const path or a monomorphic anon const).
2025-03-03Tweak error code for sized checks of const/staticMichael Goulet-2/+2
2025-03-03Improve error message for AsyncFn trait failure for RPITMichael Goulet-54/+70
2025-03-03Fix pretty printing of unsafe bindersMichael Goulet-2/+4
2025-03-01Rollup merge of #137822 - BoxyUwU:query_normalizer_docs, r=compiler-errorsMatthias Krüger-12/+9
Update query normalizer docs to not position it as the greatest pioneer in the space of normalization I don't think its true that we intend to replace all normalization with the query normalizer- its more likely that once the new solver is stable we can replace the query normalizer with normal normalization calls as the new solver caches much more than the old solver r? ``@compiler-errors``
2025-03-01Rollup merge of #137800 - BoxyUwU:param_env_docs, r=compiler-errorsMatthias Krüger-1/+1
Remove `ParamEnv::without_caller_bounds` This doesn't really do anything that `ParamEnv::empty` doesn't do nowadays as `ParamEnv` *only* stores caller bounds since other information has been moved out into `TypingMode` r? ```@compiler-errors``` ```@lcnr```
2025-03-01Rollup merge of #137776 - nnethercote:rustc_transmute-cleanups, r=jswrennMatthias Krüger-25/+12
Some `rustc_transmute` cleanups A number of small things that can be removed. r? ``@jswrenn``
2025-03-01Rollup merge of #137617 - BoxyUwU:generic_const_parameter_types, r=lcnrMatthias Krüger-3/+0
Introduce `feature(generic_const_parameter_types)` Allows to define const generic parameters whose type depends on other generic parameters, e.g. `Foo<const N: usize, const ARR: [u8; N]>;` Wasn't going to implement for this for a while until we could implement it with `bad_inference.rs` resolved but apparently the project simd folks would like to be able to use this for some intrinsics and the inference issue isn't really a huge problem there aiui. (cc ``@workingjubilee`` )
2025-03-01Rollup merge of #137689 - compiler-errors:coroutine, r=lcnrMatthias Krüger-58/+21
Use `Binder<Vec<Ty>>` instead of `Vec<Binder<Ty>>` in both solvers for sized/auto traits/etc. It's more conceptually justified IMO, especially when binders get implications. r? lcnr
2025-03-01Rollup merge of #137171 - makai410:swapping-e0277, r=compiler-errorsMatthias Krüger-0/+53
Suggest swapping equality on E0277 Closes: #132695 .
2025-02-28Introduce `feature(generic_const_parameter_types)`Boxy-3/+0
2025-02-28Update query normalizer docsBoxy-12/+9
2025-02-28reviewlcnr-3/+9
2025-02-28normalizing where-clauses is also coinductive, add testslcnr-1/+4
2025-02-28Remove `allow(unused_variables)` for `rustc_transmute`.Nicholas Nethercote-24/+11
This was hiding some genuine sins, including unused arguments in numerous functions/methods (incl. trait methods), and some unnecessary computation.
2025-02-28Remove `rustc_transmute`'s dependence on `rustc_infer`.Nicholas Nethercote-3/+3
`TransmuteTypeEnv` only needs a `TyCtxt`, not an `InferCtxt`.
2025-02-27Delete tuple unsizingAlice Ryhl-40/+2
2025-02-26Remove `ParamEnv::without_caller_bounds`Boxy-1/+1
2025-02-26Rollup merge of #137635 - compiler-errors:constrain-unstable, r=SparrowLiiLeón Orell Valerian Liehr-1/+4
Don't suggest constraining unstable associated types Fixes #137624 This could be made a bit more specific, considering the local crate's stability or nightly status or something, but I think in general we should not be suggesting associated type bounds on unstable associated items.
2025-02-26Rollup merge of #137201 - estebank:structured-errors-long-ty, r=oli-obkLeón Orell Valerian Liehr-8/+8
Teach structured errors to display short `Ty<'_>` Make it so that in every structured error annotated with `#[derive(Diagnostic)]` that has a field of type `Ty<'_>`, the printing of that value into a `String` will look at the thread-local storage `TyCtxt` in order to shorten to a length appropriate with the terminal width. When this happen, the resulting error will have a note with the file where the full type name was written to. ``` error[E0618]: expected function, found `((..., ..., ..., ...), ..., ..., ...)`` --> long.rs:7:5 | 6 | fn foo(x: D) { //~ `x` has type `(... | - `x` has type `((..., ..., ..., ...), ..., ..., ...)` 7 | x(); //~ ERROR expected function, found `(... | ^-- | | | call expression requires function | = note: the full name for the type has been written to 'long.long-type-14182675702747116984.txt' = note: consider using `--verbose` to print the full type name to the console ``` Follow up to and response to the comments on #136898. r? ``@oli-obk``
2025-02-26Use bound_coroutine_witnesses in old solverMichael Goulet-58/+21
2025-02-25Don't suggest constraining unstable associated typesMichael Goulet-1/+4
2025-02-25Teach structured errors to display short `Ty`Esteban Küber-8/+8
Make it so that every structured error annotated with `#[derive(Diagnostic)]` that has a field of type `Ty<'_>`, the printing of that value into a `String` will look at the thread-local storage `TyCtxt` in order to shorten to a length appropriate with the terminal width. When this happen, the resulting error will have a note with the file where the full type name was written to. ``` error[E0618]: expected function, found `((..., ..., ..., ...), ..., ..., ...)`` --> long.rs:7:5 | 6 | fn foo(x: D) { //~ `x` has type `(... | - `x` has type `((..., ..., ..., ...), ..., ..., ...)` 7 | x(); //~ ERROR expected function, found `(... | ^-- | | | call expression requires function | = note: the full name for the type has been written to 'long.long-type-14182675702747116984.txt' = note: consider using `--verbose` to print the full type name to the console ```
2025-02-25Auto merge of #137571 - tgross35:rollup-i1tcnv1, r=tgross35bors-1/+0
Rollup of 8 pull requests Successful merges: - #134655 (Stabilize `hash_extract_if`) - #135933 (Explain how Vec::with_capacity is faithful) - #136668 (Stabilize `core::str::from_utf8_mut` as `const`) - #136775 (Update `String::from_raw_parts` safety requirements) - #137109 (stabilize extract_if) - #137349 (Implement `read_buf` for zkVM stdin) - #137493 (configure.py: don't instruct user to run nonexistent program) - #137516 (remove some unnecessary rustc_const_unstable) r? `@ghost` `@rustbot` modify labels: rollup
2025-02-25Auto merge of #137573 - compiler-errors:rollup-noq9yhp, r=compiler-errorsbors-25/+12
Rollup of 11 pull requests Successful merges: - #136522 (Remove `feature(dyn_compatible_for_dispatch)` from the compiler) - #137289 (Consolidate and improve error messaging for `CoerceUnsized` and `DispatchFromDyn`) - #137321 (Correct doc about `temp_dir()` behavior on Android) - #137417 (rustc_target: Add more RISC-V atomic-related features) - #137489 (remove `#[rustc_intrinsic_must_be_overridde]`) - #137530 (DWARF mixed versions with LTO on MIPS) - #137543 (std: Fix another new symlink test on Windows) - #137548 (Pass correct `TypingEnv` to `InlineAsmCtxt`) - #137550 (Don't immediately panic if dropck fails without returning errors) - #137552 (Update books) - #137556 (rename simd_shuffle_generic → simd_shuffle_const_generic) r? `@ghost` `@rustbot` modify labels: rollup
2025-02-24Remove dyn_compatible_for_dispatchMichael Goulet-25/+12
2025-02-24Introduce new parsing infrastructure and types for parsed attributesJana Dönszelmann-3/+3
fixup docs in parser
2025-02-24Change span field accesses to method callsJana Dönszelmann-6/+14
2025-02-24trait_sel: resolve vars in host effectsDavid Wood-0/+2
In the standard library, the `Extend` impl for `Iterator` (specialised with `TrustedLen`) has a parameter which is constrained by a projection predicate. This projection predicate provides a value for an inference variable but host effect evaluation wasn't resolving variables first. Adding the extra resolve can the number of errors in some tests when they gain host effect predicates, but this is not unexpected as calls to `resolve_vars_if_possible` can cause more error tainting to happen. Co-authored-by: Boxy <rust@boxyuwu.dev>
2025-02-23stabilize extract_ifbendn-1/+0
2025-02-22Greatly simplify lifetime captures in edition 2024Michael Goulet-14/+8
2025-02-22Rollup merge of #137333 - compiler-errors:edition-2024-fresh, r=NadrierilMatthias Krüger-14/+13
Use `edition = "2024"` in the compiler (redux) Most of this is binding mode changes, which I fixed by running `x.py fix`. Also adds some miscellaneous `unsafe` blocks for new unsafe standard library functions (the setenv ones), and a missing `unsafe extern` block in some enzyme codegen code, and fixes some precise capturing lifetime changes (but only when they led to errors). cc ``@ehuss`` ``@traviscross``