Skip to content

Use infer tys for synthetic params when lowering const paths point to fns#157625

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
mu001999:fix-155834
Jun 27, 2026
Merged

Use infer tys for synthetic params when lowering const paths point to fns#157625
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
mu001999:fix-155834

Conversation

@mu001999

@mu001999 mu001999 commented Jun 8, 2026

Copy link
Copy Markdown
Member
#![feature(min_generic_const_args)]

trait Trait {}
impl<'t> Trait for [(); N] {}
fn N(arg: impl Trait) {}
  1. arg: impl Trait implies a synthetic param <impl Trait> and the obligation _: Trait;
  2. when matching impl Trait for [(); N], lowering const arg N fills in that synthetic param, so the impl header contains <[(); N::<impl Trait>] as Trait>;
  3. then instantiating this header with the impl's args causing a param/arg mismatch and ICE.

This PR uses infer tys for synthetic params. Although this will emit the error in ItemCtxt because infer tys are not allowed here. I think that is reasonable, because N omits the synthetic parameter, though we cannot write the ty explicitly anywhere.

Fixes #155834

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jun 8, 2026
@mu001999 mu001999 marked this pull request as ready for review June 9, 2026 02:44
@rustbot

rustbot commented Jun 9, 2026

Copy link
Copy Markdown
Collaborator

HIR ty lowering was modified

cc @fmease

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jun 9, 2026
@rustbot

rustbot commented Jun 9, 2026

Copy link
Copy Markdown
Collaborator

r? @JohnTitor

rustbot has assigned @JohnTitor.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 73 candidates
  • Random selection from 19 candidates

@JohnTitor JohnTitor 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.

@rust-bors

rust-bors Bot commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 0805fc2 has been approved by JohnTitor

It is now in the queue for this repository.

🌲 The tree is currently closed for pull requests below priority 1. This pull request will be tested once the tree is reopened.

@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 27, 2026
jhpratt added a commit to jhpratt/rust that referenced this pull request Jun 27, 2026
Use infer tys for synthetic params when lowering const paths point to fns

```rust
#![feature(min_generic_const_args)]

trait Trait {}
impl<'t> Trait for [(); N] {}
fn N(arg: impl Trait) {}
```

1. `arg: impl Trait` implies a synthetic param `<impl Trait>` and the obligation `_: Trait`;
2. when matching `impl Trait for [(); N]`, lowering const arg `N` fills in that synthetic param, so the impl header contains `<[(); N::<impl Trait>] as Trait>`;
3. then instantiating this header with the impl's args causing a param/arg mismatch and ICE.

This PR uses infer tys for synthetic params. Although this will emit the error in `ItemCtxt` because infer tys are not allowed here. I think that is reasonable, because `N` omits the synthetic parameter, though we cannot write the ty explicitly anywhere.

Fixes rust-lang#155834
rust-bors Bot pushed a commit that referenced this pull request Jun 27, 2026
Rollup of 5 pull requests

Successful merges:

 - #158234 (Cross-referencing tuple_trait tracking issue, source and the Unstable Book)
 - #157625 (Use infer tys for synthetic params when lowering const paths point to fns)
 - #158306 (tests: modify s390x vector test to be robust to instruction scheduling)
 - #158431 (More lint cleanups)
 - #158452 (Add missing links in integer docs)
@jhpratt

jhpratt commented Jun 27, 2026

Copy link
Copy Markdown
Member

This is the only PR in the rollup touching const generics, so I presume this is the cause.

error[E0121]: the placeholder `_` is not allowed within types on item signatures for implementations
##[error]  --> /checkout/tests/ui/const-generics/mgca/synth-gen-arg-ice-158152.rs:6:16
   |
LL | impl A<[usize; fn_item]> for () {}
   |                ^^^^^^^ not allowed in type signatures

error[E0747]: type provided when a constant was expected
##[error]  --> /checkout/tests/ui/const-generics/mgca/synth-gen-arg-ice-158152.rs:8:26
   |
