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 21 pull requests #35469

Merged
merged 44 commits into from
Aug 7, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
2f5294e
Fixes #35304
mikhail-m1 Aug 5, 2016
e7e5cfe
Merge branch 'master' of https://github.com/rust-lang/rust
mikhail-m1 Aug 5, 2016
065c685
Update E0223 to the new format
KiChjang Aug 6, 2016
c9e9d42
Update compiler error 0027 to use new error format.
silenuss Aug 6, 2016
1d25e2e
Update compiler error 0029 to use new error format.
silenuss Aug 6, 2016
eb469d6
Updated E0225 to new format.
razielgn Aug 6, 2016
6eba89e
Fixing compiler error E0121
intrepion Aug 6, 2016
95cce86
Indicate tracking issue for `exact_size_is_empty` unstability.
frewsxcv Aug 6, 2016
19e4579
Updated error message E0282
Aug 5, 2016
e8da915
Fix build on DragonFly (unused function errno_location)
mneumann Aug 6, 2016
0a6b862
Add doc example for `std::ffi::NulError::into_vec`.
frewsxcv Aug 6, 2016
5e06da2
E0131 updated to new format
Aug 6, 2016
02f3609
Update error message for E0243 and E0244
Aug 6, 2016
ac10b5f
Update error E0117 to new format
Detegr Aug 7, 2016
e91f3f6
Update error E0118 to new format
Detegr Aug 7, 2016
54e1e98
Update E0204 to the new error format
munyari Aug 7, 2016
ed72c65
Updates compiler error E0046 with new format
shri3k Aug 5, 2016
b564c6a
Updates compiler error E0040 with new format
shri3k Aug 5, 2016
6487396
Update E0185 and E0186 to new format
Aug 4, 2016
dfb66c3
Update E0010 to use the new format
pcn Aug 6, 2016
da86ae2
Update E0101 and E0102 to new format
franleplant Aug 7, 2016
03dc484
Update E0116 to new error code format.
terrynsun Aug 7, 2016
0b248f1
Update E0205 to the new error format
munyari Aug 7, 2016
f9f6fd4
Rollup merge of #35314 - yossi-k:issue/35277, r=jonathandturner
Aug 7, 2016
0b567c6
Rollup merge of #35355 - shri3k:E0046, r=jonathandturner
Aug 7, 2016
b69b2db
Rollup merge of #35357 - shri3k:E0040, r=jonathandturner
Aug 7, 2016
94cb842
Rollup merge of #35366 - medzin:E0282, r=jonathandturner
Aug 7, 2016
46392c8
Rollup merge of #35394 - mikhail-m1:master, r=jonathandturner
Aug 7, 2016
4df5825
Rollup merge of #35410 - silenuss:e0027-formatting, r=jonathandturner
Aug 7, 2016
7e37442
Rollup merge of #35411 - KiChjang:e0223-new-format, r=jonathandturner
Aug 7, 2016
0297196
Rollup merge of #35413 - silenuss:e0029-formatting, r=jonathandturner
Aug 7, 2016
d4ed060
Rollup merge of #35417 - Limeth:master, r=jonathandturner
Aug 7, 2016
c92ca5f
Rollup merge of #35419 - Keats:err-243, r=jonathandturner
Aug 7, 2016
6bb7f35
Rollup merge of #35421 - razielgn:updated-e0225-to-new-format, r=jona…
Aug 7, 2016
9151431
Rollup merge of #35429 - frewsxcv:tracking-is-empty, r=apasel422
Aug 7, 2016
56ffcbd
Rollup merge of #35433 - mneumann:dragonfly-fix-libstd-errno-location…
Aug 7, 2016
87e129e
Rollup merge of #35434 - intrepion:fix-compile-fail-e0121, r=jonathan…
Aug 7, 2016
3917d0e
Rollup merge of #35436 - frewsxcv:into-vec, r=GuillaumeGomez
Aug 7, 2016
7d9ea8b
Rollup merge of #35439 - pcn:update-E0010-error-message, r=jonathandt…
Aug 7, 2016
a6cf011
Rollup merge of #35443 - franleplant:master, r=jonathandturner
Aug 7, 2016
fe7b3ae
Rollup merge of #35454 - Detegr:master, r=jonathandturner
Aug 7, 2016
cfebba5
Rollup merge of #35455 - munyari:e0204, r=jonathandturner
Aug 7, 2016
8bd8cef
Rollup merge of #35467 - terrynsun:master, r=jonathandturner
Aug 7, 2016
995eeb0
Rollup merge of #35468 - munyari:e0205, r=jonathandturner
Aug 7, 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
2 changes: 1 addition & 1 deletion src/libcore/iter/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ pub trait ExactSizeIterator: Iterator {
/// assert_eq!(one_element.next(), None);
/// ```
#[inline]
#[unstable(feature = "exact_size_is_empty", issue = "0")]
#[unstable(feature = "exact_size_is_empty", issue = "35428")]
fn is_empty(&self) -> bool {
self.len() == 0
}
Expand Down
10 changes: 6 additions & 4 deletions src/librustc/traits/error_reporting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -870,10 +870,12 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {


fn need_type_info(&self, span: Span, ty: Ty<'tcx>) {
span_err!(self.tcx.sess, span, E0282,
"unable to infer enough type information about `{}`; \
type annotations or generic parameter binding required",
ty);
let mut err = struct_span_err!(self.tcx.sess, span, E0282,
"unable to infer enough type information about `{}`",
ty);
err.note("type annotations or generic parameter binding required");
err.span_label(span, &format!("cannot infer type for `{}`", ty));
err.emit()
}

fn note_obligation_cause<T>(&self,
Expand Down
6 changes: 4 additions & 2 deletions src/librustc_mir/transform/qualify_consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -686,8 +686,10 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> {
Rvalue::Box(_) => {
self.add(Qualif::NOT_CONST);
if self.mode != Mode::Fn {
span_err!(self.tcx.sess, self.span, E0010,
"allocations are not allowed in {}s", self.mode);
struct_span_err!(self.tcx.sess, self.span, E0010,
"allocations are not allowed in {}s", self.mode)
.span_label(self.span, &format!("allocation not allowed in {}s", self.mode))
.emit();
}
}

Expand Down
46 changes: 29 additions & 17 deletions src/librustc_typeck/astconv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1215,10 +1215,12 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
type_str: &str,
trait_str: &str,
name: &str) {
span_err!(self.tcx().sess, span, E0223,
"ambiguous associated type; specify the type using the syntax \
`<{} as {}>::{}`",
type_str, trait_str, name);
struct_span_err!(self.tcx().sess, span, E0223, "ambiguous associated type")
.span_label(span, &format!("ambiguous associated type"))
.note(&format!("specify the type using the syntax `<{} as {}>::{}`",
type_str, trait_str, name))
.emit();

}

// Search for a bound on a type parameter which includes the associated item
Expand Down Expand Up @@ -2095,8 +2097,11 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {

if !trait_bounds.is_empty() {
let b = &trait_bounds[0];
span_err!(self.tcx().sess, b.trait_ref.path.span, E0225,
"only the builtin traits can be used as closure or object bounds");
let span = b.trait_ref.path.span;
struct_span_err!(self.tcx().sess, span, E0225,
"only the builtin traits can be used as closure or object bounds")
.span_label(span, &format!("non-builtin trait used as bounds"))
.emit();
}

let region_bound =
Expand Down Expand Up @@ -2255,20 +2260,27 @@ fn check_type_argument_count(tcx: TyCtxt, span: Span, supplied: usize,
} else {
"expected"
};
span_err!(tcx.sess, span, E0243,
"wrong number of type arguments: {} {}, found {}",
expected, required, supplied);
struct_span_err!(tcx.sess, span, E0243, "wrong number of type arguments")
.span_label(
span,
&format!("{} {} type arguments, found {}", expected, required, supplied)
)
.emit();
} else if supplied > accepted {
let expected = if required < accepted {
"expected at most"
let expected = if required == 0 {
"expected no".to_string()
} else if required < accepted {
format!("expected at most {}", accepted)
} else {
"expected"
format!("expected {}", accepted)
};
span_err!(tcx.sess, span, E0244,
"wrong number of type arguments: {} {}, found {}",
expected,
accepted,
supplied);

struct_span_err!(tcx.sess, span, E0244, "wrong number of type arguments")
.span_label(
span,
&format!("{} type arguments, found {}", expected, supplied)
)
.emit();
}
}

Expand Down
21 changes: 11 additions & 10 deletions src/librustc_typeck/check/_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,12 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
end.span
};

// Note: spacing here is intentional, we want a space before "start" and "end".
span_err!(tcx.sess, span, E0029,
"only char and numeric types are allowed in range patterns\n \
start type: {}\n end type: {}",
self.ty_to_string(lhs_ty),
self.ty_to_string(rhs_ty)
);
struct_span_err!(tcx.sess, span, E0029,
"only char and numeric types are allowed in range patterns")
.span_label(span, &format!("ranges require char or numeric types"))
.note(&format!("start type: {}", self.ty_to_string(lhs_ty)))
.note(&format!("end type: {}", self.ty_to_string(rhs_ty)))
.emit();
return;
}

Expand Down Expand Up @@ -700,9 +699,11 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
for field in variant.fields
.iter()
.filter(|field| !used_fields.contains_key(&field.name)) {
span_err!(tcx.sess, span, E0027,
"pattern does not mention field `{}`",
field.name);
struct_span_err!(tcx.sess, span, E0027,
"pattern does not mention field `{}`",
field.name)
.span_label(span, &format!("missing field `{}`", field.name))
.emit();
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/librustc_typeck/check/callee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ use rustc::hir;
/// method that is called)
pub fn check_legal_trait_for_method_call(ccx: &CrateCtxt, span: Span, trait_id: DefId) {
if ccx.tcx.lang_items.drop_trait() == Some(trait_id) {
span_err!(ccx.tcx.sess, span, E0040, "explicit use of destructor method");
struct_span_err!(ccx.tcx.sess, span, E0040, "explicit use of destructor method")
.span_label(span, &format!("call to destructor method"))
.emit();
}
}

Expand Down
18 changes: 16 additions & 2 deletions src/librustc_typeck/check/compare_method.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,33 @@ pub fn compare_impl_method<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
(&ty::ExplicitSelfCategory::Static,
&ty::ExplicitSelfCategory::Static) => {}
(&ty::ExplicitSelfCategory::Static, _) => {
span_err!(tcx.sess, impl_m_span, E0185,
let mut err = struct_span_err!(tcx.sess, impl_m_span, E0185,
"method `{}` has a `{}` declaration in the impl, \
but not in the trait",
trait_m.name,
impl_m.explicit_self);
err.span_label(impl_m_span, &format!("`{}` used in impl",
impl_m.explicit_self));
if let Some(span) = tcx.map.span_if_local(trait_m.def_id) {
err.span_label(span, &format!("trait declared without `{}`",
impl_m.explicit_self));
}
err.emit();
return;
}
(_, &ty::ExplicitSelfCategory::Static) => {
span_err!(tcx.sess, impl_m_span, E0186,
let mut err = struct_span_err!(tcx.sess, impl_m_span, E0186,
"method `{}` has a `{}` declaration in the trait, \
but not in the impl",
trait_m.name,
trait_m.explicit_self);
err.span_label(impl_m_span, &format!("expected `{}` in impl",
trait_m.explicit_self));
if let Some(span) = tcx.map.span_if_local(trait_m.def_id) {
err.span_label(span, & format!("`{}` used in trait",
trait_m.explicit_self));
}
err.emit();
return;
}
_ => {
Expand Down
7 changes: 6 additions & 1 deletion src/librustc_typeck/check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1136,11 +1136,16 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
}

if !missing_items.is_empty() {
span_err!(tcx.sess, impl_span, E0046,
struct_span_err!(tcx.sess, impl_span, E0046,
"not all trait items implemented, missing: `{}`",
missing_items.iter()
.map(|name| name.to_string())
.collect::<Vec<_>>().join("`, `"))
.span_label(impl_span, &format!("missing `{}` in implementation",
missing_items.iter()
.map(|name| name.to_string())
.collect::<Vec<_>>().join("`, `"))
).emit();
}

if !invalidated_items.is_empty() {
Expand Down
14 changes: 10 additions & 4 deletions src/librustc_typeck/check/writeback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -441,13 +441,19 @@ impl<'cx, 'gcx, 'tcx> Resolver<'cx, 'gcx, 'tcx> {
if !self.tcx.sess.has_errors() {
match self.reason {
ResolvingExpr(span) => {
span_err!(self.tcx.sess, span, E0101,
"cannot determine a type for this expression: {}", e);
struct_span_err!(
self.tcx.sess, span, E0101,
"cannot determine a type for this expression: {}", e)
.span_label(span, &format!("cannot resolve type of expression"))
.emit();
}

ResolvingLocal(span) => {
span_err!(self.tcx.sess, span, E0102,
"cannot determine a type for this local variable: {}", e);
struct_span_err!(
self.tcx.sess, span, E0102,
"cannot determine a type for this local variable: {}", e)
.span_label(span, &format!("cannot resolve type of variable"))
.emit();
}

ResolvingPattern(span) => {
Expand Down
21 changes: 13 additions & 8 deletions src/librustc_typeck/coherence/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,18 +311,23 @@ impl<'a, 'gcx, 'tcx> CoherenceChecker<'a, 'gcx, 'tcx> {
match param_env.can_type_implement_copy(tcx, self_type, span) {
Ok(()) => {}
Err(CopyImplementationError::InfrigingField(name)) => {
span_err!(tcx.sess, span, E0204,
"the trait `Copy` may not be \
implemented for this type; field \
`{}` does not implement `Copy`",
name)
struct_span_err!(tcx.sess, span, E0204,
"the trait `Copy` may not be implemented for \
this type")
.span_label(span, &format!(
"field `{}` does not implement `Copy`", name)
)
.emit()

}
Err(CopyImplementationError::InfrigingVariant(name)) => {
span_err!(tcx.sess, span, E0205,
struct_span_err!(tcx.sess, span, E0205,
"the trait `Copy` may not be \
implemented for this type; variant \
implemented for this type")
.span_label(span, &format!("variant \
`{}` does not implement `Copy`",
name)
name))
.emit()
}
Err(CopyImplementationError::NotAnAdt) => {
span_err!(tcx.sess, span, E0206,
Expand Down
30 changes: 17 additions & 13 deletions src/librustc_typeck/coherence/orphan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,12 @@ struct OrphanChecker<'cx, 'tcx:'cx> {
impl<'cx, 'tcx> OrphanChecker<'cx, 'tcx> {
fn check_def_id(&self, item: &hir::Item, def_id: DefId) {
if def_id.krate != LOCAL_CRATE {
span_err!(self.tcx.sess, item.span, E0116,
struct_span_err!(self.tcx.sess, item.span, E0116,
"cannot define inherent `impl` for a type outside of the \
crate where the type is defined; define and implement \
a trait or new type instead");
crate where the type is defined")
.span_label(item.span, &format!("impl for type defined outside of crate."))
.span_note(item.span, &format!("define and implement a trait or new type instead"))
.emit();
}
}

Expand Down Expand Up @@ -66,7 +68,7 @@ impl<'cx, 'tcx> OrphanChecker<'cx, 'tcx> {
fn check_item(&self, item: &hir::Item) {
let def_id = self.tcx.map.local_def_id(item.id);
match item.node {
hir::ItemImpl(_, _, _, None, _, _) => {
hir::ItemImpl(_, _, _, None, ref ty, _) => {
// For inherent impls, self type must be a nominal type
// defined in this crate.
debug!("coherence2::orphan check: inherent impl {}",
Expand Down Expand Up @@ -209,11 +211,11 @@ impl<'cx, 'tcx> OrphanChecker<'cx, 'tcx> {
return;
}
_ => {
struct_span_err!(self.tcx.sess, item.span, E0118,
struct_span_err!(self.tcx.sess, ty.span, E0118,
"no base type found for inherent implementation")
.span_help(item.span,
"either implement a trait on it or create a newtype to wrap it \
instead")
.span_label(ty.span, &format!("impl requires a base type"))
.note(&format!("either implement a trait on it or create a newtype \
to wrap it instead"))
.emit();
return;
}
Expand All @@ -228,12 +230,14 @@ impl<'cx, 'tcx> OrphanChecker<'cx, 'tcx> {
match traits::orphan_check(self.tcx, def_id) {
Ok(()) => { }
Err(traits::OrphanCheckErr::NoLocalInputType) => {
span_err!(
struct_span_err!(
self.tcx.sess, item.span, E0117,
"the impl does not reference any \
types defined in this crate; \
only traits defined in the current crate can be \
implemented for arbitrary types");
"only traits defined in the current crate can be \
implemented for arbitrary types")
.span_label(item.span, &format!("impl doesn't use types inside crate"))
.note(&format!("the impl does not reference any \
types defined in this crate"))
.emit();
return;
}
Err(traits::OrphanCheckErr::UncoveredTy(param_ty)) => {
Expand Down
16 changes: 11 additions & 5 deletions src/librustc_typeck/collect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -367,8 +367,13 @@ impl<'a, 'tcx> AstConv<'tcx, 'tcx> for ItemCtxt<'a, 'tcx> {
_substs: Option<&mut Substs<'tcx>>,
_space: Option<ParamSpace>,
span: Span) -> Ty<'tcx> {
span_err!(self.tcx().sess, span, E0121,
"the type placeholder `_` is not allowed within types on item signatures");
struct_span_err!(
self.tcx().sess,
span,
E0121,
"the type placeholder `_` is not allowed within types on item signatures"
).span_label(span, &format!("not allowed in type signatures"))
.emit();
self.tcx().types.err
}

Expand Down Expand Up @@ -770,9 +775,10 @@ fn convert_item(ccx: &CrateCtxt, it: &hir::Item) {
let mut err = struct_span_err!(tcx.sess, impl_item.span, E0201,
"duplicate definitions with name `{}`:",
impl_item.name);
span_note!(&mut err, *entry.get(),
"previous definition of `{}` here",
impl_item.name);
err.span_label(*entry.get(),
&format!("previous definition of `{}` here",
impl_item.name));
err.span_label(impl_item.span, &format!("duplicate definition"));
err.emit();
}
Vacant(entry) => {
Expand Down
14 changes: 9 additions & 5 deletions src/librustc_typeck/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,11 +211,15 @@ fn check_main_fn_ty(ccx: &CrateCtxt,
match tcx.map.find(main_id) {
Some(hir_map::NodeItem(it)) => {
match it.node {
hir::ItemFn(_, _, _, _, ref ps, _)
if ps.is_parameterized() => {
span_err!(ccx.tcx.sess, main_span, E0131,
"main function is not allowed to have type parameters");
return;
hir::ItemFn(_, _, _, _, ref generics, _) => {
if let Some(gen_span) = generics.span() {
struct_span_err!(ccx.tcx.sess, gen_span, E0131,
"main function is not allowed to have type parameters")
.span_label(gen_span,
&format!("main cannot have type parameters"))
.emit();
return;
}
}
_ => ()
}
Expand Down
9 changes: 9 additions & 0 deletions src/libstd/ffi/c_str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,15 @@ impl NulError {

/// Consumes this error, returning the underlying vector of bytes which
/// generated the error in the first place.
///
/// # Examples
///
/// ```
/// use std::ffi::CString;
///
/// let nul_error = CString::new("foo\0bar").unwrap_err();
/// assert_eq!(nul_error.into_vec(), b"foo\0bar");
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub fn into_vec(self) -> Vec<u8> { self.1 }
}
Expand Down
Loading