Skip to content

Commit 4ef1674

Browse files
committed
Utilize fewer reexports
In regards to: #19253 (comment) 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
1 parent 6f4c11b commit 4ef1674

Some content is hidden

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

85 files changed

+277
-195
lines changed

src/doc/reference.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -994,7 +994,7 @@ An example of `use` declarations:
994994

995995
```
996996
use std::iter::range_step;
997-
use std::option::{Some, None};
997+
use std::option::Option::{Some, None};
998998
use std::collections::hash_map::{mod, HashMap};
999999
10001000
fn foo<T>(_: T){}
@@ -1004,8 +1004,8 @@ fn main() {
10041004
// Equivalent to 'std::iter::range_step(0u, 10u, 2u);'
10051005
range_step(0u, 10u, 2u);
10061006
1007-
// Equivalent to 'foo(vec![std::option::Some(1.0f64),
1008-
// std::option::None]);'
1007+
// Equivalent to 'foo(vec![std::option::Option::Some(1.0f64),
1008+
// std::option::Option::None]);'
10091009
foo(vec![Some(1.0f64), None]);
10101010
10111011
// Both `hash_map` and `HashMap` are in scope.

src/etc/unicode.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ def escape_char(c):
292292
def emit_bsearch_range_table(f):
293293
f.write("""
294294
fn bsearch_range_table(c: char, r: &'static [(char,char)]) -> bool {
295-
use core::cmp::{Equal, Less, Greater};
295+
use core::cmp::Ordering::{Equal, Less, Greater};
296296
use core::slice::SlicePrelude;
297297
r.binary_search(|&(lo,hi)| {
298298
if lo <= c && c <= hi { Equal }
@@ -350,10 +350,11 @@ def emit_regex_module(f, cats, w_data):
350350
def emit_conversions_module(f, lowerupper, upperlower):
351351
f.write("pub mod conversions {")
352352
f.write("""
353-
use core::cmp::{Equal, Less, Greater};
353+
use core::cmp::Ordering::{Equal, Less, Greater};
354354
use core::slice::SlicePrelude;
355355
use core::tuple::Tuple2;
356-
use core::option::{Option, Some, None};
356+
use core::option::Option;
357+
use core::option::Option::{Some, None};
357358
use core::slice;
358359
359360
pub fn to_lower(c: char) -> char {
@@ -403,7 +404,7 @@ def emit_grapheme_module(f, grapheme_table, grapheme_cats):
403404
f.write(""" }
404405
405406
fn bsearch_range_value_table(c: char, r: &'static [(char, char, GraphemeCat)]) -> GraphemeCat {
406-
use core::cmp::{Equal, Less, Greater};
407+
use core::cmp::Ordering::{Equal, Less, Greater};
407408
match r.binary_search(|&(lo, hi, _)| {
408409
if lo <= c && c <= hi { Equal }
409410
else if hi < c { Less }
@@ -430,12 +431,13 @@ def emit_grapheme_module(f, grapheme_table, grapheme_cats):
430431

431432
def emit_charwidth_module(f, width_table):
432433
f.write("pub mod charwidth {\n")
433-
f.write(" use core::option::{Option, Some, None};\n")
434+
f.write(" use core::option::Option;\n")
435+
f.write(" use core::option::Option::{Some, None};\n")
434436
f.write(" use core::slice::SlicePrelude;\n")
435437
f.write(" use core::slice;\n")
436438
f.write("""
437439
fn bsearch_range_value_table(c: char, is_cjk: bool, r: &'static [(char, char, u8, u8)]) -> u8 {
438-
use core::cmp::{Equal, Less, Greater};
440+
use core::cmp::Ordering::{Equal, Less, Greater};
439441
match r.binary_search(|&(lo, hi, _, _)| {
440442
if lo <= c && c <= hi { Equal }
441443
else if hi < c { Less }
@@ -530,7 +532,7 @@ def comp_pfun(char):
530532

531533
f.write("""
532534
fn bsearch_range_value_table(c: char, r: &'static [(char, char, u8)]) -> u8 {
533-
use core::cmp::{Equal, Less, Greater};
535+
use core::cmp::Ordering::{Equal, Less, Greater};
534536
use core::slice::SlicePrelude;
535537
use core::slice;
536538
match r.binary_search(|&(lo, hi, _)| {

src/liballoc/arc.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ use core::kinds::{Sync, Send};
2222
use core::mem::{min_align_of, size_of, drop};
2323
use core::mem;
2424
use core::ops::{Drop, Deref};
25-
use core::option::{Some, None, Option};
25+
use core::option::Option;
26+
use core::option::Option::{Some, None};
2627
use core::ptr::RawPtr;
2728
use core::ptr;
2829
use heap::deallocate;
@@ -326,7 +327,8 @@ mod tests {
326327
use std::comm::channel;
327328
use std::mem::drop;
328329
use std::ops::Drop;
329-
use std::option::{Option, Some, None};
330+
use std::option::Option;
331+
use std::option::Option::{Some, None};
330332
use std::str::Str;
331333
use std::sync::atomic;
332334
use std::task;

src/liballoc/boxed.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ use core::kinds::Sized;
1919
use core::mem;
2020
use core::option::Option;
2121
use core::raw::TraitObject;
22-
use core::result::{Ok, Err, Result};
22+
use core::result::Result;
23+
use core::result::Result::{Ok, Err};
2324

2425
/// A value that represents the global exchange heap. This is the default
2526
/// place that the `box` keyword allocates into when no place is supplied.

src/liballoc/heap.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,8 @@ mod imp {
177177

178178
#[cfg(all(not(external_funcs), not(external_crate), jemalloc))]
179179
mod imp {
180-
use core::option::{None, Option};
180+
use core::option::Option;
181+
use core::option::Option::None;
181182
use core::ptr::{null_mut, null};
182183
use core::num::Int;
183184
use libc::{c_char, c_int, c_void, size_t};

src/liballoc/rc.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,12 @@ use core::fmt;
149149
use core::kinds::marker;
150150
use core::mem::{transmute, min_align_of, size_of, forget};
151151
use core::ops::{Deref, Drop};
152-
use core::option::{Option, Some, None};
152+
use core::option::Option;
153+
use core::option::Option::{Some, None};
153154
use core::ptr;
154155
use core::ptr::RawPtr;
155-
use core::result::{Result, Ok, Err};
156+
use core::result::Result;
157+
use core::result::Result::{Ok, Err};
156158

157159
use heap::deallocate;
158160

@@ -739,8 +741,9 @@ impl<T> RcBoxPtr<T> for Weak<T> {
739741
mod tests {
740742
use super::{Rc, Weak, weak_count, strong_count};
741743
use std::cell::RefCell;
742-
use std::option::{Option, Some, None};
743-
use std::result::{Err, Ok};
744+
use std::option::Option;
745+
use std::option::Option::{Some, None};
746+
use std::result::Result::{Err, Ok};
744747
use std::mem::drop;
745748
use std::clone::Clone;
746749

src/libcollections/str.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -833,8 +833,10 @@ mod tests {
833833
use std::default::Default;
834834
use std::char::Char;
835835
use std::clone::Clone;
836-
use std::cmp::{Equal, Greater, Less, Ord, PartialOrd, Equiv};
837-
use std::option::{Some, None};
836+
use std::cmp::{Ord, PartialOrd, Equiv};
837+
use std::cmp::Ordering::{Equal, Greater, Less};
838+
use std::option::Option;
839+
use std::option::Option::{Some, None};
838840
use std::ptr::RawPtr;
839841
use std::iter::{Iterator, IteratorExt, DoubleEndedIteratorExt};
840842

src/libcore/any.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@
7272
#![stable]
7373

7474
use mem::{transmute};
75-
use option::{Option, Some, None};
75+
use option::Option;
76+
use option::Option::{Some, None};
7677
use raw::TraitObject;
7778
use intrinsics::TypeId;
7879

src/libcore/cell.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,8 @@ use cmp::PartialEq;
160160
use default::Default;
161161
use kinds::{marker, Copy};
162162
use ops::{Deref, DerefMut, Drop};
163-
use option::{None, Option, Some};
163+
use option::Option;
164+
use option::Option::{None, Some};
164165

165166
/// A mutable memory location that admits only `Copy` data.
166167
#[unstable = "likely to be renamed; otherwise stable"]

src/libcore/char.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
#![doc(primitive = "char")]
1717

1818
use mem::transmute;
19-
use option::{None, Option, Some};
19+
use option::Option;
20+
use option::Option::{None, Some};
2021
use iter::{range_step, Iterator, RangeStep};
2122
use slice::SlicePrelude;
2223

0 commit comments

Comments
 (0)