Utilize fewer reexports

In regards to:

https://github.com/rust-lang/rust/issues/19253#issuecomment-64836729

This commit:

* Changes the #deriving code so that it generates code that utilizes fewer
  reexports (in particur Option::* and Result::*), which is necessary to
  remove those reexports in the future
* Changes other areas of the codebase so that fewer reexports are utilized
This commit is contained in:
Corey Farwell 2014-11-28 11:57:41 -05:00
parent 6f4c11be3b
commit 4ef16741e3
85 changed files with 277 additions and 195 deletions

View file

@ -77,8 +77,8 @@ fn sort_and_fmt(mm: &HashMap<Vec<u8> , uint>, total: uint) -> String {
fn find(mm: &HashMap<Vec<u8> , uint>, key: String) -> uint {
let key = key.into_ascii().as_slice().to_lowercase().into_string();
match mm.get(key.as_bytes()) {
option::None => { return 0u; }
option::Some(&num) => { return num; }
option::Option::None => { return 0u; }
option::Option::Some(&num) => { return num; }
}
}
@ -190,8 +190,8 @@ fn main() {
// start processing if this is the one
('>', false) => {
match line.as_slice().slice_from(1).find_str("THREE") {
option::Some(_) => { proc_mode = true; }
option::None => { }
option::Option::Some(_) => { proc_mode = true; }
option::Option::None => { }
}
}

View file

@ -21,7 +21,7 @@
extern crate getopts;
use std::os;
use std::result::{Ok, Err};
use std::result::Result::{Ok, Err};
use std::task;
use std::time::Duration;

View file

@ -18,8 +18,8 @@ use std::mem::*; // shouldn't get errors for not using
// everything imported
// Should get errors for both 'Some' and 'None'
use std::option::{Some, None}; //~ ERROR unused import
//~^ ERROR unused import
use std::option::Option::{Some, None}; //~ ERROR unused import
//~^ ERROR unused import
use test::A; //~ ERROR unused import
// Be sure that if we just bring some methods into scope that they're also

View file

@ -10,8 +10,8 @@
// error-pattern:called `Result::unwrap()` on an `Err` value
use std::result;
use std::result::Result::Err;
fn main() {
println!("{}", result::Err::<int,String>("kitty".to_string()).unwrap());
println!("{}", Err::<int,String>("kitty".to_string()).unwrap());
}

View file

@ -39,5 +39,5 @@ pub fn main() {
assert!(a != b);
assert!(a < b);
assert_eq!(a.cmp(&b), ::std::cmp::Less);
assert_eq!(a.cmp(&b), ::std::cmp::Ordering::Less);
}

View file

@ -10,7 +10,7 @@
// ignore-test FIXME #11820: & is unreliable in deriving
use std::cmp::{Less,Equal,Greater};
use std::cmp::Ordering::{Less,Equal,Greater};
#[deriving(Eq,Ord)]
struct A<'a> {

View file

@ -8,7 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::result::{Result,Ok};
use std::result::Result;
use std::result::Result::Ok;
static C: Result<(), Box<int>> = Ok(());

View file

@ -24,14 +24,14 @@ enum object {
fn lookup(table: json::Object, key: String, default: String) -> String
{
match table.find(&key.to_string()) {
option::Some(&Json::String(ref s)) => {
option::Option::Some(&Json::String(ref s)) => {
s.to_string()
}
option::Some(value) => {
option::Option::Some(value) => {
println!("{} was expected to be a string but is a {}", key, value);
default
}
option::None => {
option::Option::None => {
default
}
}

View file

@ -20,7 +20,7 @@ type rsrc_loader = proc(path: &Path):'static -> result::Result<String, String>;
fn tester()
{
let loader: rsrc_loader = proc(_path) {
result::Ok("more blah".to_string())
result::Result::Ok("more blah".to_string())
};
let path = path::Path::new("blah");

View file

@ -41,9 +41,9 @@ macro_rules! check_option {
check_option!($e: $T, |ptr| assert!(*ptr == $e));
}};
($e:expr: $T:ty, |$v:ident| $chk:expr) => {{
assert!(option::None::<$T>.is_none());
assert!(option::Option::None::<$T>.is_none());
let e = $e;
let s_ = option::Some::<$T>(e);
let s_ = option::Option::Some::<$T>(e);
let $v = s_.as_ref().unwrap();
$chk
}}

View file

@ -11,7 +11,7 @@
extern crate collections;
use std::collections::HashMap;
use std::option::Some;
use std::option::Option::Some;
use std::str::SendStr;
pub fn main() {

View file

@ -11,7 +11,7 @@
extern crate collections;
use self::collections::TreeMap;
use std::option::Some;
use std::option::Option::Some;
use std::str::SendStr;
use std::string::ToString;