diff --git a/src/doc/book/getting-started.md b/src/doc/book/getting-started.md index b0d4c6d6dd2..ca83f2226c0 100644 --- a/src/doc/book/getting-started.md +++ b/src/doc/book/getting-started.md @@ -501,7 +501,7 @@ Cargo checks to see if any of your project’s files have been modified, and onl rebuilds your project if they’ve changed since the last time you built it. With simple projects, Cargo doesn't bring a whole lot over just using `rustc`, -but it will become useful in future. This is especially true when you start +but it will become useful in the future. This is especially true when you start using crates; these are synonymous with a ‘library’ or ‘package’ in other programming languages. For complex projects composed of multiple crates, it’s much easier to let Cargo coordinate the build. Using Cargo, you can run `cargo diff --git a/src/doc/book/if.md b/src/doc/book/if.md index a532dabf8d1..52d0dd888ef 100644 --- a/src/doc/book/if.md +++ b/src/doc/book/if.md @@ -4,7 +4,7 @@ Rust’s take on `if` is not particularly complex, but it’s much more like the `if` you’ll find in a dynamically typed language than in a more traditional systems language. So let’s talk about it, to make sure you grasp the nuances. -`if` is a specific form of a more general concept, the ‘branch’. The name comes +`if` is a specific form of a more general concept, the ‘branch’, whose name comes from a branch in a tree: a decision point, where depending on a choice, multiple paths can be taken. diff --git a/src/doc/book/strings.md b/src/doc/book/strings.md index 68c7235975e..5ed1f3de062 100644 --- a/src/doc/book/strings.md +++ b/src/doc/book/strings.md @@ -44,7 +44,7 @@ let s = "foo\ assert_eq!("foobar", s); ``` -Rust has more than only `&str`s though. A `String`, is a heap-allocated string. +Rust has more than only `&str`s though. A `String` is a heap-allocated string. This string is growable, and is also guaranteed to be UTF-8. `String`s are commonly created by converting from a string slice using the `to_string` method. @@ -89,7 +89,7 @@ Viewing a `String` as a `&str` is cheap, but converting the `&str` to a ## Indexing -Because strings are valid UTF-8, strings do not support indexing: +Because strings are valid UTF-8, they do not support indexing: ```rust,ignore let s = "hello"; diff --git a/src/librustc/middle/infer/mod.rs b/src/librustc/middle/infer/mod.rs index 3eca4624bc1..e671dd73431 100644 --- a/src/librustc/middle/infer/mod.rs +++ b/src/librustc/middle/infer/mod.rs @@ -1120,11 +1120,15 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { .map(|method| resolve_ty(method.ty))) } + pub fn errors_since_creation(&self) -> bool { + self.tcx.sess.err_count() - self.err_count_on_creation != 0 + } + pub fn node_type(&self, id: ast::NodeId) -> Ty<'tcx> { match self.tables.borrow().node_types.get(&id) { Some(&t) => t, // FIXME - None if self.tcx.sess.err_count() - self.err_count_on_creation != 0 => + None if self.errors_since_creation() => self.tcx.types.err, None => { self.tcx.sess.bug( @@ -1147,7 +1151,14 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { free_regions: &FreeRegionMap, subject_node_id: ast::NodeId) { let errors = self.region_vars.resolve_regions(free_regions, subject_node_id); - self.report_region_errors(&errors); // see error_reporting.rs + if !self.errors_since_creation() { + // As a heuristic, just skip reporting region errors + // altogether if other errors have been reported while + // this infcx was in use. This is totally hokey but + // otherwise we have a hard time separating legit region + // errors from silly ones. + self.report_region_errors(&errors); // see error_reporting.rs + } } pub fn ty_to_string(&self, t: Ty<'tcx>) -> String { diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs index 679da4abf5f..dba0bcf19be 100644 --- a/src/librustc/session/config.rs +++ b/src/librustc/session/config.rs @@ -1095,6 +1095,10 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options { } } + if cg.codegen_units < 1 { + early_error(error_format, "Value for codegen units must be a positive nonzero integer"); + } + let cg = cg; let sysroot_opt = matches.opt_str("sysroot").map(|m| PathBuf::from(&m)); diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index a8bea2da833..f7621b0131a 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -927,7 +927,7 @@ pub enum ExprKind { Binary(BinOp, P, P), /// A unary operation (For example: `!x`, `*x`) Unary(UnOp, P), - /// A literal (For example: `1u8`, `"foo"`) + /// A literal (For example: `1`, `"foo"`) Lit(P), /// A cast (`foo as f64`) Cast(P, P), @@ -1016,7 +1016,7 @@ pub enum ExprKind { /// An array literal constructed from one repeated element. /// - /// For example, `[1u8; 5]`. The first expression is the element + /// For example, `[1; 5]`. The first expression is the element /// to be repeated; the second is the number of times to repeat it. Repeat(P, P), @@ -1288,7 +1288,7 @@ pub enum LitKind { Byte(u8), /// A character literal (`'a'`) Char(char), - /// An integer literal (`1u8`) + /// An integer literal (`1`) Int(u64, LitIntType), /// A float literal (`1f64` or `1E10f64`) Float(InternedString, FloatTy), diff --git a/src/libsyntax/print/pp.rs b/src/libsyntax/print/pp.rs index cbbd5289a5a..c1d922ea665 100644 --- a/src/libsyntax/print/pp.rs +++ b/src/libsyntax/print/pp.rs @@ -168,8 +168,8 @@ pub fn mk_printer<'a>(out: Box, linewidth: usize) -> Printer<'a> { let n: usize = 3 * linewidth; debug!("mk_printer {}", linewidth); let token = vec![Token::Eof; n]; - let size = vec![0_isize; n]; - let scan_stack = vec![0_usize; n]; + let size = vec![0; n]; + let scan_stack = vec![0; n]; Printer { out: out, buf_len: n, diff --git a/src/test/compile-fail/issue-30580.rs b/src/test/compile-fail/issue-30580.rs new file mode 100644 index 00000000000..88d4aef6d9d --- /dev/null +++ b/src/test/compile-fail/issue-30580.rs @@ -0,0 +1,27 @@ +// Copyright 2012 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. + +// Test that we do not see uninformative region-related errors +// when we get some basic type-checking failure. See #30580. + +pub struct Foo { a: u32 } +pub struct Pass<'a, 'tcx: 'a>(&'a mut &'a (), &'a &'tcx ()); + +impl<'a, 'tcx> Pass<'a, 'tcx> +{ + pub fn tcx(&self) -> &'a &'tcx () { self.1 } + fn lol(&mut self, b: &Foo) + { + b.c; //~ ERROR no field with that name was found + self.tcx(); + } +} + +fn main() {}