Skip to content

Commit 57185bb

Browse files
committed
---
yaml --- r: 152719 b: refs/heads/try2 c: f556c8c h: refs/heads/master i: 152717: 3a756cf 152715: f3bede1 152711: 5ecac0a 152703: bf55bd9 v: v3
1 parent 9872aad commit 57185bb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+1226
-790
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: ae067477fbc08e5998756d36b6ab0b82173e5c74
8+
refs/heads/try2: f556c8cbd8af182a9dd871a4a36692a0dba7cc2e
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/doc/guide-unsafe.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,8 @@ As an example, we give a reimplementation of owned boxes by wrapping
192192
reimplementation is as safe as the `Box` type.
193193

194194
```
195+
#![feature(unsafe_destructor)]
196+
195197
extern crate libc;
196198
use libc::{c_void, size_t, malloc, free};
197199
use std::mem;
@@ -242,10 +244,12 @@ impl<T: Send> Unique<T> {
242244
// A key ingredient for safety, we associate a destructor with
243245
// Unique<T>, making the struct manage the raw pointer: when the
244246
// struct goes out of scope, it will automatically free the raw pointer.
247+
//
245248
// NB: This is an unsafe destructor, because rustc will not normally
246-
// allow destructors to be associated with parametrized types, due to
249+
// allow destructors to be associated with parameterized types, due to
247250
// bad interaction with managed boxes. (With the Send restriction,
248-
// we don't have this problem.)
251+
// we don't have this problem.) Note that the `#[unsafe_destructor]`
252+
// feature gate is required to use unsafe destructors.
249253
#[unsafe_destructor]
250254
impl<T: Send> Drop for Unique<T> {
251255
fn drop(&mut self) {

branches/try2/src/doc/rust.md

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1940,12 +1940,13 @@ interpreted:
19401940
enum representation in C is undefined, and this may be incorrect when the C
19411941
code is compiled with certain flags.
19421942
- `simd` - on certain tuple structs, derive the arithmetic operators, which
1943-
lower to the target's SIMD instructions, if any.
1943+
lower to the target's SIMD instructions, if any; the `simd` feature gate
1944+
is necessary to use this attribute.
19441945
- `static_assert` - on statics whose type is `bool`, terminates compilation
19451946
with an error if it is not initialized to `true`.
19461947
- `unsafe_destructor` - allow implementations of the "drop" language item
19471948
where the type it is implemented for does not implement the "send" language
1948-
item.
1949+
item; the `unsafe_destructor` feature gate is needed to use this attribute
19491950
- `unsafe_no_drop_flag` - on structs, remove the flag that prevents
19501951
destructors from being run twice. Destructors might be run multiple times on
19511952
the same object with this attribute.
@@ -2300,28 +2301,43 @@ One can indicate the stability of an API using the following attributes:
23002301
These levels are directly inspired by
23012302
[Node.js' "stability index"](http://nodejs.org/api/documentation.html).
23022303

2303-
There are lints for disallowing items marked with certain levels:
2304-
`deprecated`, `experimental` and `unstable`; the first two will warn
2305-
by default. Items with not marked with a stability are considered to
2306-
be unstable for the purposes of the lint. One can give an optional
2304+
Stability levels are inherited, so an items's stability attribute is the
2305+
default stability for everything nested underneath it.
2306+
2307+
There are lints for disallowing items marked with certain levels: `deprecated`,
2308+
`experimental` and `unstable`. For now, only `deprecated` warns by default, but
2309+
this will change once the standard library has been stabilized.
2310+
Stability levels are meant to be promises at the crate
2311+
level, so these lints only apply when referencing
2312+
items from an _external_ crate, not to items defined within the
2313+
current crate. Items with no stability level are considered
2314+
to be unstable for the purposes of the lint. One can give an optional
23072315
string that will be displayed when the lint flags the use of an item.
23082316

2309-
~~~~ {.ignore}
2310-
#![warn(unstable)]
2317+
For example, if we define one crate called `stability_levels`:
23112318

2319+
~~~~ {.ignore}
23122320
#[deprecated="replaced by `best`"]
2313-
fn bad() {
2321+
pub fn bad() {
23142322
// delete everything
23152323
}
23162324
2317-
fn better() {
2325+
pub fn better() {
23182326
// delete fewer things
23192327
}
23202328
23212329
#[stable]
2322-
fn best() {
2330+
pub fn best() {
23232331
// delete nothing
23242332
}
2333+
~~~~
2334+
2335+
then the lints will work as follows for a client crate:
2336+
2337+
~~~~ {.ignore}
2338+
#![warn(unstable)]
2339+
extern crate stability_levels;
2340+
use stability_levels::{bad, better, best};
23252341
23262342
fn main() {
23272343
bad(); // "warning: use of deprecated item: replaced by `best`"

branches/try2/src/liballoc/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@
6969
html_root_url = "http://doc.rust-lang.org/")]
7070

7171
#![no_std]
72-
#![feature(phase)]
72+
#![feature(phase, unsafe_destructor)]
73+
#![allow(unknown_features)] // NOTE: remove after a stage0 snap
7374

7475
#[phase(plugin, link)]
7576
extern crate core;

branches/try2/src/libarena/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@
2727
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
2828
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
2929
html_root_url = "http://doc.rust-lang.org/")]
30+
31+
#![feature(unsafe_destructor)]
3032
#![allow(missing_doc)]
33+
#![allow(unknown_features)] // NOTE: remove after a stage0 snap
3134

3235
use std::cell::{Cell, RefCell};
3336
use std::cmp;

branches/try2/src/libcollections/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@
2222
html_playground_url = "http://play.rust-lang.org/")]
2323

2424
#![feature(macro_rules, managed_boxes, default_type_params, phase, globs)]
25+
#![feature(unsafe_destructor)]
2526
#![no_std]
27+
#![allow(unknown_features)] // NOTE: remove after a stage0 snap
2628

2729
#[phase(plugin, link)] extern crate core;
2830
extern crate alloc;

branches/try2/src/libcore/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,9 @@
5555
html_playground_url = "http://play.rust-lang.org/")]
5656

