Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 23 pull requests #35592

Merged
merged 56 commits into from
Aug 12, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
15be66d
Provide a cleaner documentation for 'write!'
cengizio Aug 4, 2016
800aa92
Use consistent spelling for word 'implementor'
cengizio Aug 4, 2016
c630bea
Be more explicit about duck typing
cengizio Aug 4, 2016
751d43a
Ignore VS Code settings directory
vadimcn Aug 5, 2016
abe1cc7
run rustfmt on compiletest folder in src/tools/ folder
srinivasreddy Jun 11, 2016
ec1ef79
Updated the messages for E0017
pcn Aug 7, 2016
e28521e
Remove unnecessary `main` functions in doc examples.
frewsxcv Aug 8, 2016
bd2bd6c
Shrink span to variant discriminant expression for E0081
KiChjang Aug 8, 2016
3c04ba2
add test for issue #29053
Aug 8, 2016
156c822
Update error messages for E0091 and E0092
stephen-lazaro Aug 8, 2016
da8fed5
Update unit test for E0092
stephen-lazaro Aug 8, 2016
0cb8439
Update E0008 to new format
Aug 8, 2016
0a98d73
Do not span across nodes for E0004
KiChjang Aug 8, 2016
ee076dd
Updated E0433 to new error message. (no bonus)
hank-der-hafenarbeiter Aug 8, 2016
ae9c09d
Updated error for E0045 (no bonus)
hank-der-hafenarbeiter Aug 8, 2016
b5ead00
updated unit test
hank-der-hafenarbeiter Aug 9, 2016
2adc07f
added unit test
hank-der-hafenarbeiter Aug 9, 2016
0e8ec43
Update error message E0384 to new format
theypsilon Aug 9, 2016
71a34d7
Merge branch 'master' of github.com:theypsilon/rust
theypsilon Aug 9, 2016
20ea8cb
Update E0038 to the new error format
munyari Aug 8, 2016
0a3564a
Add tracking issue for `String::insert_str`
murarth Aug 9, 2016
aa40ec7
Update E0007 to new format
Aug 9, 2016
766a0ab
E0128 update error format
circuitfox Aug 9, 2016
46265a0
E0263 updated to new format. rust-lang/rust#35518
Aug 9, 2016
70e760f
Remove redundant `&mut ref mut` in doc for Result::as_mut()
birkenfeld Aug 10, 2016
e7065b7
Update E0133 to new format
wdv4758h Aug 10, 2016
e3ebe8b
Fix docs typo in std::os::unix::net::SocketAddr::is_unnamed
Aug 10, 2016
907a20c
Clarify std::os::unix::net::SocketAddr::is_unnamed's docstring
Aug 10, 2016
034df94
Update error format for E0326
trixnz Aug 5, 2016
f656a92
Update error format for E0130
trixnz Aug 4, 2016
e2cc157
Fixed no-pattern-in-args test for new E0130 format
trixnz Aug 5, 2016
c5f9feb
E0072 update error format
circuitfox Aug 10, 2016
476e496
Rollup merge of #35279 - cengizIO:master, r=brson
Aug 11, 2016
260a379
Rollup merge of #35331 - trixnz:update-error-130, r=jonathandturner
Aug 11, 2016
0fecdc5
Rollup merge of #35358 - vadimcn:vscode, r=steveklabnik
Aug 11, 2016
e24c326
Rollup merge of #35375 - trixnz:update-error-326, r=jonathandturner
Aug 11, 2016
d2e9573
Rollup merge of #35445 - pcn:update-E0017-to-new-format, r=arielb1
Aug 11, 2016
b179042
Rollup merge of #35448 - srinivasreddy:rf_compiletest, r=nikomatsakis
Aug 11, 2016
d423c25
Rollup merge of #35482 - frewsxcv:patch-31, r=GuillaumeGomez
Aug 11, 2016
853fe86
Rollup merge of #35486 - KiChjang:e0081-bonus, r=jonathandturner
Aug 11, 2016
ea34254
Rollup merge of #35505 - futile:test_29053, r=nikomatsakis
Aug 11, 2016
0283443
Rollup merge of #35528 - Vassah:master, r=jonathandturner
Aug 11, 2016
c7513d7
Rollup merge of #35530 - srdja:master, r=jonathandturner
Aug 11, 2016
d0922f6
Rollup merge of #35532 - KiChjang:e0004-follow-up, r=jonathandturner
Aug 11, 2016
294ac7b
Rollup merge of #35536 - hank-der-hafenarbeiter:E0433, r=jonathandturner
Aug 11, 2016
8d63269
Rollup merge of #35537 - munyari:e0038, r=jonathandturner
Aug 11, 2016
08d5df8
Rollup merge of #35541 - hank-der-hafenarbeiter:E0045, r=jonathandturner
Aug 11, 2016
b758688
Rollup merge of #35552 - theypsilon:master, r=jonathandturner
Aug 11, 2016
b76ca89
Rollup merge of #35554 - murarth:insert-str-issue, r=apasel422
Aug 11, 2016
a5408a5
Rollup merge of #35555 - circuitfox:E0128-update-error-format, r=jona…
Aug 11, 2016
aaed538
Rollup merge of #35557 - Limeth:master, r=jonathandturner
Aug 11, 2016
6692f41
Rollup merge of #35562 - birkenfeld:as-mut-doc, r=steveklabnik
Aug 11, 2016
efbed8b
Rollup merge of #35565 - wdv4758h:E0133, r=jonathandturner
Aug 11, 2016
0e92c5e
Rollup merge of #35569 - pietroalbini:fix-typo, r=steveklabnik
Aug 11, 2016
cdedad5
Rollup merge of #35576 - circuitfox:E0072-update-error-format, r=jona…
Aug 11, 2016
d3af9a3
Fix tidy warning
Aug 11, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ __pycache__/
.project
.settings/
.valgrindrc
.vscode/
/*-*-*-*/
/*-*-*/
/Makefile
Expand Down
2 changes: 1 addition & 1 deletion src/libcollections/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1180,7 +1180,7 @@ impl String {
#[inline]
#[unstable(feature = "insert_str",
reason = "recent addition",
issue = "0")]
issue = "35553")]
pub fn insert_str(&mut self, idx: usize, string: &str) {
let len = self.len();
assert!(idx <= len);
Expand Down
45 changes: 37 additions & 8 deletions src/libcore/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,14 +229,28 @@ macro_rules! try {
})
}