LL | fn fn_item(_: impl Trait<usize>) {}
   |                          ^^^^^
   |
help: if this generic argument was intended as a const parameter, surround it with braces
   |
LL | fn fn_item(_: impl Trait<{ usize }>) {}
   |                          +       +

error: aborting due to 2 previous errors

#158465 (comment)

@bors r-

@rust-bors rust-bors Bot 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-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jun 27, 2026
@rust-bors

rust-bors Bot commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

This pull request was unapproved.

This PR was contained in a rollup (#158465), which was unapproved.

View changes since this unapproval

@jhpratt

jhpratt commented Jun 27, 2026

Copy link
Copy Markdown
Member

Just to be sure

@bors try jobs=x86_64-gnu-llvm-21

@rust-bors

rust-bors Bot commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

⌛ Trying commit 0805fc2 with merge 0ac3a15

To cancel the try build, run the command @bors try cancel.

Workflow: https://github.com/rust-lang/rust/actions/runs/28280079330

rust-bors Bot pushed a commit that referenced this pull request Jun 27, 2026
Use infer tys for synthetic params when lowering const paths point to fns


try-job: x86_64-gnu-llvm-21
@mu001999

Copy link
Copy Markdown
Member Author

This is the cause, I will rebase and update the test.

@jhpratt

jhpratt commented Jun 27, 2026

Copy link
Copy Markdown
Member

@bors try cancel

@rust-bors

rust-bors Bot commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Try build cancelled. Cancelled workflows:

@rustbot

rustbot commented Jun 27, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@jhpratt

jhpratt commented Jun 27, 2026

Copy link
Copy Markdown
Member

@bors r=JohnTitor

@rust-bors

rust-bors Bot commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 4bbd8fc has been approved by JohnTitor

It is now in the queue for this repository.

🌲 The tree is currently closed for pull requests below priority 5. This pull request will be tested once the tree is reopened.

@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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jun 27, 2026
jhpratt added a commit to jhpratt/rust that referenced this pull request Jun 27, 2026
Use infer tys for synthetic params when lowering const paths point to fns

```rust
#![feature(min_generic_const_args)]

trait Trait {}
impl<'t> Trait for [(); N] {}
fn N(arg: impl Trait) {}
```

1. `arg: impl Trait` implies a synthetic param `<impl Trait>` and the obligation `_: Trait`;
2. when matching `impl Trait for [(); N]`, lowering const arg `N` fills in that synthetic param, so the impl header contains `<[(); N::<impl Trait>] as Trait>`;
3. then instantiating this header with the impl's args causing a param/arg mismatch and ICE.

This PR uses infer tys for synthetic params. Although this will emit the error in `ItemCtxt` because infer tys are not allowed here. I think that is reasonable, because `N` omits the synthetic parameter, though we cannot write the ty explicitly anywhere.

Fixes rust-lang#155834
rust-bors Bot pushed a commit that referenced this pull request Jun 27, 2026
Rollup of 5 pull requests

Successful merges:

 - #158234 (Cross-referencing tuple_trait tracking issue, source and the Unstable Book)
 - #157625 (Use infer tys for synthetic params when lowering const paths point to fns)
 - #158306 (tests: modify s390x vector test to be robust to instruction scheduling)
 - #158431 (More lint cleanups)
 - #158452 (Add missing links in integer docs)
jhpratt added a commit to jhpratt/rust that referenced this pull request Jun 27, 2026
Use infer tys for synthetic params when lowering const paths point to fns

```rust
#![feature(min_generic_const_args)]

trait Trait {}
impl<'t> Trait for [(); N] {}
fn N(arg: impl Trait) {}
```

1. `arg: impl Trait` implies a synthetic param `<impl Trait>` and the obligation `_: Trait`;
2. when matching `impl Trait for [(); N]`, lowering const arg `N` fills in that synthetic param, so the impl header contains `<[(); N::<impl Trait>] as Trait>`;
3. then instantiating this header with the impl's args causing a param/arg mismatch and ICE.

This PR uses infer tys for synthetic params. Although this will emit the error in `ItemCtxt` because infer tys are not allowed here. I think that is reasonable, because `N` omits the synthetic parameter, though we cannot write the ty explicitly anywhere.

Fixes rust-lang#155834
rust-bors Bot pushed a commit that referenced this pull request Jun 27, 2026
Rollup of 6 pull requests

Successful merges:

 - #158234 (Cross-referencing tuple_trait tracking issue, source and the Unstable Book)
 - #157625 (Use infer tys for synthetic params when lowering const paths point to fns)
 - #158306 (tests: modify s390x vector test to be robust to instruction scheduling)
 - #158431 (More lint cleanups)
 - #158452 (Add missing links in integer docs)
 - #158472 (Add regression test for unexpected pointer dereference issue)
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jun 27, 2026
Use infer tys for synthetic params when lowering const paths point to fns

```rust
#![feature(min_generic_const_args)]

trait Trait {}
impl<'t> Trait for [(); N] {}
fn N(arg: impl Trait) {}
```

1. `arg: impl Trait` implies a synthetic param `<impl Trait>` and the obligation `_: Trait`;
2. when matching `impl Trait for [(); N]`, lowering const arg `N` fills in that synthetic param, so the impl header contains `<[(); N::<impl Trait>] as Trait>`;
3. then instantiating this header with the impl's args causing a param/arg mismatch and ICE.

This PR uses infer tys for synthetic params. Although this will emit the error in `ItemCtxt` because infer tys are not allowed here. I think that is reasonable, because `N` omits the synthetic parameter, though we cannot write the ty explicitly anywhere.

Fixes rust-lang#155834
rust-bors Bot pushed a commit that referenced this pull request Jun 27, 2026
…uwer

Rollup of 13 pull requests

Successful merges:

 - #157871 ([rustdoc] Update `doc_cfg` hide/show syntax)
 - #158234 (Cross-referencing tuple_trait tracking issue, source and the Unstable Book)
 - #158480 (add smoketest for std::net::hostname)
 - #157625 (Use infer tys for synthetic params when lowering const paths point to fns)
 - #158290 (add crashtests [1/N])
 - #158306 (tests: modify s390x vector test to be robust to instruction scheduling)
 - #158313 (Move `check_target_feature` into the attribute parser)
 - #158431 (More lint cleanups)
 - #158452 (Add missing links in integer docs)
 - #158467 (Add proc macro for unused assignments and corresponding test)
 - #158472 (Add regression test for unexpected pointer dereference issue)
 - #158475 (Fix doc comment on get_debug_as_hex.)
 - #158476 (Fix doc comment on FormattingOptions::new().)
rust-bors Bot pushed a commit that referenced this pull request Jun 27, 2026
…uwer

Rollup of 13 pull requests

Successful merges:

 - #157871 ([rustdoc] Update `doc_cfg` hide/show syntax)
 - #158234 (Cross-referencing tuple_trait tracking issue, source and the Unstable Book)
 - #158480 (add smoketest for std::net::hostname)
 - #157625 (Use infer tys for synthetic params when lowering const paths point to fns)
 - #158290 (add crashtests [1/N])
 - #158306 (tests: modify s390x vector test to be robust to instruction scheduling)
 - #158313 (Move `check_target_feature` into the attribute parser)
 - #158431 (More lint cleanups)
 - #158452 (Add missing links in integer docs)
 - #158467 (Add proc macro for unused assignments and corresponding test)
 - #158472 (Add regression test for unexpected pointer dereference issue)
 - #158475 (Fix doc comment on get_debug_as_hex.)
 - #158476 (Fix doc comment on FormattingOptions::new().)
rust-bors Bot pushed a commit that referenced this pull request Jun 27, 2026
…uwer

Rollup of 13 pull requests

Successful merges:

 - #157871 ([rustdoc] Update `doc_cfg` hide/show syntax)
 - #158234 (Cross-referencing tuple_trait tracking issue, source and the Unstable Book)
 - #158480 (add smoketest for std::net::hostname)
 - #157625 (Use infer tys for synthetic params when lowering const paths point to fns)
 - #158290 (add crashtests [1/N])
 - #158306 (tests: modify s390x vector test to be robust to instruction scheduling)
 - #158313 (Move `check_target_feature` into the attribute parser)
 - #158431 (More lint cleanups)
 - #158452 (Add missing links in integer docs)
 - #158467 (Add proc macro for unused assignments and corresponding test)
 - #158472 (Add regression test for unexpected pointer dereference issue)
 - #158475 (Fix doc comment on get_debug_as_hex.)
 - #158476 (Fix doc comment on FormattingOptions::new().)
rust-bors Bot pushed a commit that referenced this pull request Jun 27, 2026
…uwer

Rollup of 13 pull requests

Successful merges:

 - #157871 ([rustdoc] Update `doc_cfg` hide/show syntax)
 - #158234 (Cross-referencing tuple_trait tracking issue, source and the Unstable Book)
 - #158480 (add smoketest for std::net::hostname)
 - #157625 (Use infer tys for synthetic params when lowering const paths point to fns)
 - #158290 (add crashtests [1/N])
 - #158306 (tests: modify s390x vector test to be robust to instruction scheduling)
 - #158313 (Move `check_target_feature` into the attribute parser)
 - #158431 (More lint cleanups)
 - #158452 (Add missing links in integer docs)
 - #158467 (Add proc macro for unused assignments and corresponding test)
 - #158472 (Add regression test for unexpected pointer dereference issue)
 - #158475 (Fix doc comment on get_debug_as_hex.)
 - #158476 (Fix doc comment on FormattingOptions::new().)
@rust-bors rust-bors Bot merged commit ad69585 into rust-lang:main Jun 27, 2026
13 checks passed
@rustbot rustbot added this to the 1.98.0 milestone Jun 27, 2026
rust-timer added a commit that referenced this pull request Jun 27, 2026
Rollup merge of #157625 - mu001999:fix-155834, r=JohnTitor

Use infer tys for synthetic params when lowering const paths point to fns

```rust
#![feature(min_generic_const_args)]

trait Trait {}
impl<'t> Trait for [(); N] {}
fn N(arg: impl Trait) {}
```

1. `arg: impl Trait` implies a synthetic param `<impl Trait>` and the obligation `_: Trait`;
2. when matching `impl Trait for [(); N]`, lowering const arg `N` fills in that synthetic param, so the impl header contains `<[(); N::<impl Trait>] as Trait>`;
3. then instantiating this header with the impl's args causing a param/arg mismatch and ICE.

This PR uses infer tys for synthetic params. Although this will emit the error in `ItemCtxt` because infer tys are not allowed here. I think that is reasonable, because `N` omits the synthetic parameter, though we cannot write the ty explicitly anywhere.

Fixes #155834
@JonathanBrouwer

JonathanBrouwer commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

@rust-timer build 0ce5a1c
Perf run for #158487

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (0ce5a1c): comparison URL.

Overall result: no relevant changes - no action needed

Benchmarking means the PR may be perf-sensitive. Consider adding rollup=never if this change is not fit for rolling up.

@rustbot label: -S-waiting-on-perf -perf-regression

Instruction count

This perf run didn't have relevant results for this metric.

Max RSS (memory usage)

Results (primary 9.4%, secondary 6.6%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
9.4% [9.4%, 9.4%] 1
Regressions ❌
(secondary)
6.6% [6.4%, 6.7%] 2
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 9.4% [9.4%, 9.4%] 1

Cycles

Results (secondary -2.7%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.7% [-3.2%, -2.2%] 2
All ❌✅ (primary) - - 0

Binary size

This perf run didn't have relevant results for this metric.

Bootstrap: 485.171s -> 486.984s (0.37%)
Artifact size: 393.14 MiB -> 393.13 MiB (-0.00%)

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.

[ICE]: expected type for impl Trait .. but found Lifetime ..

6 participants