use std::marker::PhantomData;
use std::arch::global_asm;
struct S<T>(PhantomData<T>);
impl<T> S<T> {
fn meow(&self) {
global_asm!("/* {} */", sym Self::meow);
}
}
This code should be forbidden because it uses a generic in global_asm!, which isn't meaningful.
Instead, the compiler became confused and was reporting errors about Sized.
error[E0277]: the size for values of type `T` cannot be known at compilation time
--> src/lib.rs:8:37
|
6 | impl<T> S<T> {
| - this type parameter needs to be `Sized`
7 | fn meow(&self) {
8 | global_asm!("/* {} */", sym Self::meow);
| ^^^^ doesn't have a size known at compile-time
|
note: required by an implicit `Sized` bound in `S`
--> src/lib.rs:4:10
|
4 | struct S<T>(PhantomData<T>);
| ^ required by the implicit `Sized` requirement on this type parameter in `S`
help: consider relaxing the implicit `Sized` restriction
|
4 | struct S<T: ?Sized>(PhantomData<T>);
| ++++++++
error[E0599]: the associated function or constant `meow` exists for struct `S<T>`, but its trait bounds were not satisfied
--> src/lib.rs:8:43
|
4 | struct S<T>(PhantomData<T>);
| ----------- associated function or constant `meow` not found for this struct
...
8 | global_asm!("/* {} */", sym Self::meow);
| ^^^^ associated function or constant cannot be called on `S<T>` due to unsatisfied trait bounds
|
note: trait bound `T: Sized` was not satisfied
--> src/lib.rs:6:6
|
6 | impl<T> S<T> {
| ^ ----
| |
| unsatisfied trait bound introduced here
help: consider relaxing the type parameter's implicit `Sized` bound
|
6 | impl<T: ?Sized> S<T> {
| ++++++++
Meta
rustc --version --verbose:
rustc 1.98.0-nightly (23a3312d9 2026-05-23)
binary: rustc
commit-hash: 23a3312d92a1c4ba0373f1e25277be20ba8bb28c
commit-date: 2026-05-23
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
Caused by #156582 allowing this position
Potentially related to #156760, a variant that uses turbofish syntax instead
cc #156855 and #156884
@rustbot label +A-global-asm +T-compiler
This code should be forbidden because it uses a generic in
global_asm!, which isn't meaningful.Instead, the compiler became confused and was reporting errors about
Sized.Meta
rustc --version --verbose:Caused by #156582 allowing this position
Potentially related to #156760, a variant that uses turbofish syntax instead
cc #156855 and #156884
@rustbot label +A-global-asm +T-compiler