Skip to content

Commit bd32c4c

Browse files
committed
Convert a span_bug to a span_delayed_bug.
PR #121208 converted this from a `span_delayed_bug` to a `span_bug` because nothing in the test suite caused execution to hit this path. But now fuzzing has found a test case that does hit it. So this commit converts it back to `span_delayed_bug` and adds the relevant test. Fixes #126385.
1 parent e794b0f commit bd32c4c

File tree

4 files changed

+49
-13
lines changed

4 files changed

+49
-13
lines changed

compiler/rustc_borrowck/src/diagnostics/region_name.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -628,9 +628,7 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
628628
| GenericArgKind::Const(_),
629629
_,
630630
) => {
631-
// This was previously a `span_delayed_bug` and could be
632-
// reached by the test for #82126, but no longer.
633-
self.dcx().span_bug(
631+
self.dcx().span_delayed_bug(
634632
hir_arg.span(),
635633
format!("unmatched arg and hir arg: found {kind:?} vs {hir_arg:?}"),
636634
);

tests/crashes/126385.rs

-10
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// This test was triggering a `span_bug` crash, which was then fixed by
2+
// downgrading it to a `span_delayed_bug`.
3+
4+
pub struct MyStruct<'field> {
5+
field: &'field [u32],
6+
}
7+
8+
impl MyStruct<'_> {
9+
pub fn f(field: &[u32]) -> Self<u32> { //~ ERROR type arguments are not allowed on self type
10+
Self { field } //~ ERROR lifetime may not live long enough
11+
}
12+
}
13+
14+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
error[E0109]: type arguments are not allowed on self type
2+
--> $DIR/unmatched-arg-and-hir-arg-issue-126385.rs:9:37
3+
|
4+
LL | pub fn f(field: &[u32]) -> Self<u32> {
5+
| ---- ^^^ type argument not allowed
6+
| |
7+
| not allowed on self type
8+
|
9+
note: `Self` is of type `MyStruct<'_>`
10+
--> $DIR/unmatched-arg-and-hir-arg-issue-126385.rs:4:12
11+
|
12+
LL | pub struct MyStruct<'field> {
13+
| ^^^^^^^^ `Self` corresponds to this type
14+
...
15+
LL | impl MyStruct<'_> {
16+
| ----------------- `Self` is on type `MyStruct` in this `impl`
17+
help: the `Self` type doesn't accept type parameters, use the concrete type's name `MyStruct` instead if you want to specify its type parameters
18+
|
19+
LL | pub fn f(field: &[u32]) -> MyStruct<u32> {
20+
| ~~~~~~~~
21+
22+
error: lifetime may not live long enough
23+
--> $DIR/unmatched-arg-and-hir-arg-issue-126385.rs:10:9
24+
|
25+
LL | pub fn f(field: &[u32]) -> Self<u32> {
26+
| - --------- return type is MyStruct<'2>
27+
| |
28+
| let's call the lifetime of this reference `'1`
29+
LL | Self { field }
30+
| ^^^^^^^^^^^^^^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
31+
32+
error: aborting due to 2 previous errors
33+
34+
For more information about this error, try `rustc --explain E0109`.

0 commit comments

Comments
 (0)