/// Use the `format!` syntax to write data into a buffer.
/// Write formatted data into a buffer
///
/// This macro is typically used with a buffer of `&mut `[`Write`][write].
/// This macro accepts any value with `write_fmt` method as a writer, a format string, and a list
/// of arguments to format.
///
/// `write_fmt` method usually comes from an implementation of [`std::fmt::Write`][fmt_write] or
/// [`std::io::Write`][io_write] traits. These are sometimes called 'writers'.
///
/// Passed arguments will be formatted according to the specified format string and the resulting
/// string will be passed to the writer.
///
/// See [`std::fmt`][fmt] for more information on format syntax.
///
/// Return value is completely dependent on the 'write_fmt' method.
///
/// Common return values are: [`Result`][enum_result], [`io::Result`][type_result]
///
/// [fmt]: ../std/fmt/index.html
/// [write]: ../std/io/trait.Write.html
/// [fmt_write]: ../std/fmt/trait.Write.html
/// [io_write]: ../std/io/trait.Write.html
/// [enum_result]: ../std/result/enum.Result.html
/// [type_result]: ../std/io/type.Result.html
///
/// # Examples
///
Expand All @@ -255,16 +269,31 @@ macro_rules! write {
($dst:expr, $($arg:tt)*) => ($dst.write_fmt(format_args!($($arg)*)))
}

