Skip to content

Commit

Permalink
Auto merge of #35407 - eddyb:rollup, r=eddyb
Browse files Browse the repository at this point in the history
Rollup of 21 pull requests

- Successful merges: #33951, #34916, #35287, #35288, #35351, #35353, #35356, #35362, #35363, #35364, #35366, #35368, #35370, #35372, #35373, #35374, #35375, #35376, #35380, #35393, #35394
- Failed merges: #35331, #35395
  • Loading branch information
bors authored Aug 6, 2016
2 parents ecdd51b + 67f0822 commit 444ff9f
Show file tree
Hide file tree
Showing 56 changed files with 701 additions and 260 deletions.
4 changes: 2 additions & 2 deletions man/rustc.1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.TH RUSTC "1" "August 2015" "rustc 1.2.0" "User Commands"
.TH RUSTC "1" "August 2016" "rustc 1.12.0" "User Commands"
.SH NAME
rustc \- The Rust compiler
.SH SYNOPSIS
Expand Down Expand Up @@ -299,7 +299,7 @@ To build an executable with debug info:
See https://github.com/rust\-lang/rust/issues for issues.

.SH "AUTHOR"
See \fIAUTHORS.txt\fR in the Rust source distribution.
See https://github.com/rust\-lang/rust/graphs/contributors or use `git log --all --format='%cN <%cE>' | sort -u` in the rust source distribution.

.SH "COPYRIGHT"
This work is dual\[hy]licensed under Apache\ 2.0 and MIT terms.
Expand Down
2 changes: 1 addition & 1 deletion man/rustdoc.1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.TH RUSTDOC "1" "August 2015" "rustdoc 1.2.0" "User Commands"
.TH RUSTDOC "1" "August 2016" "rustdoc 1.12.0" "User Commands"
.SH NAME
rustdoc \- generate documentation from Rust source code
.SH SYNOPSIS
Expand Down
16 changes: 8 additions & 8 deletions src/libcore/raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,13 @@
/// only designed to be used by unsafe code that needs to manipulate
/// the low-level details.
///
/// There is no `Repr` implementation for `TraitObject` because there
/// is no way to refer to all trait objects generically, so the only
/// There is no way to refer to all trait objects generically, so the only
/// way to create values of this type is with functions like
/// `std::mem::transmute`. Similarly, the only way to create a true
/// [`std::mem::transmute`][transmute]. Similarly, the only way to create a true
/// trait object from a `TraitObject` value is with `transmute`.
///
/// [transmute]: ../intrinsics/fn.transmute.html
///
/// Synthesizing a trait object with mismatched types—one where the
/// vtable does not correspond to the type of the value to which the
/// data pointer points—is highly likely to lead to undefined
Expand All @@ -50,13 +51,13 @@
/// ```
/// #![feature(raw)]
///
/// use std::mem;
/// use std::raw;
/// use std::{mem, raw};
///
/// // an example trait
/// trait Foo {
/// fn bar(&self) -> i32;
/// }
///
/// impl Foo for i32 {
/// fn bar(&self) -> i32 {
/// *self + 1
Expand All @@ -74,19 +75,18 @@
/// // the data pointer is the address of `value`
/// assert_eq!(raw_object.data as *const i32, &value as *const _);
///
///
/// let other_value: i32 = 456;
///
/// // construct a new object, pointing to a different `i32`, being
/// // careful to use the `i32` vtable from `object`
/// let synthesized: &Foo = unsafe {
/// mem::transmute(raw::TraitObject {
/// data: &other_value as *const _ as *mut (),
/// vtable: raw_object.vtable
/// vtable: raw_object.vtable,
/// })
/// };
///
/// // it should work just like we constructed a trait object out of
/// // it should work just as if we had constructed a trait object out of
/// // `other_value` directly
/// assert_eq!(synthesized.bar(), 457);
/// ```
Expand Down
5 changes: 3 additions & 2 deletions src/librustc/middle/astconv_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {

pub fn prohibit_projection(self, span: Span)
{
span_err!(self.sess, span, E0229,
"associated type bindings are not allowed here");
let mut err = struct_span_err!(self.sess, span, E0229,
"associated type bindings are not allowed here");
err.span_label(span, &format!("associate type not allowed here")).emit();
}

pub fn prim_ty_to_ty(self,
Expand Down
5 changes: 4 additions & 1 deletion src/librustc_borrowck/borrowck/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -942,9 +942,12 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
but it borrows {}, \
which is owned by the current function",
cmt_path_or_string)
.span_note(capture_span,
.span_label(capture_span,
&format!("{} is borrowed here",
cmt_path_or_string))
.span_label(err.span,
&format!("may outlive borrowed value {}",
cmt_path_or_string))
.span_suggestion(err.span,
&format!("to force the closure to take ownership of {} \
(and any other referenced variables), \
Expand Down
9 changes: 7 additions & 2 deletions src/librustc_const_eval/check_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -424,10 +424,15 @@ fn check_exhaustive<'a, 'tcx>(cx: &MatchCheckCtxt<'a, 'tcx>,
format!("`{}` and {} more", head.join("`, `"), tail.len())
}
};
span_err!(cx.tcx.sess, sp, E0004,

let label_text = match pattern_strings.len(){
1 => format!("pattern {} not covered", joined_patterns),
_ => format!("patterns {} not covered", joined_patterns)
};
struct_span_err!(cx.tcx.sess, sp, E0004,
"non-exhaustive patterns: {} not covered",
joined_patterns
);
).span_label(sp, &label_text).emit();
},
}
}
Expand Down
11 changes: 7 additions & 4 deletions src/librustc_const_eval/eval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1337,10 +1337,13 @@ pub fn eval_length<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
Ok(val as usize)
},
Ok(const_val) => {
span_err!(tcx.sess, count_expr.span, E0306,
"expected usize for {}, found {}",
reason,
const_val.description());
struct_span_err!(tcx.sess, count_expr.span, E0306,
"expected `usize` for {}, found {}",
reason,
const_val.description())
.span_label(count_expr.span, &format!("expected `usize`"))
.emit();

Err(ErrorReported)
}
Err(err) => {
Expand Down
101 changes: 60 additions & 41 deletions src/librustc_passes/ast_validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,18 @@ impl<'a> AstValidator<'a> {
self.err_handler().span_err(span, &format!("invalid label name `{}`", label.name));
}
if label.name.as_str() == "'_" {
self.session.add_lint(
lint::builtin::LIFETIME_UNDERSCORE, id, span,
format!("invalid label name `{}`", label.name)
);
self.session.add_lint(lint::builtin::LIFETIME_UNDERSCORE,
id,
span,
format!("invalid label name `{}`", label.name));
}
}

