Skip to content

Commit 5b3a75f

Browse files
committed
Auto merge of #30883 - Manishearth:rollup, r=Manishearth
- Successful merges: #30626, #30662, #30770, #30801, #30818, #30823, #30828, #30835, #30837, #30839, #30845, #30848, #30850, #30851, #30863 - Failed merges:
2 parents e1f550e + 1246f43 commit 5b3a75f

File tree

34 files changed

+833
-351
lines changed

34 files changed

+833
-351
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Read ["Installing Rust"] from [The Book].
1717
1. Make sure you have installed the dependencies:
1818

1919
* `g++` 4.7 or `clang++` 3.x
20-
* `python` 2.6 or later (but not 3.x)
20+
* `python` 2.7 or later (but not 3.x)
2121
* GNU `make` 3.81 or later
2222
* `curl`
2323
* `git`

mk/crates.mk

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ DEPS_rustc_lint := rustc log syntax
103103
DEPS_rustc_llvm := native:rustllvm libc std rustc_bitflags
104104
DEPS_rustc_metadata := rustc rustc_front syntax rbml
105105
DEPS_rustc_mir := rustc rustc_front syntax
106-
DEPS_rustc_resolve := rustc rustc_front log syntax
106+
DEPS_rustc_resolve := arena rustc rustc_front log syntax
107107
DEPS_rustc_platform_intrinsics := rustc rustc_llvm
108108
DEPS_rustc_plugin := rustc rustc_metadata syntax
109109
DEPS_rustc_privacy := rustc rustc_front log syntax

src/liballoc/lib.rs

+3-11
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@
9292
#![feature(unsize)]
9393
#![feature(drop_in_place)]
9494
#![feature(fn_traits)]
95+
#![feature(const_fn)]
9596

9697
#![feature(needs_allocator)]
9798

@@ -134,15 +135,6 @@ mod boxed_test;
134135
pub mod arc;
135136
pub mod rc;
136137
pub mod raw_vec;
138+
pub mod oom;
137139

138-
/// Common out-of-memory routine
139-
#[cold]
140-
#[inline(never)]
141-
#[unstable(feature = "oom", reason = "not a scrutinized interface",
142-
issue = "27700")]
143-
pub fn oom() -> ! {
144-
// FIXME(#14674): This really needs to do something other than just abort
145-
// here, but any printing done must be *guaranteed* to not
146-
// allocate.
147-
unsafe { core::intrinsics::abort() }
148-
}
140+
pub use oom::oom;

src/liballoc/oom.rs

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
use core::sync::atomic::{AtomicPtr, Ordering};
12+
use core::mem;
13+
use core::intrinsics;
14+
15+
static OOM_HANDLER: AtomicPtr<()> = AtomicPtr::new(default_oom_handler as *mut ());
16+
17+
fn default_oom_handler() -> ! {
18+
// The default handler can't do much more since we can't assume the presence
19+
// of libc or any way of printing an error message.
20+
unsafe { intrinsics::abort() }
21+
}
22+
23+
/// Common out-of-memory routine
24+
#[cold]
25+
#[inline(never)]
26+
#[unstable(feature = "oom", reason = "not a scrutinized interface",
27+
issue = "27700")]
28+
pub fn oom() -> ! {
29+
let value = OOM_HANDLER.load(Ordering::SeqCst);
30+
let handler: fn() -> ! = unsafe { mem::transmute(value) };
31+
handler();
32+
}
33+
34+
/// Set a custom handler for out-of-memory conditions
35+
///
36+
/// To avoid recursive OOM failures, it is critical that the OOM handler does
37+
/// not allocate any memory itself.
38+
#[unstable(feature = "oom", reason = "not a scrutinized interface",
39+
issue = "27700")]
40+
pub fn set_oom_handler(handler: fn() -> !) {
41+
OOM_HANDLER.store(handler as *mut (), Ordering::SeqCst);
42+
}

src/libcollections/string.rs

+36
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,42 @@
1616
//!
1717
//! [`String`]: struct.String.html
1818
//! [`ToString`]: trait.ToString.html
19+
//!
20+
//! # Examples
21+
//!
22+
//! There are multiple ways to create a new `String` from a string literal:
23+
//!
24+
//! ```rust
25+
//! let s = "Hello".to_string();
26+
//!
27+
//! let s = String::from("world");
28+
//! let s: String = "also this".into();
29+
//! ```
30+
//!
31+
//! You can create a new `String` from an existing one by concatenating with
32+
//! `+`:
33+
//!
34+
//! ```rust
35+
//! let s = "Hello".to_string();
36+
//!
37+
//! let message = s + " world!";
38+
//! ```
39+
//!
40+
//! If you have a vector of valid UTF-8 bytes, you can make a `String` out of
41+
//! it. You can do the reverse too.
42+
//!
43+
//! ```rust
44+
//! let sparkle_heart = vec![240, 159, 146, 150];
45+
//!
46+
//! // We know these bytes are valid, so we'll use `unwrap()`.
47+
//! let sparkle_heart = String::from_utf8(sparkle_heart).unwrap();
48+
//!
49+
//! assert_eq!("💖", sparkle_heart);
50+
//!
51+
//! let bytes = sparkle_heart.into_bytes();
52+
//!
53+
//! assert_eq!(bytes, [240, 159, 146, 150]);
54+
//! ```
1955
2056
#![stable(feature = "rust1", since = "1.0.0")]
2157

