authorbors <bors@rust-lang.org> 2026-01-16 09:47:11 UTC
committerbors <bors@rust-lang.org> 2026-01-16 09:47:11 UTC
logc40c51f9fdfa90b9c91c1601ec1442225c6b5c36
tree48d23f1e2b70961ddb709d7938f1c03492a4f952
parentd2015e2359d5d0b154c2b192d4039f9b5711fcdc
parent6e49b64c497478d9592f44732b9d5a739b3f2766

Auto merge of #151193 - matthiaskrgr:rollup-17r4zye, r=matthiaskrgr

Rollup of 2 pull requests Successful merges: - rust-lang/rust#151166 (fix: Do not delay E0107 when there exists an assoc ty with the same name) - rust-lang/rust#151185 (Disable `dump-ice-to-disk` on `i686-pc-windows-msvc`) r? @ghost

4 files changed, 79 insertions(+), 6 deletions(-)

compiler/rustc_hir_analysis/src/hir_ty_lowering/generics.rs+20-2
......@@ -9,6 +9,7 @@ use rustc_middle::ty::{
99};
1010use rustc_session::lint::builtin::LATE_BOUND_LIFETIME_ARGUMENTS;
1111use rustc_span::kw;
12use rustc_trait_selection::traits;
1213use smallvec::SmallVec;
1314use tracing::{debug, instrument};
1415
......@@ -535,9 +536,26 @@ pub(crate) fn check_generic_arg_count(
535536 .map(|param| param.name)
536537 .collect();
537538 if constraint_names == param_names {
539 let has_assoc_ty_with_same_name =
540 if let DefKind::Trait = cx.tcx().def_kind(def_id) {
541 gen_args.constraints.iter().any(|constraint| {
542 traits::supertrait_def_ids(cx.tcx(), def_id).any(|trait_did| {
543 cx.probe_trait_that_defines_assoc_item(
544 trait_did,
545 ty::AssocTag::Type,
546 constraint.ident,
547 )
548 })
549 })
550 } else {
551 false
552 };
538553 // We set this to true and delay emitting `WrongNumberOfGenericArgs`
539 // to provide a succinct error for cases like issue #113073
540 all_params_are_binded = true;
554 // to provide a succinct error for cases like issue #113073,
555 // but only if when we don't have any assoc type with the same name with a
556 // generic arg. Otherwise it will cause an ICE due to a delayed error because we
557 // don't have any error other than `WrongNumberOfGenericArgs`.
558 all_params_are_binded = !has_assoc_ty_with_same_name;
541559 };
542560 }
543561
tests/run-make/dump-ice-to-disk/rmake.rs+7-4
......@@ -18,13 +18,16 @@
1818//! # Test history
1919//!
2020//! The previous rmake.rs iteration of this test was flaky for unknown reason on
21//! `i686-pc-windows-gnu` *specifically*, so assertion failures in this test was made extremely
22//! verbose to help diagnose why the ICE messages was different. It appears that backtraces on
23//! `i686-pc-windows-gnu` specifically are quite unpredictable in how many backtrace frames are
24//! involved.
21//! `i686-pc-windows-gnu`, so assertion failures in this test was made extremely verbose to help
22//! diagnose why the ICE messages was different. It appears that backtraces on `i686-pc-windows-gnu`
23//! specifically are quite unpredictable in how many backtrace frames are involved.
24//!
25//! Disabled on `i686-pc-windows-msvc` as well, because sometimes the middle portion of the ICE
26//! backtrace becomes `<unknown>`.
2527
2628//@ ignore-cross-compile (exercising ICE dump on host)
2729//@ ignore-i686-pc-windows-gnu (unwind mechanism produces unpredictable backtraces)
30//@ ignore-i686-pc-windows-msvc (sometimes partial backtrace becomes `<unknown>`)
2831
2932use std::cell::OnceCell;
3033use std::path::{Path, PathBuf};
tests/ui/traits/associated_type_bound/assoc-type-bounds-with-the-same-name-with-lacking-generic-arg-148121.rs created+17
......@@ -0,0 +1,17 @@
1// A regression test for https://github.com/rust-lang/rust/issues/148121
2
3pub trait Super<X> {
4 type X;
5}
6
7pub trait Zelf<X>: Super<X> {}
8
9pub trait A {}
10
11impl A for dyn Super<X = ()> {}
12//~^ ERROR: trait takes 1 generic argument but 0 generic arguments were supplied
13
14impl A for dyn Zelf<X = ()> {}
15//~^ ERROR: trait takes 1 generic argument but 0 generic arguments were supplied
16
17fn main() {}
tests/ui/traits/associated_type_bound/assoc-type-bounds-with-the-same-name-with-lacking-generic-arg-148121.stderr created+35
......@@ -0,0 +1,35 @@
1error[E0107]: trait takes 1 generic argument but 0 generic arguments were supplied
2 --> $DIR/assoc-type-bounds-with-the-same-name-with-lacking-generic-arg-148121.rs:11:16
3 |
4LL | impl A for dyn Super<X = ()> {}
5 | ^^^^^ expected 1 generic argument
6 |
7note: trait defined here, with 1 generic parameter: `X`
8 --> $DIR/assoc-type-bounds-with-the-same-name-with-lacking-generic-arg-148121.rs:3:11
9 |
10LL | pub trait Super<X> {
11 | ^^^^^ -
12help: add missing generic argument
13 |
14LL | impl A for dyn Super<X, X = ()> {}
15 | ++
16
17error[E0107]: trait takes 1 generic argument but 0 generic arguments were supplied
18 --> $DIR/assoc-type-bounds-with-the-same-name-with-lacking-generic-arg-148121.rs:14:16
19 |
20LL | impl A for dyn Zelf<X = ()> {}
21 | ^^^^ expected 1 generic argument
22 |
23note: trait defined here, with 1 generic parameter: `X`
24 --> $DIR/assoc-type-bounds-with-the-same-name-with-lacking-generic-arg-148121.rs:7:11
25 |
26LL | pub trait Zelf<X>: Super<X> {}
27 | ^^^^ -
28help: add missing generic argument
29 |
30LL | impl A for dyn Zelf<X, X = ()> {}
31 | ++
32
33error: aborting due to 2 previous errors
34
35For more information about this error, try `rustc --explain E0107`.