Skip to content

Commit 2bbc41c

Browse files
committed
---
yaml --- r: 189174 b: refs/heads/snap-stage3 c: 7a2eea5 h: refs/heads/master v: v3
1 parent 66b54f0 commit 2bbc41c

File tree

87 files changed

+1258
-294
lines changed

Some content is hidden

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

87 files changed

+1258
-294
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 4d716decb5d9944bc0d79cdc51b03e3af69bc59c
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: ccd83daa418310f2a48af29b1e6545577e579e65
4+
refs/heads/snap-stage3: 7a2eea5808da02cbc685059afc7218d3db53a782
55
refs/heads/try: 649d35e4d830b27806705dc5352c86ab6d6fd1a1
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d

branches/snap-stage3/mk/tests.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ TEST_SREQ$(1)_T_$(2)_H_$(3) = \
590590

591591
# The tests select when to use debug configuration on their own;
592592
# remove directive, if present, from CFG_RUSTC_FLAGS (issue #7898).
593-
CTEST_RUSTC_FLAGS := $$(subst --cfg ndebug,,$$(CFG_RUSTC_FLAGS))
593+
CTEST_RUSTC_FLAGS := $$(subst -C debug-assertions,,$$(CFG_RUSTC_FLAGS))
594594

595595
# The tests cannot be optimized while the rest of the compiler is optimized, so
596596
# filter out the optimization (if any) from rustc and then figure out if we need

branches/snap-stage3/src/compiletest/compiletest.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
#![feature(path)]
2525
#![feature(os)]
2626
#![feature(io)]
27-
#![feature(fs)]
2827
#![feature(net)]
28+
#![feature(path_ext)]
2929

3030
#![deny(warnings)]
3131

branches/snap-stage3/src/doc/reference.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2555,6 +2555,14 @@ The currently implemented features of the reference compiler are:
25552555
types, e.g. as the return type of a public function.
25562556
This capability may be removed in the future.
25572557

2558+
* `allow_internal_unstable` - Allows `macro_rules!` macros to be tagged with the
2559+
`#[allow_internal_unstable]` attribute, designed
2560+
to allow `std` macros to call
2561+
`#[unstable]`/feature-gated functionality
2562+
internally without imposing on callers
2563+
(i.e. making them behave like function calls in
2564+
terms of encapsulation).
2565+
25582566
If a feature is promoted to a language feature, then all existing programs will
25592567
start to receive compilation warnings about #[feature] directives which enabled
25602568
the new feature (because the directive is no longer necessary). However, if a

branches/snap-stage3/src/doc/trpl/arrays-vectors-and-slices.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@ let v = vec![1, 2, 3]; // v: Vec<i32>
6060
brackets `[]` with `vec!`. Rust allows you to use either in either situation,
6161
this is just convention.)
6262

63+
There's an alternate form of `vec!` for repeating an initial value:
64+
65+
```
66+
let v = vec![0; 10]; // ten zeroes
67+
```
68+
6369
You can get the length of, iterate over, and subscript vectors just like
6470
arrays. In addition, (mutable) vectors can grow automatically:
6571

