about summary refs log tree commit diff
path: root/compiler/rustc_trait_selection/src/traits
AgeCommit message (Collapse)AuthorLines
2024-03-18Rollup merge of #122158 - estebank:feature-sugg, r=WaffleLapkinMatthias Krüger-3/+5
Provide structured suggestion for `#![feature(foo)]` ``` error: `S2<'_>` is forbidden as the type of a const generic parameter --> $DIR/lifetime-in-const-param.rs:5:23 | LL | struct S<'a, const N: S2>(&'a ()); | ^^ | = note: the only supported types are integers, `bool` and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] | ``` Fix #55941.
2024-03-18Provide structured suggestion for `#![feature(foo)]`Esteban Küber-3/+5
``` error: `S2<'_>` is forbidden as the type of a const generic parameter --> $DIR/lifetime-in-const-param.rs:5:23 | LL | struct S<'a, const N: S2>(&'a ()); | ^^ | = note: the only supported types are integers, `bool` and `char` help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types | LL + #![feature(adt_const_params)] | ``` Fix #55941.
2024-03-18Avoid various uses of `Option<Span>` in favor of using `DUMMY_SP` in the few ↵Oli Scherer-5/+5
cases that used `None`
2024-03-15Auto merge of #122571 - matthiaskrgr:rollup-36wwovk, r=matthiaskrgrbors-8/+8
Rollup of 6 pull requests Successful merges: - #122254 (Detect calls to .clone() on T: !Clone types on borrowck errors) - #122495 (Visually mark 👻hidden👻 items with document-hidden-items) - #122543 (Add `#![rustc_never_type_mode = "..."]` crate-level attribute to allow experimenting) - #122560 (Safe Transmute: Use 'not yet supported', not 'unspecified' in errors) - #122562 (Mention labelled blocks in `break` docs) - #122563 (CI: cache PR CI Docker builds) r? `@ghost` `@rustbot` modify labels: rollup
2024-03-15Rollup merge of #122560 - jswrenn:not-yet-supported, r=compiler-errorsMatthias Krüger-8/+8
Safe Transmute: Use 'not yet supported', not 'unspecified' in errors We can (and will) support analyzing the transmutability of types whose layouts aren't completely specified by its repr. This change ensures that the error messages remain sensible after this support lands. r? ``@compiler-errors``
2024-03-15Auto merge of #122341 - compiler-errors:alias-wfness, r=lcnrbors-20/+8
Consolidate WF for aliases Make RPITs/TAITs/weak (type) aliases/projections all enforce: 1. their nominal predicates 2. their args are WF This possibly does extra work, but is also nice for consistency sake. r? lcnr
2024-03-15Safe Transmute: lowercase diagnosticsJack Wrenn-4/+4
2024-03-15Safe Transmute: Use 'not yet supported', not 'unspecified' in errorsJack Wrenn-4/+4
We can (and will) support analyzing the transmutability of types whose layouts aren't completely specified by its repr. This change ensures that the error messages remain sensible after this support lands.
2024-03-15Rollup merge of #122513 - petrochenkov:somehir4, r=fmeaseGuillaume Gomez-13/+12
hir: Remove `opt_local_def_id_to_hir_id` and `opt_hir_node_by_def_id` Also replace a few `hir_node()` calls with `hir_node_by_def_id()`. Follow up to https://github.com/rust-lang/rust/pull/120943.
2024-03-15Rollup merge of #122174 - notriddle:master, r=TaKO8KiMatthias Krüger-10/+50
diagnostics: suggest `Clone` bounds when noop `clone()` Fixes #121524
2024-03-15Auto merge of #122511 - matthiaskrgr:rollup-swzilin, r=matthiaskrgrbors-1/+1
Rollup of 10 pull requests Successful merges: - #117118 ([AIX] Remove AixLinker's debuginfo() implementation) - #121650 (change std::process to drop supplementary groups based on CAP_SETGID) - #121764 (Make incremental sessions identity no longer depend on the crate names provided by source code) - #122212 (Copy byval argument to alloca if alignment is insufficient) - #122322 (coverage: Initial support for branch coverage instrumentation) - #122373 (Fix the conflict problem between the diagnostics fixes of lint `unnecessary_qualification` and `unused_imports`) - #122479 (Implement `Duration::as_millis_{f64,f32}`) - #122487 (Rename `StmtKind::Local` variant into `StmtKind::Let`) - #122498 (Update version of cc crate) - #122503 (Make `SubdiagMessageOp` well-formed) r? `@ghost` `@rustbot` modify labels: rollup
2024-03-14use a let chainLukas Markeffsky-7/+4
2024-03-14clean up ADT sized constraint computationLukas Markeffsky-5/+3
2024-03-14hir: Remove `opt_local_def_id_to_hir_id` and `opt_hir_node_by_def_id`Vadim Petrochenkov-13/+12
Also replace a few `hir_node()` calls with `hir_node_by_def_id()`
2024-03-14rebaselcnr-1/+1
2024-03-14eagerly instantiate binders to avoid relying on `sub`lcnr-22/+48
2024-03-14Consolidate WF for aliasesMichael Goulet-20/+8
2024-03-14Rename `hir::StmtKind::Local` into `hir::StmtKind::Let`Guillaume Gomez-1/+1
2024-03-13Rollup merge of #122438 - jswrenn:check-referent-size, r=compiler-errorsMatthias Krüger-0/+7
Safe Transmute: Require that source referent is smaller than destination `BikeshedIntrinsicFrom` currently models transmute-via-union; i.e., it attempts to provide a `where` bound for this function: ```rust pub unsafe fn transmute_via_union<Src, Dst>(src: Src) -> Dst { use core::mem::*; #[repr(C)] union Transmute<T, U> { src: ManuallyDrop<T>, dst: ManuallyDrop<U>, } let transmute = Transmute { src: ManuallyDrop::new(src) }; // SAFETY: The caller must guarantee that the transmutation is safe. let dst = transmute.dst; ManuallyDrop::into_inner(dst) } ``` A quirk of this model is that it admits padding extensions in value-to-value transmutation: The destination type can be bigger than the source type, so long as the excess consists of uninitialized bytes. However, this isn't permissible for reference-to-reference transmutations (introduced in #110662) — extra referent bytes cannot come from thin air. This PR patches our analysis for reference-to-reference transmutations to require that the destination referent is no larger than the source referent. r? `@compiler-errors`
2024-03-13safe transmute: require that src referent is smaller than dstJack Wrenn-0/+7
The source referent absolutely must be smaller than the destination referent of a ref-to-ref transmute; the excess bytes referenced cannot arise from thin air, even if those bytes are uninitialized.
2024-03-13Rollup merge of #122360 - veera-sivarajan:bugfix-121941, r=compiler-errorsMatthias Krüger-0/+7
Don't Create `ParamCandidate` When Obligation Contains Errors Fixes #121941 I'm not sure if I understand this correctly but this bug was caused by an error type incorrectly matching against `ParamCandidate`. This was introduced by the changes made in #72621 (figured using cargo-bisect-rustc). This PR fixes it by skipping `ParamCandidate` generation when an error type is involved. Also, this is similar to #73005 but addresses `ParamCandidate` instead of `ImplCandidate`.
2024-03-12Don't Create `ParamCandidate` When Obligation Contains ErrorsVeera-0/+7
Fixes #121941
2024-03-12Fix discriminant_kind copy paste from the pointee trait caseDaria Sukhonina-2/+3
2024-03-11Make `DefiningAnchor::Bind` only store the opaque types that may be ↵Oli Scherer-13/+6
constrained, instead of the current infcx root item. This makes `Bind` almost always be empty, so we can start forwarding it to queries, allowing us to remove `Bubble` entirely
2024-03-09Auto merge of #122150 - ShoyuVanilla:replace-typewalker, r=lcnrbors-300/+301
Replace `TypeWalker` usage with `TypeVisitor` in `wf.rs` Resolves #121693
2024-03-08Stabilize associated type boundsMichael Goulet-2/+1
2024-03-08diagnostics: suggest `Clone` bounds when noop `clone()`Michael Howell-10/+50
2024-03-08Rollup merge of #121563 - Jarcho:use_cf, r=petrochenkovMatthias Krüger-14/+13
Use `ControlFlow` in visitors. Follow up to #121256 This does have a few small behaviour changes in some diagnostic output where the visitor will now find the first match rather than the last match. The change in `find_anon_types.rs` has the only affected test. I don't see this being an issue as the last occurrence isn't any better of a choice than the first.
2024-03-08Replace `TypeWalker` usage with `TypeVisitor`Shoyu Vanilla-300/+301
2024-03-07Rollup merge of #122123 - compiler-errors:object-trait-alias-bounds, r=oli-obkGuillaume Gomez-1/+1
Don't require specifying unrelated assoc types when trait alias is in `dyn` type Object types must specify the associated types for all of the principal trait ref's supertraits. However, we weren't doing elaboration properly, so we incorrectly errored with erroneous suggestions to specify associated types that were unrelated to that principal trait ref. To fix this, use proper supertrait elaboration when expanding trait aliases in `conv_object_ty_poly_trait_ref`. **NOTE**: Please use the ignore-whitespace option when reviewing. This only touches a handful of lines. r? oli-obk or please feel free to reassign. Fixes #122118
2024-03-07Rollup merge of #122043 - Y-Nak:move-early-binder, r=lcnrGuillaume Gomez-16/+15
Apply `EarlyBinder` only to `TraitRef` in `ImplTraitHeader` Resolves #121852 This PR 1. Moves `EarlyBinder` to `TraitRef` inside `ImplTraitHeader`, 2. Changes visibility of `coherence::builtin::check_trait` to `pub(super)` from `pub` as it seems not being re-exported from the `coherence` module.
2024-03-07Rollup merge of #121863 - lukas-code:silence-mismatched-super-projections, ↵Guillaume Gomez-66/+110
r=lcnr silence mismatched types errors for implied projections Currently, if a trait bound is not satisfied, then we suppress any errors for the trait's supertraits not being satisfied, but still report errors for super projections not being satisfied. For example: ```rust trait Super { type Assoc; } trait Sub: Super<Assoc = ()> {} ``` Before this PR, if `T: Sub` is not satisfied, then errors for `T: Super` are suppressed, but errors for `<T as Super>::Assoc == ()` are still shown. This PR makes it so that errors about super projections not being satisfied are also suppressed. The errors are only suppressed if the span of the trait obligation matches the span of the super predicate obligation to avoid silencing error that are not related. This PR removes some differences between the spans of supertraits and super projections to make the suppression work correctly. This PR fixes the majority of the diagnostics fallout when making `Thin` a supertrait of `Sized` (in a future PR). cc https://github.com/rust-lang/rust/pull/120354#issuecomment-1930585382 cc `@lcnr`
2024-03-07Apply `EarlyBinder` only to `TraitRef` in `ImplTraitHeader`Yoshitomo Nakanishi-16/+15
2024-03-07improve debug loggingLukas Markeffsky-14/+3
2024-03-07Don't require specifying unrelated assoc types when trait alias is in dyn typeMichael Goulet-1/+1
2024-03-06Auto merge of #122045 - matthiaskrgr:rollup-5l3vpn7, r=matthiaskrgrbors-2/+0
Rollup of 9 pull requests Successful merges: - #121065 (Add basic i18n guidance for `Display`) - #121744 (Stop using Bubble in coherence and instead emulate it with an intercrate check) - #121829 (Dummy tweaks (attempt 2)) - #121857 (Implement async closure signature deduction) - #121894 (const_eval_select: make it safe but be careful with what we expose on stable for now) - #122014 (Change some attributes to only_local.) - #122016 (will_wake tests fail on Miri and that is expected) - #122018 (only set noalias on Box with the global allocator) - #122028 (Remove some dead code) r? `@ghost` `@rustbot` modify labels: rollup
2024-03-05Use `ControlFlow` in HIR visitorsJason Newcomb-14/+13
2024-03-05Rollup merge of #121744 - oli-obk:eager_opaque_checks2, r=lcnrMatthias Krüger-2/+0
Stop using Bubble in coherence and instead emulate it with an intercrate check r? `````@compiler-errors````` This change is kinda funny, because all I've done is reimplement `Bubble` behaviour for coherence without using `Bubble` explicitly.
2024-03-05Convert `ProofTreeVisitor` to use `VisitorResult`Jason Newcomb-7/+4
2024-03-05Convert `TypeVisitor` and `DefIdVisitor` to use `VisitorResult`Jason Newcomb-42/+27
2024-03-05Stop using Bubble in coherence and instead emulate it with an intercrate checkOli Scherer-2/+0
2024-03-05Rollup merge of #121826 - estebank:e0277-root-obligation-2, r=oli-obkMatthias Krüger-5/+54
Use root obligation on E0277 for some cases When encountering trait bound errors that satisfy some heuristics that tell us that the relevant trait for the user comes from the root obligation and not the current obligation, we use the root predicate for the main message. This allows to talk about "X doesn't implement Pattern<'_>" over the most specific case that just happened to fail, like "char doesn't implement Fn(&mut char)" in `tests/ui/traits/suggest-dereferences/root-obligation.rs` The heuristics are: - the type of the leaf predicate is (roughly) the same as the type from the root predicate, as a proxy for "we care about the root" - the leaf trait and the root trait are different, so as to avoid talking about `&mut T: Trait` and instead remain talking about `T: Trait` instead - the root trait is not `Unsize`, as to avoid talking about it in `tests/ui/coercion/coerce-issue-49593-box-never.rs`. ``` error[E0277]: the trait bound `&char: Pattern<'_>` is not satisfied --> $DIR/root-obligation.rs:6:38 | LL | .filter(|c| "aeiou".contains(c)) | -------- ^ the trait `Fn<(char,)>` is not implemented for `&char`, which is required by `&char: Pattern<'_>` | | | required by a bound introduced by this call | = note: required for `&char` to implement `FnOnce<(char,)>` = note: required for `&char` to implement `Pattern<'_>` note: required by a bound in `core::str::<impl str>::contains` --> $SRC_DIR/core/src/str/mod.rs:LL:COL help: consider dereferencing here | LL | .filter(|c| "aeiou".contains(*c)) | + ``` Fix #79359, fix #119983, fix #118779, cc #118415 (the suggestion needs to change), cc #121398 (doesn't fix the underlying issue).
2024-03-05Rename `DiagnosticMessage` as `DiagMessage`.Nicholas Nethercote-2/+1
2024-03-04address review feedbackLukas Markeffsky-30/+56
2024-03-04suppress fulfillment errors for super projectionsLukas Markeffsky-31/+38
2024-03-04adjust obligation spans for super projectionsLukas Markeffsky-35/+57
2024-03-03Use `can_eq` instead of `Ty<'_> == Ty<'_>`Esteban Küber-4/+12
2024-03-03Use root obligation on E0277 for some casesEsteban Küber-5/+46
When encountering trait bound errors that satisfy some heuristics that tell us that the relevant trait for the user comes from the root obligation and not the current obligation, we use the root predicate for the main message. This allows to talk about "X doesn't implement Pattern<'_>" over the most specific case that just happened to fail, like "char doesn't implement Fn(&mut char)" in `tests/ui/traits/suggest-dereferences/root-obligation.rs` The heuristics are: - the type of the leaf predicate is (roughly) the same as the type from the root predicate, as a proxy for "we care about the root" - the leaf trait and the root trait are different, so as to avoid talking about `&mut T: Trait` and instead remain talking about `T: Trait` instead - the root trait is not `Unsize`, as to avoid talking about it in `tests/ui/coercion/coerce-issue-49593-box-never.rs`. ``` error[E0277]: the trait bound `&char: Pattern<'_>` is not satisfied --> $DIR/root-obligation.rs:6:38 | LL | .filter(|c| "aeiou".contains(c)) | -------- ^ the trait `Fn<(char,)>` is not implemented for `&char`, which is required by `&char: Pattern<'_>` | | | required by a bound introduced by this call | = note: required for `&char` to implement `FnOnce<(char,)>` = note: required for `&char` to implement `Pattern<'_>` note: required by a bound in `core::str::<impl str>::contains` --> $SRC_DIR/core/src/str/mod.rs:LL:COL help: consider dereferencing here | LL | .filter(|c| "aeiou".contains(*c)) | + ``` Fix #79359, fix #119983, fix #118779, cc #118415 (the suggestion needs to change).
2024-03-03Properly deal with GATs when looking for method chains to point atLeón Orell Valerian Liehr-16/+13
2024-03-02Rollup merge of #121875 - estebank:e0277-drive-by, r=compiler-errorsMatthias Krüger-12/+13
Account for unmet T: !Copy in E0277 message ``` error[E0277]: the trait bound `T: !Copy` is not satisfied --> $DIR/simple.rs:10:16 | LL | not_copy::<T>(); | ^ the trait bound `T: !Copy` is not satisfied ``` instead of the current ``` error[E0277]: the trait bound `T: !Copy` is not satisfied --> $DIR/simple.rs:10:16 | LL | not_copy::<T>(); | ^ the trait `!Copy` is not implemented for `T` ```