summary refs log tree commit diff
path: root/compiler/rustc_trait_selection/src/traits
AgeCommit message (Collapse)AuthorLines
2025-01-23add cache to `AmbiguityCausesVisitor`lcnr-2/+12
(cherry picked from commit 94bf8f04f402a2410ab85a6e6b9e542e3942b2a2)
2025-01-23avoid running the overlap check twicelcnr-22/+33
(cherry picked from commit ebbcfd4e7721aaf3211f0e8d3d6e304400c80f78)
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
2024-12-12Rollup merge of #133122 - compiler-errors:afidt, r=oli-obkMatthias Krüger-12/+184
Add unpolished, experimental support for AFIDT (async fn in dyn trait) This allows us to begin messing around `async fn` in `dyn Trait`. Calling an async fn from a trait object always returns a `dyn* Future<Output = ...>`. To make it work, Implementations are currently required to return something that can be coerced to a `dyn* Future` (see the example in `tests/ui/async-await/dyn/works.rs`). If it's not the right size, then it'll raise an error at the coercion site (see the example in `tests/ui/async-await/dyn/wrong-size.rs`). Currently the only practical way of doing this is wrapping the body in `Box::pin(async move { .. })`. This PR does not implement a helper type like a "`Boxing`"[^boxing] adapter, and I'll probably follow-up with another PR to improve the error message for the `PointerLike` trait (something that explains in just normal prose what is happening here, rather than a trait error). [^boxing]: https://rust-lang.github.io/async-fundamentals-initiative/explainer/user_guide_future.html#the-boxing-adapter This PR also does not implement new trait solver support for AFIDT; I'll need to think how best to integrate it into candidate assembly, and that's a bit of a matter of taste, but I don't think it will be difficult to do. This could also be generalized: * To work on functions that are `-> impl Future` (soon). * To work on functions that are `-> impl Iterator` and other "dyn rpitit safe" traits. We still need to nail down exactly what is needed for this to be okay (not soon). Tracking: * https://github.com/rust-lang/rust/issues/133119
2024-12-11Rename projection_def_id to item_def_idMichael Goulet-3/+3
2024-12-10Don't check RPITITs that are Self:Sized for PointerLikeMichael Goulet-0/+5
2024-12-10Implement projection and shim for AFIDTMichael Goulet-1/+131
2024-12-10Add feature gate, not working yetMichael Goulet-11/+48
2024-12-07Make `Copy` unsafe to implement for ADTs with `unsafe` fieldsJack Wrenn-2/+10
As a rule, the application of `unsafe` to a declaration requires that use-sites of that declaration also require `unsafe`. For example, a field declared `unsafe` may only be read in the lexical context of an `unsafe` block. For nearly all safe traits, the safety obligations of fields are explicitly discharged when they are mentioned in method definitions. For example, idiomatically implementing `Clone` (a safe trait) for a type with unsafe fields will require `unsafe` to clone those fields. Prior to this commit, `Copy` violated this rule. The trait is marked safe, and although it has no explicit methods, its implementation permits reads of `Self`. This commit resolves this by making `Copy` conditionally safe to implement. It remains safe to implement for ADTs without unsafe fields, but unsafe to implement for ADTs with unsafe fields. Tracking: #132922
2024-12-05do not implement unsafe auto traits for types with unsafe fieldsJack Wrenn-0/+9
If a type has unsafe fields, its safety invariants are not simply the conjunction of its field types' safety invariants. Consequently, it's invalid to reason about the safety properties of these types in a purely structural manner — i.e., the manner in which `auto` traits are implemented. Makes progress towards #132922.
2024-12-05Auto merge of #133893 - fmease:rollup-11pi6fg, r=fmeasebors-52/+2
Rollup of 10 pull requests Successful merges: - #118833 (Add lint against function pointer comparisons) - #122161 (Fix suggestion when shorthand `self` has erroneous type) - #133233 (Add context to "const in pattern" errors) - #133761 (Update books) - #133843 (Do not emit empty suggestion) - #133863 (Rename `core_pattern_type` and `core_pattern_types` lib feature gates to `pattern_type_macro`) - #133872 (No need to create placeholders for GAT args in confirm_object_candidate) - #133874 (`fn_sig_for_fn_abi` should return a `ty::FnSig`, no need for a binder) - #133890 (Add a new test ui/incoherent-inherent-impls/no-other-unrelated-errors to check E0116 does not cause unrelated errors) - #133892 (Revert #133817) r? `@ghost` `@rustbot` modify labels: rollup
2024-12-04No need to create placeholders for GAT args in confirm_object_candidateMichael Goulet-52/+2
2024-12-04Make sure to record deps from cached task in new solver on first runMichael Goulet-4/+1
2024-12-04Auto merge of #133818 - matthiaskrgr:rollup-iav1wq7, r=matthiaskrgrbors-30/+3
Rollup of 7 pull requests Successful merges: - #132937 (a release operation synchronizes with an acquire operation) - #133681 (improve TagEncoding::Niche docs, sanity check, and UB checks) - #133726 (Add `core::arch::breakpoint` and test) - #133768 (Remove `generic_associated_types_extended` feature gate) - #133811 ([AIX] change AIX default codemodel=large) - #133812 (Update wasm-component-ld to 0.5.11) - #133813 (compiletest: explain that UI tests are expected not to compile by default) r? `@ghost` `@rustbot` modify labels: rollup
2024-12-03Remove generic_associated_types_extended feature gateMichael Goulet-30/+3
2024-12-03Rollup merge of #133545 - clubby789:symbol-intern-lit, r=jieyouxuMatthias Krüger-2/+1
Lint against Symbol::intern on a string literal Disabled in tests where this doesn't make much sense
2024-12-03Rollup merge of #133517 - compiler-errors:deep-norm, r=lcnrMatthias Krüger-4/+21
Deeply normalize when computing implied outlives bounds r? lcnr Unfortunately resolving regions is still slightly scuffed (though in an unrelated way). Specifically, we should be normalizing our param-env outlives when constructing the `OutlivesEnv`; otherwise, these assumptions (https://github.com/rust-lang/rust/blob/dd2837ec5de4301a692e05a7c4475e980af57a57/compiler/rustc_infer/src/infer/outlives/env.rs#L78) are not constructed correctly. Let me know if you want us to track that somewhere.
2024-12-02Assert that obligations are empty before deeply normalizingMichael Goulet-0/+16
2024-12-02Deeply normalize when computing implied outlives boundsMichael Goulet-4/+5
2024-12-02Fix const specializationMichael Goulet-5/+17
2024-12-02Reimplement specialization for const traitsMichael Goulet-18/+112
2024-12-02Auto merge of #133626 - lcnr:fix-diesel, r=BoxyUwUbors-6/+11
check local cache even if global is usable we store overflow errors locally, even if we can otherwise use the global cache for this goal. should fix #133616, didn't test it locally yet as diesel tends to hit an unrelated debug assertion in rustdoc. r? types
2024-11-29check local cache even if global is usablelcnr-6/+11
we store overflow errors locally, even if we can otherwise use the global cache for this goal.
2024-11-28Replace `Symbol::intern` calls with preinterned symbolsclubby789-2/+1
2024-11-28support revealing defined opaque post borrowcklcnr-11/+20