From d14109ec7e90f42a7cb966415b96094b146d3706 Mon Sep 17 00:00:00 2001 From: Thomas Jespersen Date: Tue, 14 Apr 2015 15:36:38 +0200 Subject: [PATCH 01/28] Add "trace-macros" as a compiler flag Fixes #22619 --- src/librustc/session/config.rs | 4 +++- src/librustc_driver/driver.rs | 1 + src/libsyntax/ext/base.rs | 6 ++---- src/libsyntax/ext/expand.rs | 2 ++ 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs index a7d608d2c879c..47049969f0c78 100644 --- a/src/librustc/session/config.rs +++ b/src/librustc/session/config.rs @@ -606,6 +606,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options, "Force overflow checks on or off"), force_dropflag_checks: Option = (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 { @@ -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[..] { diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs index e310798b20ab7..f7815a58d062b 100644 --- a/src/librustc_driver/driver.rs +++ b/src/librustc_driver/driver.rs @@ -482,6 +482,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.opt.debugging_opts.trace_macros, }; let ret = syntax::ext::expand::expand_crate(&sess.parse_sess, cfg, diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index 9994fad3e317b..9c2837d71ff89 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -554,7 +554,6 @@ pub struct ExtCtxt<'a> { pub use_std: bool, pub mod_path: Vec , - pub trace_mac: bool, pub exported_macros: Vec, pub syntax_env: SyntaxEnv, @@ -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, @@ -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) diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index b65798b8a4980..c8ff08eeb9488 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -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 { @@ -1427,6 +1428,7 @@ impl<'feat> ExpansionConfig<'feat> { crate_name: crate_name, features: None, recursion_limit: 64, + trace_mac: false, } } From bed2d33523be222195aff71bb813eb14a1faef97 Mon Sep 17 00:00:00 2001 From: Thomas Jespersen Date: Tue, 14 Apr 2015 15:40:10 +0200 Subject: [PATCH 02/28] Add "run-make" test for trace-macros flag --- src/test/run-make/trace-macros-flag/Makefile | 9 +++++++++ src/test/run-make/trace-macros-flag/hello.rs | 13 +++++++++++++ src/test/run-make/trace-macros-flag/hello.trace | 2 ++ 3 files changed, 24 insertions(+) create mode 100644 src/test/run-make/trace-macros-flag/Makefile create mode 100644 src/test/run-make/trace-macros-flag/hello.rs create mode 100644 src/test/run-make/trace-macros-flag/hello.trace diff --git a/src/test/run-make/trace-macros-flag/Makefile b/src/test/run-make/trace-macros-flag/Makefile new file mode 100644 index 0000000000000..fc49c8c900c81 --- /dev/null +++ b/src/test/run-make/trace-macros-flag/Makefile @@ -0,0 +1,9 @@ +# This test verifies that "-Z trace-macros" works as it should. The traditional +# "hello world" program provides a small example of this as not only println! is +# listed, but also print! (since println! expands to this) + +-include ../tools.mk + +all: + $(RUSTC) -o $(TMPDIR)/hello -Z trace-macros hello.rs &> $(TMPDIR)/hello.trace + diff -u $(TMPDIR)/hello.trace hello.trace diff --git a/src/test/run-make/trace-macros-flag/hello.rs b/src/test/run-make/trace-macros-flag/hello.rs new file mode 100644 index 0000000000000..42d3d4c799df8 --- /dev/null +++ b/src/test/run-make/trace-macros-flag/hello.rs @@ -0,0 +1,13 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + println!("Hello, World!"); +} diff --git a/src/test/run-make/trace-macros-flag/hello.trace b/src/test/run-make/trace-macros-flag/hello.trace new file mode 100644 index 0000000000000..cf733339eadf6 --- /dev/null +++ b/src/test/run-make/trace-macros-flag/hello.trace @@ -0,0 +1,2 @@ +println! { "Hello, World!" } +print! { concat ! ( "Hello, World!" , "\n" ) } From 35b49fe20604ee840246123acd44cf2f9a04ab08 Mon Sep 17 00:00:00 2001 From: Thomas Jespersen Date: Tue, 14 Apr 2015 22:18:24 +0200 Subject: [PATCH 03/28] Fix: sess.opt should have been sess.opts --- src/librustc_driver/driver.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs index f7815a58d062b..f93c543543c07 100644 --- a/src/librustc_driver/driver.rs +++ b/src/librustc_driver/driver.rs @@ -482,7 +482,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.opt.debugging_opts.trace_macros, + trace_mac: sess.opts.debugging_opts.trace_macros, }; let ret = syntax::ext::expand::expand_crate(&sess.parse_sess, cfg, From 5e1505f82396d696fd11b28c2aae5b01c14ed3f9 Mon Sep 17 00:00:00 2001 From: Thomas Jespersen Date: Tue, 14 Apr 2015 23:43:09 +0200 Subject: [PATCH 04/28] Remove -o flag from build command It generates a warning that --outdir argument is ignored, which is captured and spoils the output Also ensure that test output is captured in a different file than the expected output file --- src/test/run-make/trace-macros-flag/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/run-make/trace-macros-flag/Makefile b/src/test/run-make/trace-macros-flag/Makefile index fc49c8c900c81..4dfa238413dd2 100644 --- a/src/test/run-make/trace-macros-flag/Makefile +++ b/src/test/run-make/trace-macros-flag/Makefile @@ -5,5 +5,5 @@ -include ../tools.mk all: - $(RUSTC) -o $(TMPDIR)/hello -Z trace-macros hello.rs &> $(TMPDIR)/hello.trace + $(RUSTC) -Z trace-macros hello.rs &> $(TMPDIR)/hello.trace diff -u $(TMPDIR)/hello.trace hello.trace From 53b7a06fafd00627d721d168bc993152a0f265c8 Mon Sep 17 00:00:00 2001 From: Tobias Bucher Date: Wed, 15 Apr 2015 09:52:08 +0200 Subject: [PATCH 05/28] Remove one allocation for the file path in file opening Fixes #22190. --- src/libstd/fs.rs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/libstd/fs.rs b/src/libstd/fs.rs index 914830d9dcfea..a92ef2a2aef7d 100644 --- a/src/libstd/fs.rs +++ b/src/libstd/fs.rs @@ -51,7 +51,6 @@ use vec::Vec; #[stable(feature = "rust1", since = "1.0.0")] pub struct File { inner: fs_imp::File, - path: Option, } /// Metadata information about a file. @@ -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 } /// Attempt to sync all OS-internal metadata to disk. @@ -302,7 +301,7 @@ impl AsInner for File { } impl FromInner for File { fn from_inner(f: fs_imp::File) -> File { - File { inner: f, path: None } + File { inner: f } } } @@ -470,7 +469,7 @@ impl OpenOptions { pub fn open>(&self, path: P) -> io::Result { 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 }) } } From 9891ea74d6f706cf38e91599f1e65816977cefdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adolfo=20Ochagav=C3=ADa?= Date: Wed, 15 Apr 2015 11:17:58 +0200 Subject: [PATCH 06/28] Implement traits for parser error structs Implement `Debug`, `Display` and `Error` for `FatalError` and `ExplicitBug` --- src/libsyntax/diagnostic.rs | 37 +++++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/src/libsyntax/diagnostic.rs b/src/libsyntax/diagnostic.rs index f3715d765e391..e9af6c00995a6 100644 --- a/src/libsyntax/diagnostic.rs +++ b/src/libsyntax/diagnostic.rs @@ -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. @@ -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. From 6a95d90b86fcfb04377db34324b513f108e4f060 Mon Sep 17 00:00:00 2001 From: Ariel Ben-Yehuda Date: Tue, 14 Apr 2015 21:09:59 +0300 Subject: [PATCH 07/28] make Repr of TraitRef more useful --- src/librustc/util/ppaux.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/librustc/util/ppaux.rs b/src/librustc/util/ppaux.rs index 7358b4cc0f6ec..698f6c4750216 100644 --- a/src/librustc/util/ppaux.rs +++ b/src/librustc/util/ppaux.rs @@ -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) + } } } @@ -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)) } From 9e1a07883bcf7b5881dec9bd1ff83ffd6da13d02 Mon Sep 17 00:00:00 2001 From: Ariel Ben-Yehuda Date: Tue, 14 Apr 2015 21:14:42 +0300 Subject: [PATCH 08/28] clean visit_expr --- src/librustc_typeck/check/writeback.rs | 61 +++++++++++++------------- 1 file changed, 30 insertions(+), 31 deletions(-) diff --git a/src/librustc_typeck/check/writeback.rs b/src/librustc_typeck/check/writeback.rs index f778a64f94969..5eab90764d4e3 100644 --- a/src/librustc_typeck/check/writeback.rs +++ b/src/librustc_typeck/check/writeback.rs @@ -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.expr_ty(lhs.id); + let lhs_ty = self.fcx.infcx().resolve_type_vars_if_possible(&lhs_ty); + + let rhs_ty = self.fcx.expr_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); + } + } + } + } } /////////////////////////////////////////////////////////////////////////// @@ -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); From 9c1dfed2ba2946bbf9de787de647f5c58e336ae0 Mon Sep 17 00:00:00 2001 From: Ariel Ben-Yehuda Date: Tue, 14 Apr 2015 21:17:14 +0300 Subject: [PATCH 09/28] Use node_ty instead of expr_ty in binary expr fixup --- src/librustc_typeck/check/writeback.rs | 4 ++-- src/test/compile-fail/issue-24363.rs | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 src/test/compile-fail/issue-24363.rs diff --git a/src/librustc_typeck/check/writeback.rs b/src/librustc_typeck/check/writeback.rs index 5eab90764d4e3..889975f0eb2f9 100644 --- a/src/librustc_typeck/check/writeback.rs +++ b/src/librustc_typeck/check/writeback.rs @@ -92,10 +92,10 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> { // 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.expr_ty(lhs.id); + 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.expr_ty(rhs.id); + 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) { diff --git a/src/test/compile-fail/issue-24363.rs b/src/test/compile-fail/issue-24363.rs new file mode 100644 index 0000000000000..590c464371c06 --- /dev/null +++ b/src/test/compile-fail/issue-24363.rs @@ -0,0 +1,16 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + 1.create_a_type_error[ //~ ERROR attempted access of field + ()+() //~ ERROR binary operation `+` cannot be applied + // ^ ensure that we typeck the inner expression ^ + ]; +} From fd8c592757144b8d0655aaf1ff3dd3c5b8b16a80 Mon Sep 17 00:00:00 2001 From: Ariel Ben-Yehuda Date: Wed, 15 Apr 2015 19:53:19 +0300 Subject: [PATCH 10/28] Always type-check the index of an IndexExpr Fixes #24363. --- src/librustc_typeck/check/mod.rs | 48 ++++++++++++++++---------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 8264647b2561b..402465355b685 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -3515,34 +3515,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); } } } From 3a203636e9f5c40cd8117b006ffa732f894c734c Mon Sep 17 00:00:00 2001 From: Thomas Jespersen Date: Wed, 15 Apr 2015 21:47:33 +0200 Subject: [PATCH 11/28] Make sure to disambiguate obtained out from expected output --- src/test/run-make/trace-macros-flag/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/run-make/trace-macros-flag/Makefile b/src/test/run-make/trace-macros-flag/Makefile index 4dfa238413dd2..88a52773c01d4 100644 --- a/src/test/run-make/trace-macros-flag/Makefile +++ b/src/test/run-make/trace-macros-flag/Makefile @@ -5,5 +5,5 @@ -include ../tools.mk all: - $(RUSTC) -Z trace-macros hello.rs &> $(TMPDIR)/hello.trace - diff -u $(TMPDIR)/hello.trace hello.trace + $(RUSTC) -Z trace-macros hello.rs &> $(TMPDIR)/hello.out + diff -u $(TMPDIR)/hello.out hello.trace From c1f6d6a13633d71845a84ffbe3709057be4e437c Mon Sep 17 00:00:00 2001 From: Luke Gallagher Date: Thu, 16 Apr 2015 17:18:29 +1000 Subject: [PATCH 12/28] Fix some documentation typos --- src/doc/reference.md | 6 +++--- src/libsyntax/feature_gate.rs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/doc/reference.md b/src/doc/reference.md index 0ed23dae9b559..3b3c4ea641228 100644 --- a/src/doc/reference.md +++ b/src/doc/reference.md @@ -2368,7 +2368,7 @@ The currently implemented features of the reference compiler are: removed entirely for something more wholesome. * `custom_attribute` - Allows the usage of attributes unknown to the compiler - so that new attributes can be added in a bacwards compatible + so that new attributes can be added in a backwards compatible manner (RFC 572). * `custom_derive` - Allows the use of `#[derive(Foo,Bar)]` as sugar for @@ -2397,7 +2397,7 @@ The currently implemented features of the reference compiler are: nasty hack that will certainly be removed. * `main` - Allows use of the `#[main]` attribute, which changes the entry point - into a Rust program. This capabiilty is subject to change. + into a Rust program. This capability is subject to change. * `macro_reexport` - Allows macros to be re-exported from one crate after being imported from another. This feature was originally designed with the sole @@ -2453,7 +2453,7 @@ The currently implemented features of the reference compiler are: is unintuitive and suboptimal. * `start` - Allows use of the `#[start]` attribute, which changes the entry point - into a Rust program. This capabiilty, especially the signature for the + into a Rust program. This capability, especially the signature for the annotated function, is subject to change. * `struct_inherit` - Allows using struct inheritance, which is barely diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 659eb34323259..d0975c76e9351 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -10,7 +10,7 @@ //! Feature gating //! -//! This modules implements the gating necessary for preventing certain compiler +//! This module implements the gating necessary for preventing certain compiler //! features from being used by default. This module will crawl a pre-expanded //! AST to ensure that there are no features which are used that are not //! enabled. From 709b5e8c89a5cdce911b26d2617f08c481c26341 Mon Sep 17 00:00:00 2001 From: Ulrik Sverdrup Date: Thu, 16 Apr 2015 10:02:22 +0200 Subject: [PATCH 13/28] Fix Debug impl for RangeFull The Debug impl was using quotes, which was inconsistent: => (.., 1.., 2..3, ..4) ("..", 1.., 2..3, ..4) Fix to use just .. --- src/libcore/ops.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcore/ops.rs b/src/libcore/ops.rs index 00039c4fcdf15..adfbd14121f58 100644 --- a/src/libcore/ops.rs +++ b/src/libcore/ops.rs @@ -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, "..") } } From 7d56fb214938c6e5334789c7ee37c08db417090b Mon Sep 17 00:00:00 2001 From: Ting-Yu Lin Date: Thu, 16 Apr 2015 17:35:33 +0800 Subject: [PATCH 14/28] Fix link id for stackoverflow The document does not display properly if the link id contains a space. --- src/doc/trpl/installing-rust.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/doc/trpl/installing-rust.md b/src/doc/trpl/installing-rust.md index 09b4495ffe990..58d9e57dc51cc 100644 --- a/src/doc/trpl/installing-rust.md +++ b/src/doc/trpl/installing-rust.md @@ -91,9 +91,9 @@ If not, there are a number of places where you can get help. The easiest is [Mibbit][mibbit]. Click that link, and you'll be chatting with other Rustaceans (a silly nickname we call ourselves), and we can help you out. Other great resources include [the user’s forum][users], and -[Stack Overflow][stack overflow]. +[Stack Overflow][stackoverflow]. [irc]: irc://irc.mozilla.org/#rust [mibbit]: http://chat.mibbit.com/?server=irc.mozilla.org&channel=%23rust [users]: http://users.rust-lang.org/ -[stack overflow]: http://stackoverflow.com/questions/tagged/rust +[stackoverflow]: http://stackoverflow.com/questions/tagged/rust From 61ad9fe1a3a34d358c3922d77557f626e4a21232 Mon Sep 17 00:00:00 2001 From: Mathijs van de Nes Date: Thu, 16 Apr 2015 12:14:45 +0200 Subject: [PATCH 15/28] Use BTreeMap in build_sidebar_items This ensures that later when generating HTML, the JSON will be sorted aswell. We now have a deterministic build of sidebar-items.js --- src/librustdoc/html/render.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index 5f4a3e74b6589..54fbdc28968e4 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -37,7 +37,7 @@ pub use self::ExternalLocation::*; use std::ascii::OwnedAsciiExt; use std::cell::RefCell; use std::cmp::Ordering; -use std::collections::{HashMap, HashSet}; +use std::collections::{BTreeMap, HashMap, HashSet}; use std::default::Default; use std::fmt; use std::fs::{self, File}; @@ -1319,8 +1319,9 @@ impl Context { } } - fn build_sidebar_items(&self, m: &clean::Module) -> HashMap> { - let mut map = HashMap::new(); + fn build_sidebar_items(&self, m: &clean::Module) -> BTreeMap> { + // BTreeMap instead of HashMap to get a sorted output + let mut map = BTreeMap::new(); for item in &m.items { if self.ignore_private_item(item) { continue } From d40e1cbfd856223fed8a8beb3b20da64965b53c5 Mon Sep 17 00:00:00 2001 From: Aram Visser Date: Thu, 16 Apr 2015 19:21:11 +0700 Subject: [PATCH 16/28] Fixed typo in hash_map::Entry documentation --- src/libstd/collections/hash/map.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs index f554a4f4ed6d1..9b93066f9fb21 100644 --- a/src/libstd/collections/hash/map.rs +++ b/src/libstd/collections/hash/map.rs @@ -1469,7 +1469,6 @@ impl<'a, K, V> ExactSizeIterator for Drain<'a, K, V> { } impl<'a, K, V> Entry<'a, K, V> { - /// Returns a mutable reference to the entry if occupied, or the VacantEntry if vacant. #[unstable(feature = "std_misc", reason = "will soon be replaced by or_insert")] #[deprecated(since = "1.0", From c0139cafcdbe60e446b81dda78f3595fea3e3b8d Mon Sep 17 00:00:00 2001 From: Thomas Jespersen Date: Thu, 16 Apr 2015 14:57:31 +0200 Subject: [PATCH 17/28] Remove `&` from redirected output This seems to fix the test --- src/test/run-make/trace-macros-flag/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/run-make/trace-macros-flag/Makefile b/src/test/run-make/trace-macros-flag/Makefile index 88a52773c01d4..3338e394e0ef9 100644 --- a/src/test/run-make/trace-macros-flag/Makefile +++ b/src/test/run-make/trace-macros-flag/Makefile @@ -5,5 +5,5 @@ -include ../tools.mk all: - $(RUSTC) -Z trace-macros hello.rs &> $(TMPDIR)/hello.out + $(RUSTC) -Z trace-macros hello.rs > $(TMPDIR)/hello.out diff -u $(TMPDIR)/hello.out hello.trace From f20497ca857e3ef6a63d2abf8fa75569faad4008 Mon Sep 17 00:00:00 2001 From: Florian Hartwig Date: Thu, 16 Apr 2015 15:13:47 +0200 Subject: [PATCH 18/28] Fix some broken links in the book --- src/doc/trpl/concurrency.md | 4 ++-- src/doc/trpl/error-handling.md | 2 +- src/doc/trpl/macros.md | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/doc/trpl/concurrency.md b/src/doc/trpl/concurrency.md index 159e04e9429a0..575dfc7417a7f 100644 --- a/src/doc/trpl/concurrency.md +++ b/src/doc/trpl/concurrency.md @@ -176,8 +176,8 @@ Here's the error: ^~~~~~~~~~~~~ ``` -You see, [`Mutex`](std/sync/struct.Mutex.html) has a -[`lock`](http://doc.rust-lang.org/nightly/std/sync/struct.Mutex.html#method.lock) +You see, [`Mutex`](../std/sync/struct.Mutex.html) has a +[`lock`](../std/sync/struct.Mutex.html#method.lock) method which has this signature: ```ignore diff --git a/src/doc/trpl/error-handling.md b/src/doc/trpl/error-handling.md index 491f7b0c2a0f3..aaa43b33d3b81 100644 --- a/src/doc/trpl/error-handling.md +++ b/src/doc/trpl/error-handling.md @@ -297,5 +297,5 @@ It's worth noting that you can only use `try!` from a function that returns a `Result`, which means that you cannot use `try!` inside of `main()`, because `main()` doesn't return anything. -`try!` makes use of [`From`](../std/convert/trait.From.hml) to determine +`try!` makes use of [`From`](../std/convert/trait.From.html) to determine what to return in the error case. diff --git a/src/doc/trpl/macros.md b/src/doc/trpl/macros.md index 6d21cb59383c7..713814d9147a7 100644 --- a/src/doc/trpl/macros.md +++ b/src/doc/trpl/macros.md @@ -33,7 +33,7 @@ mind. You may have seen the `vec!` macro, used to initialize a [vector][] with any number of elements. -[vector]: arrays-vectors-and-slices.html +[vector]: vectors.html ```rust let x: Vec = vec![1, 2, 3]; From 4436ade8ad62619dadd6033f116a831179b238d9 Mon Sep 17 00:00:00 2001 From: Philip Munksgaard Date: Thu, 16 Apr 2015 15:58:43 +0200 Subject: [PATCH 19/28] Add Debug to MethodCallee This fixes #24497 --- src/librustc/middle/ty.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index 1e817890440f2..eab87dc846d64 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -437,7 +437,7 @@ pub struct MethodObject<'tcx> { pub vtable_index: usize, } -#[derive(Clone)] +#[derive(Clone, Debug)] pub struct MethodCallee<'tcx> { pub origin: MethodOrigin<'tcx>, pub ty: Ty<'tcx>, From 1c6ccd96ac4c03411283749687556f4ccbf3bce5 Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Thu, 16 Apr 2015 11:53:17 -0400 Subject: [PATCH 20/28] Indicate None is code-like in doc comments --- src/libcore/iter.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/libcore/iter.rs b/src/libcore/iter.rs index e44b0d1147cbc..16ee38898803f 100644 --- a/src/libcore/iter.rs +++ b/src/libcore/iter.rs @@ -179,8 +179,8 @@ pub trait Iterator { /// Creates an iterator that iterates over both this and the specified /// iterators simultaneously, yielding the two elements as pairs. When - /// either iterator returns None, all further invocations of next() will - /// return None. + /// either iterator returns `None`, all further invocations of next() will + /// return `None`. /// /// # Examples /// @@ -254,7 +254,7 @@ pub trait Iterator { } /// Creates an iterator that both filters and maps elements. - /// If the specified function returns None, the element is skipped. + /// If the specified function returns `None`, the element is skipped. /// Otherwise the option is unwrapped and the new value is yielded. /// /// # Examples @@ -403,7 +403,7 @@ pub trait Iterator { /// Creates a new iterator that behaves in a similar fashion to fold. /// There is a state which is passed between each iteration and can be /// mutated as necessary. The yielded values from the closure are yielded - /// from the Scan instance when not None. + /// from the Scan instance when not `None`. /// /// # Examples /// @@ -701,7 +701,7 @@ pub trait Iterator { /// Returns the index of the last element satisfying the specified predicate /// - /// If no element matches, None is returned. + /// If no element matches, `None` is returned. /// /// Does not consume the iterator *before* the first found element. /// From 6de33c22e306505c95cc2f3b775e1a82925560fd Mon Sep 17 00:00:00 2001 From: Mathijs van de Nes Date: Thu, 16 Apr 2015 19:53:19 +0200 Subject: [PATCH 21/28] Omit 'obsolete' note for warning if -Awarning --- src/libsyntax/parse/obsolete.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libsyntax/parse/obsolete.rs b/src/libsyntax/parse/obsolete.rs index 3b21b5059daa1..00d9b7f4ea687 100644 --- a/src/libsyntax/parse/obsolete.rs +++ b/src/libsyntax/parse/obsolete.rs @@ -80,7 +80,8 @@ impl<'a> ParserObsoleteMethods for parser::Parser<'a> { self.span_warn(sp, &format!("obsolete syntax: {}", kind_str)); } - if !self.obsolete_set.contains(&kind) { + if !self.obsolete_set.contains(&kind) && + (error || self.sess.span_diagnostic.handler().can_emit_warnings) { self.sess .span_diagnostic .handler() From e6f1a4db5fb98407e33bfe33b2bb3debd686047f Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Thu, 16 Apr 2015 15:50:24 -0400 Subject: [PATCH 22/28] remove example usage of from_str in error docs Fixes #24185 --- src/doc/trpl/error-handling.md | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/src/doc/trpl/error-handling.md b/src/doc/trpl/error-handling.md index 491f7b0c2a0f3..492514456ebe8 100644 --- a/src/doc/trpl/error-handling.md +++ b/src/doc/trpl/error-handling.md @@ -20,18 +20,18 @@ panic. A *failure* is an error that can be recovered from in some way. A *panic* is an error that cannot be recovered from. What do we mean by "recover"? Well, in most cases, the possibility of an error -is expected. For example, consider the `from_str` function: +is expected. For example, consider the `parse` function: -```{rust,ignore} -from_str("5"); +```ignore +"5".parse(); ``` -This function takes a string argument and converts it into another type. But -because it's a string, you can't be sure that the conversion actually works. -For example, what should this convert to? +This method converts a string into another type. But because it's a string, you +can't be sure that the conversion actually works. For example, what should this +convert to? -```{rust,ignore} -from_str("hello5world"); +```ignore +"hello5world".parse(); ``` This won't work. So we know that this function will only work properly for some @@ -40,7 +40,8 @@ inputs. It's expected behavior. We call this kind of error a *failure*. On the other hand, sometimes, there are errors that are unexpected, or which we cannot recover from. A classic example is an `assert!`: -```{rust,ignore} +```rust +# let x = 5; assert!(x == 5); ``` @@ -119,17 +120,19 @@ Rust calls these sorts of errors *panics*. # Handling errors with `Option` and `Result` The simplest way to indicate that a function may fail is to use the `Option` -type. Remember our `from_str()` example? Here's its type signature: +type. For example, the `find` method on strings attempts to find a pattern +in a string, and returns an `Option`: -```{rust,ignore} -pub fn from_str(s: &str) -> Option +```rust +let s = "foo"; + +assert_eq!(s.find('f'), Some(0)); +assert_eq!(s.find('z'), None); ``` -`from_str()` returns an `Option`. If the conversion succeeds, it will return -`Some(value)`, and if it fails, it will return `None`. This is appropriate for the simplest of cases, but doesn't give us a lot of -information in the failure case. What if we wanted to know _why_ the conversion +information in the failure case. What if we wanted to know _why_ the function failed? For this, we can use the `Result` type. It looks like this: ```rust From c776d02d5da30ec4143406384f98852d8c6d0d81 Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Thu, 16 Apr 2015 15:55:10 -0400 Subject: [PATCH 23/28] Make note of documentation tests and binaries Fixes #24228 --- src/doc/trpl/documentation.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/doc/trpl/documentation.md b/src/doc/trpl/documentation.md index 06071a8f15fa4..06db63853698d 100644 --- a/src/doc/trpl/documentation.md +++ b/src/doc/trpl/documentation.md @@ -380,7 +380,10 @@ $ rustdoc --test path/to/my/crate/root.rs $ cargo test ``` -That's right, `cargo test` tests embedded documentation too. +That's right, `cargo test` tests embedded documentation too. However, +`cargo test` will not test binary crates, only library ones. This is +due to the way `rustdoc` works: it links against the library to be tested, +but with a binary, there’s nothing to link to. There are a few more annotations that are useful to help `rustdoc` do the right thing when testing your code: From dabc4864c07b2c31136b3c861c980c6ff72da11d Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Thu, 16 Apr 2015 16:12:47 -0400 Subject: [PATCH 24/28] Descripe tuple indexing in TRPL FIxes #23962 --- src/doc/trpl/primitive-types.md | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/src/doc/trpl/primitive-types.md b/src/doc/trpl/primitive-types.md index fcbe2b2f8bf70..811080cd50987 100644 --- a/src/doc/trpl/primitive-types.md +++ b/src/doc/trpl/primitive-types.md @@ -216,6 +216,18 @@ In systems programming languages, strings are a bit more complex than in other languages. For now, just read `&str` as a *string slice*, and we’ll learn more soon. +You can assign one tuple into another, if they have the same contained types +and [arity]. Tuples have the same arity when they have the same length. + +[arity]: glossary.html#arity + +```rust +let mut x = (1, 2); // x: (i32, i32) +let y = (2, 3); // y: (i32, i32) + +x = y; +``` + You can access the fields in a tuple through a *destructuring let*. Here’s an example: @@ -235,20 +247,24 @@ or "breaks up," the tuple, and assigns the bits to three bindings. This pattern is very powerful, and we’ll see it repeated more later. -There are also a few things you can do with a tuple as a whole, without -destructuring. You can assign one tuple into another, if they have the same -contained types and [arity]. Tuples have the same arity when they have the same -length. +## Tuple Indexing + +You can also access fields of a tuple with indexing syntax: -[arity]: glossary.html#arity ```rust -let mut x = (1, 2); // x: (i32, i32) -let y = (2, 3); // y: (i32, i32) +let tuple = (1, 2, 3); -x = y; +let x = tuple.0; +let y = tuple.1; +let z = tuple.2; + +println!("x is {}", x); ``` +Like array indexing, it starts at zero, but unlike array indexing, it uses a +`.`, rather than `[]`s. + You can find more documentation for tuples [in the standard library documentation][tuple]. From 6ac836f229b10d281c034dcf5acfff5003f86fba Mon Sep 17 00:00:00 2001 From: Florian Hartwig Date: Thu, 16 Apr 2015 22:12:13 +0200 Subject: [PATCH 25/28] Fix broken links in the docs --- src/doc/complement-design-faq.md | 4 ++-- src/doc/trpl/closures.md | 6 +++--- src/libcore/raw.rs | 4 ++-- src/libcore/result.rs | 4 ++-- src/librustc/plugin/mod.rs | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/doc/complement-design-faq.md b/src/doc/complement-design-faq.md index 0f2c37a5abf83..678c3970fe282 100644 --- a/src/doc/complement-design-faq.md +++ b/src/doc/complement-design-faq.md @@ -56,7 +56,7 @@ Types which are [`Sync`][sync] are thread-safe when multiple shared references to them are used concurrently. Types which are not `Sync` are not thread-safe, and thus when used in a global require unsafe code to use. -[sync]: core/kinds/trait.Sync.html +[sync]: core/marker/trait.Sync.html ### If mutable static items that implement `Sync` are safe, why is taking &mut SHARABLE unsafe? @@ -139,7 +139,7 @@ and explicitly calling the `clone` method. Making user-defined copy operators explicit surfaces the underlying complexity, forcing the developer to opt-in to potentially expensive operations. -[copy]: core/kinds/trait.Copy.html +[copy]: core/marker/trait.Copy.html [clone]: core/clone/trait.Clone.html ## No move constructors diff --git a/src/doc/trpl/closures.md b/src/doc/trpl/closures.md index e63331e5206bf..e3de8eb30be91 100644 --- a/src/doc/trpl/closures.md +++ b/src/doc/trpl/closures.md @@ -205,11 +205,11 @@ you tons of control over what your code does, and closures are no different. Rust's implementation of closures is a bit different than other languages. They are effectively syntax sugar for traits. You'll want to make sure to have read -the [traits chapter][traits] before this one, as well as the chapter on [static -and dynamic dispatch][dispatch], which talks about trait objects. +the [traits chapter][traits] before this one, as well as the chapter on [trait +objects][trait-objects]. [traits]: traits.html -[dispatch]: static-and-dynamic-dispatch.html +[trait-objects]: trait-objects.html Got all that? Good. diff --git a/src/libcore/raw.rs b/src/libcore/raw.rs index ded52ff07785e..685b3e5c546dd 100644 --- a/src/libcore/raw.rs +++ b/src/libcore/raw.rs @@ -71,11 +71,11 @@ impl Clone for Slice { /// The representation of a trait object like `&SomeTrait`. /// /// This struct has the same layout as types like `&SomeTrait` and -/// `Box`. The [Static and Dynamic Dispatch chapter of the +/// `Box`. The [Trait Objects chapter of the /// Book][moreinfo] contains more details about the precise nature of /// these internals. /// -/// [moreinfo]: ../../book/static-and-dynamic-dispatch.html#representation +/// [moreinfo]: ../../book/trait-objects.html#representation /// /// `TraitObject` is guaranteed to match layouts, but it is not the /// type of trait objects (e.g. the fields are not directly accessible diff --git a/src/libcore/result.rs b/src/libcore/result.rs index 4c74f4646ac06..26bc653b26fa4 100644 --- a/src/libcore/result.rs +++ b/src/libcore/result.rs @@ -86,12 +86,12 @@ //! useful value. //! //! Consider the `write_all` method defined for I/O types -//! by the [`Write`](../io/trait.Write.html) trait: +//! by the [`Write`](../../std/io/trait.Write.html) trait: //! //! ``` //! use std::io; //! -//! trait Writer { +//! trait Write { //! fn write_all(&mut self, bytes: &[u8]) -> Result<(), io::Error>; //! } //! ``` diff --git a/src/librustc/plugin/mod.rs b/src/librustc/plugin/mod.rs index 3162c4fc57023..4a85e1893f0a1 100644 --- a/src/librustc/plugin/mod.rs +++ b/src/librustc/plugin/mod.rs @@ -47,7 +47,7 @@ //! #![plugin(myplugin)] //! ``` //! -//! See the [Plugins Chapter](../../book/plugins.html) of the book +//! See the [Plugins Chapter](../../book/compiler-plugins.html) of the book //! for more examples. pub use self::registry::Registry; From d04b2047a7bd1e623875c7af91978a0194f3f2f1 Mon Sep 17 00:00:00 2001 From: Nelo Onyiah Date: Fri, 17 Apr 2015 00:02:17 +0100 Subject: [PATCH 26/28] Update hello-cargo.md --- src/doc/trpl/hello-cargo.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/trpl/hello-cargo.md b/src/doc/trpl/hello-cargo.md index 8d8b17343343e..6967532a44735 100644 --- a/src/doc/trpl/hello-cargo.md +++ b/src/doc/trpl/hello-cargo.md @@ -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! From d9515ad40fe24feea4da0a740d9e0cfe0aa3814e Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Thu, 16 Apr 2015 23:17:36 -0400 Subject: [PATCH 27/28] Link up some stuff in the vectors chapter Fixes #24070 or rather, fixes it even though it's already been fixed: slices are before now. But the linking is nice anyway. --- src/doc/trpl/vectors.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/doc/trpl/vectors.md b/src/doc/trpl/vectors.md index 0dfbfc1191347..6fa5917ea99ba 100644 --- a/src/doc/trpl/vectors.md +++ b/src/doc/trpl/vectors.md @@ -1,13 +1,18 @@ % Vectors A *vector* is a dynamic or "growable" array, implemented as the standard -library type [`Vec`](../std/vec/) (Where `` 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`](../std/vec/) (Where `` 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 ``` +[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.) From c98115cefb1e10b582569404f6142a918f3ccbe5 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Fri, 17 Apr 2015 15:47:38 +0530 Subject: [PATCH 28/28] Remove info for path (fixup #24452) --- src/librustdoc/html/render.rs | 1 - src/librustdoc/lib.rs | 1 - 2 files changed, 2 deletions(-) diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index 250ec34edf707..3f3f8201b0019 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -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| { diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index 2682bbf4662e0..e3b429a37d3ee 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -32,7 +32,6 @@ #![feature(test)] #![feature(unicode)] #![feature(str_words)] -#![feature(file_path)] #![feature(path_ext)] #![feature(path_relative_from)] #![feature(slice_patterns)]