Skip to content

Commit 3b2530c

Browse files
committed
Auto merge of #24524 - Manishearth:rollup, r=Manishearth
2 parents 9d2ac9b + c98115c commit 3b2530c

File tree

14 files changed

+76
-26
lines changed

14 files changed

+76
-26
lines changed

src/doc/trpl/hello-cargo.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ we hadn’t changed the source file, and so it just ran the binary. If we had
8989
made a modification, we would have seen it do both:
9090

9191
```bash
92-
$ cargo build
92+
$ cargo run
9393
Compiling hello_world v0.0.1 (file:///home/yourname/projects/hello_world)
9494
Running `target/debug/hello_world`
9595
Hello, world!

src/doc/trpl/vectors.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
% Vectors
22

33
A *vector* is a dynamic or "growable" array, implemented as the standard
4-
library type [`Vec<T>`](../std/vec/) (Where `<T>` is a [Generic](./generics.md) statement). Vectors always allocate their data on the heap. Vectors are to slices
5-
what `String` is to `&str`. You can create them with the `vec!` macro:
4+
library type [`Vec<T>`](../std/vec/) (Where `<T>` is a [Generic](./generics.md)
5+
statement). Vectors always allocate their data on the heap. Vectors are to
6+
[slices][slices] what [`String`][string] is to `&str`. You can
7+
create them with the `vec!` macro:
68

79
```{rust}
810
let v = vec![1, 2, 3]; // v: Vec<i32>
911
```
1012

13+
[slices]: primitive-types.html#slices
14+
[string]: strings.html
15+
1116
(Notice that unlike the `println!` macro we've used in the past, we use square
1217
brackets `[]` with `vec!`. Rust allows you to use either in either situation,
1318
this is just convention.)

src/libcore/ops.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -969,7 +969,7 @@ pub struct RangeFull;
969969
#[stable(feature = "rust1", since = "1.0.0")]
970970
impl fmt::Debug for RangeFull {
971971
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
972-
fmt::Debug::fmt("..", fmt)
972+
write!(fmt, "..")
973973
}
974974
}
975975

src/librustc/session/config.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -606,6 +606,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
606606
"Force overflow checks on or off"),
607607
force_dropflag_checks: Option<bool> = (None, parse_opt_bool,
608608
"Force drop flag checks on or off"),
609+
trace_macros: bool = (false, parse_bool,
610+
"For every macro invocation, print its name and arguments"),
609611
}
610612

611613
pub fn default_lib_output() -> CrateType {
@@ -667,7 +669,7 @@ pub fn build_target_config(opts: &Options, sp: &SpanHandler) -> Config {
667669
Ok(t) => t,
668670
Err(e) => {
669671
sp.handler().fatal(&format!("Error loading target specification: {}", e));
670-
}
672+
}
671673
};
672674

673675
let (int_type, uint_type) = match &target.target_pointer_width[..] {

src/librustc_driver/driver.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,7 @@ pub fn phase_2_configure_and_expand(sess: &Session,
483483
crate_name: crate_name.to_string(),
484484
features: Some(&features),
485485
recursion_limit: sess.recursion_limit.get(),
486+
trace_mac: sess.opts.debugging_opts.trace_macros,
486487
};
487488
let ret = syntax::ext::expand::expand_crate(&sess.parse_sess,
488489
cfg,

src/librustdoc/html/render.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1178,7 +1178,6 @@ impl Context {
11781178
{
11791179
fn render(w: File, cx: &Context, it: &clean::Item,
11801180
pushname: bool) -> io::Result<()> {
1181-
info!("Rendering an item to {}", w.path().unwrap().display());
11821181
// A little unfortunate that this is done like this, but it sure
11831182
// does make formatting *a lot* nicer.
11841183
CURRENT_LOCATION_KEY.with(|slot| {

src/librustdoc/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
#![feature(test)]
3333
#![feature(unicode)]
3434
#![feature(str_words)]
35-
#![feature(file_path)]
3635
#![feature(path_ext)]
3736
#![feature(path_relative_from)]
3837
#![feature(slice_patterns)]

src/libstd/fs.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ use vec::Vec;
5151
#[stable(feature = "rust1", since = "1.0.0")]
5252
pub struct File {
5353
inner: fs_imp::File,
54-
path: Option<PathBuf>,
5554
}
5655

5756
/// Metadata information about a file.
@@ -193,12 +192,12 @@ impl File {
193192
OpenOptions::new().write(true).create(true).truncate(true).open(path)
194193
}
195194

196-
/// Returns the original path that was used to open this file.
195+
/// Returns `None`.
197196
#[unstable(feature = "file_path",
198-
reason = "this abstraction is imposed by this library instead \
199-
of the underlying OS and may be removed")]
197+
reason = "this abstraction was imposed by this library and was removed")]
198+
#[deprecated(since = "1.0.0", reason = "abstraction was removed")]
200199
pub fn path(&self) -> Option<&Path> {
201-
self.path.as_ref().map(|p| &**p)
200+
None
202201
}
203202

204203
/// Attempts to sync all OS-internal metadata to disk.
@@ -302,7 +301,7 @@ impl AsInner<fs_imp::File> for File {
302301
}
303302
impl FromInner<fs_imp::File> for File {
304303
fn from_inner(f: fs_imp::File) -> File {
305-
File { inner: f, path: None }
304+
File { inner: f }
306305
}
307306
}
308307

@@ -470,7 +469,7 @@ impl OpenOptions {
470469
pub fn open<P: AsRef<Path>>(&self, path: P) -> io::Result<File> {
471470
let path = path.as_ref();
472471
let inner = try!(fs_imp::File::open(path, &self.0));
473-
Ok(File { path: Some(path.to_path_buf()), inner: inner })
472+
Ok(File { inner: inner })
474473
}
475474
}
476475

src/libsyntax/diagnostic.rs

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,14 @@ pub use self::RenderSpan::*;
1313
pub use self::ColorConfig::*;
1414
use self::Destination::*;
1515

16-
use codemap::{COMMAND_LINE_SP, COMMAND_LINE_EXPN, Pos, Span};
17-
use codemap;
16+
use codemap::{self, COMMAND_LINE_SP, COMMAND_LINE_EXPN, Pos, Span};
1817
use diagnostics;
1918

2019
use std::cell::{RefCell, Cell};
21-
use std::cmp;
22-
use std::fmt;
20+
use std::{cmp, error, fmt};
2321
use std::io::prelude::*;
2422
use std::io;
25-
use term::WriterWrapper;
26-
use term;
23+
use term::{self, WriterWrapper};
2724
use libc;
2825

2926
/// maximum number of lines we will print for each error; arbitrary.
@@ -83,15 +80,39 @@ pub trait Emitter {
8380
/// Used as a return value to signify a fatal error occurred. (It is also
8481
/// used as the argument to panic at the moment, but that will eventually
8582
/// not be true.)
86-
#[derive(Copy, Clone)]
83+
#[derive(Copy, Clone, Debug)]
8784
#[must_use]
8885
pub struct FatalError;
8986

87+
impl fmt::Display for FatalError {
88+
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
89+
write!(f, "parser fatal error")
90+
}
91+
}
92+
93+
impl error::Error for FatalError {
94+
fn description(&self) -> &str {
95+
"The parser has encountered a fatal error"
96+
}
97+
}
98+
9099
/// Signifies that the compiler died with an explicit call to `.bug`
91100
/// or `.span_bug` rather than a failed assertion, etc.
92-
#[derive(Copy, Clone)]
101+
#[derive(Copy, Clone, Debug)]
93102
pub struct ExplicitBug;
94103

104+
impl fmt::Display for ExplicitBug {
105+
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
106+
write!(f, "parser internal bug")
107+
}
108+
}
109+
110+
impl error::Error for ExplicitBug {
111+
fn description(&self) -> &str {
112+
"The parser has encountered an internal bug"
113+
}
114+
}
115+
95116
/// A span-handler is like a handler but also
96117
/// accepts span information for source-location
97118
/// reporting.

src/libsyntax/ext/base.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,6 @@ pub struct ExtCtxt<'a> {
554554
pub use_std: bool,
555555

556556
pub mod_path: Vec<ast::Ident> ,
557-
pub trace_mac: bool,
558557
pub exported_macros: Vec<ast::MacroDef>,
559558

560559
pub syntax_env: SyntaxEnv,
@@ -572,7 +571,6 @@ impl<'a> ExtCtxt<'a> {
572571
mod_path: Vec::new(),
573572
ecfg: ecfg,
574573
use_std: true,
575-
trace_mac: false,
576574
exported_macros: Vec::new(),
577575
syntax_env: env,
578576
recursion_count: 0,
@@ -732,10 +730,10 @@ impl<'a> ExtCtxt<'a> {
732730
self.parse_sess.span_diagnostic.handler().bug(msg);
733731
}
734732
pub fn trace_macros(&self) -> bool {
735-
self.trace_mac
733+
self.ecfg.trace_mac
736734
}
737735
pub fn set_trace_macros(&mut self, x: bool) {
738-
self.trace_mac = x
736+
self.ecfg.trace_mac = x
739737
}
740738
pub fn ident_of(&self, st: &str) -> ast::Ident {
741739
str_to_ident(st)

src/libsyntax/ext/expand.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1406,6 +1406,7 @@ pub struct ExpansionConfig<'feat> {
14061406
pub crate_name: String,
14071407
pub features: Option<&'feat Features>,
14081408
pub recursion_limit: usize,
1409+
pub trace_mac: bool,
14091410
}
14101411

14111412
macro_rules! feature_tests {
@@ -1427,6 +1428,7 @@ impl<'feat> ExpansionConfig<'feat> {
14271428
crate_name: crate_name,
14281429
features: None,
14291430
recursion_limit: 64,
1431+
trace_mac: false,
14301432
}
14311433
}
14321434

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# This test verifies that "-Z trace-macros" works as it should. The traditional
2+
# "hello world" program provides a small example of this as not only println! is
3+
# listed, but also print! (since println! expands to this)
4+
5+
-include ../tools.mk
6+
7+
all:
8+
$(RUSTC) -Z trace-macros hello.rs > $(TMPDIR)/hello.out
9+
diff -u $(TMPDIR)/hello.out hello.trace
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright 2014 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+
fn main() {
12+
println!("Hello, World!");
13+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
println! { "Hello, World!" }
2+
print! { concat ! ( "Hello, World!" , "\n" ) }

0 commit comments

Comments
 (0)