5757
#![no_std]
58-
#![feature(globs, macro_rules, managed_boxes, phase, simd)]
58+
#![feature(globs, macro_rules, managed_boxes, phase, simd, unsafe_destructor)]
5959
#![deny(missing_doc)]
60+
#![allow(unknown_features)] // NOTE: remove after a stage0 snap
6061

6162
#[cfg(test)] extern crate realcore = "core";
6263
#[cfg(test)] extern crate libc;

branches/try2/src/libnative/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,17 @@
5252
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
5353
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
5454
html_root_url = "http://doc.rust-lang.org/")]
55+
5556
#![deny(unused_result, unused_must_use)]
5657
#![allow(non_camel_case_types)]
5758
#![allow(deprecated)]
59+
#![allow(unknown_features)] // NOTE: remove after a stage0 snap
5860
#![feature(default_type_params)]
5961

6062
// NB this crate explicitly does *not* allow glob imports, please seriously
6163
// consider whether they're needed before adding that feature here (the
6264
// answer is that you don't need them)
63-
#![feature(macro_rules)]
65+
#![feature(macro_rules, unsafe_destructor)]
6466

6567
extern crate alloc;
6668
extern crate libc;

branches/try2/src/librustc/driver/driver.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use metadata::common::LinkMeta;
2020
use metadata::creader;
2121
use middle::cfg;
2222
use middle::cfg::graphviz::LabelledCFG;
23-
use middle::{trans, freevars, kind, ty, typeck, lint, reachable};
23+
use middle::{trans, freevars, stability, kind, ty, typeck, lint, reachable};
2424
use middle::dependency_format;
2525
use middle;
2626
use plugin::load::Plugins;
@@ -312,8 +312,11 @@ pub fn phase_3_run_analysis_passes(sess: Session,
312312
time(time_passes, "loop checking", (), |_|
313313
middle::check_loop::check_crate(&sess, krate));
314314

315+
let stability_index = time(time_passes, "stability index", (), |_|
316+
stability::Index::build(krate));
317+
315318
let ty_cx = ty::mk_ctxt(sess, def_map, named_region_map, ast_map,
316-
freevars, region_map, lang_items);
319+
freevars, region_map, lang_items, stability_index);
317320