fn invalid_visibility(&self, vis: &Visibility, span: Span, note: Option<&str>) {
if vis != &Visibility::Inherited {
let mut err = struct_span_err!(self.session, span, E0449,
let mut err = struct_span_err!(self.session,
span,
E0449,
"unnecessary visibility qualifier");
if let Some(note) = note {
err.span_note(span, note);
Expand All @@ -71,20 +73,23 @@ impl<'a> AstValidator<'a> {
impl<'a> Visitor for AstValidator<'a> {
fn visit_lifetime(&mut self, lt: &Lifetime) {
if lt.name.as_str() == "'_" {
self.session.add_lint(
lint::builtin::LIFETIME_UNDERSCORE, lt.id, lt.span,
format!("invalid lifetime name `{}`", lt.name)
);
self.session.add_lint(lint::builtin::LIFETIME_UNDERSCORE,
lt.id,
lt.span,
format!("invalid lifetime name `{}`", lt.name));
}

visit::walk_lifetime(self, lt)
}

fn visit_expr(&mut self, expr: &Expr) {
match expr.node {
ExprKind::While(_, _, Some(ident)) | ExprKind::Loop(_, Some(ident)) |
ExprKind::WhileLet(_, _, _, Some(ident)) | ExprKind::ForLoop(_, _, _, Some(ident)) |
ExprKind::Break(Some(ident)) | ExprKind::Continue(Some(ident)) => {
ExprKind::While(_, _, Some(ident)) |
ExprKind::Loop(_, Some(ident)) |
ExprKind::WhileLet(_, _, _, Some(ident)) |
ExprKind::ForLoop(_, _, _, Some(ident)) |
ExprKind::Break(Some(ident)) |
ExprKind::Continue(Some(ident)) => {
self.check_label(ident.node, ident.span, expr.id);
}
_ => {}
Expand All @@ -97,10 +102,13 @@ impl<'a> Visitor for AstValidator<'a> {
match ty.node {
TyKind::BareFn(ref bfty) => {
self.check_decl_no_pat(&bfty.decl, |span, _| {
let mut err = struct_span_err!(self.session, span, E0561,
"patterns aren't allowed in function pointer types");
err.span_note(span, "this is a recent error, see \
issue #35203 for more details");
let mut err = struct_span_err!(self.session,
span,
E0561,
"patterns aren't allowed in function pointer \
types");
err.span_note(span,
"this is a recent error, see issue #35203 for more details");
err.emit();
});
}
Expand All @@ -114,10 +122,10 @@ impl<'a> Visitor for AstValidator<'a> {
if path.global && path.segments.len() > 0 {
let ident = path.segments[0].identifier;
if token::Ident(ident).is_path_segment_keyword() {
self.session.add_lint(
lint::builtin::SUPER_OR_SELF_IN_GLOBAL_PATH, id, path.span,
format!("global paths cannot start with `{}`", ident)
);
self.session.add_lint(lint::builtin::SUPER_OR_SELF_IN_GLOBAL_PATH,
id,
path.span,
format!("global paths cannot start with `{}`", ident));
}
}

Expand All @@ -129,8 +137,8 @@ impl<'a> Visitor for AstValidator<'a> {
ItemKind::Use(ref view_path) => {
let path = view_path.node.path();
if !path.segments.iter().all(|segment| segment.parameters.is_empty()) {
self.err_handler().span_err(path.span, "type or lifetime parameters \
in import path");
self.err_handler()
.span_err(path.span, "type or lifetime parameters in import path");
}
}
ItemKind::Impl(_, _, _, Some(..), _, ref impl_items) => {
Expand All @@ -140,15 +148,18 @@ impl<'a> Visitor for AstValidator<'a> {
}
}
ItemKind::Impl(_, _, _, None, _, _) => {
self.invalid_visibility(&item.vis, item.span, Some("place qualifiers on individual \
impl items instead"));
self.invalid_visibility(&item.vis,
item.span,
Some("place qualifiers on individual impl items instead"));
}
ItemKind::DefaultImpl(..) => {
self.invalid_visibility(&item.vis, item.span, None);
}
ItemKind::ForeignMod(..) => {
self.invalid_visibility(&item.vis, item.span, Some("place qualifiers on individual \
foreign items instead"));
self.invalid_visibility(&item.vis,
item.span,
Some("place qualifiers on individual foreign items \
instead"));
}
ItemKind::Enum(ref def, _) => {
for variant in &def.variants {
Expand All @@ -167,11 +178,14 @@ impl<'a> Visitor for AstValidator<'a> {
match fi.node {
ForeignItemKind::Fn(ref decl, _) => {
self.check_decl_no_pat(decl, |span, is_recent| {
let mut err = struct_span_err!(self.session, span, E0130,
"patterns aren't allowed in foreign function declarations");
let mut err = struct_span_err!(self.session,
span,
E0130,
"patterns aren't allowed in foreign function \
declarations");
if is_recent {
err.span_note(span, "this is a recent error, see \
issue #35203 for more details");
err.span_note(span,
"this is a recent error, see issue #35203 for more details");
}
err.emit();
});
Expand All @@ -182,16 +196,21 @@ impl<'a> Visitor for AstValidator<'a> {
visit::walk_foreign_item(self, fi)
}

fn visit_variant_data(&mut self, vdata: &VariantData, _: Ident,
_: &Generics, _: NodeId, span: Span) {
fn visit_variant_data(&mut self,
vdata: &VariantData,
_: Ident,
_: &Generics,
_: NodeId,
span: Span) {
if vdata.fields().is_empty() {
if vdata.is_tuple() {
self.err_handler().struct_span_err(span, "empty tuple structs and enum variants \
are not allowed, use unit structs and \
enum variants instead")
.span_help(span, "remove trailing `()` to make a unit \
struct or unit enum variant")
.emit();
self.err_handler()
.struct_span_err(span,
"empty tuple structs and enum variants are not allowed, use \
unit structs and enum variants instead")
.span_help(span,
"remove trailing `()` to make a unit struct or unit enum variant")
.emit();
}
}

Expand All @@ -200,10 +219,10 @@ impl<'a> Visitor for AstValidator<'a> {

fn visit_vis(&mut self, vis: &Visibility) {
match *vis {
Visibility::Restricted{ref path, ..} => {
Visibility::Restricted { ref path, .. } => {
if !path.segments.iter().all(|segment| segment.parameters.is_empty()) {
self.err_handler().span_err(path.span, "type or lifetime parameters \
in visibility path");
self.err_handler()
.span_err(path.span, "type or lifetime parameters in visibility path");
}
}
_ => {}
Expand Down
Loading

0 comments on commit 444ff9f

Please sign in to comment.