Skip to content
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//@ edition:2021
// Regression test for #125805.
// ICE when using `offset_of!` on a field whose type is a bare trait object
// with a missing lifetime parameter.

trait X<'a> {}

use std::mem::offset_of;

struct T {
y: X,
//~^ ERROR missing lifetime specifier [E0106]
//~| ERROR expected a type, found a trait [E0782]
}

fn other() {
offset_of!(T, y);
}

fn main() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
error[E0106]: missing lifetime specifier
--> $DIR/offset-of-unsized-trait-object-missing-lifetime.rs:11:8
|
LL | y: X,
| ^ expected named lifetime parameter
|
help: consider introducing a named lifetime parameter
|
LL ~ struct T<'a> {
LL ~ y: X<'a>,
|

error[E0782]: expected a type, found a trait
--> $DIR/offset-of-unsized-trait-object-missing-lifetime.rs:11:8
|
LL | y: X,
| ^
|
help: you can add the `dyn` keyword if you want a trait object
|
LL | y: dyn X,
| +++

error: aborting due to 2 previous errors

Some errors have detailed explanations: E0106, E0782.
For more information about an error, try `rustc --explain E0106`.
Loading