branches/snap-stage3/src/libcore/macros.rs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,12 @@ macro_rules! assert_eq {
100100
/// This will invoke the `panic!` macro if the provided expression cannot be
101101
/// evaluated to `true` at runtime.
102102
///
103-
/// Unlike `assert!`, `debug_assert!` statements can be disabled by passing
104-
/// `--cfg ndebug` to the compiler. This makes `debug_assert!` useful for
105-
/// checks that are too expensive to be present in a release build but may be
106-
/// helpful during development.
103+
/// Unlike `assert!`, `debug_assert!` statements are only enabled in non
104+
/// optimized builds by default. An optimized build will omit all
105+
/// `debug_assert!` statements unless `-C debug-assertions` is passed to the
106+
/// compiler. This makes `debug_assert!` useful for checks that are too
107+
/// expensive to be present in a release build but may be helpful during
108+
/// development.
107109
///
108110
/// # Example
109111
///
@@ -125,18 +127,20 @@ macro_rules! assert_eq {
125127
#[macro_export]
126128
#[stable(feature = "rust1", since = "1.0.0")]
127129
macro_rules! debug_assert {
128-
($($arg:tt)*) => (if cfg!(not(ndebug)) { assert!($($arg)*); })
130+
($($arg:tt)*) => (if cfg!(debug_assertions) { assert!($($arg)*); })
129131
}
130132

131133
/// Asserts that two expressions are equal to each other, testing equality in
132134
/// both directions.
133135
///
134136
/// On panic, this macro will print the values of the expressions.
135137
///
136-
/// Unlike `assert_eq!`, `debug_assert_eq!` statements can be disabled by
137-
/// passing `--cfg ndebug` to the compiler. This makes `debug_assert_eq!`
138-
/// useful for checks that are too expensive to be present in a release build
139-
/// but may be helpful during development.
138+
/// Unlike `assert_eq!`, `debug_assert_eq!` statements are only enabled in non
139+
/// optimized builds by default. An optimized build will omit all
140+
/// `debug_assert_eq!` statements unless `-C debug-assertions` is passed to the
141+
/// compiler. This makes `debug_assert_eq!` useful for checks that are too
142+
/// expensive to be present in a release build but may be helpful during
143+
/// development.
140144
///
141145
/// # Example
142146
///
@@ -147,7 +151,7 @@ macro_rules! debug_assert {
147151
/// ```
148152
#[macro_export]
149153
macro_rules! debug_assert_eq {
150-
($($arg:tt)*) => (if cfg!(not(ndebug)) { assert_eq!($($arg)*); })
154+
($($arg:tt)*) => (if cfg!(debug_assertions) { assert_eq!($($arg)*); })
151155
}
152156

153157
/// Short circuiting evaluation on Err

branches/snap-stage3/src/libcore/num/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1238,6 +1238,7 @@ pub fn from_f64<A: FromPrimitive>(n: f64) -> Option<A> {
12381238

12391239
macro_rules! impl_from_primitive {
12401240
($T:ty, $to_ty:ident) => (
1241+
#[allow(deprecated)]
12411242
impl FromPrimitive for $T {
12421243
#[inline] fn from_int(n: int) -> Option<$T> { n.$to_ty() }
12431244
#[inline] fn from_i8(n: i8) -> Option<$T> { n.$to_ty() }
@@ -1299,6 +1300,7 @@ macro_rules! impl_num_cast {
12991300
($T:ty, $conv:ident) => (
13001301
impl NumCast for $T {
13011302
#[inline]
1303+
#[allow(deprecated)]
13021304
fn from<N: ToPrimitive>(n: N) -> Option<$T> {
13031305
// `$conv` could be generated using `concat_idents!`, but that
13041306
// macro seems to be broken at the moment

branches/snap-stage3/src/libgetopts/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@
9292
#![feature(collections)]
9393
#![feature(int_uint)]
9494
#![feature(staged_api)]
95-
#![feature(str_words)]
9695
#![feature(core)]
96+
#![feature(str_words)]
9797
#![cfg_attr(test, feature(rustc_private))]
9898

9999
#[cfg(test)] #[macro_use] extern crate log;

branches/snap-stage3/src/liblibc/lib.rs

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,8 @@ pub mod types {
383383
target_arch = "mips",
384384
target_arch = "mipsel",
385385
target_arch = "powerpc",
386-
target_arch = "le32"))]
386+
target_arch = "le32",
387+
all(target_arch = "arm", not(target_os = "android"))))]
387388
pub mod posix88 {
388389
pub type off_t = i32;
389390
pub type dev_t = u64;
@@ -395,7 +396,7 @@ pub mod types {
395396
pub type mode_t = u32;
396397
pub type ssize_t = i32;
397398
}
398-
#[cfg(target_arch = "arm")]
399+
#[cfg(all(target_arch = "arm", target_os = "android"))]
399400
pub mod posix88 {
400401
pub type off_t = i32;
401402
pub type dev_t = u32;
@@ -409,7 +410,8 @@ pub mod types {
409410
}
410411
#[cfg(any(target_arch = "x86",
411412
target_arch = "le32",
412-
target_arch = "powerpc"))]
413+
target_arch = "powerpc",
414+
all(target_arch = "arm", not(target_os = "android"))))]
413415
pub mod posix01 {
414416
use types::os::arch::c95::{c_short, c_long, time_t};
415417
use types::os::arch::posix88::{dev_t, gid_t, ino_t};
@@ -455,7 +457,7 @@ pub mod types {
455457
pub __size: [u32; 9]
456458
}
457459
}
458-
#[cfg(target_arch = "arm")]
460+
#[cfg(all(target_arch = "arm", target_os = "android"))]
459461
pub mod posix01 {
460462
use types::os::arch::c95::{c_uchar, c_uint, c_ulong, time_t};
461463
use types::os::arch::c99::{c_longlong, c_ulonglong};
@@ -4999,9 +5001,36 @@ pub mod funcs {
49995001
use types::os::arch::c95::{c_char, c_int};
50005002
use types::os::arch::posix88::mode_t;
50015003

5004+
mod open_shim {
5005+
extern {
5006+
#[cfg(any(target_os = "macos",
5007+
target_os = "ios"))]
5008+
pub fn open(path: *const ::c_char, oflag: ::c_int, ...)
5009+
-> ::c_int;
5010+
5011+
#[cfg(not(any(target_os = "macos",
5012+
target_os = "ios")))]
5013+
pub fn open(path: *const ::c_char, oflag: ::c_int, mode: ::mode_t)
5014+
-> ::c_int;
5015+
}
5016+
}
5017+
5018+
#[cfg(any(target_os = "macos",
5019+
target_os = "ios"))]
5020+
#[inline]
5021+
pub unsafe extern fn open(path: *const c_char, oflag: c_int, mode: mode_t) -> c_int {
5022+
use types::os::arch::c95::c_uint;
5023+
open_shim::open(path, oflag, mode as c_uint)
5024+
}
5025+
5026+
#[cfg(not(any(target_os = "macos",
5027+
target_os = "ios")))]
5028+
#[inline]
5029+
pub unsafe extern fn open(path: *const c_char, oflag: c_int, mode: mode_t) -> c_int {
5030+
open_shim::open(path, oflag, mode)
5031+
}
5032+
50025033
extern {
5003-
pub fn open(path: *const c_char, oflag: c_int, mode: mode_t)
5004-
-> c_int;
50055034
pub fn creat(path: *const c_char, mode: mode_t) -> c_int;
50065035
pub fn fcntl(fd: c_int, cmd: c_int, ...) -> c_int;
50075036
}

