Change:
<!-- [31mICE[0m: Rustc '--crate-type=lib -ooutputfile -Zdump-mir-dir=dir' 'error: internal compiler error[E0107]: trait takes 1 generic argument but 0 generic arguments were supplied', 'error: internal compiler error[E0107]: trait takes 1 generic argument but 0 generic arguments were supplied' File: --auto-reduced (treereduce-rust): original: Version information ` Command: <!-- Include a backtrace in the code block by setting in your environment. E.g. . --<details<summary<strongProgram output</strong</summary<p</p</details<!-- query stack: --<!-- TRIAGEBOTSTART --<!-- TRIAGEBOTASSIGNSTART --<!-- TRIAGEBOTASSIGNDATASTARTTRIAGEBOTASSIGNDATAEND --<!-- TRIAGEBOTASSIGNEND --<!-- TRIAGEBOTEND --
cc :thinking:
claim

Discussion:
} } <ins> /// Check if node is an impl block. pub fn is_impl_block(&self) -> bool { matches!(self, OwnerNode::Item(Item { kind: ItemKind::Impl(_), .. })) } </ins> expect_methods_self! { expect_item,         &'hir Item<'hir>,        OwnerNode::Item(n),        n; expect_foreign_item, &'hir ForeignItem<'hir>, OwnerNode::ForeignItem(n), n;

synth_provided, } } else { <del> let num_missing_args = expected_max - provided; </del> <ins> // Check if associated type bounds are incorrectly written in impl block header like: // ``` // trait Foo<T> {} // impl Foo<T: Default> for u8 {} // ``` let parent_is_impl_block = cx .tcx() .hir() .parent_owner_iter(seg.hir_id) .next() .is_some_and(|(_, owner_node)| owner_node.is_impl_block()); if parent_is_impl_block { let constraint_names: Vec<_> = gen_args.constraints.iter().map(|b| b.ident.name).collect(); let param_names: Vec<_> = gen_params .own_params .iter() .filter(|param| !has_self || param.index != 0) // Assumes `Self` will always be the first parameter .map(|param| param.name) .collect(); if constraint_names == param_names { // We set this to true and delay emitting `WrongNumberOfGenericArgs` // to provide a succinct error for cases like issue #113073 all_params_are_binded = true; }; } </ins> <del> let constraint_names: Vec<_> = gen_args.constraints.iter().map(|b| b.ident.name).collect(); let param_names: Vec<_> = gen_params .own_params .iter() .filter(|param| !has_self || param.index != 0) // Assumes `Self` will always be the first parameter .map(|param| param.name) .collect(); if constraint_names == param_names { // We set this to true and delay emitting `WrongNumberOfGenericArgs` // to provide a succinct error for cases like issue #113073 all_params_are_binded = true; }; </del> <ins> let num_missing_args = expected_max - provided; </ins> GenericArgsInfo::MissingTypesOrConsts { num_missing_args,

<ins> trait Trait<Type> { type Type; fn one(&self, val:  impl Trait<Type: Default>); //~^ ERROR trait takes 1 generic argument but 0 generic arguments were supplied fn two<T: Trait<Type: Default>>(&self) -> T; //~^ ERROR trait takes 1 generic argument but 0 generic arguments were supplied fn three<T>(&self) -> T where T: Trait<Type: Default>,; //~^ ERROR trait takes 1 generic argument but 0 generic arguments were supplied } fn main() {} </ins>

<ins> error[E0107]: trait takes 1 generic argument but 0 generic arguments were supplied --> $DIR/name-same-as-generic-type-issue-128249.rs:4:30 | LL |     fn one(&self, val:  impl Trait<Type: Default>); |                              ^^^^^ expected 1 generic argument | note: trait defined here, with 1 generic parameter: `Type` --> $DIR/name-same-as-generic-type-issue-128249.rs:1:7 | LL | trait Trait<Type> { |       ^^^^^ ---- help: add missing generic argument | LL |     fn one(&self, val:  impl Trait<Type, Type: Default>); |                                    +++++ error[E0107]: trait takes 1 generic argument but 0 generic arguments were supplied --> $DIR/name-same-as-generic-type-issue-128249.rs:7:15 | LL |     fn two<T: Trait<Type: Default>>(&self) -> T; |               ^^^^^ expected 1 generic argument | note: trait defined here, with 1 generic parameter: `Type` --> $DIR/name-same-as-generic-type-issue-128249.rs:1:7 | LL | trait Trait<Type> { |       ^^^^^ ---- help: add missing generic argument | LL |     fn two<T: Trait<Type, Type: Default>>(&self) -> T; |                     +++++ error[E0107]: trait takes 1 generic argument but 0 generic arguments were supplied --> $DIR/name-same-as-generic-type-issue-128249.rs:11:12 | LL |         T: Trait<Type: Default>,; |            ^^^^^ expected 1 generic argument | note: trait defined here, with 1 generic parameter: `Type` --> $DIR/name-same-as-generic-type-issue-128249.rs:1:7 | LL | trait Trait<Type> { |       ^^^^^ ---- help: add missing generic argument | LL |         T: Trait<Type, Type: Default>,; |                  +++++ error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0107`. </ins>