Skip to content

Add regression test for #138891 (fresh type during canonicalization ICE)#154788

Closed
Herrtian wants to merge 1 commit intorust-lang:mainfrom
Herrtian:add-test-138891-fresh-type-ice
Closed

Add regression test for #138891 (fresh type during canonicalization ICE)#154788
Herrtian wants to merge 1 commit intorust-lang:mainfrom
Herrtian:add-test-138891-fresh-type-ice

Conversation

@Herrtian
Copy link
Copy Markdown

@Herrtian Herrtian commented Apr 3, 2026

Summary

Adds a regression test for #138891.

Using a trait alias with Self as a return type in a dyn context with extra generic arguments used to ICE with "encountered a fresh type during canonicalization". The compiler now correctly reports:

  • E0107: trait alias takes 0 generic arguments
  • associated type binding mentions Self

Test

tests/ui/traits/alias/ice-fresh-type-canonicalization-138891.rs

Closes #138891

…ization ICE)

This code used to ICE with "encountered a fresh type during
canonicalization" when using a trait alias with `Self` in a dyn
context with extra generic arguments. The compiler now correctly
reports errors without crashing.
@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 Apr 3, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 3, 2026

r? @petrochenkov

rustbot has assigned @petrochenkov.
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 69 candidates
  • Random selection from 10 candidates

@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 3, 2026

⚠️ Warning ⚠️

  • There are issue links (such as #123) in the commit messages of the following commits.
    Please move them to the PR description, to avoid spamming the issues with references to the commit, and so this bot can automatically canonicalize them to avoid issues with subtree.

@rust-log-analyzer
Copy link
Copy Markdown
Collaborator

The job aarch64-gnu-llvm-21-1 failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
##[endgroup]
Executing "/scripts/stage_2_test_set1.sh"
+ /scripts/stage_2_test_set1.sh
+ '[' 1 == 1 ']'
+ echo 'PR_CI_JOB set; skipping tidy'
+ SKIP_TIDY='--skip tidy'
+ ../x.py --stage 2 test --skip tidy --skip compiler --skip src
PR_CI_JOB set; skipping tidy
##[group]Building bootstrap
    Finished `dev` profile [unoptimized] target(s) in 0.04s
##[endgroup]
---
test [ui] tests/ui/zero-sized/zero-sized-btreemap-insert.rs ... ok

failures:

---- [ui] tests/ui/traits/alias/ice-fresh-type-canonicalization-138891.rs stdout ----
Saved the actual stderr to `/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/traits/alias/ice-fresh-type-canonicalization-138891/ice-fresh-type-canonicalization-138891.stderr`
diff of stderr:

1 error[E0107]: trait alias takes 0 generic arguments but 1 generic argument was supplied
-  --> $DIR/ice-fresh-type-canonicalization-138891.rs:9:20
-   |
+   --> $DIR/ice-fresh-type-canonicalization-138891.rs:9:20
+    |
4 LL | fn _f3<Fut>(a: dyn F<Fut>) {}
-   |                    ^----- help: remove the unnecessary generics
-   |                    |
-   |                    expected 0 generic arguments
-   |
+    |                    ^----- help: remove the unnecessary generics
---
+    |
18 LL | trait F = Fn() -> Self;
-   |                   ---- this binding mentions `Self`
- ...
+    |                   ---- this binding mentions `Self`
+ LL |
21 LL | fn _f3<Fut>(a: dyn F<Fut>) {}
-   |                ^^^^^^^^^^ contains a mention of `Self`
+    |                ^^^^^^^^^^ contains a mention of `Self`
23 
24 error: aborting due to 2 previous errors
25 

Note: some mismatched output was normalized before being compared
---
To only update this specific test, also pass `--test-args traits/alias/ice-fresh-type-canonicalization-138891.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/traits/alias/ice-fresh-type-canonicalization-138891.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/traits/alias/ice-fresh-type-canonicalization-138891" "-A" "unused" "-W" "unused_attributes" "-A" "internal_features" "-A" "incomplete_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers"
stdout: none
--- stderr -------------------------------
error[E0107]: trait alias takes 0 generic arguments but 1 generic argument was supplied
##[error]  --> /checkout/tests/ui/traits/alias/ice-fresh-type-canonicalization-138891.rs:9:20
   |
LL | fn _f3<Fut>(a: dyn F<Fut>) {}
   |                    ^----- help: remove the unnecessary generics
   |                    |
   |                    expected 0 generic arguments
   |
note: trait alias defined here, with 0 generic parameters
---
   |
LL | trait F = Fn() -> Self;
   |                   ---- this binding mentions `Self`
LL |
LL | fn _f3<Fut>(a: dyn F<Fut>) {}
   |                ^^^^^^^^^^ contains a mention of `Self`

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0107`.
------------------------------------------

@jieyouxu
Copy link
Copy Markdown
Member

jieyouxu commented Apr 4, 2026

Hi, you've opened 10 PRs in very quick succession, and looking at the PR descriptions and some of the tests, I have some doubts regarding if the contributions are adaqutely self-reviewed. Recently, we have seen waves of automated contributions that are not adequately self-reviewed, which is why we are being more cautious.

In my capacity as a venue moderator, I am requesting that you respond to reviewer questions to

I am hereby placing a temporary embargo on creation of new PRs from you before the PRs mentioned above are responded to, and the reviewers develop more confidence that you are self-reviewing and understand your contributions. The temporary embargo will be lifted if the reviewers have sufficient confidence in your contributions.

Before the temporary embargo is lifted, any further PRs from your account will be closed. If new PRs continue to be raised from your account before so, further moderation action may be applied.

I am closing and locking this PR before the review discussions in the PRs linked above are settled and the temporary embargo lifted. If the temporary embargo is lifted, I will unlock and reopen this PR.

@jieyouxu jieyouxu closed this Apr 4, 2026
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 4, 2026
@rust-lang rust-lang locked and limited conversation to collaborators Apr 4, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

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: encountered a fresh type during canonicalization

5 participants