Skip to content

Commit 43c5fef

Browse files
committed
Auto merge of #33354 - Manishearth:rollup, r=Manishearth
Rollup of 14 pull requests - Successful merges: #32756, #33129, #33225, #33260, #33309, #33320, #33323, #33324, #33325, #33330, #33332, #33334, #33335, #33346 - Failed merges:
2 parents 44b3cd8 + 638cf9f commit 43c5fef

File tree

12 files changed

+167
-114
lines changed

12 files changed

+167
-114
lines changed

src/libcore/intrinsics.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -192,11 +192,8 @@ extern "rust-intrinsic" {
192192

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

202199
/// Moves a value to an uninitialized memory location.

src/libcore/mem.rs

+3
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,9 @@ pub fn forget<T>(t: T) {
117117

118118
/// Returns the size of a type in bytes.
119119
///
120+
/// More specifically, this is the offset in bytes between successive
121+
/// items of the same type, including alignment padding.
122+
///
120123
/// # Examples
121124
///
122125
/// ```

src/librustc/diagnostics.rs

+11-1
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,17 @@ fn foo(x: u8) -> u8 {
635635
```
636636
637637
It is advisable to find out what the unhandled cases are and check for them,
638-
returning an appropriate value or panicking if necessary.
638+
returning an appropriate value or panicking if necessary. Check if you need
639+
to remove a semicolon from the last expression, like in this case:
640+
641+
```ignore
642+
fn foo(x: u8) -> u8 {
643+
inner(2*x + 1);
644+
}
645+
```
646+
647+
The semicolon discards the return value of `inner`, instead of returning
648+
it from `foo`.
639649
"##,
640650

641651
E0270: r##"

src/librustc_const_eval/check_match.rs

+21-2
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,15 @@ fn check_arms(cx: &MatchCheckCtxt,
341341
},
342342

343343
hir::MatchSource::Normal => {
344-
span_err!(cx.tcx.sess, pat.span, E0001, "unreachable pattern")
344+
let mut err = struct_span_err!(cx.tcx.sess, pat.span, E0001,
345+
"unreachable pattern");
346+
// if we had a catchall pattern, hint at that
347+
for row in &seen.0 {
348+
if pat_is_catchall(&cx.tcx.def_map.borrow(), row[0]) {
349+
span_note!(err, row[0].span, "this pattern matches any value");
350+
}
351+
}
352+
err.emit();
345353
},
346354

347355
hir::MatchSource::TryDesugar => {
@@ -361,7 +369,18 @@ fn check_arms(cx: &MatchCheckCtxt,
361369
}
362370
}
363371

364-
fn raw_pat<'a>(p: &'a Pat) -> &'a Pat {
372+
/// Checks for common cases of "catchall" patterns that may not be intended as such.
373+
fn pat_is_catchall(dm: &DefMap, p: &Pat) -> bool {
374+
match p.node {
375+
PatKind::Ident(_, _, None) => pat_is_binding(dm, p),
376+
PatKind::Ident(_, _, Some(ref s)) => pat_is_catchall(dm, &s),
377+
PatKind::Ref(ref s, _) => pat_is_catchall(dm, &s),
378+
PatKind::Tup(ref v) => v.iter().all(|p| pat_is_catchall(dm, &p)),
379+
_ => false
380+
}
381+
}
382+
383+
fn raw_pat(p: &Pat) -> &Pat {
365384
match p.node {
366385
PatKind::Ident(_, _, Some(ref s)) => raw_pat(&s),
367386
_ => p

src/librustc_incremental/persist/util.rs

+24-2
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,16 @@
99
// except according to those terms.
1010

1111
use rustc::ty;
12+
1213
use std::fs;
13-
use std::path::PathBuf;
14+
use std::io;
15+
use std::path::{PathBuf, Path};
1416

1517
pub fn dep_graph_path<'tcx>(tcx: &ty::TyCtxt<'tcx>) -> Option<PathBuf> {
1618
// For now, just save/load dep-graph from
1719
// directory/dep_graph.rbml
1820
tcx.sess.opts.incremental.as_ref().and_then(|incr_dir| {
19-
match fs::create_dir_all(&incr_dir){
21+
match create_dir_racy(&incr_dir) {
2022
Ok(()) => {}
2123
Err(err) => {
2224
tcx.sess.err(
@@ -30,3 +32,23 @@ pub fn dep_graph_path<'tcx>(tcx: &ty::TyCtxt<'tcx>) -> Option<PathBuf> {
3032
})
3133
}
3234

35+
// Like std::fs::create_dir_all, except handles concurrent calls among multiple
36+
// threads or processes.
37+
fn create_dir_racy(path: &Path) -> io::Result<()> {
38+
match fs::create_dir(path) {
39+
Ok(()) => return Ok(()),
40+
Err(ref e) if e.kind() == io::ErrorKind::AlreadyExists => return Ok(()),
41+
Err(ref e) if e.kind() == io::ErrorKind::NotFound => {}
42+
Err(e) => return Err(e),
43+
}
44+
match path.parent() {
45+
Some(p) => try!(create_dir_racy(p)),
46+
None => return Err(io::Error::new(io::ErrorKind::Other,
47+
"failed to create whole tree")),
48+
}
49+
match fs::create_dir(path) {
50+
Ok(()) => Ok(()),
51+
Err(ref e) if e.kind() == io::ErrorKind::AlreadyExists => Ok(()),
52+
Err(e) => Err(e),
53+
}
54+
}

src/librustc_resolve/diagnostics.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -916,19 +916,22 @@ An import was unresolved. Erroneous code example:
916916
use something::Foo; // error: unresolved import `something::Foo`.
917917
```
918918
919-
Please verify you didn't misspell the import name or the import does exist
920-
in the module from where you tried to import it. Example:
919+
Paths in `use` statements are relative to the crate root. To import items
920+
relative to the current and parent modules, use the `self::` and `super::`
921+
prefixes, respectively. Also verify that you didn't misspell the import
922+
name and that the import exists in the module from where you tried to
923+
import it. Example:
921924
922925
```ignore
923-
use something::Foo; // ok!
926+
use self::something::Foo; // ok!
924927
925928
mod something {
926929
pub struct Foo;
927930
}
928931
```
929932
930933
Or, if you tried to use a module from an external crate, you may have missed
931-
the `extern crate` declaration:
934+
the `extern crate` declaration (which is usually placed in the crate root):
932935
933936
```ignore
934937
extern crate homura; // Required to use the `homura` crate

src/librustc_typeck/check/method/suggest.rs

-4
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,6 @@ pub fn report_error<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
156156
if let Some(expr) = rcvr_expr {
157157
if let Ok (expr_string) = cx.sess.codemap().span_to_snippet(expr.span) {
158158
report_function!(expr.span, expr_string);
159-
err.span_suggestion(expr.span,
160-
"try calling the base function:",
161-
format!("{}()",
162-
expr_string));
163159
}
164160
else if let Expr_::ExprPath(_, path) = expr.node.clone() {
165161
if let Some(segment) = path.segments.last() {

src/libstd/io/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@
195195
//!
196196
//! ## Functions
197197
//!
198-
//! There are a number of [functions][functions] that offer access to various
198+
//! There are a number of [functions][functions-list] that offer access to various
199199
//! features. For example, we can use three of these functions to copy everything
200200
//! from standard input to standard output:
201201
//!
@@ -208,7 +208,7 @@
208208
//! # }
209209
//! ```
210210
//!
211-
//! [functions]: #functions
211+
//! [functions-list]: #functions-1
212212
//!
213213
//! ## io::Result
214214
//!

src/libsyntax/parse/lexer/mod.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -931,11 +931,10 @@ impl<'a> StringReader<'a> {
931931
_ => {
932932
if ascii_only && first_source_char > '\x7F' {
933933
let last_pos = self.last_pos;
934-
self.err_span_char(start,
935-
last_pos,
936-
"byte constant must be ASCII. Use a \\xHH escape for a \
937-
non-ASCII byte",
938-
first_source_char);
934+
self.err_span_(start,
935+
last_pos,
936+
"byte constant must be ASCII. Use a \\xHH escape for a \
937+
non-ASCII byte");
939938
return false;
940939
}
941940
}

0 commit comments

Comments
 (0)