mirror of
https://github.com/rust-lang/rust.git
synced 2025-10-02 18:27:37 +00:00
21 lines
659 B
Rust
21 lines
659 B
Rust
//! Originally, inner statics in generic functions were generated only once, causing the same
|
|
//! static to be shared across all generic instantiations. This created a soundness hole where
|
|
//! different types could be coerced through thread-local storage in safe code.
|
|
//!
|
|
//! This test checks that generic parameters from outer scopes cannot be used in inner statics,
|
|
//! preventing this soundness issue.
|
|
//!
|
|
//! See https://github.com/rust-lang/rust/issues/9186
|
|
|
|
enum Bar<T> {
|
|
//~^ ERROR parameter `T` is never used
|
|
What,
|
|
}
|
|
|
|
fn foo<T>() {
|
|
static a: Bar<T> = Bar::What;
|
|
//~^ ERROR can't use generic parameters from outer item
|
|
}
|
|
|
|
fn main() {}
|