src/libcore/fmt/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1569,7 +1569,7 @@ impl Debug for () {
15691569
}
15701570
}
15711571
#[stable(feature = "rust1", since = "1.0.0")]
1572-
impl<T> Debug for PhantomData<T> {
1572+
impl<T: ?Sized> Debug for PhantomData<T> {
15731573
fn fmt(&self, f: &mut Formatter) -> Result {
15741574
f.pad("PhantomData")
15751575
}

src/librustc/session/config.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@ pub struct Options {
132132
pub prints: Vec<PrintRequest>,
133133
pub cg: CodegenOptions,
134134
pub color: ColorConfig,
135-
pub show_span: Option<String>,
136135
pub externs: HashMap<String, Vec<String>>,
137136
pub crate_name: Option<String>,
138137
/// An optional name to use as the crate for std during std injection,
@@ -243,7 +242,6 @@ pub fn basic_options() -> Options {
243242
prints: Vec::new(),
244243
cg: basic_codegen_options(),
245244
color: ColorConfig::Auto,
246-
show_span: None,
247245
externs: HashMap::new(),
248246
crate_name: None,
249247
alt_std_name: None,
@@ -634,6 +632,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
634632
"don't clear the resolution tables after analysis"),
635633
keep_ast: bool = (false, parse_bool,
636634
"keep the AST after lowering it to HIR"),
635+
show_span: Option<String> = (None, parse_opt_string,
636+
"show spans for compiler debugging (expr|pat|ty)"),
637637
}
638638

639639
pub fn default_lib_output() -> CrateType {
@@ -882,7 +882,6 @@ pub fn rustc_optgroups() -> Vec<RustcOptGroup> {
882882
`hir` (the HIR), `hir,identified`, or
883883
`hir,typed` (HIR with types for each node).",
884884
"TYPE"),
885-
opt::opt_u("", "show-span", "Show spans for compiler debugging", "expr|pat|ty"),
886885
]);
887886
opts
888887
}
@@ -1123,7 +1122,6 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
11231122
prints: prints,
11241123
cg: cg,
11251124
color: color,
1126-
show_span: None,
11271125
externs: externs,
11281126
crate_name: crate_name,
11291127
alt_std_name: None,

src/librustc_driver/driver.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ pub fn phase_1_parse_input(sess: &Session, cfg: ast::CrateConfig, input: &Input)
428428
println!("Pre-expansion node count: {}", count_nodes(&krate));
429429
}
430430

431-
if let Some(ref s) = sess.opts.show_span {
431+
if let Some(ref s) = sess.opts.debugging_opts.show_span {
432432
syntax::show_span::run(sess.diagnostic(), s, &krate);
433433
}
434434

src/librustc_driver/lib.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,9 @@ pub fn run_compiler<'a>(args: &[String], callbacks: &mut CompilerCalls<'a>) {
138138
};
139139

140140
let cstore = Rc::new(CStore::new(token::get_ident_interner()));
141-
let mut sess = build_session(sopts, input_file_path, descriptions,
141+
let sess = build_session(sopts, input_file_path, descriptions,
142142
cstore.clone());
143143
rustc_lint::register_builtins(&mut sess.lint_store.borrow_mut(), Some(&sess));
144-
if sess.unstable_options() {
145-
sess.opts.show_span = matches.opt_str("show-span");
146-
}
147144
let mut cfg = config::build_configuration(&sess);
148145
target_features::add_configuration(&mut cfg, &sess);
149146

@@ -387,7 +384,7 @@ impl<'a> CompilerCalls<'a> for RustcDefaultCalls {
387384
fn build_controller(&mut self, sess: &Session) -> CompileController<'a> {
388385
let mut control = CompileController::basic();
389386

390-
if sess.opts.parse_only || sess.opts.show_span.is_some() ||
387+
if sess.opts.parse_only || sess.opts.debugging_opts.show_span.is_some() ||
391388
sess.opts.debugging_opts.ast_json_noexpand {
392389
control.after_parse.stop = Compilation::Stop;
393390
}

0 commit comments

Comments
 (0)