Skip to content

fix binding const argument to assoc type suggestion#157908

Open
Kivooeo wants to merge 1 commit into
rust-lang:mainfrom
Kivooeo:fix-mgca-assoc-sugg
Open

fix binding const argument to assoc type suggestion#157908
Kivooeo wants to merge 1 commit into
rust-lang:mainfrom
Kivooeo:fix-mgca-assoc-sugg

Conversation

@Kivooeo

@Kivooeo Kivooeo commented Jun 15, 2026

Copy link
Copy Markdown
Member

View all comments

r? fmease

fixes #151602

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jun 15, 2026

@fmease fmease left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

preliminary review, thanks for working on this!

View changes since this review

Comment thread compiler/rustc_hir_analysis/src/diagnostics/wrong_number_of_generic_args.rs Outdated
Comment thread compiler/rustc_hir_analysis/src/diagnostics/wrong_number_of_generic_args.rs Outdated
Comment thread compiler/rustc_hir_analysis/src/diagnostics/wrong_number_of_generic_args.rs Outdated
Comment thread compiler/rustc_hir_analysis/src/diagnostics/wrong_number_of_generic_args.rs Outdated
Comment on lines +1022 to +1026
.filter(|(potential, item)| match potential {
hir::GenericArg::Const(_) => item.is_type_const(),
hir::GenericArg::Type(_) => item.is_type(),
_ => false,
})

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... this check assumes that the type & const arguments magically line up with the associated types & consts, respectively, which doesn't hold up in reality IINM because the unbound_assoc_items (unbound_types) come in definition order.

What I'm saying is that your code probably emits a suggestion here:

trait Trait { type A; type const B: usize; }
fn f<T: Trait<(), 0>>(); // your PR emits a suggestion

but not here:

trait Trait { type const A: usize; type B; }
fn f<T: Trait<(), 0>>(); // your PR does *not* emit a suggestion IINM

because "[(TyAssocConst, Ty), (AssocTy, Const)]" doesn't contain any matches according to the filter.

@fmease fmease added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 15, 2026
Comment thread compiler/rustc_hir_analysis/src/diagnostics/wrong_number_of_generic_args.rs Outdated
@Kivooeo

Kivooeo commented Jun 15, 2026

Copy link
Copy Markdown
Member Author

it seems like i've addressed all reviews, but not sure

@rustbot ready

@rustbot rustbot removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Jun 15, 2026
@rust-log-analyzer

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 15, 2026
@rust-cloud-vms rust-cloud-vms Bot force-pushed the fix-mgca-assoc-sugg branch from d1c91a7 to d0c3c77 Compare June 15, 2026 11:25
Comment thread compiler/rustc_hir_analysis/src/diagnostics/wrong_number_of_generic_args.rs Outdated
Comment thread compiler/rustc_hir_analysis/src/diagnostics/wrong_number_of_generic_args.rs Outdated
Comment thread compiler/rustc_hir_analysis/src/diagnostics/wrong_number_of_generic_args.rs Outdated
Comment thread compiler/rustc_hir_analysis/src/diagnostics/wrong_number_of_generic_args.rs Outdated
Comment thread compiler/rustc_hir_analysis/src/diagnostics/wrong_number_of_generic_args.rs Outdated
Comment thread tests/ui/const-generics/mgca/type-const-suggestion.rs
@Kivooeo

Kivooeo commented Jun 15, 2026

Copy link
Copy Markdown
Member Author

are you fine if i will stack commits on top of each other while review is going, but i will squash them later before merge, just to make it easier to follow what's changed after every push?

@fmease

fmease commented Jun 15, 2026

Copy link
Copy Markdown
Member

You can already squash / fix up / amend everything as you go, I'm gonna use the View changes since this review link in #157908 (review) which is sufficient for this patch.

Anyway, r=me with suggestions applied @bors rollup

@rust-cloud-vms rust-cloud-vms Bot force-pushed the fix-mgca-assoc-sugg branch from d0c3c77 to 8aa97c0 Compare June 15, 2026 11:59
Comment on lines +17 to +23
error[E0107]: trait takes 0 generic arguments but 1 generic argument was supplied
--> $DIR/use-type-argument-instead-of-assoc-type.rs:11:17
|
LL | fn take(_: impl Iterator<0>) {}
| ^^^^^^^^ expected 0 generic arguments

error: aborting due to 2 previous errors

@Kivooeo Kivooeo Jun 15, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here is new test, i've extended existed test with it

View changes since the review

@rust-cloud-vms rust-cloud-vms Bot force-pushed the fix-mgca-assoc-sugg branch from 8aa97c0 to c1f6331 Compare June 15, 2026 12:02
@Kivooeo

Kivooeo commented Jun 15, 2026

Copy link
Copy Markdown
Member Author

@bors r=fmease rollup

@rust-bors

rust-bors Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

📌 Commit c1f6331 has been approved by fmease

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 15, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jun 15, 2026
fix binding const argument to assoc type suggestion

r? fmease

fixes rust-lang#151602
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Suggestion to replace generic args with assoc item bindings doesn't properly deal with const args

4 participants