Skip to content

Commit e575f9e

Browse files
committed
Make sure we don't talk about unstable things
Fixes #14
1 parent 927ffc2 commit e575f9e

File tree

7 files changed

+58
-66
lines changed

7 files changed

+58
-66
lines changed

Diff for: .travis.yml

+1
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ before_script:
88

99
script:
1010
- export PATH=$PATH:/home/travis/.cargo/bin && mdbook test
11+
- cd stable-check && cargo run -- ../src

Diff for: src/expressions.md

-19
Original file line numberDiff line numberDiff line change
@@ -308,25 +308,6 @@ let y = 0..10;
308308
assert_eq!(x, y);
309309
```
310310

311-
Similarly, the `...` operator will construct an object of one of the
312-
`std::ops::RangeInclusive` variants.
313-
314-
```rust
315-
# #![feature(inclusive_range_syntax)]
316-
1...2; // std::ops::RangeInclusive
317-
...4; // std::ops::RangeToInclusive
318-
```
319-
320-
The following expressions are equivalent.
321-
322-
```rust
323-
# #![feature(inclusive_range_syntax, inclusive_range)]
324-
let x = std::ops::RangeInclusive::NonEmpty {start: 0, end: 10};
325-
let y = 0...10;
326-
327-
assert_eq!(x, y);
328-
```
329-
330311
## Unary operator expressions
331312

332313
Rust defines the following unary operators. With the exception of `?`, they are

Diff for: src/items.md

-47
Original file line numberDiff line numberDiff line change
@@ -663,53 +663,6 @@ unsafe fn bump_levels_unsafe2() -> u32 {
663663
Mutable statics have the same restrictions as normal statics, except that the
664664
type of the value is not required to ascribe to `Sync`.
665665

666-
#### `'static` lifetime elision
667-
668-
[Unstable] Both constant and static declarations of reference types have
669-
*implicit* `'static` lifetimes unless an explicit lifetime is specified. As
670-
such, the constant declarations involving `'static` above may be written
671-
without the lifetimes. Returning to our previous example:
672-
673-
```rust
674-
# #![feature(static_in_const)]
675-
const BIT1: u32 = 1 << 0;
676-
const BIT2: u32 = 1 << 1;
677-
678-
const BITS: [u32; 2] = [BIT1, BIT2];
679-
const STRING: &str = "bitstring";
680-
681-
struct BitsNStrings<'a> {
682-
mybits: [u32; 2],
683-
mystring: &'a str,
684-
}
685-
686-
const BITS_N_STRINGS: BitsNStrings = BitsNStrings {
687-
mybits: BITS,
688-
mystring: STRING,
689-
};
690-
```
691-
692-
Note that if the `static` or `const` items include function or closure
693-
references, which themselves include references, the compiler will first try the
694-
standard elision rules ([see discussion in the nomicon][elision-nomicon]). If it
695-
is unable to resolve the lifetimes by its usual rules, it will default to using
696-
the `'static` lifetime. By way of example:
697-
698-
[elision-nomicon]: ../nomicon/lifetime-elision.html
699-
700-
```rust,ignore
701-
// Resolved as `fn<'a>(&'a str) -> &'a str`.
702-
const RESOLVED_SINGLE: fn(&str) -> &str = ..
703-
704-
// Resolved as `Fn<'a, 'b, 'c>(&'a Foo, &'b Bar, &'c Baz) -> usize`.
705-
const RESOLVED_MULTIPLE: Fn(&Foo, &Bar, &Baz) -> usize = ..
706-
707-
// There is insufficient information to bound the return reference lifetime
708-
// relative to the argument lifetimes, so the signature is resolved as
709-
// `Fn(&'static Foo, &'static Bar) -> &'static Baz`.
710-
const RESOLVED_STATIC: Fn(&Foo, &Bar) -> &Baz = ..
711-
```
712-
713666
### Traits
714667

715668
A _trait_ describes an abstract interface that types can

Diff for: stable-check/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
target

Diff for: stable-check/Cargo.lock

+4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: stable-check/Cargo.toml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[package]
2+
name = "stable-check"
3+
version = "0.1.0"
4+
authors = ["steveklabnik <steve@steveklabnik.com>"]
5+
6+
[dependencies]

Diff for: stable-check/src/main.rs

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
use std::error::Error;
2+
use std::env;
3+
use std::fs;
4+
use std::fs::File;
5+
use std::io::prelude::*;
6+
use std::path::Path;
7+
8+
fn main() {
9+
let arg = env::args().nth(1).unwrap_or_else(|| {
10+
println!("Please pass a src directory as the first argument");
11+
std::process::exit(1);
12+
});
13+
14+
match check_directory(&Path::new(&arg)) {
15+
Ok(()) => println!("passed!"),
16+
Err(e) => {
17+
println!("Error: {}", e);
18+
std::process::exit(1);
19+
}
20+
}
21+
22+
}
23+
24+
fn check_directory(dir: &Path) -> Result<(), Box<Error>> {
25+
for entry in fs::read_dir(dir)? {
26+
let entry = entry?;
27+
let path = entry.path();
28+
29+
if path.is_dir() {
30+
continue;
31+
}
32+
33+
let mut file = File::open(&path)?;
34+
let mut contents = String::new();
35+
file.read_to_string(&mut contents)?;
36+
37+
if contents.contains("#![feature") {
38+
// attributes.md contains this and it is legitimate
39+
if !contents.contains("#![feature(feature1, feature2, feature3)]") {
40+
return Err(From::from(format!("Feature flag found in {:?}", path)));
41+
}
42+
}
43+
}
44+
45+
Ok(())
46+
}

0 commit comments

Comments
 (0)