summaryrefslogtreecommitdiffstats
path: root/tests/ui/offset-of
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/offset-of')
-rw-r--r--tests/ui/offset-of/offset-of-dst-field.rs2
-rw-r--r--tests/ui/offset-of/offset-of-dst-field.stderr41
-rw-r--r--tests/ui/offset-of/offset-of-must-use.rs9
-rw-r--r--tests/ui/offset-of/offset-of-must-use.stderr16
-rw-r--r--tests/ui/offset-of/offset-of-output-type.stderr20
-rw-r--r--tests/ui/offset-of/offset-of-tuple-nested.rs32
-rw-r--r--tests/ui/offset-of/offset-of-tuple.rs54
-rw-r--r--tests/ui/offset-of/offset-of-tuple.stderr226
-rw-r--r--tests/ui/offset-of/offset-of-unsized.rs16
9 files changed, 385 insertions, 31 deletions
diff --git a/tests/ui/offset-of/offset-of-dst-field.rs b/tests/ui/offset-of/offset-of-dst-field.rs
index 3b8dc0b84..e393b159e 100644
--- a/tests/ui/offset-of/offset-of-dst-field.rs
+++ b/tests/ui/offset-of/offset-of-dst-field.rs
@@ -36,6 +36,8 @@ fn main() {
offset_of!(Alpha, z); //~ ERROR the size for values of type
offset_of!(Beta, z); //~ ERROR the size for values of type
offset_of!(Gamma, z); //~ ERROR the size for values of type
+ offset_of!((u8, dyn Trait), 0); // ok
+ offset_of!((u8, dyn Trait), 1); //~ ERROR the size for values of type
}
fn delta() {
diff --git a/tests/ui/offset-of/offset-of-dst-field.stderr b/tests/ui/offset-of/offset-of-dst-field.stderr
index 128c783d5..658678dc4 100644
--- a/tests/ui/offset-of/offset-of-dst-field.stderr
+++ b/tests/ui/offset-of/offset-of-dst-field.stderr
@@ -25,26 +25,17 @@ LL | offset_of!(Gamma, z);
= help: the trait `Sized` is not implemented for `Extern`
= note: this error originates in the macro `offset_of` (in Nightly builds, run with -Z macro-backtrace for more info)
-error[E0277]: the size for values of type `Extern` cannot be known at compilation time
- --> $DIR/offset-of-dst-field.rs:43:5
- |
-LL | offset_of!(Delta<Extern>, z);
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
- |
- = help: the trait `Sized` is not implemented for `Extern`
- = note: this error originates in the macro `offset_of` (in Nightly builds, run with -Z macro-backtrace for more info)
-
error[E0277]: the size for values of type `dyn Trait` cannot be known at compilation time
- --> $DIR/offset-of-dst-field.rs:44:5
+ --> $DIR/offset-of-dst-field.rs:40:5
|
-LL | offset_of!(Delta<dyn Trait>, z);
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
+LL | offset_of!((u8, dyn Trait), 1);
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
|
= help: the trait `Sized` is not implemented for `dyn Trait`
= note: this error originates in the macro `offset_of` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
- --> $DIR/offset-of-dst-field.rs:42:5
+ --> $DIR/offset-of-dst-field.rs:44:5
|
LL | offset_of!(Delta<Alpha>, z);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
@@ -57,11 +48,29 @@ LL | struct Alpha {
| ^^^^^
= note: this error originates in the macro `offset_of` (in Nightly builds, run with -Z macro-backtrace for more info)
+error[E0277]: the size for values of type `Extern` cannot be known at compilation time
+ --> $DIR/offset-of-dst-field.rs:45:5
+ |
+LL | offset_of!(Delta<Extern>, z);
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
+ |
+ = help: the trait `Sized` is not implemented for `Extern`
+ = note: this error originates in the macro `offset_of` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error[E0277]: the size for values of type `dyn Trait` cannot be known at compilation time
+ --> $DIR/offset-of-dst-field.rs:46:5
+ |
+LL | offset_of!(Delta<dyn Trait>, z);
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
+ |
+ = help: the trait `Sized` is not implemented for `dyn Trait`
+ = note: this error originates in the macro `offset_of` (in Nightly builds, run with -Z macro-backtrace for more info)
+
error[E0277]: the size for values of type `T` cannot be known at compilation time
- --> $DIR/offset-of-dst-field.rs:48:5
+ --> $DIR/offset-of-dst-field.rs:50:5
|
LL | fn generic_with_maybe_sized<T: ?Sized>() -> usize {
- | - this type parameter needs to be `std::marker::Sized`
+ | - this type parameter needs to be `Sized`
LL | offset_of!(Delta<T>, z)
| ^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
|
@@ -72,6 +81,6 @@ LL - fn generic_with_maybe_sized<T: ?Sized>() -> usize {
LL + fn generic_with_maybe_sized<T>() -> usize {
|
-error: aborting due to 7 previous errors
+error: aborting due to 8 previous errors
For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/offset-of/offset-of-must-use.rs b/tests/ui/offset-of/offset-of-must-use.rs
new file mode 100644
index 000000000..e30145d7a
--- /dev/null
+++ b/tests/ui/offset-of/offset-of-must-use.rs
@@ -0,0 +1,9 @@
+// check-pass
+
+#![feature(offset_of)]
+#![warn(unused)]
+
+fn main() {
+ core::mem::offset_of!((String,), 0);
+ //~^ WARN unused return value of `must_use` that must be used
+}
diff --git a/tests/ui/offset-of/offset-of-must-use.stderr b/tests/ui/offset-of/offset-of-must-use.stderr
new file mode 100644
index 000000000..5fe387a72
--- /dev/null
+++ b/tests/ui/offset-of/offset-of-must-use.stderr
@@ -0,0 +1,16 @@
+warning: unused return value of `must_use` that must be used
+ --> $DIR/offset-of-must-use.rs:7:5
+ |
+LL | core::mem::offset_of!((String,), 0);
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+note: the lint level is defined here
+ --> $DIR/offset-of-must-use.rs:4:9
+ |
+LL | #![warn(unused)]
+ | ^^^^^^
+ = note: `#[warn(unused_must_use)]` implied by `#[warn(unused)]`
+ = note: this warning originates in the macro `core::mem::offset_of` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+warning: 1 warning emitted
+
diff --git a/tests/ui/offset-of/offset-of-output-type.stderr b/tests/ui/offset-of/offset-of-output-type.stderr
index 6f8c94750..6133f3263 100644
--- a/tests/ui/offset-of/offset-of-output-type.stderr
+++ b/tests/ui/offset-of/offset-of-output-type.stderr
@@ -2,9 +2,7 @@ error[E0308]: mismatched types
--> $DIR/offset-of-output-type.rs:12:17
|
LL | let _: u8 = offset_of!(S, v);
- | -- ^^^^^^^^^^^^^^^^ expected `u8`, found `usize`
- | |
- | expected due to this
+ | ^^^^^^^^^^^^^^^^ expected `u8`, found `usize`
|
= note: this error originates in the macro `offset_of` (in Nightly builds, run with -Z macro-backtrace for more info)
@@ -12,9 +10,7 @@ error[E0308]: mismatched types
--> $DIR/offset-of-output-type.rs:13:18
|
LL | let _: u16 = offset_of!(S, v);
- | --- ^^^^^^^^^^^^^^^^ expected `u16`, found `usize`
- | |
- | expected due to this
+ | ^^^^^^^^^^^^^^^^ expected `u16`, found `usize`
|
= note: this error originates in the macro `offset_of` (in Nightly builds, run with -Z macro-backtrace for more info)
@@ -22,9 +18,7 @@ error[E0308]: mismatched types
--> $DIR/offset-of-output-type.rs:14:18
|
LL | let _: u32 = offset_of!(S, v);
- | --- ^^^^^^^^^^^^^^^^ expected `u32`, found `usize`
- | |
- | expected due to this
+ | ^^^^^^^^^^^^^^^^ expected `u32`, found `usize`
|
= note: this error originates in the macro `offset_of` (in Nightly builds, run with -Z macro-backtrace for more info)
@@ -32,9 +26,7 @@ error[E0308]: mismatched types
--> $DIR/offset-of-output-type.rs:15:18
|
LL | let _: u64 = offset_of!(S, v);
- | --- ^^^^^^^^^^^^^^^^ expected `u64`, found `usize`
- | |
- | expected due to this
+ | ^^^^^^^^^^^^^^^^ expected `u64`, found `usize`
|
= note: this error originates in the macro `offset_of` (in Nightly builds, run with -Z macro-backtrace for more info)
@@ -42,9 +34,7 @@ error[E0308]: mismatched types
--> $DIR/offset-of-output-type.rs:16:20
|
LL | let _: isize = offset_of!(S, v);
- | ----- ^^^^^^^^^^^^^^^^ expected `isize`, found `usize`
- | |
- | expected due to this
+ | ^^^^^^^^^^^^^^^^ expected `isize`, found `usize`
|
= note: this error originates in the macro `offset_of` (in Nightly builds, run with -Z macro-backtrace for more info)
diff --git a/tests/ui/offset-of/offset-of-tuple-nested.rs b/tests/ui/offset-of/offset-of-tuple-nested.rs
new file mode 100644
index 000000000..00fbb6bf8
--- /dev/null
+++ b/tests/ui/offset-of/offset-of-tuple-nested.rs
@@ -0,0 +1,32 @@
+// run-pass
+// Test for issue #112204 -- make sure this goes through the entire compilation pipeline,
+// similar to why `offset-of-unsized.rs` is also build-pass
+
+#![feature(offset_of)]
+#![feature(builtin_syntax)]
+
+use std::mem::offset_of;
+
+type ComplexTup = ((u8, (u8, (u8, u16), u8)), (u8, u32, u16));
+
+fn main() {
+ println!("{}", offset_of!(((u8, u8), u8), 0));
+ println!("{}", offset_of!(((u8, u8), u8), 1));
+ println!("{}", offset_of!(((u8, (u8, u8)), (u8, u8, u8)), 0.1.0));
+
+ // Complex case: do all combinations of spacings because the spacing determines what gets
+ // sent to the lexer.
+ println!("{}", offset_of!(ComplexTup, 0.1.1.1));
+ println!("{}", builtin # offset_of(ComplexTup, 0. 1.1.1));
+ println!("{}", offset_of!(ComplexTup, 0 . 1.1.1));
+ println!("{}", offset_of!(ComplexTup, 0 .1.1.1));
+ println!("{}", offset_of!(ComplexTup, 0.1 .1.1));
+ println!("{}", offset_of!(ComplexTup, 0.1 . 1.1));
+ println!("{}", offset_of!(ComplexTup, 0.1. 1.1));
+ println!("{}", builtin # offset_of(ComplexTup, 0.1.1. 1));
+ println!("{}", offset_of!(ComplexTup, 0.1.1 . 1));
+ println!("{}", offset_of!(ComplexTup, 0.1.1 .1));
+
+ println!("{}", offset_of!(((u8, u16), (u32, u16, u8)), 0.0));
+ println!("{}", offset_of!(((u8, u16), (u32, u16, u8)), 1.2));
+}
diff --git a/tests/ui/offset-of/offset-of-tuple.rs b/tests/ui/offset-of/offset-of-tuple.rs
new file mode 100644
index 000000000..e31b037ee
--- /dev/null
+++ b/tests/ui/offset-of/offset-of-tuple.rs
@@ -0,0 +1,54 @@
+#![feature(offset_of)]
+#![feature(builtin_syntax)]
+
+use std::mem::offset_of;
+
+fn main() {
+ offset_of!((u8, u8), _0); //~ ERROR no field `_0`
+ offset_of!((u8, u8), 01); //~ ERROR no field `01`
+ offset_of!((u8, u8), 1e2); //~ ERROR no field `1e2`
+ offset_of!((u8, u8), 1_u8); //~ ERROR no field `1_`
+ //~| ERROR suffixes on a tuple index
+ offset_of!((u8, u8), +1); //~ ERROR no rules expected
+ offset_of!((u8, u8), -1); //~ ERROR no rules expected
+ offset_of!((u8, u8), 1.); //~ ERROR expected identifier, found `)`
+ offset_of!((u8, u8), 1 .); //~ ERROR unexpected end of macro
+ builtin # offset_of((u8, u8), 1e2); //~ ERROR no field `1e2`
+ builtin # offset_of((u8, u8), _0); //~ ERROR no field `_0`
+ builtin # offset_of((u8, u8), 01); //~ ERROR no field `01`
+ builtin # offset_of((u8, u8), 1_u8); //~ ERROR no field `1_`
+ //~| ERROR suffixes on a tuple index
+ // We need to put these into curly braces, otherwise only one of the
+ // errors will be emitted and the others suppressed.
+ { builtin # offset_of((u8, u8), +1) }; //~ ERROR expected identifier, found `+`
+ { builtin # offset_of((u8, u8), 1.) }; //~ ERROR expected identifier, found `)`
+ { builtin # offset_of((u8, u8), 1 .) }; //~ ERROR expected identifier, found `)`
+}
+
+type ComplexTup = ((u8, (u8, u8)), u8);
+
+fn nested() {
+ offset_of!(((u8, u16), (u32, u16, u8)), 0.2); //~ ERROR no field `2`
+ offset_of!(((u8, u16), (u32, u16, u8)), 1.2);
+ offset_of!(((u8, u16), (u32, u16, u8)), 1.2.0); //~ ERROR no field `0`
+
+ // All combinations of spaces (this sends different tokens to the parser)
+ offset_of!(ComplexTup, 0.0.1.); //~ ERROR expected identifier
+ offset_of!(ComplexTup, 0 .0.1.); //~ ERROR unexpected end of macro
+ offset_of!(ComplexTup, 0 . 0.1.); //~ ERROR unexpected end of macro
+ offset_of!(ComplexTup, 0. 0.1.); //~ ERROR no rules expected
+ offset_of!(ComplexTup, 0.0 .1.); //~ ERROR expected identifier, found `)`
+ offset_of!(ComplexTup, 0.0 . 1.); //~ ERROR expected identifier, found `)`
+ offset_of!(ComplexTup, 0.0. 1.); //~ ERROR expected identifier, found `)`
+
+ // Test for builtin too to ensure that the builtin syntax can also handle these cases
+ // We need to put these into curly braces, otherwise only one of the
+ // errors will be emitted and the others suppressed.
+ { builtin # offset_of(ComplexTup, 0.0.1.) }; //~ ERROR expected identifier, found `)`
+ { builtin # offset_of(ComplexTup, 0 .0.1.) }; //~ ERROR expected identifier, found `)`
+ { builtin # offset_of(ComplexTup, 0 . 0.1.) }; //~ ERROR expected identifier, found `)`
+ { builtin # offset_of(ComplexTup, 0. 0.1.) }; //~ ERROR expected identifier, found `)`
+ { builtin # offset_of(ComplexTup, 0.0 .1.) }; //~ ERROR expected identifier, found `)`
+ { builtin # offset_of(ComplexTup, 0.0 . 1.) }; //~ ERROR expected identifier, found `)`
+ { builtin # offset_of(ComplexTup, 0.0. 1.) }; //~ ERROR expected identifier, found `)`
+}
diff --git a/tests/ui/offset-of/offset-of-tuple.stderr b/tests/ui/offset-of/offset-of-tuple.stderr
new file mode 100644
index 000000000..ed9523458
--- /dev/null
+++ b/tests/ui/offset-of/offset-of-tuple.stderr
@@ -0,0 +1,226 @@
+error: suffixes on a tuple index are invalid
+ --> $DIR/offset-of-tuple.rs:19:35
+ |
+LL | builtin # offset_of((u8, u8), 1_u8);
+ | ^^^^ invalid suffix `u8`
+
+error: expected identifier, found `+`
+ --> $DIR/offset-of-tuple.rs:23:37
+ |
+LL | { builtin # offset_of((u8, u8), +1) };
+ | ^ expected identifier
+
+error: expected identifier, found `)`
+ --> $DIR/offset-of-tuple.rs:24:39
+ |
+LL | { builtin # offset_of((u8, u8), 1.) };
+ | ^ expected identifier
+
+error: expected identifier, found `)`
+ --> $DIR/offset-of-tuple.rs:25:40
+ |
+LL | { builtin # offset_of((u8, u8), 1 .) };
+ | ^ expected identifier
+
+error: expected identifier, found `)`
+ --> $DIR/offset-of-tuple.rs:47:45
+ |
+LL | { builtin # offset_of(ComplexTup, 0.0.1.) };
+ | ^ expected identifier
+
+error: expected identifier, found `)`
+ --> $DIR/offset-of-tuple.rs:48:46
+ |
+LL | { builtin # offset_of(ComplexTup, 0 .0.1.) };
+ | ^ expected identifier
+
+error: expected identifier, found `)`
+ --> $DIR/offset-of-tuple.rs:49:47
+ |
+LL | { builtin # offset_of(ComplexTup, 0 . 0.1.) };
+ | ^ expected identifier
+
+error: expected identifier, found `)`
+ --> $DIR/offset-of-tuple.rs:50:46
+ |
+LL | { builtin # offset_of(ComplexTup, 0. 0.1.) };
+ | ^ expected identifier
+
+error: expected identifier, found `)`
+ --> $DIR/offset-of-tuple.rs:51:46
+ |
+LL | { builtin # offset_of(ComplexTup, 0.0 .1.) };
+ | ^ expected identifier
+
+error: expected identifier, found `)`
+ --> $DIR/offset-of-tuple.rs:52:47
+ |
+LL | { builtin # offset_of(ComplexTup, 0.0 . 1.) };
+ | ^ expected identifier
+
+error: expected identifier, found `)`
+ --> $DIR/offset-of-tuple.rs:53:46
+ |
+LL | { builtin # offset_of(ComplexTup, 0.0. 1.) };
+ | ^ expected identifier
+
+error: suffixes on a tuple index are invalid
+ --> $DIR/offset-of-tuple.rs:10:26
+ |
+LL | offset_of!((u8, u8), 1_u8);
+ | ^^^^ invalid suffix `u8`
+
+error: no rules expected the token `1`
+ --> $DIR/offset-of-tuple.rs:12:27
+ |
+LL | offset_of!((u8, u8), +1);
+ | ^ no rules expected this token in macro call
+ |
+ = note: while trying to match sequence start
+
+error: no rules expected the token `1`
+ --> $DIR/offset-of-tuple.rs:13:27
+ |
+LL | offset_of!((u8, u8), -1);
+ | ^ no rules expected this token in macro call
+ |
+ = note: while trying to match sequence start
+
+error: expected identifier, found `)`
+ --> $DIR/offset-of-tuple.rs:14:5
+ |
+LL | offset_of!((u8, u8), 1.);
+ | ^^^^^^^^^^^^^^^^^^^^^^^^ expected identifier
+ |
+ = note: this error originates in the macro `offset_of` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: unexpected end of macro invocation
+ --> $DIR/offset-of-tuple.rs:15:29
+ |
+LL | offset_of!((u8, u8), 1 .);
+ | ^ missing tokens in macro arguments
+ |
+note: while trying to match meta-variable `$fields:tt`
+ --> $SRC_DIR/core/src/mem/mod.rs:LL:COL
+
+error: expected identifier, found `)`
+ --> $DIR/offset-of-tuple.rs:36:5
+ |
+LL | offset_of!(ComplexTup, 0.0.1.);
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected identifier
+ |
+ = note: this error originates in the macro `offset_of` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: unexpected end of macro invocation
+ --> $DIR/offset-of-tuple.rs:37:35
+ |
+LL | offset_of!(ComplexTup, 0 .0.1.);
+ | ^ missing tokens in macro arguments
+ |
+note: while trying to match meta-variable `$fields:tt`
+ --> $SRC_DIR/core/src/mem/mod.rs:LL:COL
+
+error: unexpected end of macro invocation
+ --> $DIR/offset-of-tuple.rs:38:36
+ |
+LL | offset_of!(ComplexTup, 0 . 0.1.);
+ | ^ missing tokens in macro arguments
+ |
+note: while trying to match meta-variable `$fields:tt`
+ --> $SRC_DIR/core/src/mem/mod.rs:LL:COL
+
+error: no rules expected the token `0.1`
+ --> $DIR/offset-of-tuple.rs:39:31
+ |
+LL | offset_of!(ComplexTup, 0. 0.1.);
+ | ^^^ no rules expected this token in macro call
+ |
+ = note: while trying to match sequence start
+
+error: expected identifier, found `)`
+ --> $DIR/offset-of-tuple.rs:40:5
+ |
+LL | offset_of!(ComplexTup, 0.0 .1.);
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected identifier
+ |
+ = note: this error originates in the macro `offset_of` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: expected identifier, found `)`
+ --> $DIR/offset-of-tuple.rs:41:5
+ |
+LL | offset_of!(ComplexTup, 0.0 . 1.);
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected identifier
+ |
+ = note: this error originates in the macro `offset_of` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: expected identifier, found `)`
+ --> $DIR/offset-of-tuple.rs:42:5
+ |
+LL | offset_of!(ComplexTup, 0.0. 1.);
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected identifier
+ |
+ = note: this error originates in the macro `offset_of` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error[E0609]: no field `_0` on type `(u8, u8)`
+ --> $DIR/offset-of-tuple.rs:7:26
+ |
+LL | offset_of!((u8, u8), _0);
+ | ^^
+
+error[E0609]: no field `01` on type `(u8, u8)`
+ --> $DIR/offset-of-tuple.rs:8:26
+ |
+LL | offset_of!((u8, u8), 01);
+ | ^^
+
+error[E0609]: no field `1e2` on type `(u8, u8)`
+ --> $DIR/offset-of-tuple.rs:9:26
+ |
+LL | offset_of!((u8, u8), 1e2);
+ | ^^^
+
+error[E0609]: no field `1_` on type `(u8, u8)`
+ --> $DIR/offset-of-tuple.rs:10:26
+ |
+LL | offset_of!((u8, u8), 1_u8);
+ | ^^^^
+
+error[E0609]: no field `1e2` on type `(u8, u8)`
+ --> $DIR/offset-of-tuple.rs:16:35
+ |
+LL | builtin # offset_of((u8, u8), 1e2);
+ | ^^^
+
+error[E0609]: no field `_0` on type `(u8, u8)`
+ --> $DIR/offset-of-tuple.rs:17:35
+ |
+LL | builtin # offset_of((u8, u8), _0);
+ | ^^
+
+error[E0609]: no field `01` on type `(u8, u8)`
+ --> $DIR/offset-of-tuple.rs:18:35
+ |
+LL | builtin # offset_of((u8, u8), 01);
+ | ^^
+
+error[E0609]: no field `1_` on type `(u8, u8)`
+ --> $DIR/offset-of-tuple.rs:19:35
+ |
+LL | builtin # offset_of((u8, u8), 1_u8);
+ | ^^^^
+
+error[E0609]: no field `2` on type `(u8, u16)`
+ --> $DIR/offset-of-tuple.rs:31:47
+ |
+LL | offset_of!(((u8, u16), (u32, u16, u8)), 0.2);
+ | ^
+
+error[E0609]: no field `0` on type `u8`
+ --> $DIR/offset-of-tuple.rs:33:49
+ |
+LL | offset_of!(((u8, u16), (u32, u16, u8)), 1.2.0);
+ | ^
+
+error: aborting due to 33 previous errors
+
+For more information about this error, try `rustc --explain E0609`.
diff --git a/tests/ui/offset-of/offset-of-unsized.rs b/tests/ui/offset-of/offset-of-unsized.rs
new file mode 100644
index 000000000..49c8328da
--- /dev/null
+++ b/tests/ui/offset-of/offset-of-unsized.rs
@@ -0,0 +1,16 @@
+// build-pass
+// regression test for #112051, not in `offset-of-dst` as the issue is in codegen,
+// and isn't triggered in the presence of typeck errors
+
+#![feature(offset_of)]
+
+struct S<T: ?Sized> {
+ a: u64,
+ b: T,
+}
+trait Tr {}
+
+fn main() {
+ let _a = core::mem::offset_of!(S<dyn Tr>, a);
+ let _b = core::mem::offset_of!((u64, dyn Tr), 0);
+}