Skip to content

Commit a810c03

Browse files
committed
librustc: Make unqualified identifier searches terminate at the nearest module scope. r=tjc
1 parent 44ab00e commit a810c03

File tree

251 files changed

+1353
-454
lines changed

Some content is hidden

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

251 files changed

+1353
-454
lines changed

doc/tutorial.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -2284,6 +2284,10 @@ struct level. Note that fields and methods are _public_ by default.
22842284
~~~
22852285
mod farm {
22862286
# use farm;
2287+
# pub type Chicken = int;
2288+
# type Cow = int;
2289+
# enum Human = int;
2290+
# impl Human { fn rest(&self) { } }
22872291
# pub fn make_me_a_farm() -> farm::Farm { farm::Farm { chickens: ~[], cows: ~[], farmer: Human(0) } }
22882292
pub struct Farm {
22892293
priv mut chickens: ~[Chicken],
@@ -2310,12 +2314,8 @@ fn main() {
23102314
farm::feed_animals(&f);
23112315
f.farmer.rest();
23122316
}
2313-
# type Chicken = int;
2314-
# type Cow = int;
2315-
# enum Human = int;
23162317
# fn make_me_a_farm() -> farm::Farm { farm::make_me_a_farm() }
2317-
# fn make_me_a_chicken() -> Chicken { 0 }
2318-
# impl Human { fn rest(&self) { } }
2318+
# fn make_me_a_chicken() -> farm::Chicken { 0 }
23192319
~~~
23202320

23212321
## Crates

src/compiletest/common.rs

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
use core::prelude::*;
12+
1113
use cmp;
1214

1315
enum mode { mode_compile_fail, mode_run_fail, mode_run_pass, mode_pretty, }

src/compiletest/errors.rs

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
use core::prelude::*;
12+
1113
use common::config;
1214
use io;
1315
use io::ReaderUtil;

src/compiletest/header.rs

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
use core::prelude::*;
12+
1113
use common;
1214
use common::config;
1315
use io;

src/compiletest/procsrv.rs

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
use core::prelude::*;
12+
1113
use io;
1214
use io::{ReaderUtil, WriterUtil};
1315
use libc;

src/compiletest/runtest.rs

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
use core::prelude::*;
12+
1113
use io;
1214
use io::WriterUtil;
1315
use os;

src/compiletest/util.rs

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
use core::prelude::*;
12+
1113
use io;
1214
use os;
1315
use os::getenv;

src/libcargo/pgp.rs

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// except according to those terms.
1010

1111
use core::os;
12+
use core::path::Path;
1213
use core::run;
1314

1415
fn gpgv(args: ~[~str]) -> { status: int, out: ~str, err: ~str } {

src/libcore/at_vec.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@
1515
#[forbid(deprecated_pattern)];
1616

1717
use cast::transmute;
18+
use kinds::Copy;
1819
use iter;
1920
use libc;
21+
use option::Option;
2022
use ptr::addr_of;
2123
use sys;
2224
use uint;
@@ -150,6 +152,10 @@ pub pure fn from_elem<T: Copy>(n_elts: uint, t: T) -> @[T] {
150152

151153
#[cfg(notest)]
152154
pub mod traits {
155+
use at_vec::append;
156+
use kinds::Copy;
157+
use ops::Add;
158+
153159
pub impl<T: Copy> @[T] : Add<&[const T],@[T]> {
154160
#[inline(always)]
155161
pure fn add(&self, rhs: & &self/[const T]) -> @[T] {
@@ -162,8 +168,10 @@ pub mod traits {
162168
pub mod traits {}
163169

164170
pub mod raw {
165-
use at_vec::{rusti, rustrt};
171+
use at_vec::{capacity, rusti, rustrt};
172+
use cast::transmute;
166173
use libc;
174+
use ptr::addr_of;
167175
use ptr;
168176
use sys;
169177
use uint;

src/libcore/bool.rs

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use bool;
2020
use cmp;
2121
use cmp::Eq;
22+
use option::{None, Option, Some};
2223

2324
/// Negation / inverse
2425
pub pure fn not(v: bool) -> bool { !v }

src/libcore/cast.rs

+2
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ pub unsafe fn copy_lifetime_vec<S,T>(_ptr: &a/[S], ptr: &T) -> &a/T {
108108

109109
#[cfg(test)]
110110
pub mod tests {
111+
use cast::{bump_box_refcount, reinterpret_cast, transmute};
112+
111113
#[test]
112114
pub fn test_reinterpret_cast() {
113115
assert 1u == unsafe { reinterpret_cast(&1) };

src/libcore/char.rs

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
use char;
1818
use cmp::Eq;
19+
use option::{None, Option, Some};
1920
use str;
2021
use u32;
2122
use uint;

src/libcore/condition.rs

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
use prelude::*;
1112
use task;
1213
use task::local_data::{local_data_pop, local_data_set};
1314

src/libcore/core.rc

+5
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ Implicitly, all crates behave as if they included the following prologue:
5353
#[warn(vecs_implicitly_copyable)];
5454
#[deny(non_camel_case_types)];
5555

56+
/* The Prelude. */
57+
58+
pub mod prelude;
5659

5760
/* Primitive types */
5861

@@ -243,6 +246,8 @@ pub mod core {
243246

244247
pub use cmp;
245248
pub use condition;
249+
pub use option;
250+
pub use kinds;
246251
}
247252

248253

src/libcore/dlist.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ Do not use ==, !=, <, etc on doubly-linked lists -- it may not terminate.
2222
#[forbid(deprecated_mode)];
2323
#[forbid(deprecated_pattern)];
2424

25+
use kinds::Copy;
2526
use managed;
27+
use option::{None, Option, Some};
2628
use option;
2729
use vec;
2830

@@ -94,13 +96,13 @@ impl<T> DListNode<T> {
9496
}
9597

9698
/// Creates a new dlist node with the given data.
97-
pure fn new_dlist_node<T>(data: T) -> DListNode<T> {
99+
pub pure fn new_dlist_node<T>(data: T) -> DListNode<T> {
98100
DListNode(@{data: move data, mut linked: false,
99101
mut prev: None, mut next: None})
100102
}
101103

102104
/// Creates a new, empty dlist.
103-
pure fn DList<T>() -> DList<T> {
105+
pub pure fn DList<T>() -> DList<T> {
104106
DList_(@{mut size: 0, mut hd: None, mut tl: None})
105107
}
106108

@@ -120,7 +122,7 @@ pub fn from_vec<T: Copy>(vec: &[T]) -> DList<T> {
120122

121123
/// Produce a list from a list of lists, leaving no elements behind in the
122124
/// input. O(number of sub-lists).
123-
fn concat<T>(lists: DList<DList<T>>) -> DList<T> {
125+
pub fn concat<T>(lists: DList<DList<T>>) -> DList<T> {
124126
let result = DList();
125127
while !lists.is_empty() {
126128
result.append(lists.pop().get());
@@ -474,7 +476,9 @@ impl<T: Copy> DList<T> {
474476
mod tests {
475477
#[legacy_exports];
476478

479+
use dlist::{DList, concat, from_vec, new_dlist_node};
477480
use iter;
481+
use option::{None, Some};
478482
use vec;
479483

480484
#[test]

src/libcore/dvec.rs

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Note that recursive use is not permitted.
2525

2626
use cast;
2727
use cast::reinterpret_cast;
28+
use prelude::*;
2829
use ptr::null;
2930
use vec;
3031

src/libcore/either.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@
1414

1515
//! A type that represents one of two alternatives
1616
17-
use cmp;
1817
use cmp::Eq;
19-
use result;
18+
use cmp;
19+
use kinds::Copy;
2020
use result::Result;
21+
use result;
2122
use vec;
2223

2324
/// The either type

src/libcore/extfmt.rs

+2
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ debug!("hello, %s!", "world");
8282

8383
use cmp::Eq;
8484
use option::{Some, None};
85+
use prelude::*;
8586
use str;
8687

8788
/*
@@ -99,6 +100,7 @@ use str;
99100
#[doc(hidden)]
100101
pub mod ct {
101102
use char;
103+
use prelude::*;
102104
use str;
103105
use vec;
104106

src/libcore/float.rs

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ use cmp;
3131
use f64;
3232
use num;
3333
use num::Num::from_int;
34+
use option::{None, Option, Some};
3435
use str;
3536
use uint;
3637

src/libcore/gc.rs

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ with destructors.
4242
use cast;
4343
use io;
4444
use libc::{size_t, uintptr_t};
45+
use option::{None, Option, Some};
4546
use ptr;
4647
use send_map::linear::LinearMap;
4748
use stackwalk;

src/libcore/int-template.rs

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ use from_str::FromStr;
2121
use iter;
2222
use num;
2323
use num::Num::from_int;
24+
use prelude::*;
2425
use str;
2526
use uint;
2627
use vec;

src/libcore/int-template/int.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ mod inst {
5050

5151
#[test]
5252
fn test_overflows() {
53-
assert (max_value > 0);
54-
assert (min_value <= 0);
55-
assert (min_value + max_value + 1 == 0);
53+
assert (::int::max_value > 0);
54+
assert (::int::min_value <= 0);
55+
assert (::int::min_value + ::int::max_value + 1 == 0);
5656
}
5757
}

src/libcore/io.rs

+12-5
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,15 @@ use libc::consts::os::posix88::*;
2828
use libc::consts::os::extra::*;
2929
use option;
3030
use os;
31+
use prelude::*;
3132
use ptr;
3233
use result;
3334
use str;
3435
use uint;
3536
use vec;
3637

3738
#[allow(non_camel_case_types)] // not sure what to do about this
38-
type fd_t = c_int;
39+
pub type fd_t = c_int;
3940

4041
#[abi = "cdecl"]
4142
extern mod rustrt {
@@ -452,12 +453,12 @@ impl<T: Reader, C> {base: T, cleanup: C}: Reader {
452453
fn tell(&self) -> uint { self.base.tell() }
453454
}
454455

455-
struct FILERes {
456+
pub struct FILERes {
456457
f: *libc::FILE,
457458
drop { libc::fclose(self.f); }
458459
}
459460

460-
fn FILERes(f: *libc::FILE) -> FILERes {
461+
pub fn FILERes(f: *libc::FILE) -> FILERes {
461462
FILERes {
462463
f: f
463464
}
@@ -629,12 +630,12 @@ impl fd_t: Writer {
629630
}
630631
}
631632

632-
struct FdRes {
633+
pub struct FdRes {
633634
fd: fd_t,
634635
drop { libc::close(self.fd); }
635636
}
636637

637-
fn FdRes(fd: fd_t) -> FdRes {
638+
pub fn FdRes(fd: fd_t) -> FdRes {
638639
FdRes {
639640
fd: fd
640641
}
@@ -1028,7 +1029,10 @@ pub fn read_whole_file(file: &Path) -> Result<~[u8], ~str> {
10281029
// fsync related
10291030

10301031
pub mod fsync {
1032+
use io::{FILERes, FdRes, fd_t};
1033+
use kinds::Copy;
10311034
use libc;
1035+
use option::Option;
10321036
use option;
10331037
use os;
10341038

@@ -1113,8 +1117,11 @@ pub mod fsync {
11131117

11141118
#[cfg(test)]
11151119
mod tests {
1120+
use debug;
11161121
use i32;
1122+
use io::{BytesWriter, SeekCur, SeekEnd, SeekSet};
11171123
use io;
1124+
use path::Path;
11181125
use result;
11191126
use str;
11201127
use u64;

src/libcore/iter-trait.rs

+3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@
1616
#[forbid(deprecated_pattern)];
1717

1818
use cmp::{Eq, Ord};
19+
use iter::BaseIter;
1920
use iter;
21+
use kinds::Copy;
22+
use option::Option;
2023

2124
use self::inst::{IMPL_T, EACH, SIZE_HINT};
2225

src/libcore/iter-trait/dlist.rs

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
mod inst {
1212
use dlist;
1313
use managed;
14+
use option::{Option, Some};
1415
use option;
1516

1617
#[allow(non_camel_case_types)]

src/libcore/iter-trait/dvec.rs

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
mod inst {
1212
use dvec;
13+
use option::{Option, Some};
1314

1415
#[allow(non_camel_case_types)]
1516
pub type IMPL_T<A> = dvec::DVec<A>;

0 commit comments

Comments
 (0)