318321
// passes are timed inside typeck
319322
typeck::check_crate(&ty_cx, trait_map, krate);

branches/try2/src/librustc/front/feature_gate.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ static KNOWN_FEATURES: &'static [(&'static str, Status)] = &[
5050
("log_syntax", Active),
5151
("trace_macros", Active),
5252
("concat_idents", Active),
53+
("unsafe_destructor", Active),
5354

5455
("simd", Active),
5556
("default_type_params", Active),
@@ -220,6 +221,17 @@ impl<'a> Visitor<()> for Context<'a> {
220221
}
221222
}
222223

224+
ast::ItemImpl(..) => {
225+
if attr::contains_name(i.attrs.as_slice(),
226+
"unsafe_destructor") {
227+
self.gate_feature("unsafe_destructor",
228+
i.span,
229+
"`#[unsafe_destructor]` allows too \
230+
many unsafe patterns and may be \
231+
removed in the future");
232+
}
233+
}
234+
223235
_ => {}
224236
}
225237

branches/try2/src/librustc/lib.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@ This API is completely unstable and subject to change.
2929
html_root_url = "http://doc.rust-lang.org/")]
3030

3131
#![allow(deprecated)]
32-
#![feature(macro_rules, globs, struct_variant, managed_boxes, quote,
33-
default_type_params, phase)]
32+
#![allow(unknown_features)] // NOTE: remove after a stage0 snap
33+
#![feature(macro_rules, globs, struct_variant, managed_boxes, quote)]
34+
#![feature(default_type_params, phase, unsafe_destructor)]
3435

3536
extern crate arena;
3637
extern crate debug;
@@ -80,6 +81,7 @@ pub mod middle {
8081
pub mod weak_lang_items;
8182
pub mod save;
8283
pub mod intrinsicck;
84+
pub mod stability;
8385
}
8486

8587
pub mod front {

branches/try2/src/librustc/metadata/common.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,9 @@ pub static tag_method_argument_name: uint = 0x8f;
210210
pub static tag_reachable_extern_fns: uint = 0x90;
211211
pub static tag_reachable_extern_fn_id: uint = 0x91;
212212

213+
pub static tag_items_data_item_stability: uint = 0x92;
214+
215+
213216
#[deriving(Clone, Show)]
214217
pub struct LinkMeta {
215218
pub crateid: CrateId,

branches/try2/src/librustc/metadata/csearch.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ use serialize::ebml::reader;
2525
use std::rc::Rc;
2626
use syntax::ast;
2727
use syntax::ast_map;
28+
use syntax::attr;
2829
use syntax::diagnostic::expect;
2930
use syntax::parse::token;
3031

@@ -328,3 +329,10 @@ pub fn is_typedef(cstore: &cstore::CStore, did: ast::DefId) -> bool {
328329
let cdata = cstore.get_crate_data(did.krate);
329330
decoder::is_typedef(&*cdata, did.node)
330331
}
332+
333+
pub fn get_stability(cstore: &cstore::CStore,
334+
def: ast::DefId)
335+
-> Option<attr::Stability> {
336+
let cdata = cstore.get_crate_data(def.krate);
337+
decoder::get_stability(&*cdata, def.node)
338+
}

branches/try2/src/librustc/metadata/decoder.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,14 @@ pub fn get_type(cdata: Cmd, id: ast::NodeId, tcx: &ty::ctxt)
439439
}
440440
}
441441

442+
pub fn get_stability(cdata: Cmd, id: ast::NodeId) -> Option<attr::Stability> {
443+
let item = lookup_item(id, cdata.data());
444+
reader::maybe_get_doc(item, tag_items_data_item_stability).map(|doc| {
445+
let mut decoder = reader::Decoder::new(doc);
446+
Decodable::decode(&mut decoder).unwrap()
447+
})
448+
}
449+
442450
pub fn get_impl_trait(cdata: Cmd,
443451
id: ast::NodeId,
444452
tcx: &ty::ctxt) -> Option<Rc<ty::TraitRef>>

0 commit comments

Comments
 (0)