Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert a span_bug to a span_delayed_bug. #126570

Merged
merged 1 commit into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions compiler/rustc_borrowck/src/diagnostics/region_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -628,9 +628,7 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
| GenericArgKind::Const(_),
_,
) => {
// This was previously a `span_delayed_bug` and could be
// reached by the test for #82126, but no longer.
self.dcx().span_bug(
self.dcx().span_delayed_bug(
hir_arg.span(),
format!("unmatched arg and hir arg: found {kind:?} vs {hir_arg:?}"),
);
Expand Down
10 changes: 0 additions & 10 deletions tests/crashes/126385.rs

This file was deleted.

14 changes: 14 additions & 0 deletions tests/ui/borrowck/unmatched-arg-and-hir-arg-issue-126385.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// This test was triggering a `span_bug` crash, which was then fixed by
// downgrading it to a `span_delayed_bug`.

pub struct MyStruct<'field> {
field: &'field [u32],
}

impl MyStruct<'_> {
pub fn f(field: &[u32]) -> Self<u32> { //~ ERROR type arguments are not allowed on self type
Self { field } //~ ERROR lifetime may not live long enough
}
}

fn main() {}
34 changes: 34 additions & 0 deletions tests/ui/borrowck/unmatched-arg-and-hir-arg-issue-126385.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
error[E0109]: type arguments are not allowed on self type
--> $DIR/unmatched-arg-and-hir-arg-issue-126385.rs:9:37
|
LL | pub fn f(field: &[u32]) -> Self<u32> {
| ---- ^^^ type argument not allowed
| |
| not allowed on self type
|
note: `Self` is of type `MyStruct<'_>`
--> $DIR/unmatched-arg-and-hir-arg-issue-126385.rs:4:12
|
LL | pub struct MyStruct<'field> {
| ^^^^^^^^ `Self` corresponds to this type
...
LL | impl MyStruct<'_> {
| ----------------- `Self` is on type `MyStruct` in this `impl`
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
|
LL | pub fn f(field: &[u32]) -> MyStruct<u32> {
| ~~~~~~~~

error: lifetime may not live long enough
--> $DIR/unmatched-arg-and-hir-arg-issue-126385.rs:10:9
|
LL | pub fn f(field: &[u32]) -> Self<u32> {
| - --------- return type is MyStruct<'2>
| |
| let's call the lifetime of this reference `'1`
LL | Self { field }
| ^^^^^^^^^^^^^^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`

error: aborting due to 2 previous errors

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