auto merge of #9703 : alexcrichton/rust/compiler-features, r=cmr

This implements the necessary logic for gating particular features off by default in the compiler. There are a number of issues which have been wanting this form of mechanism, and this initially gates features which we have open issues for.

Additionally, this should unblock #9255
This commit is contained in:
bors 2013-10-06 14:41:28 -07:00
commit 8eb28bb7dc
122 changed files with 493 additions and 43 deletions

View File

@ -1833,6 +1833,58 @@ fn main() {
> individual functions, structs, methods and enum variants, *not* to
> entire modules, traits, impls or enums themselves.
### Compiler Features
Certain aspects of Rust may be implemented in the compiler, but they're not
necessarily ready for every-day use. These features are often of "prototype
quality" or "almost production ready", but may not be stable enough to be
considered a full-fleged language feature.
For this reason, rust recognizes a special crate-level attribute of the form:
~~~ {.xfail-test}
#[feature(feature1, feature2, feature3)]
~~~
This directive informs the compiler that the feature list: `feature1`,
`feature2`, and `feature3` should all be enabled. This is only recognized at a
crate-level, not at a module-level. Without this directive, all features are
considered off, and using the features will result in a compiler error.
The currently implemented features of the compiler are:
* `macro_rules` - The definition of new macros. This does not encompass
macro-invocation, that is always enabled by default, this only
covers the definition of new macros. There are currently
various problems with invoking macros, how they interact with
their environment, and possibly how they are used outside of
location in which they are defined. Macro definitions are
likely to change slightly in the future, so they are currently
hidden behind this feature.
* `globs` - Importing everything in a module through `*`. This is currently a
large source of bugs in name resolution for Rust, and it's not clear
whether this will continue as a feature or not. For these reasons,
the glob import statement has been hidden behind this feature flag.
* `struct_variant` - Structural enum variants (those with named fields). It is
currently unknown whether this style of enum variant is as
fully supported as the tuple-forms, and it's not certain
that this style of variant should remain in the language.
For now this style of variant is hidden behind a feature
flag.
If a feature is promoted to a language feature, then all existing programs will
start to receive compilation warnings about #[feature] directives which enabled
the new feature (because the directive is no longer necessary). However, if
a feature is decided to be removed from the language, errors will be issued (if
there isn't a parser error first). The directive in this case is no longer
necessary, and it's likely that existing code will break if the feature isn't
removed.
If a unknown feature is found in a directive, it results in a compiler error. An
unknown feature is one which has never been recognized by the compiler.
# Statements and expressions
Rust is _primarily_ an expression language. This means that most forms of

View File

@ -746,6 +746,10 @@ fn area(sh: Shape) -> f64 {
}
~~~~
> ***Note:*** This feature of the compiler is currently gated behind the
> `#[feature(struct_variant)]` directive. More about these directives can be
> found in the manual.
## Tuples
Tuples in Rust behave exactly like structs, except that their fields
@ -2665,6 +2669,10 @@ use farm::*;
# fn main() { cow(); chicken() }
~~~
> ***Note:*** This feature of the compiler is currently gated behind the
> `#[feature(globs)]` directive. More about these directives can be found in
> the manual.
However, that's not all. You can also rename an item while you're bringing it into scope:
~~~

View File

@ -40,6 +40,7 @@ c = open("tmp/run_pass_stage2.rc", "w")
i = 0
c.write("// AUTO-GENERATED FILE: DO NOT EDIT\n")
c.write("#[link(name=\"run_pass_stage2\", vers=\"0.1\")];\n")
c.write("#[feature(globs, macro_rules, struct_variant)];\n")
for t in stage2_tests:
p = os.path.join(run_pass, t)
p = p.replace("\\", "\\\\")
@ -51,6 +52,7 @@ c.close()
d = open("tmp/run_pass_stage2_driver.rs", "w")
d.write("// AUTO-GENERATED FILE: DO NOT EDIT\n")
d.write("#[feature(globs)];\n")
d.write("extern mod extra;\n")
d.write("extern mod run_pass_stage2;\n")
d.write("use run_pass_stage2::*;\n")

View File

@ -63,6 +63,7 @@ while cur < len(lines):
#[ allow(unused_variable) ];\n
#[ allow(dead_assignment) ];\n
#[ allow(unused_mut) ];\n
#[ feature(macro_rules, globs, struct_variant) ];\n
""" + block
if xfail:
block = "// xfail-test\n" + block

View File

@ -33,6 +33,8 @@ Rust extras are part of the standard Rust distribution.
#[license = "MIT/ASL2"];
#[crate_type = "lib"];
#[feature(macro_rules, globs)];
#[deny(non_camel_case_types)];
#[deny(missing_doc)];

View File

@ -159,6 +159,8 @@ pub fn phase_2_configure_and_expand(sess: Session,
*sess.building_library = session::building_library(sess.opts.crate_type,
&crate, sess.opts.test);
time(time_passes, "gated feature checking", (), |_|
front::feature_gate::check_crate(sess, &crate));
// strip before expansion to allow macros to depend on
// configuration variables e.g/ in

View File

@ -0,0 +1,176 @@
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
//! Feature gating
//!
//! This modules implements the gating necessary for preventing certain compiler
//! features from being used by default. This module will crawl a pre-expanded
//! AST to ensure that there are no features which are used that are not
//! enabled.
//!
//! Features are enabled in programs via the crate-level attributes of
//! #[feature(...)] with a comma-separated list of features.
use syntax::ast;
use syntax::attr::AttrMetaMethods;
use syntax::codemap::Span;
use syntax::visit;
use syntax::visit::Visitor;
use driver::session::Session;
/// This is a list of all known features since the beginning of time. This list
/// can never shrink, it may only be expanded (in order to prevent old programs
/// from failing to compile). The status of each feature may change, however.
static KNOWN_FEATURES: &'static [(&'static str, Status)] = &[
("globs", Active),
("macro_rules", Active),
("struct_variant", Active),
// These are used to test this portion of the compiler, they don't actually
// mean anything
("test_accepted_feature", Accepted),
("test_removed_feature", Removed),
];
enum Status {
/// Represents an active feature that is currently being implemented or
/// currently being considered for addition/removal.
Active,
/// Represents a feature which has since been removed (it was once Active)
Removed,
/// This language feature has since been Accepted (it was once Active)
Accepted,
}
struct Context {
features: ~[&'static str],
sess: Session,
}
impl Context {
fn gate_feature(&self, feature: &str, span: Span, explain: &str) {
if !self.has_feature(feature) {
self.sess.span_err(span, explain);
self.sess.span_note(span, format!("add \\#[feature({})] to the \
crate attributes to enable",
feature));
}
}
fn has_feature(&self, feature: &str) -> bool {
self.features.iter().any(|n| n.as_slice() == feature)
}
}
impl Visitor<()> for Context {
fn visit_view_item(&mut self, i: &ast::view_item, _: ()) {
match i.node {
ast::view_item_use(ref paths) => {
for path in paths.iter() {
match path.node {
ast::view_path_glob(*) => {
self.gate_feature("globs", path.span,
"glob import statements are \
experimental and possibly buggy");
}
_ => {}
}
}
}
_ => {}
}
visit::walk_view_item(self, i, ())
}
fn visit_item(&mut self, i: @ast::item, _:()) {
match i.node {
ast::item_enum(ref def, _) => {
for variant in def.variants.iter() {
match variant.node.kind {
ast::struct_variant_kind(*) => {
self.gate_feature("struct_variant", variant.span,
"enum struct variants are \
experimental and possibly buggy");
}
_ => {}
}
}
}
ast::item_mac(ref mac) => {
match mac.node {
ast::mac_invoc_tt(ref path, _, _) => {
let rules = self.sess.ident_of("macro_rules");
if path.segments.last().identifier == rules {
self.gate_feature("macro_rules", i.span,
"macro definitions are not \
stable enough for use and are \
subject to change");
}
}
}
}
_ => {}
}
visit::walk_item(self, i, ());
}
}
pub fn check_crate(sess: Session, crate: &ast::Crate) {
let mut cx = Context {
features: ~[],
sess: sess,
};
for attr in crate.attrs.iter() {
if "feature" != attr.name() { continue }
match attr.meta_item_list() {
None => {
sess.span_err(attr.span, "malformed feature attribute, \
expected #[feature(...)]");
}
Some(list) => {
for &mi in list.iter() {
let name = match mi.node {
ast::MetaWord(word) => word,
_ => {
sess.span_err(mi.span, "malformed feature, expected \
just one word");
continue
}
};
match KNOWN_FEATURES.iter().find(|& &(n, _)| n == name) {
Some(&(name, Active)) => { cx.features.push(name); }
Some(&(_, Removed)) => {
sess.span_err(mi.span, "feature has been removed");
}
Some(&(_, Accepted)) => {
sess.span_warn(mi.span, "feature has added to rust, \
directive not necessary");
}
None => {
sess.span_err(mi.span, "unknown feature");
}
}
}
}
}
}
visit::walk_crate(&mut cx, crate, ());
sess.abort_if_errors();
}

View File

@ -17,6 +17,8 @@
#[license = "MIT/ASL2"];
#[crate_type = "lib"];
#[feature(macro_rules, globs, struct_variant)];
// Rustc tasks always run on a fixed_stack_segment, so code in this
// module can call C functions (in particular, LLVM functions) with
// impunity.
@ -83,6 +85,7 @@ pub mod front {
pub mod test;
pub mod std_inject;
pub mod assign_node_ids;
pub mod feature_gate;
}
pub mod back {

View File

@ -17,6 +17,8 @@
#[license = "MIT/ASL2"];
#[crate_type = "lib"];
#[feature(globs, struct_variant)];
extern mod syntax;
extern mod rustc;
extern mod extra;

View File

@ -66,6 +66,8 @@
#[license = "MIT/ASL2"];
#[crate_type = "lib"];
#[feature(globs)];
extern mod extra;
extern mod rustc;
extern mod syntax;

View File

@ -18,6 +18,8 @@
#[license = "MIT/ASL2"];
#[crate_type = "lib"];
#[feature(globs)];
extern mod extra;
extern mod rustc;
extern mod syntax;

View File

@ -61,6 +61,8 @@ they contained the following prologue:
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
html_root_url = "http://static.rust-lang.org/doc/master")];
#[feature(macro_rules, globs)];
// Don't link to std. We are std.
#[no_std];

View File

@ -20,6 +20,8 @@
#[license = "MIT/ASL2"];
#[crate_type = "lib"];
#[feature(macro_rules, globs)];
extern mod extra;
pub mod util {

View File

@ -9,6 +9,7 @@
// except according to those terms.
#[allow(unused_imports)];
#[feature(globs)];
extern mod issue_2316_a;

View File

@ -12,6 +12,8 @@
vers = "0.1")];
#[crate_type = "lib"];
#[feature(struct_variant)];
pub enum Enum {
Variant { arg: u8 }
}

View File

@ -10,6 +10,8 @@
// Microbenchmarks for various functions in std and extra
#[feature(macro_rules)];
extern mod extra;
use extra::time::precise_time_s;

View File

@ -14,7 +14,7 @@ use std::os;
use std::uint;
use std::rt::test::spawntask_later;
use std::cell::Cell;
use std::comm::*;
use std::comm::oneshot;
// A simple implementation of parfib. One subtree is found in a new
// task and communicated over a oneshot pipe, the other is found

View File

@ -13,7 +13,7 @@
extern mod extra;
use std::cell::Cell;
use std::comm::*;
use std::comm::{stream, SharedChan};
use std::io;
use std::option;
use std::os;

View File

@ -22,7 +22,7 @@
extern mod extra;
use extra::{time, getopts};
use std::comm::*;
use std::comm::{stream, SharedChan};
use std::io::WriterUtil;
use std::io;
use std::os;

View File

@ -22,7 +22,7 @@
// Creates in the background 'num_tasks' tasks, all blocked forever.
// Doesn't return until all such tasks are ready, but doesn't block forever itself.
use std::comm::*;
use std::comm::{stream, SharedChan};
use std::os;
use std::result;
use std::task;

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[feature(struct_variant)];
use std::num::FromPrimitive;
use std::int;

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[feature(struct_variant)];
enum Foo { C { a: int, b: int } }
struct C { a: int, b: int } //~ ERROR error: duplicate definition of type `C`

View File

@ -12,7 +12,7 @@
// xfail-fast #7103
extern mod extra;
use extra::arc::*;
use extra::arc::Arc;
struct A { y: Arc<int>, x: Arc<int> }

View File

@ -0,0 +1,24 @@
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[feature(
foo_bar_baz,
foo(bar),
foo = "baz"
)];
//~^^^^ ERROR: unknown feature
//~^^^^ ERROR: malformed feature
//~^^^^ ERROR: malformed feature
#[feature]; //~ ERROR: malformed feature
#[feature = "foo"]; //~ ERROR: malformed feature
#[feature(test_removed_feature)]; //~ ERROR: feature has been removed
#[feature(test_accepted_feature)]; //~ WARNING: feature has added

View File

@ -0,0 +1,14 @@
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::*;
//~^ ERROR: glob import statements are experimental
fn main() {}

View File

@ -0,0 +1,14 @@
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
macro_rules! foo(() => ())
//~^ ERROR: macro definitions are not stable enough for use
fn main() {}

View File

@ -0,0 +1,15 @@
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
enum A { B { foo: int } }
//~^ ERROR: enum struct variants are experimental
fn main() {}

View File

@ -10,6 +10,8 @@
// error-pattern: unresolved name
#[feature(globs)];
use module_of_many_things::*;
mod module_of_many_things {

View File

@ -10,6 +10,8 @@
// error-pattern: unresolved
#[feature(globs)];
mod circ1 {
pub use circ2::f2;
pub fn f1() { info2!("f1"); }

View File

@ -10,6 +10,8 @@
// Testing that we don't fail abnormally after hitting the errors
#[feature(globs)];
use unresolved::*; //~ ERROR unresolved import. maybe a missing
//~^ ERROR failed to resolve import

View File

@ -13,6 +13,8 @@
// ensures that 'use foo:*' doesn't import non-public 'use' statements in the
// module 'foo'
#[feature(globs)];
use m1::*;
mod foo {

View File

@ -8,6 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[feature(macro_rules)];
use std::io;

View File

@ -1,4 +1,8 @@
macro_rules! e( //~ ERROR unknown macro variable `nonexistent`
#[feature(macro_rules)];
// error-pattern: unknown macro variable `nonexistent`
macro_rules! e(
($inp:ident) => (
$nonexistent
);

View File

@ -10,6 +10,7 @@
// When denying at the crate level, be sure to not get random warnings from the
// injected intrinsics by the compiler.
#[feature(struct_variant)];
#[deny(missing_doc)];
struct Foo {

View File

@ -11,6 +11,7 @@
// xfail-fast aux-build
// aux-build:lint_stability.rs
#[feature(globs)];
#[deny(unstable)];
#[deny(deprecated)];
#[deny(experimental)];

View File

@ -8,6 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[feature(globs)];
#[deny(unused_imports)];
mod A {

View File

@ -8,6 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[feature(globs)];
#[deny(unused_imports)];
use cal = bar::c::cc;

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[feature(macro_rules)];
macro_rules! ignored_item {
() => {
fn foo() {}

View File

@ -1,3 +1,5 @@
#[feature(macro_rules)];
macro_rules! test ( ($nm:ident,
$a:attr,
$i:item) => (mod $nm { $a; $i }); )

View File

@ -1,3 +1,5 @@
#[feature(macro_rules)];
macro_rules! test ( ($nm:ident,
$a:attr,
$i:item) => (mod $nm { $a $i }); )

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[feature(globs)];
// error-pattern:declaration of `None` shadows
use std::option::*;

View File

@ -11,7 +11,7 @@
// xfail-fast
// aux-build:cci_class_5.rs
extern mod cci_class_5;
use cci_class_5::kitties::*;
use cci_class_5::kitties::cat;
fn main() {
let nyan : cat = cat(52, 99);

View File

@ -10,7 +10,7 @@
// aux-build:cci_class.rs
extern mod cci_class;
use cci_class::kitties::*;
use cci_class::kitties::cat;
fn main() {
let nyan : cat = cat(52u, 99);

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[feature(struct_variant)];
enum A {
B { x: Option<int> },
C

View File

@ -23,6 +23,7 @@
// check:$3 = {4820353753753434}
#[allow(unused_variable)];
#[feature(struct_variant)];
// The first element is to ensure proper alignment, irrespective of the machines word size. Since
// the size of the discriminant value is machine dependent, this has be taken into account when

View File

@ -41,6 +41,8 @@
// check:$7 = {{Case1, x = 0, y = 8970181431921507452}, {Case1, 0, 2088533116, 2088533116}}
// debugger:continue
#[feature(struct_variant)];
#[deriving(Clone)]
struct Struct {
a: int,

View File

@ -30,6 +30,7 @@
// check:$5 = 5
// debugger:continue
#[feature(struct_variant)];
struct Struct {
x: int

View File

@ -26,6 +26,8 @@
// debugger:print univariant
// check:$4 = {a = -1}
#[feature(struct_variant)];
// NOTE: This is a copy of the non-generic test case. The `Txx` type parameters have to be
// substituted with something of size `xx` bits and the same alignment as an integer type of the
// same size.

View File

@ -63,6 +63,8 @@
// check:$15 = 400
// debugger:continue
#[feature(macro_rules)];
macro_rules! trivial(
($e1:expr) => ($e1)
)

View File

@ -23,6 +23,7 @@
// check:$3 = {-9747455}
#[allow(unused_variable)];
#[feature(struct_variant)];
// The first element is to ensure proper alignment, irrespective of the machines word size. Since
// the size of the discriminant value is machine dependent, this has be taken into account when

View File

@ -92,6 +92,8 @@
// check:$21 = -16
// debugger:continue
#[feature(struct_variant)];
enum Enum {
Variant1 { x: u16, y: u16 },
Variant2 (u32)

View File

@ -33,6 +33,8 @@
// debugger:continue
#[feature(struct_variant)];
// If a struct has exactly two variants, one of them is empty, and the other one
// contains a non-nullable pointer, then this value is used as the discriminator.
// The test cases in this file make sure that something readable is generated for

View File

@ -99,6 +99,7 @@
// debugger:continue
#[allow(unused_variable)];
#[feature(struct_variant)];
enum Opt<T> {
Empty,

View File

@ -30,6 +30,7 @@
// check:$5 = 5
// debugger:continue
#[feature(struct_variant)];
struct Struct {
x: int

View File

@ -27,6 +27,7 @@
// check:$4 = {a = -1}
#[allow(unused_variable)];
#[feature(struct_variant)];
// The first element is to ensure proper alignment, irrespective of the machines word size. Since
// the size of the discriminant value is machine dependent, this has be taken into account when

View File

@ -23,6 +23,7 @@
// check:$3 = {123234}
#[allow(unused_variable)];
#[feature(struct_variant)];
// The first element is to ensure proper alignment, irrespective of the machines word size. Since
// the size of the discriminant value is machine dependent, this has be taken into account when

View File

@ -12,7 +12,7 @@
// aux-build:anon-extern-mod-cross-crate-1.rs
extern mod anonexternmod;
use anonexternmod::*;
use anonexternmod::rust_get_test_int;
#[fixed_stack_segment]
pub fn main() {

View File

@ -11,7 +11,7 @@
// except according to those terms.
extern mod extra;
use extra::bitv::*;
use extra::bitv::Bitv;
fn bitv_test() {
let mut v1 = ~Bitv::new(31, false);

View File

@ -1,6 +1,8 @@
// Check that we do not ICE when compiling this
// macro, which reuses the expression `$id`
#[feature(macro_rules)];
struct Foo {
a: int
}

View File

@ -11,6 +11,8 @@
// xfail-fast - check-fast doesn't understand aux-build
// aux-build:cci_nested_lib.rs
#[feature(globs)];
extern mod cci_nested_lib;
use cci_nested_lib::*;

View File

@ -14,6 +14,8 @@
// check that cfg correctly chooses between the macro impls (see also
// cfg-macros-notfoo.rs)
#[feature(macro_rules)];
#[cfg(foo)]
#[macro_escape]
mod foo {

View File

@ -14,6 +14,8 @@
// check that cfg correctly chooses between the macro impls (see also
// cfg-macros-foo.rs)
#[feature(macro_rules)];
#[cfg(foo)]
#[macro_escape]
mod foo {

View File

@ -12,7 +12,7 @@
// aux-build:cci_class_cast.rs
extern mod cci_class_cast;
use std::to_str::ToStr;
use cci_class_cast::kitty::*;
use cci_class_cast::kitty::cat;
fn print_out(thing: @ToStr, expected: ~str) {
let actual = thing.to_str();

View File

@ -13,7 +13,7 @@
/* Test that exporting a class also exports its
public fields and methods */
use kitty::*;
use kitty::cat;
mod kitty {
pub struct cat {

View File

@ -11,7 +11,7 @@
// xfail-fast
// aux-build:cci_class_trait.rs
extern mod cci_class_trait;
use cci_class_trait::animals::*;
use cci_class_trait::animals::noisy;
struct cat {
priv meows: uint,

View File

@ -11,7 +11,7 @@
// xfail-fast
// aux-build:cci_class_2.rs
extern mod cci_class_2;
use cci_class_2::kitties::*;
use cci_class_2::kitties::cat;
pub fn main() {
let nyan : cat = cat(52u, 99);

View File

@ -11,7 +11,7 @@
// xfail-fast
// aux-build:cci_class_3.rs
extern mod cci_class_3;
use cci_class_3::kitties::*;
use cci_class_3::kitties::cat;
pub fn main() {
let mut nyan : cat = cat(52u, 99);

View File

@ -11,7 +11,7 @@
// xfail-fast
// aux-build:cci_class_6.rs
extern mod cci_class_6;
use cci_class_6::kitties::*;
use cci_class_6::kitties::cat;
pub fn main() {
let mut nyan : cat<char> = cat::<char>(52u, 99, ~['p']);

View File

@ -11,7 +11,7 @@
// xfail-fast
// aux-build:cci_class_4.rs
extern mod cci_class_4;
use cci_class_4::kitties::*;
use cci_class_4::kitties::cat;
pub fn main() {
let mut nyan = cat(0u, 2, ~"nyan");

View File

@ -11,7 +11,7 @@
// xfail-fast
// aux-build:cci_class.rs
extern mod cci_class;
use cci_class::kitties::*;
use cci_class::kitties::cat;
pub fn main() {
let nyan : cat = cat(52u, 99);

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[feature(struct_variant)];
enum E {
S0 { s: ~str },
S1 { u: uint }

View File

@ -16,7 +16,6 @@
// instead of in std.
use std::libc;
use std::run::*;
use std::run;
use std::str;

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[feature(struct_variant)];
#[deriving(Eq, TotalEq, Ord, TotalOrd)]
enum ES<T> {
ES1 { x: T },

View File

@ -13,11 +13,13 @@
// xfail-fast
#[feature(struct_variant)];
extern mod extra;
use std::io;
use std::rand::{random, Rand};
use extra::serialize::*;
use extra::serialize::{Encodable, Decodable};
use extra::ebml;
use extra::ebml::writer::Encoder;
use extra::ebml::reader::Decoder;

View File

@ -9,6 +9,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[feature(struct_variant)];
use std::rand;
#[deriving(Rand)]

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[feature(struct_variant)];
#[deriving(ToStr)]
enum A {}
#[deriving(ToStr)]

View File

@ -1,3 +1,5 @@
#[feature(struct_variant)];
#[deriving(Eq)]
enum S {
X { x: int, y: int },

View File

@ -1,5 +1,6 @@
#[allow(dead_assignment)];
#[allow(unused_variable)];
#[feature(struct_variant)];
enum Animal {
Dog (~str, f64),

View File

@ -15,6 +15,8 @@
// Modified to not use export since it's going away. --pcw
#[feature(globs)];
mod foo {
use foo::bar::*;
pub mod bar {

View File

@ -12,7 +12,7 @@
extern mod extra;
use extra::getopts::*;
use extra::getopts::{optopt, getopts};
pub fn main() {
let args = ~[];

View File

@ -12,7 +12,7 @@
extern mod extra;
use extra::glob::*;
use extra::glob::glob;
use extra::tempfile;
use std::unstable::finally::Finally;
use std::{io, os, unstable};

View File

@ -19,7 +19,7 @@
pub fn map(filename: ~str, emit: map_reduce::putter) { emit(filename, ~"1"); }
mod map_reduce {
use std::comm::*;
use std::comm::{stream, SharedChan};
use std::hashmap::HashMap;
use std::str;
use std::task;

View File

@ -10,6 +10,7 @@
// A test of the macro system. Can we do HTML literals?
#[feature(macro_rules)];
/*

View File

@ -10,6 +10,7 @@
// xfail-fast: check-fast screws up repr paths
#[feature(macro_rules)];
#[deny(warnings)];
use std::fmt;

View File

@ -10,6 +10,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[feature(globs)];
use module_of_many_things::*;
use dug::too::greedily::and::too::deep::*;

View File

@ -10,6 +10,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[feature(globs)];
#[allow(dead_assignment)];
extern mod extra;

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[feature(globs)];
pub fn main() {
use std::util::replace;
let mut x = 5;

View File

@ -10,6 +10,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[feature(globs)];
extern mod extra;
mod rusti {

View File

@ -10,6 +10,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[feature(globs)];
mod rusti {
#[abi = "rust-intrinsic"]
extern "rust-intrinsic" {

View File

@ -11,6 +11,7 @@
// xfail-fast
// aux-build:issue-2526.rs
#[feature(globs)];
#[allow(unused_imports)];
extern mod issue_2526;

View File

@ -13,7 +13,7 @@
extern mod req;
use req::*;
use req::request;
use std::hashmap::HashMap;
pub fn main() {

View File

@ -12,7 +12,7 @@
// aux-build:issue_2723_a.rs
extern mod issue_2723_a;
use issue_2723_a::*;
use issue_2723_a::f;
pub fn main() {
unsafe {

View File

@ -13,7 +13,7 @@
// Incorrect struct size computation in the FFI, because of not taking
// the alignment of elements into account.
use std::libc::*;
use std::libc::{c_uint, uint32_t, c_void};
struct KEYGEN {
hash_algorithm: [c_uint, ..2],

View File

@ -11,7 +11,7 @@
// xfail-fast
// aux-build:issue_3979_traits.rs
extern mod issue_3979_traits;
use issue_3979_traits::*;
use issue_3979_traits::{Positioned, Movable};
struct Point { x: int, y: int }

View File

@ -12,7 +12,7 @@
// xfail-fast - Windows hates cross-crate tests
extern mod numeric;
use numeric::*;
use numeric::{sin, Angle};
fn foo<T, A:Angle<T>>(theta: A) -> T { sin(&theta) }

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[feature(macro_rules)];
use std::io;
macro_rules! print_hd_tl (

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[feature(struct_variant)];
enum Enum {
Foo { foo: uint },
Bar { bar: uint }

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[feature(macro_rules)];
use std::num::Zero;
pub struct X<T> {

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[feature(macro_rules)];
macro_rules! silly_macro(
() => (
pub mod Qux {

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[feature(macro_rules)];
// shouldn't affect evaluation of $ex:
macro_rules! bad_macro (($ex:expr) => ({let _x = 9; $ex}))
pub fn main() {

Some files were not shown because too many files have changed in this diff Show More