Skip to content
Open
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
26 changes: 26 additions & 0 deletions src/items/static-items.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,32 @@ blanket_impl: counter was 0
blanket_impl: counter was 1
```

r[items.static.generics.no-params]
Neither the type, nor the initializer of a static item declared in a generic context may refer to the generic arguments.

```rust,compile_fail,E0401
use std::marker::PhantomData;

fn f<T>() {
static A: PhantomData<T> = PhantomData;
//~^ ERROR: can't use generic parameters from outer item
}

fn g<'a>() {
static A: &'a u8 = &0;
//~^ ERROR: can't use generic parameters from outer item
}

trait HasConst {
const X: u8 = 0;
}

fn h<T: HasConst>() {
static A: u8 = T::X;
//~^ ERROR: can't use generic parameters from outer item
}
```

r[items.static.mut]
## Mutable statics

Expand Down