about summary refs log tree commit diff
path: root/compiler/rustc_trait_selection/src/traits
AgeCommit message (Collapse)AuthorLines
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
2024-11-28uplift fold_regions to rustc_type_irlcnr-1/+2
2024-11-27Auto merge of #133393 - compiler-errors:dyn-tweaks, r=lcnr,spastorinobors-29/+7
Some minor dyn-related tweaks Each commit should be self-explanatory, but I'm happy to explain what's going on if not. These are tweaks I pulled out of #133388, but they can be reviewed sooner than that. r? types
2024-11-26Rollup merge of #133471 - lcnr:uwu-gamer, r=BoxyUwUMichael Goulet-18/+25
gce: fix typing_mode mismatch Fixes #133271 r? `@BoxyUwU`
2024-11-25fix gce typing_mode mismatchlcnr-18/+25
2024-11-25Simplify object_region_boundsMichael Goulet-29/+7
2024-11-25Refactor `where` predicates, and reserve for attributes supportFrank King-2/+2
2024-11-23Auto merge of #133242 - lcnr:questionable-uwu, r=compiler-errors,BoxyUwUbors-68/+75
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-23global old solver cache: use `TypingEnv`lcnr-20/+41
2024-11-23remove remaining references to `Reveal`lcnr-6/+6
2024-11-23no more Reveal :(lcnr-42/+28
2024-11-23Rollup merge of #133366 - compiler-errors:expected-found, r=dtolnay许杰友 Jieyou Xu (Joe)-7/+10
Remove unnecessary bool from `ExpectedFound::new` It's true almost everywhere, and the one place it's not can be replaced w/ an if statement.
2024-11-23Remove unnecessary bool from ExpectedFoundMichael Goulet-7/+10
2024-11-22Rollup merge of #132090 - compiler-errors:baily, r=lcnrMichael Goulet-32/+0
Stop being so bail-y in candidate assembly A conceptual follow-up to #132084. We gotta stop bailing so much when there are errors; it's both unnecessary, leads to weird knock-on errors, and it's messing up the vibes lol
2024-11-22Rollup merge of #133323 - compiler-errors:bail-if-self-var, r=lcnr许杰友 Jieyou Xu (Joe)-0/+5
Bail in effects in old solver if self ty is ty var Otherwise when we try to check something like `?t: ~const Trait` we'll immediately stick it to the first param-env candidate, lol. r? lcnr
2024-11-22Bail in effects in old solver if self ty is ty varMichael Goulet-0/+5
2024-11-22Simplify fulfill_implicationMichael Goulet-124/+102
2024-11-21Stop being so bail-y in candidate assemblyMichael Goulet-32/+0
2024-11-20Rip out built-in PointerLike implMichael Goulet-31/+0
2024-11-19additional `TypingEnv` cleanupslcnr-6/+5
2024-11-19rustdoc: yeet `TypingEnv::from_param_env`lcnr-9/+4
2024-11-18use `TypingEnv` when no `infcx` is availablelcnr-21/+35
the behavior of the type system not only depends on the current assumptions, but also the currentnphase of the compiler. This is mostly necessary as we need to decide whether and how to reveal opaque types. We track this via the `TypingMode`.
2024-11-12Handle infer vars in anon consts on stableBoxy-9/+21
2024-11-12Consolidate type system const evaluation under `traits::evaluate_const`Boxy-74/+280
mew
2024-11-06Auto merge of #132625 - compiler-errors:cache-only-if-opaque, r=lcnrbors-6/+18
Only disable cache if predicate has opaques within it This is an alternative to https://github.com/rust-lang/rust/pull/132075. This refines the check implemented in https://github.com/rust-lang/rust/pull/126024 to only disable the global cache if the predicate being considered has opaques in it. This is still theoretically unsound, since goals can indirectly rely on opaques in the defining scope, but we're much less likely to hit it. It doesn't totally fix https://github.com/rust-lang/rust/issues/132064: for example, `lemmy` goes from 1:29 (on rust 1.81) to 9:53 (on nightly) to 4:07 (after this PR). But I think it's at least *more* sound than a total revert :/ r? lcnr
2024-11-05Only disable cache if predicate has opaques within itMichael Goulet-6/+18
2024-11-05Auto merge of #132580 - compiler-errors:globs, r=Noratriebbors-13/+15
Remove unnecessary pub enum glob-imports from `rustc_middle::ty` We used to have an idiom in the compiler where we'd prefix or suffix all the variants of an enum, for example `BoundRegionKind`, with something like `Br`, and then *glob-import* that enum variant directly. `@noratrieb` brought this up, and I think that it's easier to read when we just use the normal style `EnumName::Variant`. This PR is a bit large, but it's just naming. The only somewhat opinionated change that this PR does is rename `BorrowKind::Imm` to `BorrowKind::Immutable` and same for the other variants. I think these enums are used sparingly enough that the extra length is fine. r? `@noratrieb` or reassign
2024-11-04Rollup merge of #132486 - compiler-errors:no-binder, r=lcnrMatthias Krüger-9/+3
No need to instantiate binder in `confirm_async_closure_candidate` Removes a FIXME that is redundant. No longer needed since #122267.
2024-11-04ty::BrK -> ty::BoundRegionKind::KMichael Goulet-7/+9