From 0b45ff5dac44aa8cb65c800eb8f1ad32d2a2ded7 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Sat, 13 Jan 2024 20:55:50 +0000 Subject: [PATCH 1/3] Don't ICE when noting GAT bounds in report_no_match_method_error --- .../rustc_hir_typeck/src/method/suggest.rs | 17 +++--- ...ied-gat-bound-during-assoc-ty-selection.rs | 33 ++++++++++++ ...gat-bound-during-assoc-ty-selection.stderr | 52 +++++++++++++++++++ 3 files changed, 96 insertions(+), 6 deletions(-) create mode 100644 tests/ui/generic-associated-types/issue-119942-unsatisified-gat-bound-during-assoc-ty-selection.rs create mode 100644 tests/ui/generic-associated-types/issue-119942-unsatisified-gat-bound-during-assoc-ty-selection.stderr diff --git a/compiler/rustc_hir_typeck/src/method/suggest.rs b/compiler/rustc_hir_typeck/src/method/suggest.rs index 1f01c6b7406..3bf1e1312b3 100644 --- a/compiler/rustc_hir_typeck/src/method/suggest.rs +++ b/compiler/rustc_hir_typeck/src/method/suggest.rs @@ -825,11 +825,16 @@ pub fn report_no_match_method_error( "auto trait is invoked with no method error, but no error reported?", ); } - Some(Node::Item(hir::Item { - ident, - kind: hir::ItemKind::Trait(..) | hir::ItemKind::TraitAlias(..), - .. - })) => { + Some( + Node::Item(hir::Item { + ident, + kind: hir::ItemKind::Trait(..) | hir::ItemKind::TraitAlias(..), + .. + }) + // We may also encounter unsatisfied GAT or method bounds + | Node::TraitItem(hir::TraitItem { ident, .. }) + | Node::ImplItem(hir::ImplItem { ident, .. }), + ) => { skip_list.insert(p); let entry = spanned_predicates.entry(ident.span); let entry = entry.or_insert_with(|| { @@ -840,7 +845,7 @@ pub fn report_no_match_method_error( entry.1.insert((cause_span, "unsatisfied trait bound introduced here")); entry.2.push(p); } - Some(node) => unreachable!("encountered `{node:?}`"), + Some(node) => unreachable!("encountered `{node:?}` due to `{cause:#?}`"), None => (), } } diff --git a/tests/ui/generic-associated-types/issue-119942-unsatisified-gat-bound-during-assoc-ty-selection.rs b/tests/ui/generic-associated-types/issue-119942-unsatisified-gat-bound-during-assoc-ty-selection.rs new file mode 100644 index 00000000000..252dc7d751e --- /dev/null +++ b/tests/ui/generic-associated-types/issue-119942-unsatisified-gat-bound-during-assoc-ty-selection.rs @@ -0,0 +1,33 @@ +use std::ops::Deref; + +trait PointerFamily { + type Pointer: Deref; +} + +struct RcFamily; + +impl PointerFamily for RcFamily { + type Pointer = dyn Deref; + //~^ ERROR the size for values of type `(dyn Deref + 'static)` cannot be known at compilation time +} + +enum Node { + Cons(T, P::Pointer>), + Nil, +} + +type RcNode = Node; + +impl Node +where + P::Pointer>: Sized, +{ + fn new() -> P::Pointer { + todo!() + } +} + +fn main() { + let mut list = RcNode::::new(); + //~^ ERROR the size for values of type `Node` cannot be known at compilation time +} diff --git a/tests/ui/generic-associated-types/issue-119942-unsatisified-gat-bound-during-assoc-ty-selection.stderr b/tests/ui/generic-associated-types/issue-119942-unsatisified-gat-bound-during-assoc-ty-selection.stderr new file mode 100644 index 00000000000..3a973d356dc --- /dev/null +++ b/tests/ui/generic-associated-types/issue-119942-unsatisified-gat-bound-during-assoc-ty-selection.stderr @@ -0,0 +1,52 @@ +error[E0277]: the size for values of type `(dyn Deref + 'static)` cannot be known at compilation time + --> $DIR/issue-119942-unsatisified-gat-bound-during-assoc-ty-selection.rs:10:23 + | +LL | type Pointer = dyn Deref; + | ^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `(dyn Deref + 'static)` +note: required by a bound in `PointerFamily::Pointer` + --> $DIR/issue-119942-unsatisified-gat-bound-during-assoc-ty-selection.rs:4:5 + | +LL | type Pointer: Deref; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `PointerFamily::Pointer` +help: consider relaxing the implicit `Sized` restriction + | +LL | type Pointer: Deref + ?Sized; + | ++++++++ + +error[E0599]: the size for values of type `Node` cannot be known at compilation time + --> $DIR/issue-119942-unsatisified-gat-bound-during-assoc-ty-selection.rs:31:35 + | +LL | enum Node { + | ------------------------------ + | | + | variant or associated item `new` not found for this enum + | doesn't satisfy `Node: Sized` +... +LL | let mut list = RcNode::::new(); + | ^^^ doesn't have a size known at compile-time + --> $SRC_DIR/core/src/ops/deref.rs:LL:COL + | + = note: doesn't satisfy `_: Sized` + | +note: trait bound `Node: Sized` was not satisfied + --> $DIR/issue-119942-unsatisified-gat-bound-during-assoc-ty-selection.rs:4:18 + | +LL | type Pointer: Deref; + | ------- ^ unsatisfied trait bound introduced here +note: trait bound `(dyn Deref> + 'static): Sized` was not satisfied + --> $DIR/issue-119942-unsatisified-gat-bound-during-assoc-ty-selection.rs:23:29 + | +LL | impl Node + | ---------- +LL | where +LL | P::Pointer>: Sized, + | ^^^^^ unsatisfied trait bound introduced here +note: the trait `Sized` must be implemented + --> $SRC_DIR/core/src/marker.rs:LL:COL + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0277, E0599. +For more information about an error, try `rustc --explain E0277`. From 4ca6342eb30dfbc3fe0992de0cfc780f3992f446 Mon Sep 17 00:00:00 2001 From: clubby789 Date: Sun, 14 Jan 2024 00:24:39 +0000 Subject: [PATCH 2/3] Add note on SpecOptionPartialEq to `newtype_index` --- compiler/rustc_index_macros/src/lib.rs | 3 +++ library/core/src/option.rs | 1 + 2 files changed, 4 insertions(+) diff --git a/compiler/rustc_index_macros/src/lib.rs b/compiler/rustc_index_macros/src/lib.rs index ac374a41eb6..4f973c1f010 100644 --- a/compiler/rustc_index_macros/src/lib.rs +++ b/compiler/rustc_index_macros/src/lib.rs @@ -31,6 +31,9 @@ /// - `#[max = 0xFFFF_FFFD]`: specifies the max value, which allows niche /// optimizations. The default max value is 0xFFFF_FF00. /// - `#[gate_rustc_only]`: makes parts of the generated code nightly-only. +/// +/// `SpecOptionPartialEq` is specialized by this macro, so using it requires enabling +/// `#![feature(min_specialization)]` for the crate. #[proc_macro] #[cfg_attr( feature = "nightly", diff --git a/library/core/src/option.rs b/library/core/src/option.rs index ff435349249..781c7a91a5a 100644 --- a/library/core/src/option.rs +++ b/library/core/src/option.rs @@ -2147,6 +2147,7 @@ fn eq(&self, other: &Self) -> bool { /// /// Once that's fixed, `Option` should go back to deriving `PartialEq`, as /// it used to do before . +/// The comment regarding this trait on the `newtype_index` macro should be removed if this is done. #[unstable(feature = "spec_option_partial_eq", issue = "none", reason = "exposed only for rustc")] #[doc(hidden)] pub trait SpecOptionPartialEq: Sized { From 5788f3d350e0367cd5bbb192b8780429949844de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Le=C3=B3n=20Orell=20Valerian=20Liehr?= Date: Sun, 14 Jan 2024 13:55:18 +0100 Subject: [PATCH 3/3] Remove Zulip rustdoc nomination alert --- triagebot.toml | 9 --------- 1 file changed, 9 deletions(-) diff --git a/triagebot.toml b/triagebot.toml index 1e1db2d1663..2b818c0a990 100644 --- a/triagebot.toml +++ b/triagebot.toml @@ -389,15 +389,6 @@ message_on_remove = "Issue #{number}'s prioritization request has been removed." message_on_close = "Issue #{number} has been closed while requested for prioritization." message_on_reopen = "Issue #{number} has been reopened." -[notify-zulip."T-rustdoc"] -required_labels = ["I-nominated"] -zulip_stream = 266220 # #rustdoc -topic = "nominated: #{number}" -message_on_add = """\ -@*T-rustdoc* issue #{number} "{title}" has been nominated for `T-rustdoc` discussion. -""" -message_on_remove = "Issue #{number}'s nomination request has been removed." - [notify-zulip."I-types-nominated"] zulip_stream = 326866 # #T-types/nominated topic = "#{number}: {title}"