diff options
| author | Felix S. Klock II <pnkfelix@pnkfx.org> | 2014-03-24 13:03:43 +0100 |
|---|---|---|
| committer | Felix S. Klock II <pnkfelix@pnkfx.org> | 2014-03-24 13:03:43 +0100 |
| commit | 57ac379a630d9756c71f2747debe1756ccf62c5f (patch) | |
| tree | 926afffd210b1f877fe604da9df4efb9f514b384 /src/rustllvm/ExecutionEngineWrapper.cpp | |
| parent | 2c7f3b850ce11c70d5bef2b2d5155a1f0fdaa421 (diff) | |
| download | rust-57ac379a630d9756c71f2747debe1756ccf62c5f.tar.gz rust-57ac379a630d9756c71f2747debe1756ccf62c5f.zip | |
Correct overly broad definition of `'static` kind bound.
While double-checking my understanding of the meaning of `'static`,
I made the following test program:
```rust
fn foo<X:'static>(_x: X) { }
#[cfg(not(acceptable))]
fn bar() {
let a = 3;
let b = &a;
foo(b);
}
#[cfg(acceptable)]
fn bar() {
static c : int = 4;;
let d : &'static int = &c;
foo(d);
}
fn main() {
bar();
}
```
Transcript of compiling above program, illustrating that the `--cfg
acceptable` variant of `bar` compiles successfully, showing that the
`'static` kind bound only disallows non-`static` references, not *all*
references:
```
% rustc --version
/Users/fklock/opt/rust-dbg/bin/rustc 0.10-pre (caf17fe 2014-03-21 02:21:50 -0700)
host: x86_64-apple-darwin
% rustc /tmp/s.rs
/tmp/s.rs:7:5: 7:8 error: instantiating a type parameter with an incompatible type `&int`, which does not fulfill `'static`
/tmp/s.rs:7 foo(b);
^~~
error: aborting due to previous error
% rustc --cfg acceptable /tmp/s.rs
% ./s
%
```
(Note that the explicit type annotation on `let d : &'static int` is
necessary; it did not suffice for me to just write `let d = &'static
c;`. That might be a latent bug, I am not sure yet.)
Anyway, a fix to the documentation seemed prudent.
Diffstat (limited to 'src/rustllvm/ExecutionEngineWrapper.cpp')
0 files changed, 0 insertions, 0 deletions