/// Use the `format!` syntax to write data into a buffer, appending a newline.
/// On all platforms, the newline is the LINE FEED character (`\n`/`U+000A`)
/// alone (no additional CARRIAGE RETURN (`\r`/`U+000D`).
/// Write formatted data into a buffer, with appending a newline.
///
/// On all platforms, the newline is the LINE FEED character (`\n`/`U+000A`) alone
/// (no additional CARRIAGE RETURN (`\r`/`U+000D`).
///
/// This macro is typically used with a buffer of `&mut `[`Write`][write].
/// This macro accepts any value with `write_fmt` method as a writer, a format string, and a list
/// of arguments to format.
///
/// `write_fmt` method usually comes from an implementation of [`std::fmt::Write`][fmt_write] or
/// [`std::io::Write`][io_write] traits. These are sometimes called 'writers'.
///
/// Passed arguments will be formatted according to the specified format string and the resulting
/// string will be passed to the writer.
///
/// See [`std::fmt`][fmt] for more information on format syntax.
///
/// Return value is completely dependent on the 'write_fmt' method.
///
/// Common return values are: [`Result`][enum_result], [`io::Result`][type_result]
///
/// [fmt]: ../std/fmt/index.html
/// [write]: ../std/io/trait.Write.html
/// [fmt_write]: ../std/fmt/trait.Write.html
/// [io_write]: ../std/io/trait.Write.html
/// [enum_result]: ../std/result/enum.Result.html
/// [type_result]: ../std/io/type.Result.html
///
/// # Examples
///
Expand Down
4 changes: 2 additions & 2 deletions src/libcore/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -402,8 +402,8 @@ impl<T, E> Result<T, E> {
/// ```
/// fn mutate(r: &mut Result<i32, i32>) {
/// match r.as_mut() {
/// Ok(&mut ref mut v) => *v = 42,
/// Err(&mut ref mut e) => *e = 0,
/// Ok(v) => *v = 42,
/// Err(e) => *e = 0,
/// }
/// }
///
Expand Down
8 changes: 5 additions & 3 deletions src/librustc/middle/effect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,11 @@ impl<'a, 'tcx> EffectCheckVisitor<'a, 'tcx> {
match self.unsafe_context.root {
SafeContext => {
// Report an error.
span_err!(self.tcx.sess, span, E0133,
"{} requires unsafe function or block",
description);
struct_span_err!(
self.tcx.sess, span, E0133,
"{} requires unsafe function or block", description)
.span_label(span, &format!("unsafe call requires unsafe function or block"))
.emit();
}
UnsafeBlock(block_id) => {
// OK, but record this.
Expand Down
12 changes: 8 additions & 4 deletions src/librustc/middle/resolve_lifetime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -718,10 +718,14 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
let lifetime_j = &lifetimes[j];

if lifetime_i.lifetime.name == lifetime_j.lifetime.name {
span_err!(self.sess, lifetime_j.lifetime.span, E0263,
"lifetime name `{}` declared twice in \
the same scope",
lifetime_j.lifetime.name);
struct_span_err!(self.sess, lifetime_j.lifetime.span, E0263,
"lifetime name `{}` declared twice in the same scope",
lifetime_j.lifetime.name)
.span_label(lifetime_j.lifetime.span,
&format!("declared twice"))
.span_label(lifetime_i.lifetime.span,
&format!("previous declaration here"))
.emit();
}
}

Expand Down
14 changes: 10 additions & 4 deletions src/librustc/traits/error_reporting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
let mut err = struct_span_err!(self.sess, span, E0072,
"recursive type `{}` has infinite size",
self.item_path_str(type_def_id));
err.span_label(span, &format!("recursive type has infinite size"));
err.help(&format!("insert indirection (e.g., a `Box`, `Rc`, or `&`) \
at some point to make `{}` representable",
self.item_path_str(type_def_id)));
Expand All @@ -670,10 +671,15 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
let mut err = match warning_node_id {
Some(_) => None,
None => {
Some(struct_span_err!(
self.sess, span, E0038,
"the trait `{}` cannot be made into an object",
self.item_path_str(trait_def_id)))
let trait_str = self.item_path_str(trait_def_id);
let mut db = struct_span_err!(
self.sess, span, E0038,
"the trait `{}` cannot be made into an object",
trait_str);
db.span_label(span,
&format!("the trait `{}` cannot be made \
into an object", trait_str));
Some(db)
}
};

Expand Down
12 changes: 8 additions & 4 deletions src/librustc_borrowck/borrowck/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -760,12 +760,16 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
lp: &LoanPath<'tcx>,
assign:
&move_data::Assignment) {
struct_span_err!(
let mut err = struct_span_err!(
self.tcx.sess, span, E0384,
"re-assignment of immutable variable `{}`",
self.loan_path_to_string(lp))
.span_note(assign.span, "prior assignment occurs here")
.emit();
self.loan_path_to_string(lp));
err.span_label(span, &format!("re-assignment of immutable variable"));
if span != assign.span {
err.span_label(assign.span, &format!("first assignment to `{}`",
self.loan_path_to_string(lp)));
}
err.emit();
}

pub fn span_err(&self, s: Span, m: &str) {
Expand Down
17 changes: 9 additions & 8 deletions src/librustc_const_eval/check_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,12 +235,7 @@ fn check_expr(cx: &mut MatchCheckCtxt, ex: &hir::Expr) {
.flat_map(|arm| &arm.0)
.map(|pat| vec![wrap_pat(cx, &pat)])
.collect();
let match_span = Span {
lo: ex.span.lo,
hi: scrut.span.hi,
expn_id: ex.span.expn_id
};
check_exhaustive(cx, match_span, &matrix, source);
check_exhaustive(cx, scrut.span, &matrix, source);
},
_ => ()
}
Expand Down Expand Up @@ -1115,9 +1110,15 @@ fn check_legality_of_move_bindings(cx: &MatchCheckCtxt,

// x @ Foo(..) is legal, but x @ Foo(y) isn't.
if sub.map_or(false, |p| pat_contains_bindings(&p)) {
span_err!(cx.tcx.sess, p.span, E0007, "cannot bind by-move with sub-bindings");
struct_span_err!(cx.tcx.sess, p.span, E0007,
"cannot bind by-move with sub-bindings")
.span_label(p.span, &format!("binds an already bound by-move value by moving it"))
.emit();
} else if has_guard {
span_err!(cx.tcx.sess, p.span, E0008, "cannot bind by-move into a pattern guard");
struct_span_err!(cx.tcx.sess, p.span, E0008,
"cannot bind by-move into a pattern guard")
.span_label(p.span, &format!("moves value into pattern guard"))
.emit();
} else if by_ref_span.is_some() {
let mut err = struct_span_err!(cx.tcx.sess, p.span, E0009,
"cannot bind by-move and by-ref in the same pattern");
Expand Down
9 changes: 6 additions & 3 deletions src/librustc_mir/transform/qualify_consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -617,9 +617,12 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> {
if !allow {
self.add(Qualif::NOT_CONST);
if self.mode != Mode::Fn {
span_err!(self.tcx.sess, self.span, E0017,
"references in {}s may only refer \
to immutable values", self.mode);
struct_span_err!(self.tcx.sess, self.span, E0017,
"references in {}s may only refer \
to immutable values", self.mode)
.span_label(self.span, &format!("{}s require immutable values",
self.mode))
.emit();
}
}
} else {
Expand Down
1 change: 1 addition & 0 deletions src/librustc_passes/ast_validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ impl<'a> Visitor for AstValidator<'a> {
E0130,
"patterns aren't allowed in foreign function \
declarations");
err.span_label(span, &format!("pattern not allowed in foreign function"));
if is_recent {
err.span_note(span,
"this is a recent error, see issue #35203 for more details");
Expand Down
5 changes: 4 additions & 1 deletion src/librustc_resolve/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,10 @@ fn resolve_struct_error<'b, 'a: 'b, 'c>(resolver: &'b Resolver<'a>,
struct_span_err!(resolver.session, span, E0432, "{}", msg)
}
ResolutionError::FailedToResolve(msg) => {
struct_span_err!(resolver.session, span, E0433, "failed to resolve. {}", msg)
let mut err = struct_span_err!(resolver.session, span, E0433,
"failed to resolve. {}", msg);
err.span_label(span, &msg);
err
}
ResolutionError::CannotCaptureDynamicEnvironmentInFnItem => {
struct_span_err!(resolver.session,
Expand Down
24 changes: 23 additions & 1 deletion src/librustc_typeck/check/compare_method.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ use rustc::ty;
use rustc::traits::{self, ProjectionMode};
use rustc::ty::error::ExpectedFound;
use rustc::ty::subst::{self, Subst, Substs, VecPerParamSpace};
use rustc::hir::map::Node;
use rustc::hir::{ImplItemKind, TraitItem_};

use syntax::ast;
use syntax_pos::Span;
Expand Down Expand Up @@ -461,7 +463,7 @@ pub fn compare_const_impl<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
// Compute skolemized form of impl and trait const tys.
let impl_ty = impl_c.ty.subst(tcx, impl_to_skol_substs);
let trait_ty = trait_c.ty.subst(tcx, &trait_to_skol_substs);
let origin = TypeOrigin::Misc(impl_c_span);
let mut origin = TypeOrigin::Misc(impl_c_span);

let err = infcx.commit_if_ok(|_| {
// There is no "body" here, so just pass dummy id.
Expand Down Expand Up @@ -496,11 +498,31 @@ pub fn compare_const_impl<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
debug!("checking associated const for compatibility: impl ty {:?}, trait ty {:?}",
impl_ty,
trait_ty);

// Locate the Span containing just the type of the offending impl
if let Some(impl_trait_node) = tcx.map.get_if_local(impl_c.def_id) {
if let Node::NodeImplItem(impl_trait_item) = impl_trait_node {
if let ImplItemKind::Const(ref ty, _) = impl_trait_item.node {
origin = TypeOrigin::Misc(ty.span);
}
}
}

let mut diag = struct_span_err!(
tcx.sess, origin.span(), E0326,
"implemented const `{}` has an incompatible type for trait",
trait_c.name
);

// Add a label to the Span containing just the type of the item
if let Some(orig_trait_node) = tcx.map.get_if_local(trait_c.def_id) {
if let Node::NodeTraitItem(orig_trait_item) = orig_trait_node {
if let TraitItem_::ConstTraitItem(ref ty, _) = orig_trait_item.node {
diag.span_label(ty.span, &format!("original trait requirement"));
}
}
}

infcx.note_type_err(
&mut diag, origin,
Some(infer::ValuePairs::Types(ExpectedFound {
Expand Down
6 changes: 4 additions & 2 deletions src/librustc_typeck/check/intrinsic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,10 @@ pub fn check_intrinsic_type(ccx: &CrateCtxt, it: &hir::ForeignItem) {
(0, Vec::new(), tcx.mk_nil())
}
op => {
span_err!(tcx.sess, it.span, E0092,
"unrecognized atomic operation function: `{}`", op);
struct_span_err!(tcx.sess, it.span, E0092,
"unrecognized atomic operation function: `{}`", op)
.span_label(it.span, &format!("unrecognized atomic operation"))
.emit();
return;
}
};
Expand Down
26 changes: 18 additions & 8 deletions src/librustc_typeck/check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1272,13 +1272,21 @@ pub fn check_enum_variants<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>,

// Check for duplicate discriminant values
if let Some(i) = disr_vals.iter().position(|&x| x == current_disr_val) {
let mut err = struct_span_err!(ccx.tcx.sess, v.span, E0081,
"discriminant value `{}` already exists", disr_vals[i]);
let variant_i_node_id = ccx.tcx.map.as_local_node_id(variants[i].did).unwrap();
err.span_label(ccx.tcx.map.span(variant_i_node_id),
&format!("first use of `{}`", disr_vals[i]));
err.span_label(v.span , &format!("enum already has `{}`", disr_vals[i]));
err.emit();
let variant_i = ccx.tcx.map.expect_variant(variant_i_node_id);
let i_span = match variant_i.node.disr_expr {
Some(ref expr) => expr.span,
None => ccx.tcx.map.span(variant_i_node_id)
};
let span = match v.node.disr_expr {
Some(ref expr) => expr.span,
None => v.span
};
struct_span_err!(ccx.tcx.sess, span, E0081,
"discriminant value `{}` already exists", disr_vals[i])
.span_label(i_span, &format!("first use of `{}`", disr_vals[i]))
.span_label(span , &format!("enum already has `{}`", disr_vals[i]))
.emit();
}
disr_vals.push(current_disr_val);
}
Expand Down Expand Up @@ -4640,9 +4648,11 @@ pub fn check_bounds_are_used<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,

for (i, b) in tps_used.iter().enumerate() {
if !*b {
span_err!(ccx.tcx.sess, tps[i].span, E0091,
struct_span_err!(ccx.tcx.sess, tps[i].span, E0091,
"type parameter `{}` is unused",
tps[i].name);
tps[i].name)
.span_label(tps[i].span, &format!("unused type parameter"))
.emit();
}
}
}
9 changes: 6 additions & 3 deletions src/librustc_typeck/collect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1903,9 +1903,12 @@ fn convert_default_type_parameter<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
for leaf_ty in ty.walk() {
if let ty::TyParam(p) = leaf_ty.sty {
if p.space == space && p.idx >= index {
span_err!(ccx.tcx.sess, path.span, E0128,
"type parameters with a default cannot use \
forward declared identifiers");
struct_span_err!(ccx.tcx.sess, path.span, E0128,
"type parameters with a default cannot use \
forward declared identifiers")
.span_label(path.span, &format!("defaulted type parameters \
cannot be forward declared"))
.emit();

return ccx.tcx.types.err
}
Expand Down
4 changes: 3 additions & 1 deletion src/librustc_typeck/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,10 @@ fn require_c_abi_if_variadic(tcx: TyCtxt,
abi: Abi,
span: Span) {
if decl.variadic && abi != Abi::C {
span_err!(tcx.sess, span, E0045,
let mut err = struct_span_err!(tcx.sess, span, E0045,
"variadic function must have C calling convention");
err.span_label(span, &("variadics require C calling conventions").to_string())
.emit();
}
}

Expand Down
Loading