Skip to content

Commit

Permalink
Auto merge of #33354 - Manishearth:rollup, r=Manishearth
Browse files Browse the repository at this point in the history
Rollup of 14 pull requests

- Successful merges: #32756, #33129, #33225, #33260, #33309, #33320, #33323, #33324, #33325, #33330, #33332, #33334, #33335, #33346
- Failed merges:
  • Loading branch information
bors committed May 3, 2016
2 parents 44b3cd8 + 638cf9f commit 43c5fef
Show file tree
Hide file tree
Showing 12 changed files with 167 additions and 114 deletions.
7 changes: 2 additions & 5 deletions src/libcore/intrinsics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,8 @@ extern "rust-intrinsic" {

/// The size of a type in bytes.
///
/// This is the exact number of bytes in memory taken up by a
/// value of the given type. In other words, a memset of this size
/// would *exactly* overwrite a value. When laid out in vectors
/// and structures there may be additional padding between
/// elements.
/// More specifically, this is the offset in bytes between successive
/// items of the same type, including alignment padding.
pub fn size_of<T>() -> usize;

/// Moves a value to an uninitialized memory location.
Expand Down
3 changes: 3 additions & 0 deletions src/libcore/mem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ pub fn forget<T>(t: T) {

/// Returns the size of a type in bytes.
///
/// More specifically, this is the offset in bytes between successive
/// items of the same type, including alignment padding.
///
/// # Examples
///
/// ```
Expand Down
12 changes: 11 additions & 1 deletion src/librustc/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,17 @@ fn foo(x: u8) -> u8 {
```
It is advisable to find out what the unhandled cases are and check for them,
returning an appropriate value or panicking if necessary.
returning an appropriate value or panicking if necessary. Check if you need
to remove a semicolon from the last expression, like in this case:
```ignore
fn foo(x: u8) -> u8 {
inner(2*x + 1);
}
```
The semicolon discards the return value of `inner`, instead of returning
it from `foo`.
"##,

E0270: r##"
Expand Down
23 changes: 21 additions & 2 deletions src/librustc_const_eval/check_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,15 @@ fn check_arms(cx: &MatchCheckCtxt,
},

hir::MatchSource::Normal => {
span_err!(cx.tcx.sess, pat.span, E0001, "unreachable pattern")
let mut err = struct_span_err!(cx.tcx.sess, pat.span, E0001,
"unreachable pattern");
// if we had a catchall pattern, hint at that
for row in &seen.0 {
if pat_is_catchall(&cx.tcx.def_map.borrow(), row[0]) {
span_note!(err, row[0].span, "this pattern matches any value");
}
}
err.emit();
},

hir::MatchSource::TryDesugar => {
Expand All @@ -361,7 +369,18 @@ fn check_arms(cx: &MatchCheckCtxt,
}
}

fn raw_pat<'a>(p: &'a Pat) -> &'a Pat {
/// Checks for common cases of "catchall" patterns that may not be intended as such.
fn pat_is_catchall(dm: &DefMap, p: &Pat) -> bool {
match p.node {
PatKind::Ident(_, _, None) => pat_is_binding(dm, p),
PatKind::Ident(_, _, Some(ref s)) => pat_is_catchall(dm, &s),
PatKind::Ref(ref s, _) => pat_is_catchall(dm, &s),
PatKind::Tup(ref v) => v.iter().all(|p| pat_is_catchall(dm, &p)),
_ => false
}
}

fn raw_pat(p: &Pat) -> &Pat {
match p.node {
PatKind::Ident(_, _, Some(ref s)) => raw_pat(&s),
_ => p
Expand Down
26 changes: 24 additions & 2 deletions src/librustc_incremental/persist/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@
// except according to those terms.

use rustc::ty;

use std::fs;
use std::path::PathBuf;
use std::io;
use std::path::{PathBuf, Path};

pub fn dep_graph_path<'tcx>(tcx: &ty::TyCtxt<'tcx>) -> Option<PathBuf> {
// For now, just save/load dep-graph from
// directory/dep_graph.rbml
tcx.sess.opts.incremental.as_ref().and_then(|incr_dir| {
match fs::create_dir_all(&incr_dir){
match create_dir_racy(&incr_dir) {
Ok(()) => {}
Err(err) => {
tcx.sess.err(
Expand All @@ -30,3 +32,23 @@ pub fn dep_graph_path<'tcx>(tcx: &ty::TyCtxt<'tcx>) -> Option<PathBuf> {
})
}

// Like std::fs::create_dir_all, except handles concurrent calls among multiple
// threads or processes.
fn create_dir_racy(path: &Path) -> io::Result<()> {
match fs::create_dir(path) {
Ok(()) => return Ok(()),
Err(ref e) if e.kind() == io::ErrorKind::AlreadyExists => return Ok(()),
Err(ref e) if e.kind() == io::ErrorKind::NotFound => {}
Err(e) => return Err(e),
}
match path.parent() {
Some(p) => try!(create_dir_racy(p)),
None => return Err(io::Error::new(io::ErrorKind::Other,
"failed to create whole tree")),
}
match fs::create_dir(path) {
Ok(()) => Ok(()),
Err(ref e) if e.kind() == io::ErrorKind::AlreadyExists => Ok(()),
Err(e) => Err(e),
}
}
11 changes: 7 additions & 4 deletions src/librustc_resolve/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -916,19 +916,22 @@ An import was unresolved. Erroneous code example:
use something::Foo; // error: unresolved import `something::Foo`.
```
Please verify you didn't misspell the import name or the import does exist
in the module from where you tried to import it. Example:
Paths in `use` statements are relative to the crate root. To import items
relative to the current and parent modules, use the `self::` and `super::`
prefixes, respectively. Also verify that you didn't misspell the import
name and that the import exists in the module from where you tried to
import it. Example:
```ignore
use something::Foo; // ok!
use self::something::Foo; // ok!
mod something {
pub struct Foo;
}
```
Or, if you tried to use a module from an external crate, you may have missed
the `extern crate` declaration:
the `extern crate` declaration (which is usually placed in the crate root):
```ignore
extern crate homura; // Required to use the `homura` crate
Expand Down
4 changes: 0 additions & 4 deletions src/librustc_typeck/check/method/suggest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,6 @@ pub fn report_error<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
if let Some(expr) = rcvr_expr {
if let Ok (expr_string) = cx.sess.codemap().span_to_snippet(expr.span) {
report_function!(expr.span, expr_string);
err.span_suggestion(expr.span,
"try calling the base function:",
format!("{}()",
expr_string));
}
else if let Expr_::ExprPath(_, path) = expr.node.clone() {
if let Some(segment) = path.segments.last() {
Expand Down
4 changes: 2 additions & 2 deletions src/libstd/io/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@
//!
//! ## Functions
//!
//! There are a number of [functions][functions] that offer access to various
//! There are a number of [functions][functions-list] that offer access to various
//! features. For example, we can use three of these functions to copy everything
//! from standard input to standard output:
//!
Expand All @@ -208,7 +208,7 @@
//! # }
//! ```
//!
//! [functions]: #functions
//! [functions-list]: #functions-1
//!
//! ## io::Result
//!
Expand Down
9 changes: 4 additions & 5 deletions src/libsyntax/parse/lexer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -931,11 +931,10 @@ impl<'a> StringReader<'a> {
_ => {
if ascii_only && first_source_char > '\x7F' {
let last_pos = self.last_pos;
self.err_span_char(start,
last_pos,
"byte constant must be ASCII. Use a \\xHH escape for a \
non-ASCII byte",
first_source_char);
self.err_span_(start,
last_pos,
"byte constant must be ASCII. Use a \\xHH escape for a \
non-ASCII byte");
return false;
}
}
Expand Down
Loading

0 comments on commit 43c5fef

Please sign in to comment.