| author | bors <bors@rust-lang.org> 2026-01-16 09:47:11 UTC |
| committer | bors <bors@rust-lang.org> 2026-01-16 09:47:11 UTC |
| log | c40c51f9fdfa90b9c91c1601ec1442225c6b5c36 |
| tree | 48d23f1e2b70961ddb709d7938f1c03492a4f952 |
| parent | d2015e2359d5d0b154c2b192d4039f9b5711fcdc |
| parent | 6e49b64c497478d9592f44732b9d5a739b3f2766 |
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? @ghost4 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::{ |
| 9 | 9 | }; |
| 10 | 10 | use rustc_session::lint::builtin::LATE_BOUND_LIFETIME_ARGUMENTS; |
| 11 | 11 | use rustc_span::kw; |
| 12 | use rustc_trait_selection::traits; | |
| 12 | 13 | use smallvec::SmallVec; |
| 13 | 14 | use tracing::{debug, instrument}; |
| 14 | 15 | |
| ... | ... | @@ -535,9 +536,26 @@ pub(crate) fn check_generic_arg_count( |
| 535 | 536 | .map(|param| param.name) |
| 536 | 537 | .collect(); |
| 537 | 538 | 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 | }; | |
| 538 | 553 | // 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; | |
| 541 | 559 | }; |
| 542 | 560 | } |
| 543 | 561 |
tests/run-make/dump-ice-to-disk/rmake.rs+7-4| ... | ... | @@ -18,13 +18,16 @@ |
| 18 | 18 | //! # Test history |
| 19 | 19 | //! |
| 20 | 20 | //! 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>`. | |
| 25 | 27 | |
| 26 | 28 | //@ ignore-cross-compile (exercising ICE dump on host) |
| 27 | 29 | //@ ignore-i686-pc-windows-gnu (unwind mechanism produces unpredictable backtraces) |
| 30 | //@ ignore-i686-pc-windows-msvc (sometimes partial backtrace becomes `<unknown>`) | |
| 28 | 31 | |
| 29 | 32 | use std::cell::OnceCell; |
| 30 | 33 | use 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 | ||
| 3 | pub trait Super<X> { | |
| 4 | type X; | |
| 5 | } | |
| 6 | ||
| 7 | pub trait Zelf<X>: Super<X> {} | |
| 8 | ||
| 9 | pub trait A {} | |
| 10 | ||
| 11 | impl A for dyn Super<X = ()> {} | |
| 12 | //~^ ERROR: trait takes 1 generic argument but 0 generic arguments were supplied | |
| 13 | ||
| 14 | impl A for dyn Zelf<X = ()> {} | |
| 15 | //~^ ERROR: trait takes 1 generic argument but 0 generic arguments were supplied | |
| 16 | ||
| 17 | fn 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 @@ |
| 1 | error[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 | | | |
| 4 | LL | impl A for dyn Super<X = ()> {} | |
| 5 | | ^^^^^ expected 1 generic argument | |
| 6 | | | |
| 7 | note: 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 | | | |
| 10 | LL | pub trait Super<X> { | |
| 11 | | ^^^^^ - | |
| 12 | help: add missing generic argument | |
| 13 | | | |
| 14 | LL | impl A for dyn Super<X, X = ()> {} | |
| 15 | | ++ | |
| 16 | ||
| 17 | error[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 | | | |
| 20 | LL | impl A for dyn Zelf<X = ()> {} | |
| 21 | | ^^^^ expected 1 generic argument | |
| 22 | | | |
| 23 | note: 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 | | | |
| 26 | LL | pub trait Zelf<X>: Super<X> {} | |
| 27 | | ^^^^ - | |
| 28 | help: add missing generic argument | |
| 29 | | | |
| 30 | LL | impl A for dyn Zelf<X, X = ()> {} | |
| 31 | | ++ | |
| 32 | ||
| 33 | error: aborting due to 2 previous errors | |
| 34 | ||
| 35 | For more information about this error, try `rustc --explain E0107`. |