Rollup merge of #154671 - jakubadamw:issue-127423, r=Kivooeo

Add a test for a past ICE when calling a const fn of an unresolved type with the wrong number of args

The ICE is fixed, but there needs to be a regression test for it.

Closes rust-lang/rust#127423.
This commit is contained in:
Jonathan Brouwer
2026-04-02 22:13:57 +02:00
committed by GitHub
2 changed files with 54 additions and 0 deletions

View File

@@ -0,0 +1,15 @@
//! Regression test for https://github.com/rust-lang/rust/issues/127423
#![allow(dead_code)]
const fn add(a: &'self isize) -> usize {
//~^ ERROR use of undeclared lifetime name `'self`
//~| ERROR lifetimes cannot use keyword names
Qux + y
//~^ ERROR cannot find value `Qux` in this scope
//~| ERROR cannot find value `y` in this scope
}
const ARR: [i32; add(1, 2)] = [5, 6, 7];
pub fn main() {}

View File

@@ -0,0 +1,39 @@
error: lifetimes cannot use keyword names
--> $DIR/ice-extra-args-fn-abi-issue-127423.rs:5:18
|
LL | const fn add(a: &'self isize) -> usize {
| ^^^^^
error[E0261]: use of undeclared lifetime name `'self`
--> $DIR/ice-extra-args-fn-abi-issue-127423.rs:5:18
|
LL | const fn add(a: &'self isize) -> usize {
| ^^^^^ undeclared lifetime
|
help: consider introducing lifetime `'self` here
|
LL | const fn add<'self>(a: &'self isize) -> usize {
| +++++++
error[E0425]: cannot find value `Qux` in this scope
--> $DIR/ice-extra-args-fn-abi-issue-127423.rs:8:5
|
LL | Qux + y
| ^^^ not found in this scope
error[E0425]: cannot find value `y` in this scope
--> $DIR/ice-extra-args-fn-abi-issue-127423.rs:8:11
|
LL | Qux + y
| ^
|
help: a local variable with a similar name exists
|
LL - Qux + y
LL + Qux + a
|
error: aborting due to 4 previous errors
Some errors have detailed explanations: E0261, E0425.
For more information about an error, try `rustc --explain E0261`.