mirror of
https://github.com/rust-lang/rust.git
synced 2024-10-30 22:12:15 +00:00
Switch to purely namespaced enums
This breaks code that referred to variant names in the same namespace as their enum. Reexport the variants in the old location or alter code to refer to the new locations: ``` pub enum Foo { A, B } fn main() { let a = A; } ``` => ``` pub use self::Foo::{A, B}; pub enum Foo { A, B } fn main() { let a = A; } ``` or ``` pub enum Foo { A, B } fn main() { let a = Foo::A; } ``` [breaking-change]
This commit is contained in:
parent
0047dbe59c
commit
3dcd215740
@ -7,6 +7,7 @@
|
||||
// <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.
|
||||
pub use self::Mode::*;
|
||||
|
||||
use std::fmt;
|
||||
use std::str::FromStr;
|
||||
|
@ -9,7 +9,7 @@
|
||||
// except according to those terms.
|
||||
|
||||
#![crate_type = "bin"]
|
||||
#![feature(phase, slicing_syntax)]
|
||||
#![feature(phase, slicing_syntax, globs)]
|
||||
|
||||
#![deny(warnings)]
|
||||
|
||||
|
@ -7,6 +7,8 @@
|
||||
// <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.
|
||||
#[cfg(not(stage0))]
|
||||
use self::TargetLocation::*;
|
||||
|
||||
use common::Config;
|
||||
use common::{CompileFail, Pretty, RunFail, RunPass, RunPassValgrind, DebugInfoGdb};
|
||||
|
@ -308,8 +308,8 @@ copying.
|
||||
# }
|
||||
fn compute_area(shape: &Shape) -> f64 {
|
||||
match *shape {
|
||||
Circle(_, radius) => std::f64::consts::PI * radius * radius,
|
||||
Rectangle(_, ref size) => size.w * size.h
|
||||
Shape::Circle(_, radius) => std::f64::consts::PI * radius * radius,
|
||||
Shape::Rectangle(_, ref size) => size.w * size.h
|
||||
}
|
||||
}
|
||||
~~~
|
||||
@ -478,14 +478,14 @@ example:
|
||||
# a: &'r T, b: &'r T) -> &'r T {
|
||||
# if compute_area(shape) > threshold {a} else {b}
|
||||
# }
|
||||
// -+ r
|
||||
fn select_based_on_unit_circle<'r, T>( // |-+ B
|
||||
threshold: f64, a: &'r T, b: &'r T) -> &'r T { // | |
|
||||
// | |
|
||||
let shape = Circle(Point {x: 0., y: 0.}, 1.); // | |
|
||||
select(&shape, threshold, a, b) // | |
|
||||
} // |-+
|
||||
// -+
|
||||
// -+ r
|
||||
fn select_based_on_unit_circle<'r, T>( // |-+ B
|
||||
threshold: f64, a: &'r T, b: &'r T) -> &'r T { // | |
|
||||
// | |
|
||||
let shape = Shape::Circle(Point {x: 0., y: 0.}, 1.); // | |
|
||||
select(&shape, threshold, a, b) // | |
|
||||
} // |-+
|
||||
// -+
|
||||
~~~
|
||||
|
||||
In this call to `select()`, the lifetime of the first parameter shape
|
||||
|
@ -22,15 +22,15 @@ doing nothing otherwise:
|
||||
~~~~
|
||||
# enum T { SpecialA(uint), SpecialB(uint) }
|
||||
# fn f() -> uint {
|
||||
# let input_1 = SpecialA(0);
|
||||
# let input_2 = SpecialA(0);
|
||||
# let input_1 = T::SpecialA(0);
|
||||
# let input_2 = T::SpecialA(0);
|
||||
match input_1 {
|
||||
SpecialA(x) => { return x; }
|
||||
T::SpecialA(x) => { return x; }
|
||||
_ => {}
|
||||
}
|
||||
// ...
|
||||
match input_2 {
|
||||
SpecialB(x) => { return x; }
|
||||
T::SpecialB(x) => { return x; }
|
||||
_ => {}
|
||||
}
|
||||
# return 0u;
|
||||
@ -49,10 +49,10 @@ the pattern in the above code:
|
||||
# #![feature(macro_rules)]
|
||||
# enum T { SpecialA(uint), SpecialB(uint) }
|
||||
# fn f() -> uint {
|
||||
# let input_1 = SpecialA(0);
|
||||
# let input_2 = SpecialA(0);
|
||||
# let input_1 = T::SpecialA(0);
|
||||
# let input_2 = T::SpecialA(0);
|
||||
macro_rules! early_return(
|
||||
($inp:expr $sp:ident) => ( // invoke it like `(input_5 SpecialE)`
|
||||
($inp:expr $sp:path) => ( // invoke it like `(input_5 SpecialE)`
|
||||
match $inp {
|
||||
$sp(x) => { return x; }
|
||||
_ => {}
|
||||
@ -60,9 +60,9 @@ macro_rules! early_return(
|
||||
);
|
||||
)
|
||||
// ...
|
||||
early_return!(input_1 SpecialA);
|
||||
early_return!(input_1 T::SpecialA);
|
||||
// ...
|
||||
early_return!(input_2 SpecialB);
|
||||
early_return!(input_2 T::SpecialB);
|
||||
# return 0;
|
||||
# }
|
||||
# fn main() {}
|
||||
@ -169,10 +169,10 @@ instead of `*` to mean "at least one".
|
||||
# #![feature(macro_rules)]
|
||||
# enum T { SpecialA(uint),SpecialB(uint),SpecialC(uint),SpecialD(uint)}
|
||||
# fn f() -> uint {
|
||||
# let input_1 = SpecialA(0);
|
||||
# let input_2 = SpecialA(0);
|
||||
# let input_1 = T::SpecialA(0);
|
||||
# let input_2 = T::SpecialA(0);
|
||||
macro_rules! early_return(
|
||||
($inp:expr, [ $($sp:ident)|+ ]) => (
|
||||
($inp:expr, [ $($sp:path)|+ ]) => (
|
||||
match $inp {
|
||||
$(
|
||||
$sp(x) => { return x; }
|
||||
@ -182,9 +182,9 @@ macro_rules! early_return(
|
||||
);
|
||||
)
|
||||
// ...
|
||||
early_return!(input_1, [SpecialA|SpecialC|SpecialD]);
|
||||
early_return!(input_1, [T::SpecialA|T::SpecialC|T::SpecialD]);
|
||||
// ...
|
||||
early_return!(input_2, [SpecialB]);
|
||||
early_return!(input_2, [T::SpecialB]);
|
||||
# return 0;
|
||||
# }
|
||||
# fn main() {}
|
||||
@ -234,9 +234,9 @@ Now consider code like the following:
|
||||
# enum T3 { Good2(uint), Bad2}
|
||||
# fn f(x: T1) -> uint {
|
||||
match x {
|
||||
Good1(g1, val) => {
|
||||
T1::Good1(g1, val) => {
|
||||
match g1.body {
|
||||
Good2(result) => {
|
||||
T3::Good2(result) => {
|
||||
// complicated stuff goes here
|
||||
return result + val;
|
||||
},
|
||||
@ -281,9 +281,9 @@ macro_rules! biased_match (
|
||||
# struct T2 { body: T3 }
|
||||
# enum T3 { Good2(uint), Bad2}
|
||||
# fn f(x: T1) -> uint {
|
||||
biased_match!((x) ~ (Good1(g1, val)) else { return 0 };
|
||||
biased_match!((x) ~ (T1::Good1(g1, val)) else { return 0 };
|
||||
binds g1, val )
|
||||
biased_match!((g1.body) ~ (Good2(result) )
|
||||
biased_match!((g1.body) ~ (T3::Good2(result) )
|
||||
else { panic!("Didn't get good_2") };
|
||||
binds result )
|
||||
// complicated stuff goes here
|
||||
@ -396,8 +396,8 @@ macro_rules! biased_match (
|
||||
# enum T3 { Good2(uint), Bad2}
|
||||
# fn f(x: T1) -> uint {
|
||||
biased_match!(
|
||||
(x) ~ (Good1(g1, val)) else { return 0 };
|
||||
(g1.body) ~ (Good2(result) ) else { panic!("Didn't get Good2") };
|
||||
(x) ~ (T1::Good1(g1, val)) else { return 0 };
|
||||
(g1.body) ~ (T3::Good2(result) ) else { panic!("Didn't get Good2") };
|
||||
binds val, result )
|
||||
// complicated stuff goes here
|
||||
return result + val;
|
||||
|
@ -598,7 +598,7 @@ enum List<T> {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let list: List<int> = Cons(1, box Cons(2, box Cons(3, box Nil)));
|
||||
let list: List<int> = List::Cons(1, box List::Cons(2, box List::Cons(3, box List::Nil)));
|
||||
println!("{}", list);
|
||||
}
|
||||
```
|
||||
|
@ -1263,17 +1263,17 @@ enum OptionalInt {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let x = Value(5);
|
||||
let y = Missing;
|
||||
let x = OptionalInt::Value(5);
|
||||
let y = OptionalInt::Missing;
|
||||
|
||||
match x {
|
||||
Value(n) => println!("x is {}", n),
|
||||
Missing => println!("x is missing!"),
|
||||
OptionalInt::Value(n) => println!("x is {}", n),
|
||||
OptionalInt::Missing => println!("x is missing!"),
|
||||
}
|
||||
|
||||
match y {
|
||||
Value(n) => println!("y is {}", n),
|
||||
Missing => println!("y is missing!"),
|
||||
OptionalInt::Value(n) => println!("y is {}", n),
|
||||
OptionalInt::Missing => println!("y is missing!"),
|
||||
}
|
||||
}
|
||||
```
|
||||
@ -1702,17 +1702,17 @@ enum OptionalInt {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let x = Value(5);
|
||||
let y = Missing;
|
||||
let x = OptionalInt::Value(5);
|
||||
let y = OptionalInt::Missing;
|
||||
|
||||
match x {
|
||||
Value(n) => println!("x is {}", n),
|
||||
Missing => println!("x is missing!"),
|
||||
OptionalInt::Value(n) => println!("x is {}", n),
|
||||
OptionalInt::Missing => println!("x is missing!"),
|
||||
}
|
||||
|
||||
match y {
|
||||
Value(n) => println!("y is {}", n),
|
||||
Missing => println!("y is missing!"),
|
||||
OptionalInt::Value(n) => println!("y is {}", n),
|
||||
OptionalInt::Missing => println!("y is missing!"),
|
||||
}
|
||||
}
|
||||
```
|
||||
@ -3709,7 +3709,7 @@ enum List {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let list = Node(0, box Node(1, box Nil));
|
||||
let list = List::Node(0, box List::Node(1, box List::Nil));
|
||||
}
|
||||
```
|
||||
|
||||
@ -3895,11 +3895,11 @@ enum OptionalInt {
|
||||
Missing,
|
||||
}
|
||||
|
||||
let x = Value(5i);
|
||||
let x = OptionalInt::Value(5i);
|
||||
|
||||
match x {
|
||||
Value(..) => println!("Got an int!"),
|
||||
Missing => println!("No such luck."),
|
||||
OptionalInt::Value(..) => println!("Got an int!"),
|
||||
OptionalInt::Missing => println!("No such luck."),
|
||||
}
|
||||
```
|
||||
|
||||
@ -3911,12 +3911,12 @@ enum OptionalInt {
|
||||
Missing,
|
||||
}
|
||||
|
||||
let x = Value(5i);
|
||||
let x = OptionalInt::Value(5i);
|
||||
|
||||
match x {
|
||||
Value(i) if i > 5 => println!("Got an int bigger than five!"),
|
||||
Value(..) => println!("Got an int!"),
|
||||
Missing => println!("No such luck."),
|
||||
OptionalInt::Value(i) if i > 5 => println!("Got an int bigger than five!"),
|
||||
OptionalInt::Value(..) => println!("Got an int!"),
|
||||
OptionalInt::Missing => println!("No such luck."),
|
||||
}
|
||||
```
|
||||
|
||||
|
@ -1331,8 +1331,8 @@ enum Animal {
|
||||
Cat
|
||||
}
|
||||
|
||||
let mut a: Animal = Dog;
|
||||
a = Cat;
|
||||
let mut a: Animal = Animal::Dog;
|
||||
a = Animal::Cat;
|
||||
```
|
||||
|
||||
Enumeration constructors can have either named or unnamed fields:
|
||||
@ -1345,8 +1345,8 @@ enum Animal {
|
||||
Cat { name: String, weight: f64 }
|
||||
}
|
||||
|
||||
let mut a: Animal = Dog("Cocoa".to_string(), 37.2);
|
||||
a = Cat { name: "Spotty".to_string(), weight: 2.7 };
|
||||
let mut a: Animal = Animal::Dog("Cocoa".to_string(), 37.2);
|
||||
a = Animal::Cat { name: "Spotty".to_string(), weight: 2.7 };
|
||||
# }
|
||||
```
|
||||
|
||||
@ -3308,12 +3308,12 @@ fields of a particular variant. For example:
|
||||
```
|
||||
enum List<X> { Nil, Cons(X, Box<List<X>>) }
|
||||
|
||||
let x: List<int> = Cons(10, box Cons(11, box Nil));
|
||||
let x: List<int> = List::Cons(10, box List::Cons(11, box List::Nil));
|
||||
|
||||
match x {
|
||||
Cons(_, box Nil) => panic!("singleton list"),
|
||||
Cons(..) => return,
|
||||
Nil => panic!("empty list")
|
||||
List::Cons(_, box List::Nil) => panic!("singleton list"),
|
||||
List::Cons(..) => return,
|
||||
List::Nil => panic!("empty list")
|
||||
}
|
||||
```
|
||||
|
||||
@ -3371,16 +3371,16 @@ An example of a `match` expression:
|
||||
|
||||
enum List<X> { Nil, Cons(X, Box<List<X>>) }
|
||||
|
||||
let x: List<int> = Cons(10, box Cons(11, box Nil));
|
||||
let x: List<int> = List::Cons(10, box List::Cons(11, box List::Nil));
|
||||
|
||||
match x {
|
||||
Cons(a, box Cons(b, _)) => {
|
||||
List::Cons(a, box List::Cons(b, _)) => {
|
||||
process_pair(a, b);
|
||||
}
|
||||
Cons(10, _) => {
|
||||
List::Cons(10, _) => {
|
||||
process_ten();
|
||||
}
|
||||
Nil => {
|
||||
List::Nil => {
|
||||
return;
|
||||
}
|
||||
_ => {
|
||||
@ -3402,10 +3402,10 @@ enum List { Nil, Cons(uint, Box<List>) }
|
||||
|
||||
fn is_sorted(list: &List) -> bool {
|
||||
match *list {
|
||||
Nil | Cons(_, box Nil) => true,
|
||||
Cons(x, ref r @ box Cons(_, _)) => {
|
||||
List::Nil | List::Cons(_, box List::Nil) => true,
|
||||
List::Cons(x, ref r @ box List::Cons(_, _)) => {
|
||||
match *r {
|
||||
box Cons(y, _) => (x <= y) && is_sorted(&**r),
|
||||
box List::Cons(y, _) => (x <= y) && is_sorted(&**r),
|
||||
_ => panic!()
|
||||
}
|
||||
}
|
||||
@ -3413,7 +3413,7 @@ fn is_sorted(list: &List) -> bool {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let a = Cons(6, box Cons(7, box Cons(42, box Nil)));
|
||||
let a = List::Cons(6, box List::Cons(7, box List::Cons(42, box List::Nil)));
|
||||
assert!(is_sorted(&a));
|
||||
}
|
||||
|
||||
@ -3718,7 +3718,7 @@ enum List<T> {
|
||||
Cons(T, Box<List<T>>)
|
||||
}
|
||||
|
||||
let a: List<int> = Cons(7, box Cons(13, box Nil));
|
||||
let a: List<int> = List::Cons(7, box List::Cons(13, box List::Nil));
|
||||
```
|
||||
|
||||
### Pointer types
|
||||
|
@ -391,6 +391,7 @@ def emit_conversions_module(f, lowerupper, upperlower):
|
||||
def emit_grapheme_module(f, grapheme_table, grapheme_cats):
|
||||
f.write("""pub mod grapheme {
|
||||
use core::slice::SlicePrelude;
|
||||
pub use self::GraphemeCat::*;
|
||||
use core::slice;
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
|
@ -15,8 +15,11 @@
|
||||
// writing (August 2014) freely licensed under the following Creative Commons Attribution
|
||||
// License: [CC BY 2.5 CA](http://creativecommons.org/licenses/by/2.5/ca/).
|
||||
|
||||
pub use self::Entry::*;
|
||||
|
||||
use core::prelude::*;
|
||||
|
||||
use self::StackOp::*;
|
||||
use super::node::*;
|
||||
use std::hash::{Writer, Hash};
|
||||
use core::default::Default;
|
||||
@ -445,6 +448,7 @@ impl<K: Ord, V> BTreeMap<K, V> {
|
||||
/// to nodes. By using this module much better safety guarantees can be made, and more search
|
||||
/// boilerplate gets cut out.
|
||||
mod stack {
|
||||
pub use self::PushResult::*;
|
||||
use core::prelude::*;
|
||||
use super::BTreeMap;
|
||||
use super::super::node::*;
|
||||
|
@ -11,6 +11,10 @@
|
||||
// This module represents all the internal representation and logic for a B-Tree's node
|
||||
// with a safe interface, so that BTreeMap itself does not depend on any of these details.
|
||||
|
||||
pub use self::InsertionResult::*;
|
||||
pub use self::SearchResult::*;
|
||||
pub use self::TraversalItem::*;
|
||||
|
||||
use core::prelude::*;
|
||||
|
||||
use core::{slice, mem, ptr};
|
||||
|
@ -260,6 +260,7 @@ impl<E:CLike> Extend<E> for EnumSet<E> {
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use std::prelude::*;
|
||||
use self::Foo::*;
|
||||
use std::mem;
|
||||
|
||||
use super::{EnumSet, CLike};
|
||||
@ -488,6 +489,6 @@ mod test {
|
||||
}
|
||||
}
|
||||
let mut set = EnumSet::new();
|
||||
set.insert(V64);
|
||||
set.insert(Bar::V64);
|
||||
}
|
||||
}
|
||||
|
@ -845,6 +845,8 @@ impl<T: fmt::Show> fmt::Show for RingBuf<T> {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use self::Taggy::*;
|
||||
use self::Taggypar::*;
|
||||
use std::fmt::Show;
|
||||
use std::prelude::*;
|
||||
use std::hash;
|
||||
|
@ -87,6 +87,7 @@
|
||||
|
||||
#![doc(primitive = "slice")]
|
||||
|
||||
use self::Direction::*;
|
||||
use alloc::boxed::Box;
|
||||
use core::cmp;
|
||||
use core::kinds::Sized;
|
||||
|
@ -51,6 +51,10 @@
|
||||
|
||||
#![doc(primitive = "str")]
|
||||
|
||||
pub use self::MaybeOwned::*;
|
||||
use self::RecompositionState::*;
|
||||
use self::DecompositionType::*;
|
||||
|
||||
use core::default::Default;
|
||||
use core::fmt;
|
||||
use core::cmp;
|
||||
|
@ -9,9 +9,10 @@
|
||||
// except according to those terms.
|
||||
|
||||
//! Ordered maps and sets, implemented as simple tries.
|
||||
|
||||
use core::prelude::*;
|
||||
|
||||
pub use self::Entry::*;
|
||||
use self::TrieNode::*;
|
||||
use alloc::boxed::Box;
|
||||
use core::default::Default;
|
||||
use core::fmt;
|
||||
@ -105,7 +106,7 @@ struct InternalNode<T> {
|
||||
}
|
||||
|
||||
// Each child of an InternalNode may be internal, in which case nesting continues,
|
||||
// external (containing a value), or empty.
|
||||
// external (containing a value), or empty
|
||||
#[deriving(Clone)]
|
||||
enum TrieNode<T> {
|
||||
Internal(Box<InternalNode<T>>),
|
||||
@ -1221,8 +1222,9 @@ mod test {
|
||||
use std::uint;
|
||||
use std::hash;
|
||||
|
||||
use super::{TrieMap, InternalNode, Internal, External, Nothing};
|
||||
use super::{Occupied, Vacant};
|
||||
use super::{TrieMap, InternalNode};
|
||||
use super::Entry::*;
|
||||
use super::TrieNode::*;
|
||||
|
||||
fn check_integrity<T>(trie: &InternalNode<T>) {
|
||||
assert!(trie.count != 0);
|
||||
|
@ -12,6 +12,8 @@
|
||||
|
||||
#![stable]
|
||||
|
||||
pub use self::Ordering::*;
|
||||
|
||||
use intrinsics;
|
||||
use std::kinds::marker;
|
||||
use cell::UnsafeCell;
|
||||
|
@ -41,6 +41,8 @@
|
||||
|
||||
#![stable]
|
||||
|
||||
pub use self::Ordering::*;
|
||||
|
||||
use kinds::Sized;
|
||||
use option::{Option, Some, None};
|
||||
|
||||
|
@ -51,7 +51,7 @@
|
||||
//! }
|
||||
//!
|
||||
//! impl Default for Kind {
|
||||
//! fn default() -> Kind { A }
|
||||
//! fn default() -> Kind { Kind::A }
|
||||
//! }
|
||||
//!
|
||||
//! #[deriving(Default)]
|
||||
@ -127,7 +127,7 @@ pub trait Default {
|
||||
/// }
|
||||
///
|
||||
/// impl Default for Kind {
|
||||
/// fn default() -> Kind { A }
|
||||
/// fn default() -> Kind { Kind::A }
|
||||
/// }
|
||||
/// ```
|
||||
fn default() -> Self;
|
||||
|
@ -10,6 +10,10 @@
|
||||
|
||||
#![allow(missing_docs)]
|
||||
|
||||
pub use self::ExponentFormat::*;
|
||||
pub use self::SignificantDigits::*;
|
||||
pub use self::SignFormat::*;
|
||||
|
||||
use char;
|
||||
use fmt;
|
||||
use iter::{range, DoubleEndedIterator};
|
||||
|
@ -12,6 +12,8 @@
|
||||
|
||||
#![allow(unused_variables)]
|
||||
|
||||
pub use self::FormatError::*;
|
||||
|
||||
use any;
|
||||
use cell::{Cell, Ref, RefMut};
|
||||
use iter::{Iterator, range};
|
||||
|
@ -14,6 +14,11 @@
|
||||
//! These definitions are similar to their `ct` equivalents, but differ in that
|
||||
//! these can be statically allocated and are slightly optimized for the runtime
|
||||
|
||||
pub use self::Alignment::*;
|
||||
pub use self::Count::*;
|
||||
pub use self::Position::*;
|
||||
pub use self::Flag::*;
|
||||
|
||||
#[doc(hidden)]
|
||||
pub struct Argument<'a> {
|
||||
pub position: Position,
|
||||
|
@ -58,6 +58,8 @@ This `for` loop syntax can be applied to any iterator over any type.
|
||||
|
||||
*/
|
||||
|
||||
pub use self::MinMaxResult::*;
|
||||
|
||||
use clone::Clone;
|
||||
use cmp;
|
||||
use cmp::Ord;
|
||||
|
@ -14,6 +14,8 @@
|
||||
|
||||
#![allow(missing_docs)]
|
||||
|
||||
pub use self::FPCategory::*;
|
||||
|
||||
use {int, i8, i16, i32, i64};
|
||||
use {uint, u8, u16, u32, u64};
|
||||
use {f32, f64};
|
||||
|
@ -112,12 +112,12 @@
|
||||
//!
|
||||
//! // A list of data to search through.
|
||||
//! let all_the_big_things = [
|
||||
//! Plant(250, "redwood"),
|
||||
//! Plant(230, "noble fir"),
|
||||
//! Plant(229, "sugar pine"),
|
||||
//! Animal(25, "blue whale"),
|
||||
//! Animal(19, "fin whale"),
|
||||
//! Animal(15, "north pacific right whale"),
|
||||
//! Kingdom::Plant(250, "redwood"),
|
||||
//! Kingdom::Plant(230, "noble fir"),
|
||||
//! Kingdom::Plant(229, "sugar pine"),
|
||||
//! Kingdom::Animal(25, "blue whale"),
|
||||
//! Kingdom::Animal(19, "fin whale"),
|
||||
//! Kingdom::Animal(15, "north pacific right whale"),
|
||||
//! ];
|
||||
//!
|
||||
//! // We're going to search for the name of the biggest animal,
|
||||
@ -126,12 +126,12 @@
|
||||
//! let mut size_of_biggest_animal = 0;
|
||||
//! for big_thing in all_the_big_things.iter() {
|
||||
//! match *big_thing {
|
||||
//! Animal(size, name) if size > size_of_biggest_animal => {
|
||||
//! Kingdom::Animal(size, name) if size > size_of_biggest_animal => {
|
||||
//! // Now we've found the name of some big animal
|
||||
//! size_of_biggest_animal = size;
|
||||
//! name_of_biggest_animal = Some(name);
|
||||
//! }
|
||||
//! Animal(..) | Plant(..) => ()
|
||||
//! Kingdom::Animal(..) | Kingdom::Plant(..) => ()
|
||||
//! }
|
||||
//! }
|
||||
//!
|
||||
@ -143,6 +143,8 @@
|
||||
|
||||
#![stable]
|
||||
|
||||
pub use self::Option::*;
|
||||
|
||||
use cmp::{Eq, Ord};
|
||||
use default::Default;
|
||||
use iter::{Iterator, DoubleEndedIterator, FromIterator, ExactSize};
|
||||
|
@ -48,14 +48,17 @@ pub use str::from_str;
|
||||
pub use char::Char;
|
||||
pub use clone::Clone;
|
||||
pub use cmp::{PartialEq, PartialOrd, Eq, Ord};
|
||||
pub use cmp::{Ordering, Less, Equal, Greater, Equiv};
|
||||
pub use cmp::{Ordering, Equiv};
|
||||
pub use cmp::Ordering::{Less, Equal, Greater};
|
||||
pub use iter::{FromIterator, Extend};
|
||||
pub use iter::{Iterator, DoubleEndedIterator, RandomAccessIterator, CloneableIterator};
|
||||
pub use iter::{OrdIterator, MutableDoubleEndedIterator, ExactSize};
|
||||
pub use num::{ToPrimitive, FromPrimitive};
|
||||
pub use option::{Option, Some, None};
|
||||
pub use option::Option;
|
||||
pub use option::Option::{Some, None};
|
||||
pub use ptr::RawPtr;
|
||||
pub use result::{Result, Ok, Err};
|
||||
pub use result::Result;
|
||||
pub use result::Result::{Ok, Err};
|
||||
pub use str::{Str, StrPrelude};
|
||||
pub use tuple::{Tuple1, Tuple2, Tuple3, Tuple4};
|
||||
pub use tuple::{Tuple5, Tuple6, Tuple7, Tuple8};
|
||||
|
@ -38,8 +38,8 @@
|
||||
//! return Err("invalid header length");
|
||||
//! }
|
||||
//! match header[0] {
|
||||
//! 1 => Ok(Version1),
|
||||
//! 2 => Ok(Version2),
|
||||
//! 1 => Ok(Version::Version1),
|
||||
//! 2 => Ok(Version::Version2),
|
||||
//! _ => Err("invalid version")
|
||||
//! }
|
||||
//! }
|
||||
@ -276,6 +276,8 @@
|
||||
|
||||
#![stable]
|
||||
|
||||
pub use self::Result::*;
|
||||
|
||||
use std::fmt::Show;
|
||||
use slice;
|
||||
use slice::AsSlice;
|
||||
|
@ -34,6 +34,8 @@
|
||||
// * The `raw` and `bytes` submodules.
|
||||
// * Boilerplate trait implementations.
|
||||
|
||||
pub use self::BinarySearchResult::*;
|
||||
|
||||
use mem::transmute;
|
||||
use clone::Clone;
|
||||
use cmp::{PartialEq, PartialOrd, Eq, Ord, Ordering, Less, Equal, Greater, Equiv};
|
||||
|
@ -16,6 +16,9 @@
|
||||
|
||||
#![doc(primitive = "str")]
|
||||
|
||||
pub use self::Utf16Item::*;
|
||||
pub use self::Searcher::{Naive, TwoWay, TwoWayLong};
|
||||
|
||||
use mem;
|
||||
use char;
|
||||
use char::Char;
|
||||
|
@ -20,6 +20,11 @@
|
||||
#![crate_type = "rlib"]
|
||||
#![crate_type = "dylib"]
|
||||
#![feature(macro_rules, globs, import_shadowing)]
|
||||
pub use self::Piece::*;
|
||||
pub use self::Position::*;
|
||||
pub use self::Alignment::*;
|
||||
pub use self::Flag::*;
|
||||
pub use self::Count::*;
|
||||
|
||||
use std::char;
|
||||
use std::str;
|
||||
|
@ -93,6 +93,13 @@
|
||||
|
||||
#[cfg(test)] #[phase(plugin, link)] extern crate log;
|
||||
|
||||
pub use self::Name::*;
|
||||
pub use self::HasArg::*;
|
||||
pub use self::Occur::*;
|
||||
pub use self::Fail_::*;
|
||||
pub use self::FailType::*;
|
||||
use self::Optval::*;
|
||||
|
||||
use std::fmt;
|
||||
use std::result::{Err, Ok};
|
||||
use std::result;
|
||||
@ -831,6 +838,20 @@ pub fn short_usage(program_name: &str, opts: &[OptGroup]) -> String {
|
||||
line
|
||||
}
|
||||
|
||||
enum SplitWithinState {
|
||||
A, // leading whitespace, initial state
|
||||
B, // words
|
||||
C, // internal and trailing whitespace
|
||||
}
|
||||
enum Whitespace {
|
||||
Ws, // current char is whitespace
|
||||
Cr // current char is not whitespace
|
||||
}
|
||||
enum LengthLimit {
|
||||
UnderLim, // current char makes current substring still fit in limit
|
||||
OverLim // current char makes current substring no longer fit in limit
|
||||
}
|
||||
|
||||
|
||||
/// Splits a string into substrings with possibly internal whitespace,
|
||||
/// each of them at most `lim` bytes long. The substrings have leading and trailing
|
||||
@ -845,22 +866,11 @@ pub fn short_usage(program_name: &str, opts: &[OptGroup]) -> String {
|
||||
/// sequence longer than the limit.
|
||||
fn each_split_within<'a>(ss: &'a str, lim: uint, it: |&'a str| -> bool)
|
||||
-> bool {
|
||||
use self::SplitWithinState::*;
|
||||
use self::Whitespace::*;
|
||||
use self::LengthLimit::*;
|
||||
// Just for fun, let's write this as a state machine:
|
||||
|
||||
enum SplitWithinState {
|
||||
A, // leading whitespace, initial state
|
||||
B, // words
|
||||
C, // internal and trailing whitespace
|
||||
}
|
||||
enum Whitespace {
|
||||
Ws, // current char is whitespace
|
||||
Cr // current char is not whitespace
|
||||
}
|
||||
enum LengthLimit {
|
||||
UnderLim, // current char makes current substring still fit in limit
|
||||
OverLim // current char makes current substring no longer fit in limit
|
||||
}
|
||||
|
||||
let mut slice_start = 0;
|
||||
let mut last_start = 0;
|
||||
let mut last_end = 0;
|
||||
|
@ -274,6 +274,9 @@ pub fn main() {
|
||||
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
|
||||
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
|
||||
html_root_url = "http://doc.rust-lang.org/nightly/")]
|
||||
#![feature(globs)]
|
||||
|
||||
pub use self::LabelText::*;
|
||||
|
||||
use std::io;
|
||||
use std::str;
|
||||
@ -539,6 +542,7 @@ pub fn render<'a, N:'a, E:'a, G:Labeller<'a,N,E>+GraphWalk<'a,N,E>, W:Writer>(
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use self::NodeLabels::*;
|
||||
use super::{Id, LabelText, LabelStr, EscStr, Labeller};
|
||||
use super::{Nodes, Edges, GraphWalk, render};
|
||||
use std::io::{MemWriter, BufReader, IoResult};
|
||||
|
@ -8,6 +8,8 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
pub use self::MaybeOwnedVector::*;
|
||||
|
||||
use std::default::Default;
|
||||
use std::fmt;
|
||||
use std::iter::FromIterator;
|
||||
|
@ -14,6 +14,7 @@
|
||||
//!
|
||||
//! This implementation is also used as the fallback implementation of an event
|
||||
//! loop if no other one is provided (and M:N scheduling is desired).
|
||||
use self::Message::*;
|
||||
|
||||
use alloc::arc::Arc;
|
||||
use std::sync::atomic;
|
||||
|
@ -183,8 +183,7 @@
|
||||
html_root_url = "http://doc.rust-lang.org/nightly/",
|
||||
html_playground_url = "http://play.rust-lang.org/")]
|
||||
|
||||
// NB this does *not* include globs, please keep it that way.
|
||||
#![feature(macro_rules, phase, default_type_params)]
|
||||
#![feature(macro_rules, phase, default_type_params, globs)]
|
||||
#![allow(deprecated)]
|
||||
|
||||
#[cfg(test)] #[phase(plugin, link)] extern crate log;
|
||||
|
@ -8,6 +8,8 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
pub use self::PopResult::*;
|
||||
|
||||
use alloc::arc::Arc;
|
||||
use std::sync::mpsc_queue as mpsc;
|
||||
use std::kinds::marker;
|
||||
|
@ -8,6 +8,9 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
pub use self::SchedMessage::*;
|
||||
use self::EffortLevel::*;
|
||||
|
||||
use std::mem;
|
||||
use std::rt::local::Local;
|
||||
use std::rt::mutex::NativeMutex;
|
||||
|
@ -18,6 +18,9 @@
|
||||
//! contains the rust task itself in order to juggle around ownership of the
|
||||
//! values.
|
||||
|
||||
pub use self::TaskType::*;
|
||||
pub use self::Home::*;
|
||||
|
||||
use std::any::Any;
|
||||
use std::mem;
|
||||
use std::raw;
|
||||
|
@ -85,6 +85,8 @@ extern crate core;
|
||||
#[cfg(test)] extern crate test;
|
||||
#[cfg(test)] extern crate native;
|
||||
|
||||
pub use self::Nullable::*;
|
||||
|
||||
// Explicit export lists for the intersection (provided here) mean that
|
||||
// you can write more-platform-agnostic code if you stick to just these
|
||||
// symbols.
|
||||
|
@ -58,7 +58,7 @@
|
||||
#![deny(unused_results, unused_must_use)]
|
||||
#![allow(non_camel_case_types)]
|
||||
#![allow(unknown_features)]
|
||||
#![feature(default_type_params, lang_items, slicing_syntax)]
|
||||
#![feature(default_type_params, lang_items, slicing_syntax, globs)]
|
||||
|
||||
// NB this crate explicitly does *not* allow glob imports, please seriously
|
||||
// consider whether they're needed before adding that feature here (the
|
||||
|
@ -12,6 +12,9 @@
|
||||
|
||||
//! The Gamma and derived distributions.
|
||||
|
||||
use self::GammaRepr::*;
|
||||
use self::ChiSquaredRepr::*;
|
||||
|
||||
use core::num::Float;
|
||||
|
||||
use {Rng, Open01};
|
||||
|
@ -25,7 +25,7 @@
|
||||
html_root_url = "http://doc.rust-lang.org/nightly/",
|
||||
html_playground_url = "http://play.rust-lang.org/")]
|
||||
#![allow(unknown_features)]
|
||||
#![feature(macro_rules, phase, slicing_syntax)]
|
||||
#![feature(macro_rules, phase, slicing_syntax, globs)]
|
||||
#![allow(missing_docs)]
|
||||
|
||||
extern crate serialize;
|
||||
@ -33,6 +33,9 @@ extern crate serialize;
|
||||
#[phase(plugin, link)] extern crate log;
|
||||
#[cfg(test)] extern crate test;
|
||||
|
||||
pub use self::EbmlEncoderTag::*;
|
||||
pub use self::Error::*;
|
||||
|
||||
use std::str;
|
||||
|
||||
pub mod io;
|
||||
|
@ -11,6 +11,8 @@
|
||||
// Enable this to squash warnings due to exporting pieces of the representation
|
||||
// for use with the regex! macro. See lib.rs for explanation.
|
||||
|
||||
pub use self::Inst::*;
|
||||
|
||||
use std::cmp;
|
||||
use parse;
|
||||
use parse::{
|
||||
|
@ -370,7 +370,7 @@
|
||||
html_playground_url = "http://play.rust-lang.org/")]
|
||||
|
||||
#![allow(unknown_features)]
|
||||
#![feature(macro_rules, phase, slicing_syntax)]
|
||||
#![feature(macro_rules, phase, slicing_syntax, globs)]
|
||||
#![deny(missing_docs)]
|
||||
|
||||
#[cfg(test)]
|
||||
|
@ -8,6 +8,11 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
pub use self::Ast::*;
|
||||
pub use self::Repeater::*;
|
||||
pub use self::Greed::*;
|
||||
use self::BuildAst::*;
|
||||
|
||||
use std::char;
|
||||
use std::cmp;
|
||||
use std::fmt;
|
||||
|
@ -8,6 +8,9 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
pub use self::NamesIter::*;
|
||||
pub use self::Regex::*;
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::fmt;
|
||||
use std::str::{MaybeOwned, Owned, Slice};
|
||||
|
@ -33,6 +33,9 @@
|
||||
//
|
||||
// [1] - http://swtch.com/~rsc/regex/regex3.html
|
||||
|
||||
pub use self::MatchKind::*;
|
||||
pub use self::StepState::*;
|
||||
|
||||
use std::cmp;
|
||||
use std::mem;
|
||||
use std::slice::SlicePrelude;
|
||||
|
@ -8,6 +8,8 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
pub use self::OutputType::*;
|
||||
|
||||
use back::lto;
|
||||
use back::link::{get_cc_prog, remove};
|
||||
use driver::driver::{CrateTranslation, ModuleTranslation, OutputFilenames};
|
||||
|
@ -11,6 +11,12 @@
|
||||
//! Contains infrastructure for configuring the compiler, including parsing
|
||||
//! command line options.
|
||||
|
||||
pub use self::EntryFnType::*;
|
||||
pub use self::CrateType::*;
|
||||
pub use self::Passes::*;
|
||||
pub use self::OptLevel::*;
|
||||
pub use self::DebugInfoLevel::*;
|
||||
|
||||
use driver::{early_error, early_warn};
|
||||
use driver::driver;
|
||||
use driver::session::Session;
|
||||
|
@ -8,6 +8,7 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
pub use self::Input::*;
|
||||
|
||||
use back::link;
|
||||
use back::write;
|
||||
|
@ -10,6 +10,11 @@
|
||||
|
||||
//! The various pretty print routines.
|
||||
|
||||
pub use self::UserIdentifiedItem::*;
|
||||
pub use self::PpSourceMode::*;
|
||||
pub use self::PpMode::*;
|
||||
use self::NodesMatchingUII::*;
|
||||
|
||||
use back::link;
|
||||
|
||||
use driver::config;
|
||||
|
@ -24,6 +24,7 @@
|
||||
//! `add_builtin!` or `add_builtin_with_new!` invocation in `context.rs`.
|
||||
//! Use the former for unit-like structs and the latter for structs with
|
||||
//! a `pub fn new()`.
|
||||
use self::MethodContext::*;
|
||||
|
||||
use metadata::csearch;
|
||||
use middle::def::*;
|
||||
|
@ -23,6 +23,7 @@
|
||||
//! previous lint state is pushed onto a stack and the ast is then recursed
|
||||
//! upon. As the ast is traversed, this keeps track of the current lint level
|
||||
//! for all lint attributes.
|
||||
use self::TargetLint::*;
|
||||
|
||||
use middle::privacy::ExportedItems;
|
||||
use middle::subst;
|
||||
|
@ -30,6 +30,9 @@
|
||||
|
||||
#![macro_escape]
|
||||
|
||||
pub use self::Level::*;
|
||||
pub use self::LintSource::*;
|
||||
|
||||
use std::hash;
|
||||
use std::ascii::AsciiExt;
|
||||
use syntax::codemap::Span;
|
||||
|
@ -10,6 +10,8 @@
|
||||
|
||||
#![allow(non_camel_case_types, non_upper_case_globals)]
|
||||
|
||||
pub use self::astencode_tag::*;
|
||||
|
||||
use std::mem;
|
||||
use back::svh::Svh;
|
||||
|
||||
|
@ -12,6 +12,8 @@
|
||||
|
||||
#![allow(non_camel_case_types)]
|
||||
|
||||
pub use self::found_ast::*;
|
||||
|
||||
use metadata::common::*;
|
||||
use metadata::cstore;
|
||||
use metadata::decoder;
|
||||
|
@ -13,6 +13,10 @@
|
||||
// The crate store - a central repo for information collected about external
|
||||
// crates and libraries
|
||||
|
||||
pub use self::MetadataBlob::*;
|
||||
pub use self::LinkagePreference::*;
|
||||
pub use self::NativeLibaryKind::*;
|
||||
|
||||
use back::svh::Svh;
|
||||
use metadata::decoder;
|
||||
use metadata::loader;
|
||||
|
@ -12,6 +12,9 @@
|
||||
|
||||
#![allow(non_camel_case_types)]
|
||||
|
||||
pub use self::DefLike::*;
|
||||
use self::Family::*;
|
||||
|
||||
use back::svh::Svh;
|
||||
use metadata::cstore::crate_metadata;
|
||||
use metadata::common::*;
|
||||
|
@ -13,6 +13,8 @@
|
||||
#![allow(unused_must_use)] // everything is just a MemWriter, can't fail
|
||||
#![allow(non_camel_case_types)]
|
||||
|
||||
pub use self::InlinedItemRef::*;
|
||||
|
||||
use back::svh::Svh;
|
||||
use driver::config;
|
||||
use metadata::common::*;
|
||||
@ -151,6 +153,10 @@ fn encode_variant_id(rbml_w: &mut Encoder, vid: DefId) {
|
||||
let s = def_to_string(vid);
|
||||
rbml_w.writer.write(s.as_bytes());
|
||||
rbml_w.end_tag();
|
||||
|
||||
rbml_w.start_tag(tag_mod_child);
|
||||
rbml_w.wr_str(s.as_slice());
|
||||
rbml_w.end_tag();
|
||||
}
|
||||
|
||||
pub fn write_closure_type(ecx: &EncodeContext,
|
||||
|
@ -10,6 +10,8 @@
|
||||
|
||||
#![allow(non_camel_case_types)]
|
||||
|
||||
pub use self::FileMatch::*;
|
||||
|
||||
use std::cell::RefCell;
|
||||
use std::collections::HashSet;
|
||||
use std::io::fs::PathExtensions;
|
||||
|
@ -16,6 +16,8 @@
|
||||
|
||||
#![allow(non_camel_case_types)]
|
||||
|
||||
pub use self::DefIdSource::*;
|
||||
|
||||
use middle::subst;
|
||||
use middle::subst::VecPerParamSpace;
|
||||
use middle::ty;
|
||||
|
@ -16,7 +16,7 @@
|
||||
// 2. loans made in overlapping scopes do not conflict
|
||||
// 3. assignments do not affect things loaned out as immutable
|
||||
// 4. moves do not affect things loaned out in any way
|
||||
|
||||
use self::UseError::*;
|
||||
|
||||
use middle::borrowck::*;
|
||||
use middle::expr_use_visitor as euv;
|
||||
|
@ -12,6 +12,8 @@
|
||||
* Computes the restrictions that result from a borrow.
|
||||
*/
|
||||
|
||||
pub use self::RestrictionResult::*;
|
||||
|
||||
use middle::borrowck::*;
|
||||
use middle::expr_use_visitor as euv;
|
||||
use middle::mem_categorization as mc;
|
||||
|
@ -12,6 +12,8 @@
|
||||
//! libgraphviz traits, specialized to attaching borrowck analysis
|
||||
//! data to rendered labels.
|
||||
|
||||
pub use self::Variant::*;
|
||||
|
||||
/// For clarity, rename the graphviz crate locally to dot.
|
||||
use graphviz as dot;
|
||||
pub use middle::cfg::graphviz::{Node, Edge};
|
||||
|
@ -12,6 +12,12 @@
|
||||
|
||||
#![allow(non_camel_case_types)]
|
||||
|
||||
pub use self::LoanPath::*;
|
||||
pub use self::LoanPathElem::*;
|
||||
pub use self::bckerr_code::*;
|
||||
pub use self::AliasableViolationKind::*;
|
||||
pub use self::MovedValueUseKind::*;
|
||||
|
||||
use middle::cfg;
|
||||
use middle::dataflow::DataFlowContext;
|
||||
use middle::dataflow::BitwiseOperator;
|
||||
|
@ -15,6 +15,8 @@ comments in the section "Moves and initialization" and in `doc.rs`.
|
||||
|
||||
*/
|
||||
|
||||
pub use self::MoveKind::*;
|
||||
|
||||
use std::cell::RefCell;
|
||||
use std::rc::Rc;
|
||||
use std::uint;
|
||||
|
@ -7,6 +7,7 @@
|
||||
// <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 self::Context::*;
|
||||
|
||||
use driver::session::Session;
|
||||
|
||||
|
@ -8,6 +8,10 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
pub use self::Constructor::*;
|
||||
use self::Usefulness::*;
|
||||
use self::WitnessPreference::*;
|
||||
|
||||
use middle::const_eval::{compare_const_vals, const_bool, const_float, const_val};
|
||||
use middle::const_eval::{const_expr_to_pat, eval_const_expr, lookup_const_by_id};
|
||||
use middle::def::*;
|
||||
|
@ -23,6 +23,7 @@
|
||||
// Rules Enforced Elsewhere:
|
||||
// - It's not possible to take the address of a static item with unsafe interior. This is enforced
|
||||
// by borrowck::gather_loans
|
||||
use self::Mode::*;
|
||||
|
||||
use middle::ty;
|
||||
use middle::def;
|
||||
|
@ -11,6 +11,9 @@
|
||||
#![allow(non_camel_case_types)]
|
||||
#![allow(unsigned_negation)]
|
||||
|
||||
pub use self::const_val::*;
|
||||
pub use self::constness::*;
|
||||
|
||||
use metadata::csearch;
|
||||
use middle::astencode;
|
||||
use middle::def;
|
||||
|
@ -16,6 +16,7 @@
|
||||
* GEN and KILL bits for each expression.
|
||||
*/
|
||||
|
||||
pub use self::EntryOrExit::*;
|
||||
|
||||
use middle::cfg;
|
||||
use middle::cfg::CFGIndex;
|
||||
|
@ -8,6 +8,9 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
pub use self::Def::*;
|
||||
pub use self::MethodProvenance::*;
|
||||
|
||||
use middle::subst::ParamSpace;
|
||||
use syntax::ast;
|
||||
use syntax::ast_util::local_def;
|
||||
|
@ -10,6 +10,7 @@
|
||||
|
||||
//! Enforces the Rust effect system. Currently there is just one effect,
|
||||
/// `unsafe`.
|
||||
use self::UnsafeContext::*;
|
||||
|
||||
use middle::def;
|
||||
use middle::ty;
|
||||
|
@ -14,6 +14,12 @@
|
||||
* `ExprUseVisitor` determines how expressions are being used.
|
||||
*/
|
||||
|
||||
pub use self::MutateMode::*;
|
||||
pub use self::LoanCause::*;
|
||||
pub use self::ConsumeMode::*;
|
||||
pub use self::MoveReason::*;
|
||||
use self::OverloadedCallType::*;
|
||||
|
||||
use middle::mem_categorization as mc;
|
||||
use middle::def;
|
||||
use middle::mem_categorization::Typer;
|
||||
|
@ -19,6 +19,7 @@
|
||||
//
|
||||
// * Functions called by the compiler itself.
|
||||
|
||||
pub use self::LangItem::*;
|
||||
|
||||
use driver::session::Session;
|
||||
use metadata::csearch::each_lang_item;
|
||||
|
@ -107,6 +107,9 @@
|
||||
* It is the responsibility of typeck to ensure that there are no
|
||||
* `return` expressions in a function declared as diverging.
|
||||
*/
|
||||
use self::LoopKind::*;
|
||||
use self::LiveNodeKind::*;
|
||||
use self::VarKind::*;
|
||||
|
||||
use middle::def::*;
|
||||
use middle::mem_categorization::Typer;
|
||||
|
@ -62,6 +62,17 @@
|
||||
|
||||
#![allow(non_camel_case_types)]
|
||||
|
||||
pub use self::PointerKind::*;
|
||||
pub use self::InteriorKind::*;
|
||||
pub use self::FieldName::*;
|
||||
pub use self::ElementKind::*;
|
||||
pub use self::MutabilityCategory::*;
|
||||
pub use self::InteriorSafety::*;
|
||||
pub use self::AliasableReason::*;
|
||||
pub use self::Note::*;
|
||||
pub use self::deref_kind::*;
|
||||
pub use self::categorization::*;
|
||||
|
||||
use middle::def;
|
||||
use middle::ty;
|
||||
use middle::typeck;
|
||||
|
@ -11,6 +11,8 @@
|
||||
//! A pass that checks to make sure private fields and methods aren't used
|
||||
//! outside their scopes. This pass will also generate a set of exported items
|
||||
//! which are available for use externally when compiled as a library.
|
||||
use self::PrivacyResult::*;
|
||||
use self::FieldName::*;
|
||||
|
||||
use std::mem::replace;
|
||||
|
||||
|
@ -10,6 +10,32 @@
|
||||
|
||||
#![allow(non_camel_case_types)]
|
||||
|
||||
pub use self::PrivateDep::*;
|
||||
pub use self::ImportUse::*;
|
||||
pub use self::TraitItemKind::*;
|
||||
pub use self::LastPrivate::*;
|
||||
use self::PatternBindingMode::*;
|
||||
use self::Namespace::*;
|
||||
use self::NamespaceError::*;
|
||||
use self::NamespaceResult::*;
|
||||
use self::NameDefinition::*;
|
||||
use self::ImportDirectiveSubclass::*;
|
||||
use self::ReducedGraphParent::*;
|
||||
use self::ResolveResult::*;
|
||||
use self::FallbackSuggestion::*;
|
||||
use self::TypeParameters::*;
|
||||
use self::RibKind::*;
|
||||
use self::MethodSort::*;
|
||||
use self::UseLexicalScopeFlag::*;
|
||||
use self::ModulePrefixResult::*;
|
||||
use self::NameSearchType::*;
|
||||
use self::BareIdentifierPatternResolution::*;
|
||||
use self::DuplicateCheckingMode::*;
|
||||
use self::ParentLink::*;
|
||||
use self::ModuleKind::*;
|
||||
use self::TraitReferenceType::*;
|
||||
use self::FallbackChecks::*;
|
||||
|
||||
use driver::session::Session;
|
||||
use lint;
|
||||
use metadata::csearch;
|
||||
@ -574,7 +600,6 @@ bitflags! {
|
||||
flags DefModifiers: u8 {
|
||||
const PUBLIC = 0b0000_0001,
|
||||
const IMPORTABLE = 0b0000_0010,
|
||||
const ENUM_STAGING_HACK = 0b0000_0100,
|
||||
}
|
||||
}
|
||||
|
||||
@ -982,6 +1007,13 @@ impl<'a, 'b, 'v> Visitor<'v> for UnusedImportCheckVisitor<'a, 'b> {
|
||||
}
|
||||
}
|
||||
|
||||
#[deriving(PartialEq)]
|
||||
enum FallbackChecks {
|
||||
Everything,
|
||||
OnlyTraitAndStatics
|
||||
}
|
||||
|
||||
|
||||
impl<'a> Resolver<'a> {
|
||||
fn new(session: &'a Session, crate_span: Span) -> Resolver<'a> {
|
||||
let graph_root = NameBindings::new();
|
||||
@ -1320,15 +1352,7 @@ impl<'a> Resolver<'a> {
|
||||
self.build_reduced_graph_for_variant(
|
||||
&**variant,
|
||||
local_def(item.id),
|
||||
ModuleReducedGraphParent(name_bindings.get_module()),
|
||||
modifiers);
|
||||
|
||||
// Temporary staging hack
|
||||
self.build_reduced_graph_for_variant(
|
||||
&**variant,
|
||||
local_def(item.id),
|
||||
parent.clone(),
|
||||
modifiers | ENUM_STAGING_HACK);
|
||||
ModuleReducedGraphParent(name_bindings.get_module()));
|
||||
}
|
||||
parent
|
||||
}
|
||||
@ -1596,8 +1620,7 @@ impl<'a> Resolver<'a> {
|
||||
fn build_reduced_graph_for_variant(&mut self,
|
||||
variant: &Variant,
|
||||
item_id: DefId,
|
||||
parent: ReducedGraphParent,
|
||||
modifiers: DefModifiers) {
|
||||
parent: ReducedGraphParent) {
|
||||
let name = variant.node.name.name;
|
||||
let is_exported = match variant.node.kind {
|
||||
TupleVariantKind(_) => false,
|
||||
@ -1611,12 +1634,14 @@ impl<'a> Resolver<'a> {
|
||||
let child = self.add_child(name, parent,
|
||||
ForbidDuplicateTypesAndValues,
|
||||
variant.span);
|
||||
// variants are always treated as importable to allow them to be glob
|
||||
// used
|
||||
child.define_value(DefVariant(item_id,
|
||||
local_def(variant.node.id), is_exported),
|
||||
variant.span, modifiers);
|
||||
variant.span, PUBLIC | IMPORTABLE);
|
||||
child.define_type(DefVariant(item_id,
|
||||
local_def(variant.node.id), is_exported),
|
||||
variant.span, modifiers);
|
||||
variant.span, PUBLIC | IMPORTABLE);
|
||||
}
|
||||
|
||||
/// Constructs the reduced graph for one 'view item'. View items consist
|
||||
@ -1875,28 +1900,20 @@ impl<'a> Resolver<'a> {
|
||||
|
||||
match def {
|
||||
DefMod(_) | DefForeignMod(_) => {}
|
||||
// Still here for staging
|
||||
DefVariant(enum_did, variant_id, is_struct) => {
|
||||
debug!("(building reduced graph for external crate) building \
|
||||
variant {}",
|
||||
final_ident);
|
||||
// If this variant is public, then it was publicly reexported,
|
||||
// otherwise we need to inherit the visibility of the enum
|
||||
// definition.
|
||||
let is_exported = is_public ||
|
||||
self.external_exports.contains(&enum_did);
|
||||
let modifiers = IMPORTABLE | ENUM_STAGING_HACK | if is_exported {
|
||||
PUBLIC
|
||||
} else {
|
||||
DefModifiers::empty()
|
||||
};
|
||||
if is_struct {
|
||||
child_name_bindings.define_type(def, DUMMY_SP, modifiers);
|
||||
// Not adding fields for variants as they are not accessed with a self receiver
|
||||
self.structs.insert(variant_id, Vec::new());
|
||||
} else {
|
||||
child_name_bindings.define_value(def, DUMMY_SP, modifiers);
|
||||
}
|
||||
DefVariant(_, variant_id, is_struct) => {
|
||||
debug!("(building reduced graph for external crate) building \
|
||||
variant {}",
|
||||
final_ident);
|
||||
// variants are always treated as importable to allow them to be
|
||||
// glob used
|
||||
let modifiers = PUBLIC | IMPORTABLE;
|
||||
if is_struct {
|
||||
child_name_bindings.define_type(def, DUMMY_SP, modifiers);
|
||||
// Not adding fields for variants as they are not accessed with a self receiver
|
||||
self.structs.insert(variant_id, Vec::new());
|
||||
} else {
|
||||
child_name_bindings.define_value(def, DUMMY_SP, modifiers);
|
||||
}
|
||||
}
|
||||
DefFn(ctor_id, true) => {
|
||||
child_name_bindings.define_value(
|
||||
@ -1954,40 +1971,6 @@ impl<'a> Resolver<'a> {
|
||||
is_public,
|
||||
DUMMY_SP)
|
||||
}
|
||||
DefTy(def_id, true) => { // enums
|
||||
debug!("(building reduced graph for external crate) building enum {}", final_ident);
|
||||
child_name_bindings.define_type(def, DUMMY_SP, modifiers);
|
||||
let enum_module = ModuleReducedGraphParent(child_name_bindings.get_module());
|
||||
|
||||
let variants = csearch::get_enum_variant_defs(&self.session.cstore, def_id);
|
||||
for &(v_def, name, vis) in variants.iter() {
|
||||
let (variant_id, is_struct) = match v_def {
|
||||
DefVariant(_, variant_id, is_struct) => (variant_id, is_struct),
|
||||
_ => unreachable!()
|
||||
};
|
||||
let child = self.add_child(name, enum_module.clone(),
|
||||
OverwriteDuplicates,
|
||||
DUMMY_SP);
|
||||
|
||||
// If this variant is public, then it was publicly reexported,
|
||||
// otherwise we need to inherit the visibility of the enum
|
||||
// definition.
|
||||
let variant_exported = vis == ast::Public || is_exported;
|
||||
let modifiers = IMPORTABLE | if variant_exported {
|
||||
PUBLIC
|
||||
} else {
|
||||
DefModifiers::empty()
|
||||
};
|
||||
if is_struct {
|
||||
child.define_type(v_def, DUMMY_SP, modifiers);
|
||||
// Not adding fields for variants as they are not accessed with a self
|
||||
// receiver
|
||||
self.structs.insert(variant_id, Vec::new());
|
||||
} else {
|
||||
child.define_value(v_def, DUMMY_SP, modifiers);
|
||||
}
|
||||
}
|
||||
}
|
||||
DefTy(..) | DefAssociatedTy(..) => {
|
||||
debug!("(building reduced graph for external \
|
||||
crate) building type {}", final_ident);
|
||||
@ -3058,8 +3041,7 @@ impl<'a> Resolver<'a> {
|
||||
match import_resolution.value_target {
|
||||
Some(ref target) if !target.shadowable => {
|
||||
match *name_bindings.value_def.borrow() {
|
||||
// We want to allow the "flat" def of enum variants to be shadowed
|
||||
Some(ref value) if !value.modifiers.contains(ENUM_STAGING_HACK) => {
|
||||
Some(ref value) => {
|
||||
let msg = format!("import `{}` conflicts with value \
|
||||
in this module",
|
||||
token::get_name(name).get());
|
||||
@ -3082,8 +3064,7 @@ impl<'a> Resolver<'a> {
|
||||
match import_resolution.type_target {
|
||||
Some(ref target) if !target.shadowable => {
|
||||
match *name_bindings.type_def.borrow() {
|
||||
// We want to allow the "flat" def of enum variants to be shadowed
|
||||
Some(ref ty) if !ty.modifiers.contains(ENUM_STAGING_HACK) => {
|
||||
Some(ref ty) => {
|
||||
match ty.module_def {
|
||||
None => {
|
||||
let msg = format!("import `{}` conflicts with type in \
|
||||
@ -5675,12 +5656,6 @@ impl<'a> Resolver<'a> {
|
||||
}
|
||||
|
||||
fn find_fallback_in_self_type(&mut self, name: Name) -> FallbackSuggestion {
|
||||
#[deriving(PartialEq)]
|
||||
enum FallbackChecks {
|
||||
Everything,
|
||||
OnlyTraitAndStatics
|
||||
}
|
||||
|
||||
fn extract_path_and_node_id(t: &Ty, allow: FallbackChecks)
|
||||
-> Option<(Path, NodeId, FallbackChecks)> {
|
||||
match t.node {
|
||||
|
@ -17,6 +17,9 @@
|
||||
* way. Therefore we break lifetime name resolution into a separate pass.
|
||||
*/
|
||||
|
||||
pub use self::DefRegion::*;
|
||||
use self::ScopeChain::*;
|
||||
|
||||
use driver::session::Session;
|
||||
use middle::subst;
|
||||
use std::fmt;
|
||||
|
@ -8,6 +8,8 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
pub use self::Row::*;
|
||||
|
||||
use middle::save::escape;
|
||||
use middle::save::span_utils::SpanUtils;
|
||||
|
||||
|
@ -10,6 +10,9 @@
|
||||
|
||||
// Type substitutions.
|
||||
|
||||
pub use self::ParamSpace::*;
|
||||
pub use self::RegionSubsts::*;
|
||||
|
||||
use middle::ty;
|
||||
use middle::ty_fold;
|
||||
use middle::ty_fold::{TypeFoldable, TypeFolder};
|
||||
|
@ -12,6 +12,11 @@
|
||||
* Trait Resolution. See doc.rs.
|
||||
*/
|
||||
|
||||
pub use self::SelectionError::*;
|
||||
pub use self::FulfillmentErrorCode::*;
|
||||
pub use self::Vtable::*;
|
||||
pub use self::ObligationCauseCode::*;
|
||||
|
||||
use middle::mem_categorization::Typer;
|
||||
use middle::subst;
|
||||
use middle::ty;
|
||||
|
@ -11,6 +11,12 @@
|
||||
/*! See `doc.rs` for high-level documentation */
|
||||
#![allow(dead_code)] // FIXME -- just temporarily
|
||||
|
||||
pub use self::MethodMatchResult::*;
|
||||
pub use self::MethodMatchedData::*;
|
||||
use self::Candidate::*;
|
||||
use self::BuiltinBoundConditions::*;
|
||||
use self::EvaluationResult::*;
|
||||
|
||||
use super::{ErrorReported};
|
||||
use super::{Obligation, ObligationCause};
|
||||
use super::{SelectionError, Unimplemented, Overflow,
|
||||
|
@ -186,6 +186,12 @@
|
||||
*
|
||||
*/
|
||||
|
||||
pub use self::BranchKind::*;
|
||||
pub use self::OptResult::*;
|
||||
pub use self::TransBindingMode::*;
|
||||
use self::Opt::*;
|
||||
use self::FailureHandler::*;
|
||||
|
||||
use back::abi;
|
||||
use driver::config::FullDebugInfo;
|
||||
use llvm::{ValueRef, BasicBlockRef};
|
||||
@ -544,7 +550,7 @@ fn enter_opt<'a, 'p, 'blk, 'tcx>(
|
||||
&SliceLengthGreaterOrEqual(before, after) =>
|
||||
check_match::SliceWithSubslice(before, after),
|
||||
&Variant(_, _, def_id) =>
|
||||
check_match::Variant(def_id)
|
||||
check_match::Constructor::Variant(def_id)
|
||||
};
|
||||
|
||||
let mcx = check_match::MatchCheckCtxt { tcx: bcx.tcx() };
|
||||
|
@ -45,6 +45,9 @@
|
||||
|
||||
#![allow(unsigned_negation)]
|
||||
|
||||
pub use self::PointerField::*;
|
||||
pub use self::Repr::*;
|
||||
|
||||
use std::num::Int;
|
||||
use std::rc::Rc;
|
||||
|
||||
|
@ -25,6 +25,10 @@
|
||||
|
||||
#![allow(non_camel_case_types)]
|
||||
|
||||
pub use self::IsUnboxedClosureFlag::*;
|
||||
pub use self::ValueOrigin::*;
|
||||
pub use self::scalar_type::*;
|
||||
|
||||
use back::link::{mangle_exported_name};
|
||||
use back::{link, abi};
|
||||
use driver::config;
|
||||
|
@ -8,6 +8,8 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
pub use self::ArgKind::*;
|
||||
|
||||
use llvm::Attribute;
|
||||
use std::option;
|
||||
use middle::trans::context::CrateContext;
|
||||
|
@ -8,12 +8,14 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use self::Strategy::*;
|
||||
use llvm::*;
|
||||
use middle::trans::cabi::{ArgType, FnType};
|
||||
use middle::trans::type_::Type;
|
||||
use super::common::*;
|
||||
use super::machine::*;
|
||||
|
||||
enum Strategy { RetValue(Type), RetPointer }
|
||||
pub fn compute_abi_info(ccx: &CrateContext,
|
||||
atys: &[Type],
|
||||
rty: Type,
|
||||
@ -32,7 +34,6 @@ pub fn compute_abi_info(ccx: &CrateContext,
|
||||
// http://www.angelcode.com/dev/callconv/callconv.html
|
||||
// Clang's ABI handling is in lib/CodeGen/TargetInfo.cpp
|
||||
|
||||
enum Strategy { RetValue(Type), RetPointer }
|
||||
let t = &ccx.sess().target.target;
|
||||
let strategy = if t.options.is_like_osx || t.options.is_like_windows {
|
||||
match llsize_of_alloc(ccx, rty) {
|
||||
|
@ -12,6 +12,7 @@
|
||||
// https://github.com/jckarter/clay/blob/master/compiler/src/externals.cpp
|
||||
|
||||
#![allow(non_upper_case_globals)]
|
||||
use self::RegClass::*;
|
||||
|
||||
use llvm;
|
||||
use llvm::{Integer, Pointer, Float, Double};
|
||||
|
@ -16,6 +16,10 @@
|
||||
* closure.
|
||||
*/
|
||||
|
||||
pub use self::AutorefArg::*;
|
||||
pub use self::CalleeData::*;
|
||||
pub use self::CallArgs::*;
|
||||
|
||||
use arena::TypedArena;
|
||||
use back::abi;
|
||||
use back::link;
|
||||
|
@ -13,6 +13,11 @@
|
||||
* drop glue. See discussion in `doc.rs` for a high-level summary.
|
||||
*/
|
||||
|
||||
pub use self::ScopeId::*;
|
||||
pub use self::CleanupScopeKind::*;
|
||||
pub use self::EarlyExitLabel::*;
|
||||
pub use self::Heap::*;
|
||||
|
||||
use llvm::{BasicBlockRef, ValueRef};
|
||||
use middle::trans::base;
|
||||
use middle::trans::build;
|
||||
|
@ -12,6 +12,8 @@
|
||||
|
||||
//! Code that is useful in various trans modules.
|
||||
|
||||
pub use self::ExprOrMethodCall::*;
|
||||
|
||||
use driver::session::Session;
|
||||
use llvm;
|
||||
use llvm::{ValueRef, BasicBlockRef, BuilderRef, ContextRef};
|
||||
|
@ -13,6 +13,9 @@
|
||||
* Datums are and how they are intended to be used.
|
||||
*/
|
||||
|
||||
pub use self::Expr::*;
|
||||
pub use self::RvalueMode::*;
|
||||
|
||||
use llvm::ValueRef;
|
||||
use middle::trans::base::*;
|
||||
use middle::trans::build::Load;
|
||||
|
@ -183,6 +183,14 @@ the unique type ID as described above *can* be used as identifier. Since it is
|
||||
comparatively expensive to construct, though, `ty::type_id()` is still used
|
||||
additionally as an optimization for cases where the exact same type has been
|
||||
seen before (which is most of the time). */
|
||||
use self::FunctionDebugContextRepr::*;
|
||||
use self::VariableAccess::*;
|
||||
use self::VariableKind::*;
|
||||
use self::MemberOffset::*;
|
||||
use self::MemberDescriptionFactory::*;
|
||||
use self::RecursiveTypeDescription::*;
|
||||
use self::EnumDiscriminantInfo::*;
|
||||
use self::DebugLocation::*;
|
||||
|
||||
use driver::config;
|
||||
use driver::config::{FullDebugInfo, LimitedDebugInfo, NoDebugInfo};
|
||||
|
@ -33,6 +33,10 @@
|
||||
|
||||
#![allow(non_camel_case_types)]
|
||||
|
||||
pub use self::cast_kind::*;
|
||||
pub use self::Dest::*;
|
||||
use self::lazy_binop_ty::*;
|
||||
|
||||
use back::abi;
|
||||
use llvm;
|
||||
use llvm::{ValueRef};
|
||||
|
@ -10,6 +10,8 @@
|
||||
|
||||
#![allow(non_camel_case_types)]
|
||||
|
||||
pub use self::named_ty::*;
|
||||
|
||||
use middle::subst;
|
||||
use middle::trans::adt;
|
||||
use middle::trans::common::*;
|
||||
|
@ -10,6 +10,32 @@
|
||||
|
||||
#![allow(non_camel_case_types)]
|
||||
|
||||
pub use self::terr_vstore_kind::*;
|
||||
pub use self::type_err::*;
|
||||
pub use self::BuiltinBound::*;
|
||||
pub use self::InferTy::*;
|
||||
pub use self::InferRegion::*;
|
||||
pub use self::ImplOrTraitItemId::*;
|
||||
pub use self::UnboxedClosureKind::*;
|
||||
pub use self::TraitStore::*;
|
||||
pub use self::ast_ty_to_ty_cache_entry::*;
|
||||
pub use self::Variance::*;
|
||||
pub use self::AutoAdjustment::*;
|
||||
pub use self::Representability::*;
|
||||
pub use self::UnsizeKind::*;
|
||||
pub use self::AutoRef::*;
|
||||
pub use self::ExprKind::*;
|
||||
pub use self::DtorKind::*;
|
||||
pub use self::ExplicitSelfCategory::*;
|
||||
pub use self::FnOutput::*;
|
||||
pub use self::Region::*;
|
||||
pub use self::ImplOrTraitItemContainer::*;
|
||||
pub use self::BorrowKind::*;
|
||||
pub use self::ImplOrTraitItem::*;
|
||||
pub use self::BoundRegion::*;
|
||||
pub use self::sty::*;
|
||||
pub use self::IntVarValue::*;
|
||||
|
||||
use back::svh::Svh;
|
||||
use driver::session::Session;
|
||||
use lint;
|
||||
|
@ -48,7 +48,6 @@
|
||||
* case but `&a` in the second. Basically, defaults that appear inside
|
||||
* an rptr (`&r.T`) use the region `r` that appears in the rptr.
|
||||
*/
|
||||
|
||||
use middle::const_eval;
|
||||
use middle::def;
|
||||
use middle::resolve_lifetime as rl;
|
||||
|
@ -79,6 +79,10 @@ obtained the type `Foo`, we would never match this method.
|
||||
|
||||
*/
|
||||
|
||||
pub use self::CheckTraitsFlag::*;
|
||||
pub use self::AutoderefReceiverFlag::*;
|
||||
pub use self::MethodError::*;
|
||||
pub use self::CandidateSource::*;
|
||||
|
||||
use middle::subst;
|
||||
use middle::subst::{Subst, SelfSpace};
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user