about summary refs log tree commit diff
path: root/compiler/rustc_codegen_gcc/src
diff options
context:
space:
mode:
authorTrevor Gross <t.gross35@gmail.com>2025-09-05 01:53:22 -0400
committerGitHub <noreply@github.com>2025-09-05 01:53:22 -0400
commit8ff60a630222e788f899bf0c997d8112fc961ee0 (patch)
tree4585ebf94d8ccb52a1a6531a48788b85776da307 /compiler/rustc_codegen_gcc/src
parent7fc547c4f21577a715e113f40c51ab0018191783 (diff)
parent4ca8078d37c53ee4ff8fb32b4453b915116f25b8 (diff)
downloadrust-8ff60a630222e788f899bf0c997d8112fc961ee0.tar.gz
rust-8ff60a630222e788f899bf0c997d8112fc961ee0.zip
Rollup merge of #146217 - lukas-code:suggest-new-ice, r=compiler-errors
fix ICE when suggesting `::new`

fixes https://github.com/rust-lang/rust/issues/146174

This code suggests to write `Foo::new(...)` when the user writes `Foo(...)` or `Foo { ... }` and the constructor is private, where `new` is some associated function that returns `Self`.

When checking that the return type of `new` is `Self`, we need to instantiate the parameters of `new` with infer vars, so we don't end up with a type like `Box<$param(0)>` in a context that doesn't have any parameters. But then we can't use `normalize_erasing_late_bound_regions` anymore because that goes though a query that can't deal with infer vars.

Since this is diagnostic-only code that is supposed to check for exactly `-> Self`, I think it's fine to just skip normalizing here, especially since The Correct Way<sup>TM</sup> would involve a probe and make this code even more complicated.

Also, the code here does almost the same thing, and these suggestions can probably be unified in the future: https://github.com/rust-lang/rust/blob/4ca8078d37c53ee4ff8fb32b4453b915116f25b8/compiler/rustc_hir_typeck/src/method/suggest.rs#L2123-L2129

r? ````@compiler-errors````
cc ````@Qelxiros```` -- this should unblock https://github.com/rust-lang/rust/pull/144420
Diffstat (limited to 'compiler/rustc_codegen_gcc/src')
0 files changed, 0 insertions, 0 deletions