Skip to content

Rollup of PRs in the queue; Friday #24524

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 47 commits into from
Apr 17, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
d14109e
Add "trace-macros" as a compiler flag
Apr 14, 2015
bed2d33
Add "run-make" test for trace-macros flag
Apr 14, 2015
35b49fe
Fix: sess.opt should have been sess.opts
Apr 14, 2015
5e1505f
Remove -o flag from build command
Apr 14, 2015
53b7a06
Remove one allocation for the file path in file opening
tbu- Apr 15, 2015
9891ea7
Implement traits for parser error structs
aochagavia Apr 15, 2015
6a95d90
make Repr of TraitRef more useful
arielb1 Apr 14, 2015
9e1a078
clean visit_expr
arielb1 Apr 14, 2015
9c1dfed
Use node_ty instead of expr_ty in binary expr fixup
arielb1 Apr 14, 2015
fd8c592
Always type-check the index of an IndexExpr
arielb1 Apr 15, 2015
3a20363
Make sure to disambiguate obtained out from expected output
Apr 15, 2015
c1f6d6a
Fix some documentation typos
lgrz Apr 16, 2015
709b5e8
Fix Debug impl for RangeFull
Apr 16, 2015
7d56fb2
Fix link id for stackoverflow
aethanyc Apr 16, 2015
61ad9fe
Use BTreeMap in build_sidebar_items
mvdnes Apr 16, 2015
d40e1cb
Fixed typo in hash_map::Entry documentation
aramvisser Apr 16, 2015
c0139ca
Remove `&` from redirected output
Apr 16, 2015
f20497c
Fix some broken links in the book
fhartwig Apr 16, 2015
4436ade
Add Debug to MethodCallee
Munksgaard Apr 16, 2015
1c6ccd9
Indicate None is code-like in doc comments
frewsxcv Apr 16, 2015
6de33c2
Omit 'obsolete' note for warning if -Awarning
mvdnes Apr 16, 2015
e6f1a4d
remove example usage of from_str in error docs
steveklabnik Apr 16, 2015
c776d02
Make note of documentation tests and binaries
steveklabnik Apr 16, 2015
dabc486
Descripe tuple indexing in TRPL
steveklabnik Apr 16, 2015
6ac836f
Fix broken links in the docs
fhartwig Apr 16, 2015
d04b204
Update hello-cargo.md
j1n3l0 Apr 16, 2015
d9515ad
Link up some stuff in the vectors chapter
steveklabnik Apr 17, 2015
3734636
Rollup merge of #24430 - laumann:trace-macros-flag, r=pnkfelix
Manishearth Apr 17, 2015
3118cd7
Rollup merge of #24452 - tbu-:pr_file_path, r=aturon
Manishearth Apr 17, 2015
9c4995f
Rollup merge of #24454 - aochagavia:debug, r=alexcrichton
Manishearth Apr 17, 2015
a1bb0a1
Rollup merge of #24475 - arielb1:i24363-hacky-hack, r=pnkfelix
Manishearth Apr 17, 2015
bdef7f6
Rollup merge of #24491 - bluss:rangefull-debug, r=huonw
Manishearth Apr 17, 2015
e81cb17
Rollup merge of #23782 - mvdnes:obsolete_note, r=alexcrichton
Manishearth Apr 17, 2015
3b7f2ce
Rollup merge of #24490 - lstat:doc-typo, r=alexcrichton
Manishearth Apr 17, 2015
28bc94a
Rollup merge of #24493 - aethanyc:fix-stackoverflow-link, r=steveklabnik
Manishearth Apr 17, 2015
89bfacc
Rollup merge of #24494 - mvdnes:deterministic-sidebar, r=alexcrichton
Manishearth Apr 17, 2015
38588ec
Rollup merge of #24496 - aramvisser:patch-1, r=alexcrichton
Manishearth Apr 17, 2015
32c7010
Rollup merge of #24498 - fhartwig:docs-fixes, r=steveklabnik
Manishearth Apr 17, 2015
d300943
Rollup merge of #24499 - Munksgaard:methodcallee-debug, r=alexcrichton
Manishearth Apr 17, 2015
7c3975a
Rollup merge of #24501 - frewsxcv:patch-14, r=steveklabnik
Manishearth Apr 17, 2015
52db185
Rollup merge of #24507 - steveklabnik:gh24185, r=alexcrichton
Manishearth Apr 17, 2015
1d26e5f
Rollup merge of #24508 - steveklabnik:gh24228, r=alexcrichton
Manishearth Apr 17, 2015
6fcd852
Rollup merge of #24509 - steveklabnik:gh23962, r=nikomatsakis
Manishearth Apr 17, 2015
2688ceb
Rollup merge of #24510 - fhartwig:broken-links, r=nikomatsakis
Manishearth Apr 17, 2015
27dc069
Rollup merge of #24513 - j1n3l0:patch-1, r=alexcrichton
Manishearth Apr 17, 2015
1b6bd92
Rollup merge of #24515 - steveklabnik:gh24070, r=Gankro
Manishearth Apr 17, 2015
c98115c
Remove info for path (fixup #24452)
Manishearth Apr 17, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/doc/trpl/hello-cargo.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ we hadn’t changed the source file, and so it just ran the binary. If we had
made a modification, we would have seen it do both:

```bash
$ cargo build
$ cargo run
Compiling hello_world v0.0.1 (file:///home/yourname/projects/hello_world)
Running `target/debug/hello_world`
Hello, world!
Expand Down
9 changes: 7 additions & 2 deletions src/doc/trpl/vectors.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
% Vectors

A *vector* is a dynamic or "growable" array, implemented as the standard
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
what `String` is to `&str`. You can create them with the `vec!` macro:
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][slices] what [`String`][string] is to `&str`. You can
create them with the `vec!` macro:

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

[slices]: primitive-types.html#slices
[string]: strings.html

(Notice that unlike the `println!` macro we've used in the past, we use square
brackets `[]` with `vec!`. Rust allows you to use either in either situation,
this is just convention.)
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -969,7 +969,7 @@ pub struct RangeFull;
#[stable(feature = "rust1", since = "1.0.0")]
impl fmt::Debug for RangeFull {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
fmt::Debug::fmt("..", fmt)
write!(fmt, "..")
}
}

Expand Down
4 changes: 3 additions & 1 deletion src/librustc/session/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
"Force overflow checks on or off"),
force_dropflag_checks: Option<bool> = (None, parse_opt_bool,
"Force drop flag checks on or off"),
trace_macros: bool = (false, parse_bool,
"For every macro invocation, print its name and arguments"),
}

pub fn default_lib_output() -> CrateType {
Expand Down Expand Up @@ -667,7 +669,7 @@ pub fn build_target_config(opts: &Options, sp: &SpanHandler) -> Config {
Ok(t) => t,
Err(e) => {
sp.handler().fatal(&format!("Error loading target specification: {}", e));
}
}
};

let (int_type, uint_type) = match &target.target_pointer_width[..] {
Expand Down
11 changes: 7 additions & 4 deletions src/librustc/util/ppaux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -810,8 +810,12 @@ impl<'tcx> Repr<'tcx> for ty::TraitRef<'tcx> {
// to enumerate the `for<...>` etc because the debruijn index
// tells you everything you need to know.
let base = ty::item_path_str(tcx, self.def_id);
parameterized(tcx, &base, self.substs, self.def_id, &[],
|| ty::lookup_trait_def(tcx, self.def_id).generics.clone())
let result = parameterized(tcx, &base, self.substs, self.def_id, &[],
|| ty::lookup_trait_def(tcx, self.def_id).generics.clone());
match self.substs.self_ty() {
None => result,
Some(sty) => format!("<{} as {}>", sty.repr(tcx), result)
}
}
}

Expand Down Expand Up @@ -1504,8 +1508,7 @@ impl<'tcx> UserString<'tcx> for ty::ProjectionPredicate<'tcx> {

impl<'tcx> Repr<'tcx> for ty::ProjectionTy<'tcx> {
fn repr(&self, tcx: &ctxt<'tcx>) -> String {
format!("<{} as {}>::{}",
self.trait_ref.substs.self_ty().repr(tcx),
format!("{}::{}",
self.trait_ref.repr(tcx),
self.item_name.repr(tcx))
}
Expand Down
1 change: 1 addition & 0 deletions src/librustc_driver/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,7 @@ pub fn phase_2_configure_and_expand(sess: &Session,
crate_name: crate_name.to_string(),
features: Some(&features),
recursion_limit: sess.recursion_limit.get(),
trace_mac: sess.opts.debugging_opts.trace_macros,
};
let ret = syntax::ext::expand::expand_crate(&sess.parse_sess,
cfg,
Expand Down
48 changes: 24 additions & 24 deletions src/librustc_typeck/check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3542,34 +3542,34 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
}
ast::ExprIndex(ref base, ref idx) => {
check_expr_with_lvalue_pref(fcx, &**base, lvalue_pref);
check_expr(fcx, &**idx);

let base_t = fcx.expr_ty(&**base);
let idx_t = fcx.expr_ty(&**idx);

if ty::type_is_error(base_t) {
fcx.write_ty(id, base_t);
} else if ty::type_is_error(idx_t) {
fcx.write_ty(id, idx_t);
} else {
check_expr(fcx, &**idx);
let idx_t = fcx.expr_ty(&**idx);
if ty::type_is_error(idx_t) {
fcx.write_ty(id, idx_t);
} else {
let base_t = structurally_resolved_type(fcx, expr.span, base_t);
match lookup_indexing(fcx, expr, base, base_t, idx_t, lvalue_pref) {
Some((index_ty, element_ty)) => {
let idx_expr_ty = fcx.expr_ty(idx);
demand::eqtype(fcx, expr.span, index_ty, idx_expr_ty);
fcx.write_ty(id, element_ty);
}
None => {
check_expr_has_type(fcx, &**idx, fcx.tcx().types.err);
fcx.type_error_message(
expr.span,
|actual| {
format!("cannot index a value of type `{}`",
actual)
},
base_t,
None);
fcx.write_ty(id, fcx.tcx().types.err);
}
let base_t = structurally_resolved_type(fcx, expr.span, base_t);
match lookup_indexing(fcx, expr, base, base_t, idx_t, lvalue_pref) {
Some((index_ty, element_ty)) => {
let idx_expr_ty = fcx.expr_ty(idx);
demand::eqtype(fcx, expr.span, index_ty, idx_expr_ty);
fcx.write_ty(id, element_ty);
}
None => {
check_expr_has_type(fcx, &**idx, fcx.tcx().types.err);
fcx.type_error_message(
expr.span,
|actual| {
format!("cannot index a value of type `{}`",
actual)
},
base_t,
None);
fcx.write_ty(id, fcx.tcx().types.err);
}
}
}
Expand Down
61 changes: 30 additions & 31 deletions src/librustc_typeck/check/writeback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,32 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
fn tcx(&self) -> &'cx ty::ctxt<'tcx> {
self.fcx.tcx()
}

// Hacky hack: During type-checking, we treat *all* operators
// as potentially overloaded. But then, during writeback, if
// we observe that something like `a+b` is (known to be)
// operating on scalars, we clear the overload.
fn fix_scalar_binary_expr(&mut self, e: &ast::Expr) {
if let ast::ExprBinary(ref op, ref lhs, ref rhs) = e.node {
let lhs_ty = self.fcx.node_ty(lhs.id);
let lhs_ty = self.fcx.infcx().resolve_type_vars_if_possible(&lhs_ty);

let rhs_ty = self.fcx.node_ty(rhs.id);
let rhs_ty = self.fcx.infcx().resolve_type_vars_if_possible(&rhs_ty);

if ty::type_is_scalar(lhs_ty) && ty::type_is_scalar(rhs_ty) {
self.fcx.inh.method_map.borrow_mut().remove(&MethodCall::expr(e.id));

// weird but true: the by-ref binops put an
// adjustment on the lhs but not the rhs; the
// adjustment for rhs is kind of baked into the
// system.
if !ast_util::is_by_value_binop(op.node) {
self.fcx.inh.adjustments.borrow_mut().remove(&lhs.id);
}
}
}
}
}

///////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -114,43 +140,16 @@ impl<'cx, 'tcx, 'v> Visitor<'v> for WritebackCx<'cx, 'tcx> {
return;
}

// Hacky hack: During type-checking, we treat *all* operators
// as potentially overloaded. But then, during writeback, if
// we observe that something like `a+b` is (known to be)
// operating on scalars, we clear the overload.
match e.node {
ast::ExprBinary(ref op, ref lhs, ref rhs) => {
let lhs_ty = self.fcx.expr_ty(lhs);
let lhs_ty = self.fcx.infcx().resolve_type_vars_if_possible(&lhs_ty);
let rhs_ty = self.fcx.expr_ty(rhs);
let rhs_ty = self.fcx.infcx().resolve_type_vars_if_possible(&rhs_ty);
if ty::type_is_scalar(lhs_ty) && ty::type_is_scalar(rhs_ty) {
self.fcx.inh.method_map.borrow_mut().remove(&MethodCall::expr(e.id));

// weird but true: the by-ref binops put an
// adjustment on the lhs but not the rhs; the
// adjustment for rhs is kind of baked into the
// system.
if !ast_util::is_by_value_binop(op.node) {
self.fcx.inh.adjustments.borrow_mut().remove(&lhs.id);
}
}
}
_ => { }
}
self.fix_scalar_binary_expr(e);

self.visit_node_id(ResolvingExpr(e.span), e.id);
self.visit_method_map_entry(ResolvingExpr(e.span),
MethodCall::expr(e.id));

match e.node {
ast::ExprClosure(_, ref decl, _) => {
for input in &decl.inputs {
let _ = self.visit_node_id(ResolvingExpr(e.span),
input.id);
}
if let ast::ExprClosure(_, ref decl, _) = e.node {
for input in &decl.inputs {
self.visit_node_id(ResolvingExpr(e.span), input.id);
}
_ => {}
}

visit::walk_expr(self, e);
Expand Down
1 change: 0 additions & 1 deletion src/librustdoc/html/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1178,7 +1178,6 @@ impl Context {
{
fn render(w: File, cx: &Context, it: &clean::Item,
pushname: bool) -> io::Result<()> {
info!("Rendering an item to {}", w.path().unwrap().display());
// A little unfortunate that this is done like this, but it sure
// does make formatting *a lot* nicer.
CURRENT_LOCATION_KEY.with(|slot| {
Expand Down
1 change: 0 additions & 1 deletion src/librustdoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
#![feature(test)]
#![feature(unicode)]
#![feature(str_words)]
#![feature(file_path)]
#![feature(path_ext)]
#![feature(path_relative_from)]
#![feature(slice_patterns)]
Expand Down
13 changes: 6 additions & 7 deletions src/libstd/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ use vec::Vec;
#[stable(feature = "rust1", since = "1.0.0")]
pub struct File {
inner: fs_imp::File,
path: Option<PathBuf>,
}

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

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

/// Attempts to sync all OS-internal metadata to disk.
Expand Down Expand Up @@ -302,7 +301,7 @@ impl AsInner<fs_imp::File> for File {
}
impl FromInner<fs_imp::File> for File {
fn from_inner(f: fs_imp::File) -> File {
File { inner: f, path: None }
File { inner: f }
}
}

Expand Down Expand Up @@ -470,7 +469,7 @@ impl OpenOptions {
pub fn open<P: AsRef<Path>>(&self, path: P) -> io::Result<File> {
let path = path.as_ref();
let inner = try!(fs_imp::File::open(path, &self.0));
Ok(File { path: Some(path.to_path_buf()), inner: inner })
Ok(File { inner: inner })
}
}

Expand Down
37 changes: 29 additions & 8 deletions src/libsyntax/diagnostic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,14 @@ pub use self::RenderSpan::*;
pub use self::ColorConfig::*;
use self::Destination::*;

use codemap::{COMMAND_LINE_SP, COMMAND_LINE_EXPN, Pos, Span};
use codemap;
use codemap::{self, COMMAND_LINE_SP, COMMAND_LINE_EXPN, Pos, Span};
use diagnostics;

use std::cell::{RefCell, Cell};
use std::cmp;
use std::fmt;
use std::{cmp, error, fmt};
use std::io::prelude::*;
use std::io;
use term::WriterWrapper;
use term;
use term::{self, WriterWrapper};
use libc;

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

impl fmt::Display for FatalError {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
write!(f, "parser fatal error")
}
}

impl error::Error for FatalError {
fn description(&self) -> &str {
"The parser has encountered a fatal error"
}
}

/// Signifies that the compiler died with an explicit call to `.bug`
/// or `.span_bug` rather than a failed assertion, etc.
#[derive(Copy, Clone)]
#[derive(Copy, Clone, Debug)]
pub struct ExplicitBug;

impl fmt::Display for ExplicitBug {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
write!(f, "parser internal bug")
}
}

impl error::Error for ExplicitBug {
fn description(&self) -> &str {
"The parser has encountered an internal bug"
}
}

/// A span-handler is like a handler but also
/// accepts span information for source-location
/// reporting.
Expand Down
6 changes: 2 additions & 4 deletions src/libsyntax/ext/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,6 @@ pub struct ExtCtxt<'a> {
pub use_std: bool,

pub mod_path: Vec<ast::Ident> ,
pub trace_mac: bool,
pub exported_macros: Vec<ast::MacroDef>,

pub syntax_env: SyntaxEnv,
Expand All @@ -572,7 +571,6 @@ impl<'a> ExtCtxt<'a> {
mod_path: Vec::new(),
ecfg: ecfg,
use_std: true,
trace_mac: false,
exported_macros: Vec::new(),
syntax_env: env,
recursion_count: 0,
Expand Down Expand Up @@ -732,10 +730,10 @@ impl<'a> ExtCtxt<'a> {
self.parse_sess.span_diagnostic.handler().bug(msg);
}
pub fn trace_macros(&self) -> bool {
self.trace_mac
self.ecfg.trace_mac
}
pub fn set_trace_macros(&mut self, x: bool) {
self.trace_mac = x
self.ecfg.trace_mac = x
}
pub fn ident_of(&self, st: &str) -> ast::Ident {
str_to_ident(st)
Expand Down
2 changes: 2 additions & 0 deletions src/libsyntax/ext/expand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1406,6 +1406,7 @@ pub struct ExpansionConfig<'feat> {
pub crate_name: String,
pub features: Option<&'feat Features>,
pub recursion_limit: usize,
pub trace_mac: bool,
}

macro_rules! feature_tests {
Expand All @@ -1427,6 +1428,7 @@ impl<'feat> ExpansionConfig<'feat> {
crate_name: crate_name,
features: None,
recursion_limit: 64,
trace_mac: false,
}
}

Expand Down
Loading