branches/snap-stage3/src/liblog/macros.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ macro_rules! info {
157157
/// ```
158158
#[macro_export]
159159
macro_rules! debug {
160-
($($arg:tt)*) => (if cfg!(not(ndebug)) { log!(::log::DEBUG, $($arg)*) })
160+
($($arg:tt)*) => (if cfg!(debug_assertions) { log!(::log::DEBUG, $($arg)*) })
161161
}
162162

163163
/// A macro to test whether a log level is enabled for the current module.
@@ -192,7 +192,7 @@ macro_rules! debug {
192192
macro_rules! log_enabled {
193193
($lvl:expr) => ({
194194
let lvl = $lvl;
195-
(lvl != ::log::DEBUG || cfg!(not(ndebug))) &&
195+
(lvl != ::log::DEBUG || cfg!(debug_assertions)) &&
196196
lvl <= ::log::log_level() &&
197197
::log::mod_enabled(lvl, module_path!())
198198
})

branches/snap-stage3/src/librustc/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@
4040
#![feature(std_misc)]
4141
#![feature(os)]
4242
#![feature(path)]
43-
#![feature(fs)]
4443
#![feature(io)]
44+
#![feature(path_ext)]
4545
#![cfg_attr(test, feature(test))]
4646

4747
extern crate arena;

branches/snap-stage3/src/librustc/metadata/creader.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,7 @@ impl<'a> CrateReader<'a> {
542542
// overridden in plugin/load.rs
543543
export: false,
544544
use_locally: false,
545+
allow_internal_unstable: false,
545546

546547
body: body,
547548
});

branches/snap-stage3/src/librustc/metadata/macro_import.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,9 @@ impl<'a> MacroLoader<'a> {
166166
Some(sel) => sel.contains_key(&name),
167167
};
168168
def.export = reexport.contains_key(&name);
169+
def.allow_internal_unstable = attr::contains_name(&def.attrs,
170+
"allow_internal_unstable");
171+
debug!("load_macros: loaded: {:?}", def);
169172
self.macros.push(def);
170173
}
171174

branches/snap-stage3/src/librustc/middle/stability.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -362,8 +362,6 @@ pub fn check_item(tcx: &ty::ctxt, item: &ast::Item, warn_about_defns: bool,
362362
/// Helper for discovering nodes to check for stability
363363
pub fn check_expr(tcx: &ty::ctxt, e: &ast::Expr,
364364
cb: &mut FnMut(ast::DefId, Span, &Option<Stability>)) {
365-
if is_internal(tcx, e.span) { return; }
366-
367365
let span;
368366
let id = match e.node {
369367
ast::ExprMethodCall(i, _, _) => {
@@ -527,12 +525,13 @@ pub fn check_pat(tcx: &ty::ctxt, pat: &ast::Pat,
527525
fn maybe_do_stability_check(tcx: &ty::ctxt, id: ast::DefId, span: Span,
528526
cb: &mut FnMut(ast::DefId, Span, &Option<Stability>)) {
529527
if !is_staged_api(tcx, id) { return }
528+
if is_internal(tcx, span) { return }
530529
let ref stability = lookup(tcx, id);
531530
cb(id, span, stability);
532531
}
533532

534533
fn is_internal(tcx: &ty::ctxt, span: Span) -> bool {
535-
tcx.sess.codemap().span_is_internal(span)
534+
tcx.sess.codemap().span_allows_unstable(span)
536535
}
537536

538537
fn is_staged_api(tcx: &ty::ctxt, id: DefId) -> bool {

branches/snap-stage3/src/librustc/plugin/registry.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,12 @@ impl<'a> Registry<'a> {
8181
/// This is the most general hook into `libsyntax`'s expansion behavior.
8282
pub fn register_syntax_extension(&mut self, name: ast::Name, extension: SyntaxExtension) {
8383
self.syntax_exts.push((name, match extension {
84-
NormalTT(ext, _) => NormalTT(ext, Some(self.krate_span)),
85-
IdentTT(ext, _) => IdentTT(ext, Some(self.krate_span)),
84+
NormalTT(ext, _, allow_internal_unstable) => {
85+
NormalTT(ext, Some(self.krate_span), allow_internal_unstable)
86+
}
87+
IdentTT(ext, _, allow_internal_unstable) => {
88+
IdentTT(ext, Some(self.krate_span), allow_internal_unstable)
89+
}
8690
Decorator(ext) => Decorator(ext),
8791
Modifier(ext) => Modifier(ext),
8892
MultiModifier(ext) => MultiModifier(ext),
@@ -99,7 +103,8 @@ impl<'a> Registry<'a> {
99103
/// It builds for you a `NormalTT` that calls `expander`,
100104
/// and also takes care of interning the macro's name.
101105
pub fn register_macro(&mut self, name: &str, expander: MacroExpanderFn) {
102-
self.register_syntax_extension(token::intern(name), NormalTT(Box::new(expander), None));
106+
self.register_syntax_extension(token::intern(name),
107+
NormalTT(Box::new(expander), None, false));
103108
}
104109

105110
/// Register a compiler lint pass.

branches/snap-stage3/src/librustc/session/config.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ pub struct Options {
8181

8282
pub gc: bool,
8383
pub optimize: OptLevel,
84+
pub debug_assertions: bool,
8485
pub debuginfo: DebugInfoLevel,
8586
pub lint_opts: Vec<(String, lint::Level)>,
8687
pub describe_lints: bool,
@@ -238,7 +239,8 @@ pub fn basic_options() -> Options {
238239
crate_name: None,
239240
alt_std_name: None,
240241
libs: Vec::new(),
241-
unstable_features: UnstableFeatures::Disallow
242+
unstable_features: UnstableFeatures::Disallow,
243+
debug_assertions: true,
242244
}
243245
}
244246

@@ -528,6 +530,8 @@ options! {CodegenOptions, CodegenSetter, basic_codegen_options,
528530
2 = full debug info with variable and type information"),
529531
opt_level: Option<uint> = (None, parse_opt_uint,
530532
"Optimize with possible levels 0-3"),
533+
debug_assertions: Option<bool> = (None, parse_opt_bool,
534+
"explicitly enable the cfg(debug_assertions) directive"),
531535
}
532536

533537

@@ -621,15 +625,19 @@ pub fn default_configuration(sess: &Session) -> ast::CrateConfig {
621625
};
622626

623627
let mk = attr::mk_name_value_item_str;
624-
return vec!(// Target bindings.
628+
let mut ret = vec![ // Target bindings.
625629
attr::mk_word_item(fam.clone()),
626630
mk(InternedString::new("target_os"), intern(os)),
627631
mk(InternedString::new("target_family"), fam),
628632
mk(InternedString::new("target_arch"), intern(arch)),
629633
mk(InternedString::new("target_endian"), intern(end)),
630634
mk(InternedString::new("target_pointer_width"),
631635
intern(wordsz))
632-
);
636+
];
637+
if sess.opts.debug_assertions {
638+
ret.push(attr::mk_word_item(InternedString::new("debug_assertions")));
639+
}
640+
return ret;
633641
}
634642

635643
pub fn append_configuration(cfg: &mut ast::CrateConfig,
@@ -923,6 +931,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
923931
}
924932
}
925933
};
934+
let debug_assertions = cg.debug_assertions.unwrap_or(opt_level == No);
926935
let gc = debugging_opts.gc;
927936
let debuginfo = if matches.opt_present("g") {
928937
if cg.debuginfo.is_some() {
@@ -1064,6 +1073,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
10641073
alt_std_name: None,
10651074
libs: libs,
10661075
unstable_features: get_unstable_features_setting(),
1076+
debug_assertions: debug_assertions,
10671077
}
10681078
}
10691079

branches/snap-stage3/src/librustc_back/archive.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,16 @@
1111
//! A helper class for dealing with static archives
1212
1313
use std::env;
14-
use std::fs::{self, TempDir};
14+
use std::fs;
1515
use std::io::prelude::*;
1616
use std::io;
1717
use std::path::{Path, PathBuf};
1818
use std::process::{Command, Output, Stdio};
1919
use std::str;
2020
use syntax::diagnostic::Handler as ErrorHandler;
2121

22+
use tempdir::TempDir;
23+
2224
pub const METADATA_FILENAME: &'static str = "rust.metadata.bin";
2325

2426
pub struct ArchiveConfig<'a> {

0 commit comments

Comments
 (0)