From c1383e4dc4bd6598f5d73d2d6b1054f61b2b99d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Fri, 19 Jan 2018 19:57:10 -0800 Subject: [PATCH 1/8] Add filtering options to `rustc_on_unimplemented` - filter error on the evaluated value of `Self` - filter error on the evaluated value of the type arguments - add argument to include custom note in diagnostic - allow the parser to parse `Self` when processing attributes - add custom message to binops --- src/libcore/ops/arith.rs | 115 ++++++++++++++++-- src/libcore/ops/bit.rs | 30 +++-- src/librustc/traits/error_reporting.rs | 32 +++-- src/librustc/traits/on_unimplemented.rs | 34 ++++-- src/libsyntax/parse/attr.rs | 2 +- src/libsyntax/parse/parser.rs | 16 ++- .../anonymous-higher-ranked-lifetime.stderr | 66 ++-------- .../issue-39802-show-5-trait-impls.stderr | 18 +-- .../ui/did_you_mean/recursion_limit.stderr | 6 +- .../ui/feature-gate-abi_unadjusted.stderr | 2 +- src/test/ui/feature-gate-catch_expr.stderr | 2 +- src/test/ui/feature-gate-i128_type2.stderr | 10 +- src/test/ui/feature-gate-intrinsics.stderr | 4 +- .../ui/feature-gate-non_ascii_idents.stderr | 26 ++-- src/test/ui/feature-gate-repr128.stderr | 2 +- .../ui/feature-gate-unboxed-closures.stderr | 2 +- .../ui/feature-gate-untagged_unions.stderr | 6 +- src/test/ui/fmt/send-sync.stderr | 12 +- src/test/ui/generator/not-send-sync.stderr | 6 +- src/test/ui/impl-trait/auto-trait-leak.stderr | 12 +- src/test/ui/impl-trait/equality.stderr | 2 +- src/test/ui/issue-24424.stderr | 6 +- src/test/ui/lint/suggestions.stderr | 32 ++--- src/test/ui/lint/use_suggestion_json.stderr | 67 +--------- src/test/ui/macros/format-foreign.stderr | 10 +- .../ui/macros/format-unused-lables.stderr | 52 ++++---- src/test/ui/mismatched_types/E0631.stderr | 24 +--- src/test/ui/mismatched_types/binops.stderr | 8 +- .../mismatched_types/closure-arg-count.stderr | 6 +- .../closure-arg-type-mismatch.stderr | 12 +- .../mismatched_types/closure-mismatch.stderr | 12 +- .../ui/mismatched_types/fn-variance-1.stderr | 12 +- .../unboxed-closures-vtable-mismatch.stderr | 13 +- .../ui/on-unimplemented/multiple-impls.stderr | 18 +-- src/test/ui/on-unimplemented/on-impl.stderr | 6 +- src/test/ui/on-unimplemented/on-trait.stderr | 12 +- src/test/ui/span/issue-29595.stderr | 6 +- src/test/ui/span/multiline-span-simple.stderr | 2 +- .../suggestions/try-operator-on-main.stderr | 6 +- src/test/ui/type-check/issue-40294.stderr | 6 +- 40 files changed, 312 insertions(+), 403 deletions(-) diff --git a/src/libcore/ops/arith.rs b/src/libcore/ops/arith.rs index 8b3d662a6db77..59a18d6cb75ed 100644 --- a/src/libcore/ops/arith.rs +++ b/src/libcore/ops/arith.rs @@ -75,7 +75,93 @@ /// ``` #[lang = "add"] #[stable(feature = "rust1", since = "1.0.0")] -#[rustc_on_unimplemented = "no implementation for `{Self} + {RHS}`"] +#[rustc_on_unimplemented( + on( + any( + all(_Self="i128", RHS="i64"), + all(_Self="i128", RHS="i32"), + all(_Self="i128", RHS="i16"), + all(_Self="i128", RHS="i8"), + all(_Self="i64", RHS="i32"), + all(_Self="i64", RHS="i16"), + all(_Self="i64", RHS="i8"), + all(_Self="i32", RHS="i16"), + all(_Self="i32", RHS="i8"), + all(_Self="i16", RHS="i8"), + all(_Self="u128", RHS="u64"), + all(_Self="u128", RHS="u32"), + all(_Self="u128", RHS="u16"), + all(_Self="u128", RHS="u8"), + all(_Self="u64", RHS="u32"), + all(_Self="u64", RHS="u16"), + all(_Self="u64", RHS="u8"), + all(_Self="u32", RHS="u16"), + all(_Self="u32", RHS="u8"), + all(_Self="u16", RHS="u8"), + all(_Self="f64", RHS="i32"), + all(_Self="f64", RHS="i16"), + all(_Self="f64", RHS="i8"), + all(_Self="f64", RHS="u32"), + all(_Self="f64", RHS="u16"), + all(_Self="f64", RHS="u8"), + all(_Self="f32", RHS="i16"), + all(_Self="f32", RHS="i8"), + all(_Self="f32", RHS="u16"), + all(_Self="f32", RHS="u8"), + ), + message="cannot add `{RHS}` to `{Self}`", + label="no implementation for `{Self} + {RHS}`, but you can safely cast \ + `{RHS}` into `{Self}` using `as {Self}`", + ), + on( + any( + all(RHS="i128", _Self="i64"), + all(RHS="i128", _Self="i32"), + all(RHS="i128", _Self="i16"), + all(RHS="i128", _Self="i8"), + all(RHS="i64", _Self="i32"), + all(RHS="i64", _Self="i16"), + all(RHS="i64", _Self="i8"), + all(RHS="i32", _Self="i16"), + all(RHS="i32", _Self="i8"), + all(RHS="i16", _Self="i8"), + all(RHS="u128", _Self="u64"), + all(RHS="u128", _Self="u32"), + all(RHS="u128", _Self="u16"), + all(RHS="u128", _Self="u8"), + all(RHS="u64", _Self="u32"), + all(RHS="u64", _Self="u16"), + all(RHS="u64", _Self="u8"), + all(RHS="u32", _Self="u16"), + all(RHS="u32", _Self="u8"), + all(RHS="u16", _Self="u8"), + all(RHS="f64", _Self="i32"), + all(RHS="f64", _Self="i16"), + all(RHS="f64", _Self="i8"), + all(RHS="f64", _Self="u32"), + all(RHS="f64", _Self="u16"), + all(RHS="f64", _Self="u8"), + all(RHS="f32", _Self="i16"), + all(RHS="f32", _Self="i8"), + all(RHS="f32", _Self="u16"), + all(RHS="f32", _Self="u8"), + ), + message="cannot add `{RHS}` to `{Self}`", + label="no implementation for `{Self} + {RHS}`, but you can safely turn \ + `{Self}` into `{RHS}` using `as {RHS}`", + ), + on( + all(_Self="{integer}", RHS="{float}"), + message="cannot add a float to an integer", + label="no implementation for `{Self} + {RHS}`", + ), + on( + all(_Self="{float}", RHS="{integer}"), + message="cannot add an integer to a float", + label="no implementation for `{Self} + {RHS}`", + ), + message="cannot add `{RHS}` to `{Self}`", + label="no implementation for `{Self} + {RHS}`")] pub trait Add { /// The resulting type after applying the `+` operator. #[stable(feature = "rust1", since = "1.0.0")] @@ -170,7 +256,8 @@ add_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } /// ``` #[lang = "sub"] #[stable(feature = "rust1", since = "1.0.0")] -#[rustc_on_unimplemented = "no implementation for `{Self} - {RHS}`"] +#[rustc_on_unimplemented(message="cannot substract `{RHS}` from `{Self}`", + label="no implementation for `{Self} - {RHS}`")] pub trait Sub { /// The resulting type after applying the `-` operator. #[stable(feature = "rust1", since = "1.0.0")] @@ -287,7 +374,8 @@ sub_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } /// ``` #[lang = "mul"] #[stable(feature = "rust1", since = "1.0.0")] -#[rustc_on_unimplemented = "no implementation for `{Self} * {RHS}`"] +#[rustc_on_unimplemented(message="cannot multiply `{RHS}` to `{Self}`", + label="no implementation for `{Self} * {RHS}`")] pub trait Mul { /// The resulting type after applying the `*` operator. #[stable(feature = "rust1", since = "1.0.0")] @@ -408,7 +496,8 @@ mul_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } /// ``` #[lang = "div"] #[stable(feature = "rust1", since = "1.0.0")] -#[rustc_on_unimplemented = "no implementation for `{Self} / {RHS}`"] +#[rustc_on_unimplemented(message="cannot divide `{Self}` by `{RHS}`", + label="no implementation for `{Self} / {RHS}`")] pub trait Div { /// The resulting type after applying the `/` operator. #[stable(feature = "rust1", since = "1.0.0")] @@ -490,7 +579,8 @@ div_impl_float! { f32 f64 } /// ``` #[lang = "rem"] #[stable(feature = "rust1", since = "1.0.0")] -#[rustc_on_unimplemented = "no implementation for `{Self} % {RHS}`"] +#[rustc_on_unimplemented(message="cannot mod `{Self}` by `{RHS}`", + label="no implementation for `{Self} % {RHS}`")] pub trait Rem { /// The resulting type after applying the `%` operator. #[stable(feature = "rust1", since = "1.0.0")] @@ -647,7 +737,8 @@ neg_impl_numeric! { isize i8 i16 i32 i64 i128 f32 f64 } /// ``` #[lang = "add_assign"] #[stable(feature = "op_assign_traits", since = "1.8.0")] -#[rustc_on_unimplemented = "no implementation for `{Self} += {Rhs}`"] +#[rustc_on_unimplemented(message="cannot add-assign `{Rhs}` to `{Self}`", + label="no implementation for `{Self} += {Rhs}`")] pub trait AddAssign { /// Performs the `+=` operation. #[stable(feature = "op_assign_traits", since = "1.8.0")] @@ -700,7 +791,8 @@ add_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } /// ``` #[lang = "sub_assign"] #[stable(feature = "op_assign_traits", since = "1.8.0")] -#[rustc_on_unimplemented = "no implementation for `{Self} -= {Rhs}`"] +#[rustc_on_unimplemented(message="cannot substract-assign `{Rhs}` from `{Self}`", + label="no implementation for `{Self} -= {Rhs}`")] pub trait SubAssign { /// Performs the `-=` operation. #[stable(feature = "op_assign_traits", since = "1.8.0")] @@ -744,7 +836,8 @@ sub_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } /// ``` #[lang = "mul_assign"] #[stable(feature = "op_assign_traits", since = "1.8.0")] -#[rustc_on_unimplemented = "no implementation for `{Self} *= {Rhs}`"] +#[rustc_on_unimplemented(message="cannot multiply-assign `{Rhs}` to `{Self}`", + label="no implementation for `{Self} *= {Rhs}`")] pub trait MulAssign { /// Performs the `*=` operation. #[stable(feature = "op_assign_traits", since = "1.8.0")] @@ -788,7 +881,8 @@ mul_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } /// ``` #[lang = "div_assign"] #[stable(feature = "op_assign_traits", since = "1.8.0")] -#[rustc_on_unimplemented = "no implementation for `{Self} /= {Rhs}`"] +#[rustc_on_unimplemented(message="cannot divide-assign `{Self}` by `{Rhs}`", + label="no implementation for `{Self} /= {Rhs}`")] pub trait DivAssign { /// Performs the `/=` operation. #[stable(feature = "op_assign_traits", since = "1.8.0")] @@ -835,7 +929,8 @@ div_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } /// ``` #[lang = "rem_assign"] #[stable(feature = "op_assign_traits", since = "1.8.0")] -#[rustc_on_unimplemented = "no implementation for `{Self} %= {Rhs}`"] +#[rustc_on_unimplemented(message="cannot mod-assign `{Self}` by `{Rhs}``", + label="no implementation for `{Self} %= {Rhs}`")] pub trait RemAssign { /// Performs the `%=` operation. #[stable(feature = "op_assign_traits", since = "1.8.0")] diff --git a/src/libcore/ops/bit.rs b/src/libcore/ops/bit.rs index 7ac5fc4debf14..a0ecd6cf75ce9 100644 --- a/src/libcore/ops/bit.rs +++ b/src/libcore/ops/bit.rs @@ -120,7 +120,8 @@ not_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } /// ``` #[lang = "bitand"] #[stable(feature = "rust1", since = "1.0.0")] -#[rustc_on_unimplemented = "no implementation for `{Self} & {RHS}`"] +#[rustc_on_unimplemented(message="no implementation for `{Self} & {RHS}`", + label="no implementation for `{Self} & {RHS}`")] pub trait BitAnd { /// The resulting type after applying the `&` operator. #[stable(feature = "rust1", since = "1.0.0")] @@ -201,7 +202,8 @@ bitand_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } /// ``` #[lang = "bitor"] #[stable(feature = "rust1", since = "1.0.0")] -#[rustc_on_unimplemented = "no implementation for `{Self} | {RHS}`"] +#[rustc_on_unimplemented(message="no implementation for `{Self} | {RHS}`", + label="no implementation for `{Self} | {RHS}`")] pub trait BitOr { /// The resulting type after applying the `|` operator. #[stable(feature = "rust1", since = "1.0.0")] @@ -285,7 +287,8 @@ bitor_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } /// ``` #[lang = "bitxor"] #[stable(feature = "rust1", since = "1.0.0")] -#[rustc_on_unimplemented = "no implementation for `{Self} ^ {RHS}`"] +#[rustc_on_unimplemented(message="no implementation for `{Self} ^ {RHS}`", + label="no implementation for `{Self} ^ {RHS}`")] pub trait BitXor { /// The resulting type after applying the `^` operator. #[stable(feature = "rust1", since = "1.0.0")] @@ -365,7 +368,8 @@ bitxor_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } /// ``` #[lang = "shl"] #[stable(feature = "rust1", since = "1.0.0")] -#[rustc_on_unimplemented = "no implementation for `{Self} << {RHS}`"] +#[rustc_on_unimplemented(message="no implementation for `{Self} << {RHS}`", + label="no implementation for `{Self} << {RHS}`")] pub trait Shl { /// The resulting type after applying the `<<` operator. #[stable(feature = "rust1", since = "1.0.0")] @@ -466,7 +470,8 @@ shl_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 isize i128 } /// ``` #[lang = "shr"] #[stable(feature = "rust1", since = "1.0.0")] -#[rustc_on_unimplemented = "no implementation for `{Self} >> {RHS}`"] +#[rustc_on_unimplemented(message="no implementation for `{Self} >> {RHS}`", + label="no implementation for `{Self} >> {RHS}`")] pub trait Shr { /// The resulting type after applying the `>>` operator. #[stable(feature = "rust1", since = "1.0.0")] @@ -579,7 +584,8 @@ shr_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize } /// ``` #[lang = "bitand_assign"] #[stable(feature = "op_assign_traits", since = "1.8.0")] -#[rustc_on_unimplemented = "no implementation for `{Self} &= {Rhs}`"] +#[rustc_on_unimplemented(message="no implementation for `{Self} &= {Rhs}`", + label="no implementation for `{Self} &= {Rhs}`")] pub trait BitAndAssign { /// Performs the `&=` operation. #[stable(feature = "op_assign_traits", since = "1.8.0")] @@ -626,7 +632,8 @@ bitand_assign_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } /// ``` #[lang = "bitor_assign"] #[stable(feature = "op_assign_traits", since = "1.8.0")] -#[rustc_on_unimplemented = "no implementation for `{Self} |= {Rhs}`"] +#[rustc_on_unimplemented(message="no implementation for `{Self} |= {Rhs}`", + label="no implementation for `{Self} |= {Rhs}`")] pub trait BitOrAssign { /// Performs the `|=` operation. #[stable(feature = "op_assign_traits", since = "1.8.0")] @@ -673,7 +680,8 @@ bitor_assign_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } /// ``` #[lang = "bitxor_assign"] #[stable(feature = "op_assign_traits", since = "1.8.0")] -#[rustc_on_unimplemented = "no implementation for `{Self} ^= {Rhs}`"] +#[rustc_on_unimplemented(message="no implementation for `{Self} ^= {Rhs}`", + label="no implementation for `{Self} ^= {Rhs}`")] pub trait BitXorAssign { /// Performs the `^=` operation. #[stable(feature = "op_assign_traits", since = "1.8.0")] @@ -718,7 +726,8 @@ bitxor_assign_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } /// ``` #[lang = "shl_assign"] #[stable(feature = "op_assign_traits", since = "1.8.0")] -#[rustc_on_unimplemented = "no implementation for `{Self} <<= {Rhs}`"] +#[rustc_on_unimplemented(message="no implementation for `{Self} <<= {Rhs}`", + label="no implementation for `{Self} <<= {Rhs}`")] pub trait ShlAssign { /// Performs the `<<=` operation. #[stable(feature = "op_assign_traits", since = "1.8.0")] @@ -784,7 +793,8 @@ shl_assign_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize } /// ``` #[lang = "shr_assign"] #[stable(feature = "op_assign_traits", since = "1.8.0")] -#[rustc_on_unimplemented = "no implementation for `{Self} >>= {Rhs}`"] +#[rustc_on_unimplemented(message="no implementation for `{Self} >>= {Rhs}`", + label="no implementation for `{Self} >>= {Rhs}`")] pub trait ShrAssign { /// Performs the `>>=` operation. #[stable(feature = "op_assign_traits", since = "1.8.0")] diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs index d65becb912a3c..f5ff122668558 100644 --- a/src/librustc/traits/error_reporting.rs +++ b/src/librustc/traits/error_reporting.rs @@ -348,7 +348,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { if direct { // this is a "direct", user-specified, rather than derived, // obligation. - flags.push(("direct", None)); + flags.push(("direct".to_string(), None)); } if let ObligationCauseCode::ItemObligation(item) = obligation.cause.code { @@ -359,21 +359,35 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { // Currently I'm leaving it for what I need for `try`. if self.tcx.trait_of_item(item) == Some(trait_ref.def_id) { method = self.tcx.item_name(item); - flags.push(("from_method", None)); - flags.push(("from_method", Some(&*method))); + flags.push(("from_method".to_string(), None)); + flags.push(("from_method".to_string(), Some(method.to_string()))); } } if let Some(k) = obligation.cause.span.compiler_desugaring_kind() { desugaring = k.as_symbol().as_str(); - flags.push(("from_desugaring", None)); - flags.push(("from_desugaring", Some(&*desugaring))); + flags.push(("from_desugaring".to_string(), None)); + flags.push(("from_desugaring".to_string(), Some(desugaring.to_string()))); + } + let generics = self.tcx.generics_of(def_id); + let self_ty = trait_ref.self_ty(); + let self_ty_str = self_ty.to_string(); + // FIXME: remove once `Self` is accepted by the compiler + flags.push(("_Self".to_string(), Some(self_ty_str.clone()))); + flags.push(("Self".to_string(), Some(self_ty_str.clone()))); + + for param in generics.types.iter() { + let name = param.name.as_str().to_string(); + let ty = trait_ref.substs.type_for_def(param); + let ty_str = ty.to_string(); + flags.push((name.clone(), + Some(ty_str.clone()))); } if let Ok(Some(command)) = OnUnimplementedDirective::of_item( self.tcx, trait_ref.def_id, def_id ) { - command.evaluate(self.tcx, trait_ref, &flags) + command.evaluate(self.tcx, trait_ref, &flags[..]) } else { OnUnimplementedNote::empty() } @@ -549,7 +563,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { .map(|t| (format!(" in `{}`", t), format!("within `{}`, ", t))) .unwrap_or((String::new(), String::new())); - let OnUnimplementedNote { message, label } + let OnUnimplementedNote { message, label, note } = self.on_unimplemented_note(trait_ref, obligation); let have_alt_message = message.is_some() || label.is_some(); @@ -578,6 +592,10 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { trait_ref, trait_ref.self_ty())); } + if let Some(ref s) = note { + // If it has a custom "#[rustc_on_unimplemented]" note, let's display it + err.note(s.as_str()); + } self.suggest_borrow_on_unsized_slice(&obligation.cause.code, &mut err); diff --git a/src/librustc/traits/on_unimplemented.rs b/src/librustc/traits/on_unimplemented.rs index 757b078086d9c..a493b7f0bb603 100644 --- a/src/librustc/traits/on_unimplemented.rs +++ b/src/librustc/traits/on_unimplemented.rs @@ -29,16 +29,18 @@ pub struct OnUnimplementedDirective { pub subcommands: Vec, pub message: Option, pub label: Option, + pub note: Option, } pub struct OnUnimplementedNote { pub message: Option, pub label: Option, + pub note: Option, } impl OnUnimplementedNote { pub fn empty() -> Self { - OnUnimplementedNote { message: None, label: None } + OnUnimplementedNote { message: None, label: None, note: None } } } @@ -89,6 +91,7 @@ impl<'a, 'gcx, 'tcx> OnUnimplementedDirective { let mut message = None; let mut label = None; + let mut note = None; let mut subcommands = vec![]; for item in item_iter { if item.check_name("message") && message.is_none() { @@ -103,8 +106,14 @@ impl<'a, 'gcx, 'tcx> OnUnimplementedDirective { tcx, trait_def_id, label_.as_str(), span)?); continue; } + } else if item.check_name("note") && note.is_none() { + if let Some(note_) = item.value_str() { + note = Some(OnUnimplementedFormatString::try_parse( + tcx, trait_def_id, note_.as_str(), span)?); + continue; + } } else if item.check_name("on") && is_root && - message.is_none() && label.is_none() + message.is_none() && label.is_none() && note.is_none() { if let Some(items) = item.meta_item_list() { if let Ok(subcommand) = @@ -128,7 +137,7 @@ impl<'a, 'gcx, 'tcx> OnUnimplementedDirective { if errored { Err(ErrorReported) } else { - Ok(OnUnimplementedDirective { condition, message, label, subcommands }) + Ok(OnUnimplementedDirective { condition, message, label, subcommands, note }) } } @@ -154,7 +163,8 @@ impl<'a, 'gcx, 'tcx> OnUnimplementedDirective { message: None, subcommands: vec![], label: Some(OnUnimplementedFormatString::try_parse( - tcx, trait_def_id, value.as_str(), attr.span)?) + tcx, trait_def_id, value.as_str(), attr.span)?), + note: None, })) } else { return Err(parse_error(tcx, attr.span, @@ -169,20 +179,21 @@ impl<'a, 'gcx, 'tcx> OnUnimplementedDirective { pub fn evaluate(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>, trait_ref: ty::TraitRef<'tcx>, - options: &[(&str, Option<&str>)]) + options: &[(String, Option)]) -> OnUnimplementedNote { let mut message = None; let mut label = None; + let mut note = None; info!("evaluate({:?}, trait_ref={:?}, options={:?})", self, trait_ref, options); for command in self.subcommands.iter().chain(Some(self)).rev() { if let Some(ref condition) = command.condition { if !attr::eval_condition(condition, &tcx.sess.parse_sess, &mut |c| { - options.contains(&(&c.name().as_str(), - match c.value_str().map(|s| s.as_str()) { - Some(ref s) => Some(s), + options.contains(&(c.name().as_str().to_string(), + match c.value_str().map(|s| s.as_str().to_string()) { + Some(s) => Some(s), None => None })) }) { @@ -198,11 +209,16 @@ impl<'a, 'gcx, 'tcx> OnUnimplementedDirective { if let Some(ref label_) = command.label { label = Some(label_.clone()); } + + if let Some(ref note_) = command.note { + note = Some(note_.clone()); + } } OnUnimplementedNote { label: label.map(|l| l.format(tcx, trait_ref)), - message: message.map(|m| m.format(tcx, trait_ref)) + message: message.map(|m| m.format(tcx, trait_ref)), + note: note.map(|n| n.format(tcx, trait_ref)), } } } diff --git a/src/libsyntax/parse/attr.rs b/src/libsyntax/parse/attr.rs index 053746b579dcb..b01f479895b10 100644 --- a/src/libsyntax/parse/attr.rs +++ b/src/libsyntax/parse/attr.rs @@ -235,7 +235,7 @@ impl<'a> Parser<'a> { } let lo = self.span; - let ident = self.parse_ident()?; + let ident = self.parse_ident_attr()?; let node = self.parse_meta_item_kind()?; Ok(ast::MetaItem { name: ident.name, node: node, span: lo.to(self.prev_span) }) } diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index b3c485a85c063..9e8c4d3de2220 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -762,13 +762,19 @@ impl<'a> Parser<'a> { } pub fn parse_ident(&mut self) -> PResult<'a, ast::Ident> { - self.parse_ident_common(true) + self.parse_ident_common(true, false) } - fn parse_ident_common(&mut self, recover: bool) -> PResult<'a, ast::Ident> { + pub fn parse_ident_attr(&mut self) -> PResult<'a, ast::Ident> { + self.parse_ident_common(true, true) + } + + fn parse_ident_common(&mut self, recover: bool, accept_self: bool) -> PResult<'a, ast::Ident> { match self.token { token::Ident(i) => { - if self.token.is_reserved_ident() { + if self.token.is_reserved_ident() + && !(accept_self && i.name == keywords::SelfType.name()) + { let mut err = self.struct_span_err(self.span, &format!("expected identifier, found {}", self.this_token_descr())); @@ -2111,7 +2117,7 @@ impl<'a> Parser<'a> { self.bump(); Ok(Ident::with_empty_ctxt(name)) } else { - self.parse_ident_common(false) + self.parse_ident_common(false, false) } } @@ -2128,7 +2134,7 @@ impl<'a> Parser<'a> { hi = self.prev_span; (fieldname, self.parse_expr()?, false) } else { - let fieldname = self.parse_ident_common(false)?; + let fieldname = self.parse_ident_common(false, false)?; hi = self.prev_span; // Mimic `x: x` for the `x` field shorthand. diff --git a/src/test/ui/anonymous-higher-ranked-lifetime.stderr b/src/test/ui/anonymous-higher-ranked-lifetime.stderr index 4bd3b684b7ba3..e364a4d8b1441 100644 --- a/src/test/ui/anonymous-higher-ranked-lifetime.stderr +++ b/src/test/ui/anonymous-higher-ranked-lifetime.stderr @@ -6,11 +6,7 @@ error[E0631]: type mismatch in closure arguments | | | expected signature of `for<'r, 's> fn(&'r (), &'s ()) -> _` | -note: required by `f1` - --> $DIR/anonymous-higher-ranked-lifetime.rs:26:1 - | -26 | fn f1(_: F) where F: Fn(&(), &()) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: required by `f1` error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:13:5 @@ -20,11 +16,7 @@ error[E0631]: type mismatch in closure arguments | | | expected signature of `for<'a, 'r> fn(&'a (), &'r ()) -> _` | -note: required by `f2` - --> $DIR/anonymous-higher-ranked-lifetime.rs:27:1 - | -27 | fn f2(_: F) where F: for<'a> Fn(&'a (), &()) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: required by `f2` error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:14:5 @@ -34,11 +26,7 @@ error[E0631]: type mismatch in closure arguments | | | expected signature of `for<'r> fn(&(), &'r ()) -> _` | -note: required by `f3` - --> $DIR/anonymous-higher-ranked-lifetime.rs:28:1 - | -28 | fn f3<'a, F>(_: F) where F: Fn(&'a (), &()) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: required by `f3` error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:15:5 @@ -48,11 +36,7 @@ error[E0631]: type mismatch in closure arguments | | | expected signature of `for<'s, 'r> fn(&'s (), &'r ()) -> _` | -note: required by `f4` - --> $DIR/anonymous-higher-ranked-lifetime.rs:29:1 - | -29 | fn f4(_: F) where F: for<'r> Fn(&(), &'r ()) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: required by `f4` error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:16:5 @@ -62,11 +46,7 @@ error[E0631]: type mismatch in closure arguments | | | expected signature of `for<'r> fn(&'r (), &'r ()) -> _` | -note: required by `f5` - --> $DIR/anonymous-higher-ranked-lifetime.rs:30:1 - | -30 | fn f5(_: F) where F: for<'r> Fn(&'r (), &'r ()) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: required by `f5` error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:17:5 @@ -76,11 +56,7 @@ error[E0631]: type mismatch in closure arguments | | | expected signature of `for<'r> fn(&'r (), std::boxed::Box std::ops::Fn(&'s ()) + 'static>) -> _` | -note: required by `g1` - --> $DIR/anonymous-higher-ranked-lifetime.rs:33:1 - | -33 | fn g1(_: F) where F: Fn(&(), Box) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: required by `g1` error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:18:5 @@ -90,11 +66,7 @@ error[E0631]: type mismatch in closure arguments | | | expected signature of `for<'r> fn(&'r (), for<'s> fn(&'s ())) -> _` | -note: required by `g2` - --> $DIR/anonymous-higher-ranked-lifetime.rs:34:1 - | -34 | fn g2(_: F) where F: Fn(&(), fn(&())) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: required by `g2` error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:19:5 @@ -104,11 +76,7 @@ error[E0631]: type mismatch in closure arguments | | | expected signature of `for<'s> fn(&'s (), std::boxed::Box std::ops::Fn(&'r ()) + 'static>) -> _` | -note: required by `g3` - --> $DIR/anonymous-higher-ranked-lifetime.rs:35:1 - | -35 | fn g3(_: F) where F: for<'s> Fn(&'s (), Box) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: required by `g3` error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:20:5 @@ -118,11 +86,7 @@ error[E0631]: type mismatch in closure arguments | | | expected signature of `for<'s> fn(&'s (), for<'r> fn(&'r ())) -> _` | -note: required by `g4` - --> $DIR/anonymous-higher-ranked-lifetime.rs:36:1 - | -36 | fn g4(_: F) where F: Fn(&(), for<'r> fn(&'r ())) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: required by `g4` error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:21:5 @@ -132,11 +96,7 @@ error[E0631]: type mismatch in closure arguments | | | expected signature of `for<'r, 's> fn(&'r (), std::boxed::Box std::ops::Fn(&'t0 ()) + 'static>, &'s (), for<'t0, 't1> fn(&'t0 (), &'t1 ())) -> _` | -note: required by `h1` - --> $DIR/anonymous-higher-ranked-lifetime.rs:39:1 - | -39 | fn h1(_: F) where F: Fn(&(), Box, &(), fn(&(), &())) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: required by `h1` error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:22:5 @@ -146,11 +106,7 @@ error[E0631]: type mismatch in closure arguments | | | expected signature of `for<'r, 't0> fn(&'r (), std::boxed::Box std::ops::Fn(&'s ()) + 'static>, &'t0 (), for<'s, 't1> fn(&'s (), &'t1 ())) -> _` | -note: required by `h2` - --> $DIR/anonymous-higher-ranked-lifetime.rs:40:1 - | -40 | fn h2(_: F) where F: for<'t0> Fn(&(), Box, &'t0 (), fn(&(), &())) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: required by `h2` error: aborting due to 11 previous errors diff --git a/src/test/ui/did_you_mean/issue-39802-show-5-trait-impls.stderr b/src/test/ui/did_you_mean/issue-39802-show-5-trait-impls.stderr index 7ca3e8728fd9c..d5c4add34b526 100644 --- a/src/test/ui/did_you_mean/issue-39802-show-5-trait-impls.stderr +++ b/src/test/ui/did_you_mean/issue-39802-show-5-trait-impls.stderr @@ -10,11 +10,7 @@ error[E0277]: the trait bound `i8: Foo` is not satisfied > > > -note: required by `Foo::bar` - --> $DIR/issue-39802-show-5-trait-impls.rs:12:5 - | -12 | fn bar(&self){} - | ^^^^^^^^^^^^^ + = note: required by `Foo::bar` error[E0277]: the trait bound `u8: Foo` is not satisfied --> $DIR/issue-39802-show-5-trait-impls.rs:35:5 @@ -27,11 +23,7 @@ error[E0277]: the trait bound `u8: Foo` is not satisfied > > > -note: required by `Foo::bar` - --> $DIR/issue-39802-show-5-trait-impls.rs:12:5 - | -12 | fn bar(&self){} - | ^^^^^^^^^^^^^ + = note: required by `Foo::bar` error[E0277]: the trait bound `bool: Foo` is not satisfied --> $DIR/issue-39802-show-5-trait-impls.rs:36:5 @@ -45,11 +37,7 @@ error[E0277]: the trait bound `bool: Foo` is not satisfied > > and 2 others -note: required by `Foo::bar` - --> $DIR/issue-39802-show-5-trait-impls.rs:12:5 - | -12 | fn bar(&self){} - | ^^^^^^^^^^^^^ + = note: required by `Foo::bar` error: aborting due to 3 previous errors diff --git a/src/test/ui/did_you_mean/recursion_limit.stderr b/src/test/ui/did_you_mean/recursion_limit.stderr index 2bc7e9e46e7c5..7fac604ba49d7 100644 --- a/src/test/ui/did_you_mean/recursion_limit.stderr +++ b/src/test/ui/did_you_mean/recursion_limit.stderr @@ -15,11 +15,7 @@ error[E0275]: overflow evaluating the requirement `K: std::marker::Send` = note: required because it appears within the type `C` = note: required because it appears within the type `B` = note: required because it appears within the type `A` -note: required by `is_send` - --> $DIR/recursion_limit.rs:41:1 - | -41 | fn is_send() { } - | ^^^^^^^^^^^^^^^^^^^^ + = note: required by `is_send` error: aborting due to previous error diff --git a/src/test/ui/feature-gate-abi_unadjusted.stderr b/src/test/ui/feature-gate-abi_unadjusted.stderr index b3f7cd218d3e9..3cc43847156a1 100644 --- a/src/test/ui/feature-gate-abi_unadjusted.stderr +++ b/src/test/ui/feature-gate-abi_unadjusted.stderr @@ -1,4 +1,4 @@ -error[E0658]: unadjusted ABI is an implementation detail and perma-unstable +error: unadjusted ABI is an implementation detail and perma-unstable --> $DIR/feature-gate-abi_unadjusted.rs:11:1 | 11 | / extern "unadjusted" fn foo() { diff --git a/src/test/ui/feature-gate-catch_expr.stderr b/src/test/ui/feature-gate-catch_expr.stderr index 4b3bfbbe27ac8..f486373d225c3 100644 --- a/src/test/ui/feature-gate-catch_expr.stderr +++ b/src/test/ui/feature-gate-catch_expr.stderr @@ -1,4 +1,4 @@ -error[E0658]: `catch` expression is experimental (see issue #31436) +error: `catch` expression is experimental (see issue #31436) --> $DIR/feature-gate-catch_expr.rs:12:24 | 12 | let catch_result = do catch { //~ ERROR `catch` expression is experimental diff --git a/src/test/ui/feature-gate-i128_type2.stderr b/src/test/ui/feature-gate-i128_type2.stderr index ee81a26921498..26653a5739b2c 100644 --- a/src/test/ui/feature-gate-i128_type2.stderr +++ b/src/test/ui/feature-gate-i128_type2.stderr @@ -1,4 +1,4 @@ -error[E0658]: 128-bit type is unstable (see issue #35118) +error: 128-bit type is unstable (see issue #35118) --> $DIR/feature-gate-i128_type2.rs:13:15 | 13 | fn test1() -> i128 { //~ ERROR 128-bit type is unstable @@ -6,7 +6,7 @@ error[E0658]: 128-bit type is unstable (see issue #35118) | = help: add #![feature(i128_type)] to the crate attributes to enable -error[E0658]: 128-bit type is unstable (see issue #35118) +error: 128-bit type is unstable (see issue #35118) --> $DIR/feature-gate-i128_type2.rs:17:17 | 17 | fn test1_2() -> u128 { //~ ERROR 128-bit type is unstable @@ -14,7 +14,7 @@ error[E0658]: 128-bit type is unstable (see issue #35118) | = help: add #![feature(i128_type)] to the crate attributes to enable -error[E0658]: 128-bit type is unstable (see issue #35118) +error: 128-bit type is unstable (see issue #35118) --> $DIR/feature-gate-i128_type2.rs:22:12 | 22 | let x: i128 = 0; //~ ERROR 128-bit type is unstable @@ -22,7 +22,7 @@ error[E0658]: 128-bit type is unstable (see issue #35118) | = help: add #![feature(i128_type)] to the crate attributes to enable -error[E0658]: 128-bit type is unstable (see issue #35118) +error: 128-bit type is unstable (see issue #35118) --> $DIR/feature-gate-i128_type2.rs:26:12 | 26 | let x: u128 = 0; //~ ERROR 128-bit type is unstable @@ -32,7 +32,7 @@ error[E0658]: 128-bit type is unstable (see issue #35118) error[E0601]: main function not found -error[E0658]: repr with 128-bit type is unstable (see issue #35118) +error: repr with 128-bit type is unstable (see issue #35118) --> $DIR/feature-gate-i128_type2.rs:30:1 | 30 | / enum A { //~ ERROR 128-bit type is unstable diff --git a/src/test/ui/feature-gate-intrinsics.stderr b/src/test/ui/feature-gate-intrinsics.stderr index 918c749504aea..5382122e30edd 100644 --- a/src/test/ui/feature-gate-intrinsics.stderr +++ b/src/test/ui/feature-gate-intrinsics.stderr @@ -1,4 +1,4 @@ -error[E0658]: intrinsics are subject to change +error: intrinsics are subject to change --> $DIR/feature-gate-intrinsics.rs:11:1 | 11 | / extern "rust-intrinsic" { //~ ERROR intrinsics are subject to change @@ -8,7 +8,7 @@ error[E0658]: intrinsics are subject to change | = help: add #![feature(intrinsics)] to the crate attributes to enable -error[E0658]: intrinsics are subject to change +error: intrinsics are subject to change --> $DIR/feature-gate-intrinsics.rs:15:1 | 15 | / extern "rust-intrinsic" fn baz() { //~ ERROR intrinsics are subject to change diff --git a/src/test/ui/feature-gate-non_ascii_idents.stderr b/src/test/ui/feature-gate-non_ascii_idents.stderr index deb707752b066..90d0b8daee71c 100644 --- a/src/test/ui/feature-gate-non_ascii_idents.stderr +++ b/src/test/ui/feature-gate-non_ascii_idents.stderr @@ -1,4 +1,4 @@ -error[E0658]: non-ascii idents are not fully supported. (see issue #28979) +error: non-ascii idents are not fully supported. (see issue #28979) --> $DIR/feature-gate-non_ascii_idents.rs:11:1 | 11 | extern crate core as bäz; //~ ERROR non-ascii idents @@ -6,7 +6,7 @@ error[E0658]: non-ascii idents are not fully supported. (see issue #28979) | = help: add #![feature(non_ascii_idents)] to the crate attributes to enable -error[E0658]: non-ascii idents are not fully supported. (see issue #28979) +error: non-ascii idents are not fully supported. (see issue #28979) --> $DIR/feature-gate-non_ascii_idents.rs:13:5 | 13 | use föö::bar; //~ ERROR non-ascii idents @@ -14,7 +14,7 @@ error[E0658]: non-ascii idents are not fully supported. (see issue #28979) | = help: add #![feature(non_ascii_idents)] to the crate attributes to enable -error[E0658]: non-ascii idents are not fully supported. (see issue #28979) +error: non-ascii idents are not fully supported. (see issue #28979) --> $DIR/feature-gate-non_ascii_idents.rs:15:1 | 15 | mod föö { //~ ERROR non-ascii idents @@ -22,7 +22,7 @@ error[E0658]: non-ascii idents are not fully supported. (see issue #28979) | = help: add #![feature(non_ascii_idents)] to the crate attributes to enable -error[E0658]: non-ascii idents are not fully supported. (see issue #28979) +error: non-ascii idents are not fully supported. (see issue #28979) --> $DIR/feature-gate-non_ascii_idents.rs:19:1 | 19 | / fn bär( //~ ERROR non-ascii idents @@ -36,7 +36,7 @@ error[E0658]: non-ascii idents are not fully supported. (see issue #28979) | = help: add #![feature(non_ascii_idents)] to the crate attributes to enable -error[E0658]: non-ascii idents are not fully supported. (see issue #28979) +error: non-ascii idents are not fully supported. (see issue #28979) --> $DIR/feature-gate-non_ascii_idents.rs:20:5 | 20 | bäz: isize //~ ERROR non-ascii idents @@ -44,7 +44,7 @@ error[E0658]: non-ascii idents are not fully supported. (see issue #28979) | = help: add #![feature(non_ascii_idents)] to the crate attributes to enable -error[E0658]: non-ascii idents are not fully supported. (see issue #28979) +error: non-ascii idents are not fully supported. (see issue #28979) --> $DIR/feature-gate-non_ascii_idents.rs:22:9 | 22 | let _ö: isize; //~ ERROR non-ascii idents @@ -52,7 +52,7 @@ error[E0658]: non-ascii idents are not fully supported. (see issue #28979) | = help: add #![feature(non_ascii_idents)] to the crate attributes to enable -error[E0658]: non-ascii idents are not fully supported. (see issue #28979) +error: non-ascii idents are not fully supported. (see issue #28979) --> $DIR/feature-gate-non_ascii_idents.rs:25:10 | 25 | (_ä, _) => {} //~ ERROR non-ascii idents @@ -60,7 +60,7 @@ error[E0658]: non-ascii idents are not fully supported. (see issue #28979) | = help: add #![feature(non_ascii_idents)] to the crate attributes to enable -error[E0658]: non-ascii idents are not fully supported. (see issue #28979) +error: non-ascii idents are not fully supported. (see issue #28979) --> $DIR/feature-gate-non_ascii_idents.rs:29:1 | 29 | struct Föö { //~ ERROR non-ascii idents @@ -68,7 +68,7 @@ error[E0658]: non-ascii idents are not fully supported. (see issue #28979) | = help: add #![feature(non_ascii_idents)] to the crate attributes to enable -error[E0658]: non-ascii idents are not fully supported. (see issue #28979) +error: non-ascii idents are not fully supported. (see issue #28979) --> $DIR/feature-gate-non_ascii_idents.rs:30:5 | 30 | föö: isize //~ ERROR non-ascii idents @@ -76,7 +76,7 @@ error[E0658]: non-ascii idents are not fully supported. (see issue #28979) | = help: add #![feature(non_ascii_idents)] to the crate attributes to enable -error[E0658]: non-ascii idents are not fully supported. (see issue #28979) +error: non-ascii idents are not fully supported. (see issue #28979) --> $DIR/feature-gate-non_ascii_idents.rs:33:1 | 33 | enum Bär { //~ ERROR non-ascii idents @@ -84,7 +84,7 @@ error[E0658]: non-ascii idents are not fully supported. (see issue #28979) | = help: add #![feature(non_ascii_idents)] to the crate attributes to enable -error[E0658]: non-ascii idents are not fully supported. (see issue #28979) +error: non-ascii idents are not fully supported. (see issue #28979) --> $DIR/feature-gate-non_ascii_idents.rs:34:5 | 34 | Bäz { //~ ERROR non-ascii idents @@ -92,7 +92,7 @@ error[E0658]: non-ascii idents are not fully supported. (see issue #28979) | = help: add #![feature(non_ascii_idents)] to the crate attributes to enable -error[E0658]: non-ascii idents are not fully supported. (see issue #28979) +error: non-ascii idents are not fully supported. (see issue #28979) --> $DIR/feature-gate-non_ascii_idents.rs:35:9 | 35 | qüx: isize //~ ERROR non-ascii idents @@ -100,7 +100,7 @@ error[E0658]: non-ascii idents are not fully supported. (see issue #28979) | = help: add #![feature(non_ascii_idents)] to the crate attributes to enable -error[E0658]: non-ascii idents are not fully supported. (see issue #28979) +error: non-ascii idents are not fully supported. (see issue #28979) --> $DIR/feature-gate-non_ascii_idents.rs:40:5 | 40 | fn qüx(); //~ ERROR non-ascii idents diff --git a/src/test/ui/feature-gate-repr128.stderr b/src/test/ui/feature-gate-repr128.stderr index 982ebb0101662..c59964887b58f 100644 --- a/src/test/ui/feature-gate-repr128.stderr +++ b/src/test/ui/feature-gate-repr128.stderr @@ -1,4 +1,4 @@ -error[E0658]: repr with 128-bit type is unstable (see issue #35118) +error: repr with 128-bit type is unstable (see issue #35118) --> $DIR/feature-gate-repr128.rs:12:1 | 12 | / enum A { //~ ERROR repr with 128-bit type is unstable diff --git a/src/test/ui/feature-gate-unboxed-closures.stderr b/src/test/ui/feature-gate-unboxed-closures.stderr index ca8a59249463d..b79165147e590 100644 --- a/src/test/ui/feature-gate-unboxed-closures.stderr +++ b/src/test/ui/feature-gate-unboxed-closures.stderr @@ -1,4 +1,4 @@ -error[E0658]: rust-call ABI is subject to change (see issue #29625) +error: rust-call ABI is subject to change (see issue #29625) --> $DIR/feature-gate-unboxed-closures.rs:16:5 | 16 | / extern "rust-call" fn call_once(self, (a, b): (u32, u32)) -> u32 { diff --git a/src/test/ui/feature-gate-untagged_unions.stderr b/src/test/ui/feature-gate-untagged_unions.stderr index 14b66cb5c815a..26b698912bc95 100644 --- a/src/test/ui/feature-gate-untagged_unions.stderr +++ b/src/test/ui/feature-gate-untagged_unions.stderr @@ -1,4 +1,4 @@ -error[E0658]: unions with non-`Copy` fields are unstable (see issue #32836) +error: unions with non-`Copy` fields are unstable (see issue #32836) --> $DIR/feature-gate-untagged_unions.rs:19:1 | 19 | / union U3 { //~ ERROR unions with non-`Copy` fields are unstable @@ -8,7 +8,7 @@ error[E0658]: unions with non-`Copy` fields are unstable (see issue #32836) | = help: add #![feature(untagged_unions)] to the crate attributes to enable -error[E0658]: unions with non-`Copy` fields are unstable (see issue #32836) +error: unions with non-`Copy` fields are unstable (see issue #32836) --> $DIR/feature-gate-untagged_unions.rs:23:1 | 23 | / union U4 { //~ ERROR unions with non-`Copy` fields are unstable @@ -18,7 +18,7 @@ error[E0658]: unions with non-`Copy` fields are unstable (see issue #32836) | = help: add #![feature(untagged_unions)] to the crate attributes to enable -error[E0658]: unions with `Drop` implementations are unstable (see issue #32836) +error: unions with `Drop` implementations are unstable (see issue #32836) --> $DIR/feature-gate-untagged_unions.rs:27:1 | 27 | / union U5 { //~ ERROR unions with `Drop` implementations are unstable diff --git a/src/test/ui/fmt/send-sync.stderr b/src/test/ui/fmt/send-sync.stderr index 4ec5c9ebd2712..9e0e563c35f65 100644 --- a/src/test/ui/fmt/send-sync.stderr +++ b/src/test/ui/fmt/send-sync.stderr @@ -12,11 +12,7 @@ error[E0277]: the trait bound `*mut std::ops::Fn() + 'static: std::marker::Sync` = note: required because it appears within the type `[std::fmt::ArgumentV1<'_>]` = note: required because of the requirements on the impl of `std::marker::Send` for `&[std::fmt::ArgumentV1<'_>]` = note: required because it appears within the type `std::fmt::Arguments<'_>` -note: required by `send` - --> $DIR/send-sync.rs:11:1 - | -11 | fn send(_: T) {} - | ^^^^^^^^^^^^^^^^^^^^^^ + = note: required by `send` error[E0277]: the trait bound `*mut std::ops::Fn() + 'static: std::marker::Sync` is not satisfied in `std::fmt::Arguments<'_>` --> $DIR/send-sync.rs:19:5 @@ -32,11 +28,7 @@ error[E0277]: the trait bound `*mut std::ops::Fn() + 'static: std::marker::Sync` = note: required because it appears within the type `[std::fmt::ArgumentV1<'_>]` = note: required because it appears within the type `&[std::fmt::ArgumentV1<'_>]` = note: required because it appears within the type `std::fmt::Arguments<'_>` -note: required by `sync` - --> $DIR/send-sync.rs:12:1 - | -12 | fn sync(_: T) {} - | ^^^^^^^^^^^^^^^^^^^^^^ + = note: required by `sync` error: aborting due to 2 previous errors diff --git a/src/test/ui/generator/not-send-sync.stderr b/src/test/ui/generator/not-send-sync.stderr index e65c8f1546e82..fd8f3b8e6463d 100644 --- a/src/test/ui/generator/not-send-sync.stderr +++ b/src/test/ui/generator/not-send-sync.stderr @@ -7,11 +7,7 @@ error[E0277]: the trait bound `std::cell::Cell: std::marker::Sync` is not s = help: the trait `std::marker::Sync` is not implemented for `std::cell::Cell` = note: required because of the requirements on the impl of `std::marker::Send` for `&std::cell::Cell` = note: required because it appears within the type `[generator@$DIR/not-send-sync.rs:26:17: 30:6 a:&std::cell::Cell _]` -note: required by `main::assert_send` - --> $DIR/not-send-sync.rs:17:5 - | -17 | fn assert_send(_: T) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: required by `main::assert_send` error[E0277]: the trait bound `std::cell::Cell: std::marker::Sync` is not satisfied in `[generator@$DIR/not-send-sync.rs:19:17: 23:6 {std::cell::Cell, ()}]` --> $DIR/not-send-sync.rs:19:5 diff --git a/src/test/ui/impl-trait/auto-trait-leak.stderr b/src/test/ui/impl-trait/auto-trait-leak.stderr index 838a3002e3aa7..ffd6a3fe4ffb1 100644 --- a/src/test/ui/impl-trait/auto-trait-leak.stderr +++ b/src/test/ui/impl-trait/auto-trait-leak.stderr @@ -7,11 +7,7 @@ error[E0277]: the trait bound `std::rc::Rc>: std::marker::S = help: within `impl std::ops::Fn<(i32,)>`, the trait `std::marker::Send` is not implemented for `std::rc::Rc>` = note: required because it appears within the type `[closure@$DIR/auto-trait-leak.rs:21:5: 21:22 p:std::rc::Rc>]` = note: required because it appears within the type `impl std::ops::Fn<(i32,)>` -note: required by `send` - --> $DIR/auto-trait-leak.rs:24:1 - | -24 | fn send(_: T) {} - | ^^^^^^^^^^^^^^^^^^^^^^ + = note: required by `send` error[E0277]: the trait bound `std::rc::Rc>: std::marker::Send` is not satisfied in `impl std::ops::Fn<(i32,)>` --> $DIR/auto-trait-leak.rs:30:5 @@ -22,11 +18,7 @@ error[E0277]: the trait bound `std::rc::Rc>: std::marker::S = help: within `impl std::ops::Fn<(i32,)>`, the trait `std::marker::Send` is not implemented for `std::rc::Rc>` = note: required because it appears within the type `[closure@$DIR/auto-trait-leak.rs:38:5: 38:22 p:std::rc::Rc>]` = note: required because it appears within the type `impl std::ops::Fn<(i32,)>` -note: required by `send` - --> $DIR/auto-trait-leak.rs:24:1 - | -24 | fn send(_: T) {} - | ^^^^^^^^^^^^^^^^^^^^^^ + = note: required by `send` error[E0391]: unsupported cyclic reference between types/traits detected --> $DIR/auto-trait-leak.rs:44:1 diff --git a/src/test/ui/impl-trait/equality.stderr b/src/test/ui/impl-trait/equality.stderr index 3fc08a0900fb9..8ec819038031b 100644 --- a/src/test/ui/impl-trait/equality.stderr +++ b/src/test/ui/impl-trait/equality.stderr @@ -7,7 +7,7 @@ error[E0308]: mismatched types = note: expected type `i32` found type `u32` -error[E0277]: the trait bound `u32: std::ops::Add` is not satisfied +error[E0277]: cannot add `impl Foo` to `u32` --> $DIR/equality.rs:34:11 | 34 | n + sum_to(n - 1) diff --git a/src/test/ui/issue-24424.stderr b/src/test/ui/issue-24424.stderr index 55af26dd91ea3..acdf348791b20 100644 --- a/src/test/ui/issue-24424.stderr +++ b/src/test/ui/issue-24424.stderr @@ -4,11 +4,7 @@ error[E0283]: type annotations required: cannot resolve `T0: Trait0<'l0>` 14 | impl <'l0, 'l1, T0> Trait1<'l0, T0> for bool where T0 : Trait0<'l0>, T0 : Trait0<'l1> {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | -note: required by `Trait0` - --> $DIR/issue-24424.rs:12:1 - | -12 | trait Trait0<'l0> {} - | ^^^^^^^^^^^^^^^^^ + = note: required by `Trait0` error: aborting due to previous error diff --git a/src/test/ui/lint/suggestions.stderr b/src/test/ui/lint/suggestions.stderr index 8b30f552d3771..701a95222183a 100644 --- a/src/test/ui/lint/suggestions.stderr +++ b/src/test/ui/lint/suggestions.stderr @@ -1,7 +1,7 @@ warning: unnecessary parentheses around assigned value - --> $DIR/suggestions.rs:46:21 + --> $DIR/suggestions.rs:36:21 | -46 | let mut a = (1); // should suggest no `mut`, no parens +36 | let mut a = (1); // should suggest no `mut`, no parens | ^^^ help: remove these parentheses | note: lint level defined here @@ -11,17 +11,17 @@ note: lint level defined here | ^^^^^^^^^^^^^ warning: use of deprecated attribute `no_debug`: the `#[no_debug]` attribute was an experimental feature that has been deprecated due to lack of demand. See https://github.com/rust-lang/rust/issues/29721 - --> $DIR/suggestions.rs:41:1 + --> $DIR/suggestions.rs:31:1 | -41 | #[no_debug] // should suggest removal of deprecated attribute +31 | #[no_debug] // should suggest removal of deprecated attribute | ^^^^^^^^^^^ help: remove this attribute | = note: #[warn(deprecated)] on by default warning: variable does not need to be mutable - --> $DIR/suggestions.rs:46:13 + --> $DIR/suggestions.rs:36:13 | -46 | let mut a = (1); // should suggest no `mut`, no parens +36 | let mut a = (1); // should suggest no `mut`, no parens | ---^^ | | | help: remove this `mut` @@ -72,30 +72,18 @@ warning: function is marked #[no_mangle], but not exported | = note: #[warn(private_no_mangle_fns)] on by default -warning: static is marked #[no_mangle], but not exported - --> $DIR/suggestions.rs:31:18 - | -31 | #[no_mangle] pub static DAUNTLESS: bool = true; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -warning: function is marked #[no_mangle], but not exported - --> $DIR/suggestions.rs:33:18 - | -33 | #[no_mangle] pub fn val_jean() {} - | ^^^^^^^^^^^^^^^^^^^^ - warning: denote infinite loops with `loop { ... }` - --> $DIR/suggestions.rs:44:5 + --> $DIR/suggestions.rs:34:5 | -44 | while true { // should suggest `loop` +34 | while true { // should suggest `loop` | ^^^^^^^^^^ help: use `loop` | = note: #[warn(while_true)] on by default warning: the `warp_factor:` in this pattern is redundant - --> $DIR/suggestions.rs:51:23 + --> $DIR/suggestions.rs:41:23 | -51 | Equinox { warp_factor: warp_factor } => {} // should suggest shorthand +41 | Equinox { warp_factor: warp_factor } => {} // should suggest shorthand | ------------^^^^^^^^^^^^ | | | help: remove this diff --git a/src/test/ui/lint/use_suggestion_json.stderr b/src/test/ui/lint/use_suggestion_json.stderr index 86c2ad4c0e7a4..abbf3da513a6f 100644 --- a/src/test/ui/lint/use_suggestion_json.stderr +++ b/src/test/ui/lint/use_suggestion_json.stderr @@ -2,72 +2,7 @@ "message": "cannot find type `Iter` in this scope", "code": { "code": "E0412", - "explanation": " -The type name used is not in scope. - -Erroneous code examples: - -```compile_fail,E0412 -impl Something {} // error: type name `Something` is not in scope - -// or: - -trait Foo { - fn bar(N); // error: type name `N` is not in scope -} - -// or: - -fn foo(x: T) {} // type name `T` is not in scope -``` - -To fix this error, please verify you didn't misspell the type name, you did -declare it or imported it into the scope. Examples: - -``` -struct Something; - -impl Something {} // ok! - -// or: - -trait Foo { - type N; - - fn bar(_: Self::N); // ok! -} - -// or: - -fn foo(x: T) {} // ok! -``` - -Another case that causes this error is when a type is imported into a parent -module. To fix this, you can follow the suggestion and use File directly or -`use super::File;` which will import the types from the parent namespace. An -example that causes this error is below: - -```compile_fail,E0412 -use std::fs::File; - -mod foo { - fn some_function(f: File) {} -} -``` - -``` -use std::fs::File; - -mod foo { - // either - use super::File; - // or - // use std::fs::File; - fn foo(f: File) {} -} -# fn main() {} // don't insert it for us; that'll break imports -``` -" + "explanation": null }, "level": "error", "spans": [ diff --git a/src/test/ui/macros/format-foreign.stderr b/src/test/ui/macros/format-foreign.stderr index f9852c5477332..d0229957b682e 100644 --- a/src/test/ui/macros/format-foreign.stderr +++ b/src/test/ui/macros/format-foreign.stderr @@ -1,8 +1,12 @@ error: multiple unused formatting arguments - --> $DIR/format-foreign.rs:12:30 + --> $DIR/format-foreign.rs:12:5 | -12 | println!("%.*3$s %s!/n", "Hello,", "World", 4); //~ ERROR multiple unused formatting arguments - | -------------------------^^^^^^^^--^^^^^^^--^-- multiple unused arguments in this statement +12 | println!("%.*3$s %s!/n", "Hello,", "World", 4); + | ^^^^^^^^^^^^^^^^^^^^^^^^^--------^^-------^^-^^ + | | | | + | | | unused + | | unused + | unused | = help: `%.*3$s` should be written as `{:.2$}` = help: `%s` should be written as `{}` diff --git a/src/test/ui/macros/format-unused-lables.stderr b/src/test/ui/macros/format-unused-lables.stderr index 64ea5626c1d62..9efdca12dea03 100644 --- a/src/test/ui/macros/format-unused-lables.stderr +++ b/src/test/ui/macros/format-unused-lables.stderr @@ -1,43 +1,49 @@ error: multiple unused formatting arguments - --> $DIR/format-unused-lables.rs:12:22 + --> $DIR/format-unused-lables.rs:12:5 | 12 | println!("Test", 123, 456, 789); - | -----------------^^^--^^^--^^^-- multiple unused arguments in this statement + | ^^^^^^^^^^^^^^^^^---^^---^^---^^ + | | | | + | | | unused + | | unused + | unused | = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) error: multiple unused formatting arguments - --> $DIR/format-unused-lables.rs:16:9 + --> $DIR/format-unused-lables.rs:14:5 | -15 | / println!("Test2", -16 | | 123, //~ ERROR multiple unused formatting arguments - | | ^^^ -17 | | 456, - | | ^^^ -18 | | 789 - | | ^^^ -19 | | ); - | |______- multiple unused arguments in this statement +14 | / println!("Test2", +15 | | 123, + | | --- unused +16 | | 456, + | | --- unused +17 | | 789 + | | --- unused +18 | | ); + | |______^ | = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) error: named argument never used - --> $DIR/format-unused-lables.rs:21:35 + --> $DIR/format-unused-lables.rs:20:35 | -21 | println!("Some stuff", UNUSED="args"); //~ ERROR named argument never used +20 | println!("Some stuff", UNUSED="args"); //~ ERROR named argument never used | ^^^^^^ error: multiple unused formatting arguments - --> $DIR/format-unused-lables.rs:24:9 + --> $DIR/format-unused-lables.rs:22:5 | -23 | / println!("Some more $STUFF", -24 | | "woo!", //~ ERROR multiple unused formatting arguments - | | ^^^^^^ -25 | | STUFF= -26 | | "things" - | | ^^^^^^^^ -27 | | , UNUSED="args"); - | |_______________________^^^^^^_- multiple unused arguments in this statement +22 | / println!("Some more $STUFF", +23 | | "woo!", + | | ------ unused +24 | | STUFF= +25 | | "things" + | | -------- unused +26 | | , UNUSED="args"); + | |_______________________------_^ + | | + | unused | = help: `$STUFF` should be written as `{STUFF}` = note: shell formatting not supported; see the documentation for `std::fmt` diff --git a/src/test/ui/mismatched_types/E0631.stderr b/src/test/ui/mismatched_types/E0631.stderr index 53f2f54325d57..442900e0a836a 100644 --- a/src/test/ui/mismatched_types/E0631.stderr +++ b/src/test/ui/mismatched_types/E0631.stderr @@ -6,11 +6,7 @@ error[E0631]: type mismatch in closure arguments | | | expected signature of `fn(usize) -> _` | -note: required by `foo` - --> $DIR/E0631.rs:13:1 - | -13 | fn foo(_: F) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: required by `foo` error[E0631]: type mismatch in closure arguments --> $DIR/E0631.rs:18:5 @@ -20,11 +16,7 @@ error[E0631]: type mismatch in closure arguments | | | expected signature of `fn(usize) -> _` | -note: required by `bar` - --> $DIR/E0631.rs:14:1 - | -14 | fn bar>(_: F) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: required by `bar` error[E0631]: type mismatch in function arguments --> $DIR/E0631.rs:19:5 @@ -35,11 +27,7 @@ error[E0631]: type mismatch in function arguments 19 | foo(f); //~ ERROR type mismatch | ^^^ expected signature of `fn(usize) -> _` | -note: required by `foo` - --> $DIR/E0631.rs:13:1 - | -13 | fn foo(_: F) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: required by `foo` error[E0631]: type mismatch in function arguments --> $DIR/E0631.rs:20:5 @@ -50,11 +38,7 @@ error[E0631]: type mismatch in function arguments 20 | bar(f); //~ ERROR type mismatch | ^^^ expected signature of `fn(usize) -> _` | -note: required by `bar` - --> $DIR/E0631.rs:14:1 - | -14 | fn bar>(_: F) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: required by `bar` error: aborting due to 4 previous errors diff --git a/src/test/ui/mismatched_types/binops.stderr b/src/test/ui/mismatched_types/binops.stderr index 8541ad52e0177..57e66794a58a9 100644 --- a/src/test/ui/mismatched_types/binops.stderr +++ b/src/test/ui/mismatched_types/binops.stderr @@ -1,4 +1,4 @@ -error[E0277]: the trait bound `{integer}: std::ops::Add>` is not satisfied +error[E0277]: cannot add `std::option::Option<{integer}>` to `{integer}` --> $DIR/binops.rs:12:7 | 12 | 1 + Some(1); //~ ERROR is not satisfied @@ -6,7 +6,7 @@ error[E0277]: the trait bound `{integer}: std::ops::Add>` is not implemented for `{integer}` -error[E0277]: the trait bound `usize: std::ops::Sub>` is not satisfied +error[E0277]: cannot substract `std::option::Option<{integer}>` from `usize` --> $DIR/binops.rs:13:16 | 13 | 2 as usize - Some(1); //~ ERROR is not satisfied @@ -14,7 +14,7 @@ error[E0277]: the trait bound `usize: std::ops::Sub>` is not implemented for `usize` -error[E0277]: the trait bound `{integer}: std::ops::Mul<()>` is not satisfied +error[E0277]: cannot multiply `()` to `{integer}` --> $DIR/binops.rs:14:7 | 14 | 3 * (); //~ ERROR is not satisfied @@ -22,7 +22,7 @@ error[E0277]: the trait bound `{integer}: std::ops::Mul<()>` is not satisfied | = help: the trait `std::ops::Mul<()>` is not implemented for `{integer}` -error[E0277]: the trait bound `{integer}: std::ops::Div<&str>` is not satisfied +error[E0277]: cannot divide `{integer}` by `&str` --> $DIR/binops.rs:15:7 | 15 | 4 / ""; //~ ERROR is not satisfied diff --git a/src/test/ui/mismatched_types/closure-arg-count.stderr b/src/test/ui/mismatched_types/closure-arg-count.stderr index be00ee4d74e7e..d904831ba4e32 100644 --- a/src/test/ui/mismatched_types/closure-arg-count.stderr +++ b/src/test/ui/mismatched_types/closure-arg-count.stderr @@ -46,11 +46,7 @@ error[E0593]: closure is expected to take 1 argument, but it takes 0 arguments | | | expected closure that takes 1 argument | -note: required by `f` - --> $DIR/closure-arg-count.rs:13:1 - | -13 | fn f>(_: F) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^ + = note: required by `f` error[E0593]: closure is expected to take a single 2-tuple as argument, but it takes 2 distinct arguments --> $DIR/closure-arg-count.rs:26:53 diff --git a/src/test/ui/mismatched_types/closure-arg-type-mismatch.stderr b/src/test/ui/mismatched_types/closure-arg-type-mismatch.stderr index dfd02fe23b686..77d3a33276737 100644 --- a/src/test/ui/mismatched_types/closure-arg-type-mismatch.stderr +++ b/src/test/ui/mismatched_types/closure-arg-type-mismatch.stderr @@ -31,11 +31,7 @@ error[E0631]: type mismatch in function arguments | expected signature of `for<'r> fn(*mut &'r u32) -> _` | found signature of `fn(*mut &'a u32) -> _` | -note: required by `baz` - --> $DIR/closure-arg-type-mismatch.rs:18:1 - | -18 | fn baz(_: F) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: required by `baz` error[E0271]: type mismatch resolving `for<'r> >::Output == ()` --> $DIR/closure-arg-type-mismatch.rs:20:5 @@ -43,11 +39,7 @@ error[E0271]: type mismatch resolving `for<'r> $DIR/closure-arg-type-mismatch.rs:18:1 - | -18 | fn baz(_: F) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: required by `baz` error: aborting due to 5 previous errors diff --git a/src/test/ui/mismatched_types/closure-mismatch.stderr b/src/test/ui/mismatched_types/closure-mismatch.stderr index 01de7e0749500..99767ba1afaef 100644 --- a/src/test/ui/mismatched_types/closure-mismatch.stderr +++ b/src/test/ui/mismatched_types/closure-mismatch.stderr @@ -5,11 +5,7 @@ error[E0271]: type mismatch resolving `for<'r> <[closure@$DIR/closure-mismatch.r | ^^^ expected bound lifetime parameter, found concrete lifetime | = note: required because of the requirements on the impl of `Foo` for `[closure@$DIR/closure-mismatch.rs:18:9: 18:15]` -note: required by `baz` - --> $DIR/closure-mismatch.rs:15:1 - | -15 | fn baz(_: T) {} - | ^^^^^^^^^^^^^^^^^^^^ + = note: required by `baz` error[E0631]: type mismatch in closure arguments --> $DIR/closure-mismatch.rs:18:5 @@ -20,11 +16,7 @@ error[E0631]: type mismatch in closure arguments | expected signature of `for<'r> fn(&'r ()) -> _` | = note: required because of the requirements on the impl of `Foo` for `[closure@$DIR/closure-mismatch.rs:18:9: 18:15]` -note: required by `baz` - --> $DIR/closure-mismatch.rs:15:1 - | -15 | fn baz(_: T) {} - | ^^^^^^^^^^^^^^^^^^^^ + = note: required by `baz` error: aborting due to 2 previous errors diff --git a/src/test/ui/mismatched_types/fn-variance-1.stderr b/src/test/ui/mismatched_types/fn-variance-1.stderr index 64c260c30ed49..2a27ffd106247 100644 --- a/src/test/ui/mismatched_types/fn-variance-1.stderr +++ b/src/test/ui/mismatched_types/fn-variance-1.stderr @@ -7,11 +7,7 @@ error[E0631]: type mismatch in function arguments 21 | apply(&3, takes_mut); | ^^^^^ expected signature of `fn(&{integer}) -> _` | -note: required by `apply` - --> $DIR/fn-variance-1.rs:15:1 - | -15 | fn apply(t: T, f: F) where F: FnOnce(T) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: required by `apply` error[E0631]: type mismatch in function arguments --> $DIR/fn-variance-1.rs:25:5 @@ -22,11 +18,7 @@ error[E0631]: type mismatch in function arguments 25 | apply(&mut 3, takes_imm); | ^^^^^ expected signature of `fn(&mut {integer}) -> _` | -note: required by `apply` - --> $DIR/fn-variance-1.rs:15:1 - | -15 | fn apply(t: T, f: F) where F: FnOnce(T) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: required by `apply` error: aborting due to 2 previous errors diff --git a/src/test/ui/mismatched_types/unboxed-closures-vtable-mismatch.stderr b/src/test/ui/mismatched_types/unboxed-closures-vtable-mismatch.stderr index 9c9bbd19c7552..8539c8818c025 100644 --- a/src/test/ui/mismatched_types/unboxed-closures-vtable-mismatch.stderr +++ b/src/test/ui/mismatched_types/unboxed-closures-vtable-mismatch.stderr @@ -1,17 +1,12 @@ error[E0631]: type mismatch in closure arguments - --> $DIR/unboxed-closures-vtable-mismatch.rs:25:13 + --> $DIR/unboxed-closures-vtable-mismatch.rs:23:13 | -23 | let f = to_fn_mut(|x: usize, y: isize| -> isize { (x as isize) + y }); +22 | let f = to_fn_mut(|x: usize, y: isize| -> isize { (x as isize) + y }); | ----------------------------- found signature of `fn(usize, isize) -> _` -24 | //~^ NOTE found signature of `fn(usize, isize) -> _` -25 | let z = call_it(3, f); +23 | let z = call_it(3, f); | ^^^^^^^ expected signature of `fn(isize, isize) -> _` | -note: required by `call_it` - --> $DIR/unboxed-closures-vtable-mismatch.rs:17:1 - | -17 | fn call_itisize>(y: isize, mut f: F) -> isize { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: required by `call_it` error: aborting due to previous error diff --git a/src/test/ui/on-unimplemented/multiple-impls.stderr b/src/test/ui/on-unimplemented/multiple-impls.stderr index cfac3981be284..1f71be446efb5 100644 --- a/src/test/ui/on-unimplemented/multiple-impls.stderr +++ b/src/test/ui/on-unimplemented/multiple-impls.stderr @@ -5,11 +5,7 @@ error[E0277]: the trait bound `[i32]: Index` is not satisfied | ^^^^^^^^^^^^ trait message | = help: the trait `Index` is not implemented for `[i32]` -note: required by `Index::index` - --> $DIR/multiple-impls.rs:22:5 - | -22 | fn index(&self, index: Idx) -> &Self::Output; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: required by `Index::index` error[E0277]: the trait bound `[i32]: Index` is not satisfied --> $DIR/multiple-impls.rs:43:5 @@ -26,11 +22,7 @@ error[E0277]: the trait bound `[i32]: Index>` is not satisfied | ^^^^^^^^^^^^ on impl for Foo | = help: the trait `Index>` is not implemented for `[i32]` -note: required by `Index::index` - --> $DIR/multiple-impls.rs:22:5 - | -22 | fn index(&self, index: Idx) -> &Self::Output; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: required by `Index::index` error[E0277]: the trait bound `[i32]: Index>` is not satisfied --> $DIR/multiple-impls.rs:46:5 @@ -47,11 +39,7 @@ error[E0277]: the trait bound `[i32]: Index>` is not satisfied | ^^^^^^^^^^^^ on impl for Bar | = help: the trait `Index>` is not implemented for `[i32]` -note: required by `Index::index` - --> $DIR/multiple-impls.rs:22:5 - | -22 | fn index(&self, index: Idx) -> &Self::Output; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: required by `Index::index` error[E0277]: the trait bound `[i32]: Index>` is not satisfied --> $DIR/multiple-impls.rs:49:5 diff --git a/src/test/ui/on-unimplemented/on-impl.stderr b/src/test/ui/on-unimplemented/on-impl.stderr index ed2da68f08167..c8c06bf44fd6f 100644 --- a/src/test/ui/on-unimplemented/on-impl.stderr +++ b/src/test/ui/on-unimplemented/on-impl.stderr @@ -5,11 +5,7 @@ error[E0277]: the trait bound `[i32]: Index` is not satisfied | ^^^^^^^^^^^^^^^^^^^ a usize is required to index into a slice | = help: the trait `Index` is not implemented for `[i32]` -note: required by `Index::index` - --> $DIR/on-impl.rs:19:5 - | -19 | fn index(&self, index: Idx) -> &Self::Output; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: required by `Index::index` error[E0277]: the trait bound `[i32]: Index` is not satisfied --> $DIR/on-impl.rs:32:5 diff --git a/src/test/ui/on-unimplemented/on-trait.stderr b/src/test/ui/on-unimplemented/on-trait.stderr index 028200a5558c8..cde56022faea2 100644 --- a/src/test/ui/on-unimplemented/on-trait.stderr +++ b/src/test/ui/on-unimplemented/on-trait.stderr @@ -5,11 +5,7 @@ error[E0277]: the trait bound `std::option::Option>: MyFromIte | ^^^^^^^ a collection of type `std::option::Option>` cannot be built from an iterator over elements of type `&u8` | = help: the trait `MyFromIterator<&u8>` is not implemented for `std::option::Option>` -note: required by `collect` - --> $DIR/on-trait.rs:31:1 - | -31 | fn collect, B: MyFromIterator>(it: I) -> B { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: required by `collect` error[E0277]: the trait bound `std::string::String: Bar::Foo` is not satisfied --> $DIR/on-trait.rs:40:21 @@ -18,11 +14,7 @@ error[E0277]: the trait bound `std::string::String: Bar::Foo` is not | ^^^^^^ test error `std::string::String` with `u8` `_` `u32` in `Bar::Foo` | = help: the trait `Bar::Foo` is not implemented for `std::string::String` -note: required by `foobar` - --> $DIR/on-trait.rs:21:1 - | -21 | fn foobar>() -> T { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: required by `foobar` error: aborting due to 2 previous errors diff --git a/src/test/ui/span/issue-29595.stderr b/src/test/ui/span/issue-29595.stderr index 9046b90f0e9c3..81ba0057d7173 100644 --- a/src/test/ui/span/issue-29595.stderr +++ b/src/test/ui/span/issue-29595.stderr @@ -4,11 +4,7 @@ error[E0277]: the trait bound `u8: Tr` is not satisfied 17 | let a: u8 = Tr::C; //~ ERROR the trait bound `u8: Tr` is not satisfied | ^^^^^ the trait `Tr` is not implemented for `u8` | -note: required by `Tr::C` - --> $DIR/issue-29595.rs:13:5 - | -13 | const C: Self; - | ^^^^^^^^^^^^^^ + = note: required by `Tr::C` error: aborting due to previous error diff --git a/src/test/ui/span/multiline-span-simple.stderr b/src/test/ui/span/multiline-span-simple.stderr index b068798630ed8..b6182825fc278 100644 --- a/src/test/ui/span/multiline-span-simple.stderr +++ b/src/test/ui/span/multiline-span-simple.stderr @@ -1,4 +1,4 @@ -error[E0277]: the trait bound `u32: std::ops::Add<()>` is not satisfied +error[E0277]: cannot add `()` to `u32` --> $DIR/multiline-span-simple.rs:23:18 | 23 | foo(1 as u32 + //~ ERROR not satisfied diff --git a/src/test/ui/suggestions/try-operator-on-main.stderr b/src/test/ui/suggestions/try-operator-on-main.stderr index e97823a3d5d5b..36cdd558b0faf 100644 --- a/src/test/ui/suggestions/try-operator-on-main.stderr +++ b/src/test/ui/suggestions/try-operator-on-main.stderr @@ -22,11 +22,7 @@ error[E0277]: the trait bound `(): std::ops::Try` is not satisfied 25 | try_trait_generic::<()>(); //~ ERROR the trait bound | ^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::ops::Try` is not implemented for `()` | -note: required by `try_trait_generic` - --> $DIR/try-operator-on-main.rs:30:1 - | -30 | fn try_trait_generic() -> T { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: required by `try_trait_generic` error[E0277]: the `?` operator can only be applied to values that implement `std::ops::Try` --> $DIR/try-operator-on-main.rs:32:5 diff --git a/src/test/ui/type-check/issue-40294.stderr b/src/test/ui/type-check/issue-40294.stderr index cf270afdeb173..2ca97aa3ef067 100644 --- a/src/test/ui/type-check/issue-40294.stderr +++ b/src/test/ui/type-check/issue-40294.stderr @@ -10,11 +10,7 @@ error[E0283]: type annotations required: cannot resolve `&'a T: Foo` 21 | | } | |_^ | -note: required by `Foo` - --> $DIR/issue-40294.rs:11:1 - | -11 | trait Foo: Sized { - | ^^^^^^^^^^^^^^^^ + = note: required by `Foo` error: aborting due to previous error From 4c92a02b64e5cb8cfb9b885638e1dfa2067cacd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Fri, 19 Jan 2018 20:28:09 -0800 Subject: [PATCH 2/8] Change rustc_on_unimplemented for Iterator and binops --- src/libcore/ops/arith.rs | 9 +-- .../anonymous-higher-ranked-lifetime.stderr | 66 +++++++++++++++---- .../issue-39802-show-5-trait-impls.stderr | 18 ++++- .../ui/did_you_mean/recursion_limit.stderr | 6 +- .../ui/feature-gate-abi_unadjusted.stderr | 2 +- src/test/ui/feature-gate-catch_expr.stderr | 2 +- src/test/ui/feature-gate-i128_type2.stderr | 10 +-- src/test/ui/feature-gate-intrinsics.stderr | 4 +- .../ui/feature-gate-non_ascii_idents.stderr | 26 ++++---- src/test/ui/feature-gate-repr128.stderr | 2 +- .../ui/feature-gate-unboxed-closures.stderr | 2 +- .../ui/feature-gate-untagged_unions.stderr | 6 +- src/test/ui/fmt/send-sync.stderr | 12 +++- src/test/ui/generator/not-send-sync.stderr | 6 +- src/test/ui/impl-trait/auto-trait-leak.stderr | 12 +++- src/test/ui/issue-24424.stderr | 6 +- src/test/ui/lint/suggestions.stderr | 32 ++++++--- src/test/ui/macros/format-foreign.stderr | 10 +-- .../ui/macros/format-unused-lables.stderr | 52 +++++++-------- src/test/ui/mismatched_types/E0631.stderr | 24 +++++-- .../mismatched_types/closure-arg-count.stderr | 56 ++++++++-------- .../closure-arg-type-mismatch.stderr | 12 +++- .../mismatched_types/closure-mismatch.stderr | 12 +++- .../ui/mismatched_types/fn-variance-1.stderr | 12 +++- .../unboxed-closures-vtable-mismatch.stderr | 13 ++-- .../multiple-impls-complex-filtering.rs | 61 +++++++++++++++++ .../multiple-impls-complex-filtering.stderr | 44 +++++++++++++ .../ui/on-unimplemented/multiple-impls.stderr | 18 ++++- src/test/ui/on-unimplemented/on-impl.stderr | 6 +- src/test/ui/on-unimplemented/on-trait.stderr | 12 +++- src/test/ui/span/issue-29595.stderr | 6 +- .../suggestions/try-operator-on-main.stderr | 6 +- src/test/ui/type-check/issue-40294.stderr | 6 +- 33 files changed, 418 insertions(+), 153 deletions(-) create mode 100644 src/test/ui/on-unimplemented/multiple-impls-complex-filtering.rs create mode 100644 src/test/ui/on-unimplemented/multiple-impls-complex-filtering.stderr diff --git a/src/libcore/ops/arith.rs b/src/libcore/ops/arith.rs index 59a18d6cb75ed..47617b22dd34d 100644 --- a/src/libcore/ops/arith.rs +++ b/src/libcore/ops/arith.rs @@ -109,7 +109,6 @@ all(_Self="f32", RHS="u16"), all(_Self="f32", RHS="u8"), ), - message="cannot add `{RHS}` to `{Self}`", label="no implementation for `{Self} + {RHS}`, but you can safely cast \ `{RHS}` into `{Self}` using `as {Self}`", ), @@ -146,22 +145,20 @@ all(RHS="f32", _Self="u16"), all(RHS="f32", _Self="u8"), ), - message="cannot add `{RHS}` to `{Self}`", - label="no implementation for `{Self} + {RHS}`, but you can safely turn \ + label="no implementation for `{Self} + {RHS}`, but you can safely cast \ `{Self}` into `{RHS}` using `as {RHS}`", ), on( all(_Self="{integer}", RHS="{float}"), message="cannot add a float to an integer", - label="no implementation for `{Self} + {RHS}`", ), on( all(_Self="{float}", RHS="{integer}"), message="cannot add an integer to a float", - label="no implementation for `{Self} + {RHS}`", ), message="cannot add `{RHS}` to `{Self}`", - label="no implementation for `{Self} + {RHS}`")] + label="no implementation for `{Self} + {RHS}`", +)] pub trait Add { /// The resulting type after applying the `+` operator. #[stable(feature = "rust1", since = "1.0.0")] diff --git a/src/test/ui/anonymous-higher-ranked-lifetime.stderr b/src/test/ui/anonymous-higher-ranked-lifetime.stderr index e364a4d8b1441..4bd3b684b7ba3 100644 --- a/src/test/ui/anonymous-higher-ranked-lifetime.stderr +++ b/src/test/ui/anonymous-higher-ranked-lifetime.stderr @@ -6,7 +6,11 @@ error[E0631]: type mismatch in closure arguments | | | expected signature of `for<'r, 's> fn(&'r (), &'s ()) -> _` | - = note: required by `f1` +note: required by `f1` + --> $DIR/anonymous-higher-ranked-lifetime.rs:26:1 + | +26 | fn f1(_: F) where F: Fn(&(), &()) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:13:5 @@ -16,7 +20,11 @@ error[E0631]: type mismatch in closure arguments | | | expected signature of `for<'a, 'r> fn(&'a (), &'r ()) -> _` | - = note: required by `f2` +note: required by `f2` + --> $DIR/anonymous-higher-ranked-lifetime.rs:27:1 + | +27 | fn f2(_: F) where F: for<'a> Fn(&'a (), &()) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:14:5 @@ -26,7 +34,11 @@ error[E0631]: type mismatch in closure arguments | | | expected signature of `for<'r> fn(&(), &'r ()) -> _` | - = note: required by `f3` +note: required by `f3` + --> $DIR/anonymous-higher-ranked-lifetime.rs:28:1 + | +28 | fn f3<'a, F>(_: F) where F: Fn(&'a (), &()) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:15:5 @@ -36,7 +48,11 @@ error[E0631]: type mismatch in closure arguments | | | expected signature of `for<'s, 'r> fn(&'s (), &'r ()) -> _` | - = note: required by `f4` +note: required by `f4` + --> $DIR/anonymous-higher-ranked-lifetime.rs:29:1 + | +29 | fn f4(_: F) where F: for<'r> Fn(&(), &'r ()) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:16:5 @@ -46,7 +62,11 @@ error[E0631]: type mismatch in closure arguments | | | expected signature of `for<'r> fn(&'r (), &'r ()) -> _` | - = note: required by `f5` +note: required by `f5` + --> $DIR/anonymous-higher-ranked-lifetime.rs:30:1 + | +30 | fn f5(_: F) where F: for<'r> Fn(&'r (), &'r ()) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:17:5 @@ -56,7 +76,11 @@ error[E0631]: type mismatch in closure arguments | | | expected signature of `for<'r> fn(&'r (), std::boxed::Box std::ops::Fn(&'s ()) + 'static>) -> _` | - = note: required by `g1` +note: required by `g1` + --> $DIR/anonymous-higher-ranked-lifetime.rs:33:1 + | +33 | fn g1(_: F) where F: Fn(&(), Box) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:18:5 @@ -66,7 +90,11 @@ error[E0631]: type mismatch in closure arguments | | | expected signature of `for<'r> fn(&'r (), for<'s> fn(&'s ())) -> _` | - = note: required by `g2` +note: required by `g2` + --> $DIR/anonymous-higher-ranked-lifetime.rs:34:1 + | +34 | fn g2(_: F) where F: Fn(&(), fn(&())) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:19:5 @@ -76,7 +104,11 @@ error[E0631]: type mismatch in closure arguments | | | expected signature of `for<'s> fn(&'s (), std::boxed::Box std::ops::Fn(&'r ()) + 'static>) -> _` | - = note: required by `g3` +note: required by `g3` + --> $DIR/anonymous-higher-ranked-lifetime.rs:35:1 + | +35 | fn g3(_: F) where F: for<'s> Fn(&'s (), Box) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:20:5 @@ -86,7 +118,11 @@ error[E0631]: type mismatch in closure arguments | | | expected signature of `for<'s> fn(&'s (), for<'r> fn(&'r ())) -> _` | - = note: required by `g4` +note: required by `g4` + --> $DIR/anonymous-higher-ranked-lifetime.rs:36:1 + | +36 | fn g4(_: F) where F: Fn(&(), for<'r> fn(&'r ())) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:21:5 @@ -96,7 +132,11 @@ error[E0631]: type mismatch in closure arguments | | | expected signature of `for<'r, 's> fn(&'r (), std::boxed::Box std::ops::Fn(&'t0 ()) + 'static>, &'s (), for<'t0, 't1> fn(&'t0 (), &'t1 ())) -> _` | - = note: required by `h1` +note: required by `h1` + --> $DIR/anonymous-higher-ranked-lifetime.rs:39:1 + | +39 | fn h1(_: F) where F: Fn(&(), Box, &(), fn(&(), &())) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:22:5 @@ -106,7 +146,11 @@ error[E0631]: type mismatch in closure arguments | | | expected signature of `for<'r, 't0> fn(&'r (), std::boxed::Box std::ops::Fn(&'s ()) + 'static>, &'t0 (), for<'s, 't1> fn(&'s (), &'t1 ())) -> _` | - = note: required by `h2` +note: required by `h2` + --> $DIR/anonymous-higher-ranked-lifetime.rs:40:1 + | +40 | fn h2(_: F) where F: for<'t0> Fn(&(), Box, &'t0 (), fn(&(), &())) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 11 previous errors diff --git a/src/test/ui/did_you_mean/issue-39802-show-5-trait-impls.stderr b/src/test/ui/did_you_mean/issue-39802-show-5-trait-impls.stderr index d5c4add34b526..7ca3e8728fd9c 100644 --- a/src/test/ui/did_you_mean/issue-39802-show-5-trait-impls.stderr +++ b/src/test/ui/did_you_mean/issue-39802-show-5-trait-impls.stderr @@ -10,7 +10,11 @@ error[E0277]: the trait bound `i8: Foo` is not satisfied > > > - = note: required by `Foo::bar` +note: required by `Foo::bar` + --> $DIR/issue-39802-show-5-trait-impls.rs:12:5 + | +12 | fn bar(&self){} + | ^^^^^^^^^^^^^ error[E0277]: the trait bound `u8: Foo` is not satisfied --> $DIR/issue-39802-show-5-trait-impls.rs:35:5 @@ -23,7 +27,11 @@ error[E0277]: the trait bound `u8: Foo` is not satisfied > > > - = note: required by `Foo::bar` +note: required by `Foo::bar` + --> $DIR/issue-39802-show-5-trait-impls.rs:12:5 + | +12 | fn bar(&self){} + | ^^^^^^^^^^^^^ error[E0277]: the trait bound `bool: Foo` is not satisfied --> $DIR/issue-39802-show-5-trait-impls.rs:36:5 @@ -37,7 +45,11 @@ error[E0277]: the trait bound `bool: Foo` is not satisfied > > and 2 others - = note: required by `Foo::bar` +note: required by `Foo::bar` + --> $DIR/issue-39802-show-5-trait-impls.rs:12:5 + | +12 | fn bar(&self){} + | ^^^^^^^^^^^^^ error: aborting due to 3 previous errors diff --git a/src/test/ui/did_you_mean/recursion_limit.stderr b/src/test/ui/did_you_mean/recursion_limit.stderr index 7fac604ba49d7..2bc7e9e46e7c5 100644 --- a/src/test/ui/did_you_mean/recursion_limit.stderr +++ b/src/test/ui/did_you_mean/recursion_limit.stderr @@ -15,7 +15,11 @@ error[E0275]: overflow evaluating the requirement `K: std::marker::Send` = note: required because it appears within the type `C` = note: required because it appears within the type `B` = note: required because it appears within the type `A` - = note: required by `is_send` +note: required by `is_send` + --> $DIR/recursion_limit.rs:41:1 + | +41 | fn is_send() { } + | ^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/feature-gate-abi_unadjusted.stderr b/src/test/ui/feature-gate-abi_unadjusted.stderr index 3cc43847156a1..b3f7cd218d3e9 100644 --- a/src/test/ui/feature-gate-abi_unadjusted.stderr +++ b/src/test/ui/feature-gate-abi_unadjusted.stderr @@ -1,4 +1,4 @@ -error: unadjusted ABI is an implementation detail and perma-unstable +error[E0658]: unadjusted ABI is an implementation detail and perma-unstable --> $DIR/feature-gate-abi_unadjusted.rs:11:1 | 11 | / extern "unadjusted" fn foo() { diff --git a/src/test/ui/feature-gate-catch_expr.stderr b/src/test/ui/feature-gate-catch_expr.stderr index f486373d225c3..4b3bfbbe27ac8 100644 --- a/src/test/ui/feature-gate-catch_expr.stderr +++ b/src/test/ui/feature-gate-catch_expr.stderr @@ -1,4 +1,4 @@ -error: `catch` expression is experimental (see issue #31436) +error[E0658]: `catch` expression is experimental (see issue #31436) --> $DIR/feature-gate-catch_expr.rs:12:24 | 12 | let catch_result = do catch { //~ ERROR `catch` expression is experimental diff --git a/src/test/ui/feature-gate-i128_type2.stderr b/src/test/ui/feature-gate-i128_type2.stderr index 26653a5739b2c..ee81a26921498 100644 --- a/src/test/ui/feature-gate-i128_type2.stderr +++ b/src/test/ui/feature-gate-i128_type2.stderr @@ -1,4 +1,4 @@ -error: 128-bit type is unstable (see issue #35118) +error[E0658]: 128-bit type is unstable (see issue #35118) --> $DIR/feature-gate-i128_type2.rs:13:15 | 13 | fn test1() -> i128 { //~ ERROR 128-bit type is unstable @@ -6,7 +6,7 @@ error: 128-bit type is unstable (see issue #35118) | = help: add #![feature(i128_type)] to the crate attributes to enable -error: 128-bit type is unstable (see issue #35118) +error[E0658]: 128-bit type is unstable (see issue #35118) --> $DIR/feature-gate-i128_type2.rs:17:17 | 17 | fn test1_2() -> u128 { //~ ERROR 128-bit type is unstable @@ -14,7 +14,7 @@ error: 128-bit type is unstable (see issue #35118) | = help: add #![feature(i128_type)] to the crate attributes to enable -error: 128-bit type is unstable (see issue #35118) +error[E0658]: 128-bit type is unstable (see issue #35118) --> $DIR/feature-gate-i128_type2.rs:22:12 | 22 | let x: i128 = 0; //~ ERROR 128-bit type is unstable @@ -22,7 +22,7 @@ error: 128-bit type is unstable (see issue #35118) | = help: add #![feature(i128_type)] to the crate attributes to enable -error: 128-bit type is unstable (see issue #35118) +error[E0658]: 128-bit type is unstable (see issue #35118) --> $DIR/feature-gate-i128_type2.rs:26:12 | 26 | let x: u128 = 0; //~ ERROR 128-bit type is unstable @@ -32,7 +32,7 @@ error: 128-bit type is unstable (see issue #35118) error[E0601]: main function not found -error: repr with 128-bit type is unstable (see issue #35118) +error[E0658]: repr with 128-bit type is unstable (see issue #35118) --> $DIR/feature-gate-i128_type2.rs:30:1 | 30 | / enum A { //~ ERROR 128-bit type is unstable diff --git a/src/test/ui/feature-gate-intrinsics.stderr b/src/test/ui/feature-gate-intrinsics.stderr index 5382122e30edd..918c749504aea 100644 --- a/src/test/ui/feature-gate-intrinsics.stderr +++ b/src/test/ui/feature-gate-intrinsics.stderr @@ -1,4 +1,4 @@ -error: intrinsics are subject to change +error[E0658]: intrinsics are subject to change --> $DIR/feature-gate-intrinsics.rs:11:1 | 11 | / extern "rust-intrinsic" { //~ ERROR intrinsics are subject to change @@ -8,7 +8,7 @@ error: intrinsics are subject to change | = help: add #![feature(intrinsics)] to the crate attributes to enable -error: intrinsics are subject to change +error[E0658]: intrinsics are subject to change --> $DIR/feature-gate-intrinsics.rs:15:1 | 15 | / extern "rust-intrinsic" fn baz() { //~ ERROR intrinsics are subject to change diff --git a/src/test/ui/feature-gate-non_ascii_idents.stderr b/src/test/ui/feature-gate-non_ascii_idents.stderr index 90d0b8daee71c..deb707752b066 100644 --- a/src/test/ui/feature-gate-non_ascii_idents.stderr +++ b/src/test/ui/feature-gate-non_ascii_idents.stderr @@ -1,4 +1,4 @@ -error: non-ascii idents are not fully supported. (see issue #28979) +error[E0658]: non-ascii idents are not fully supported. (see issue #28979) --> $DIR/feature-gate-non_ascii_idents.rs:11:1 | 11 | extern crate core as bäz; //~ ERROR non-ascii idents @@ -6,7 +6,7 @@ error: non-ascii idents are not fully supported. (see issue #28979) | = help: add #![feature(non_ascii_idents)] to the crate attributes to enable -error: non-ascii idents are not fully supported. (see issue #28979) +error[E0658]: non-ascii idents are not fully supported. (see issue #28979) --> $DIR/feature-gate-non_ascii_idents.rs:13:5 | 13 | use föö::bar; //~ ERROR non-ascii idents @@ -14,7 +14,7 @@ error: non-ascii idents are not fully supported. (see issue #28979) | = help: add #![feature(non_ascii_idents)] to the crate attributes to enable -error: non-ascii idents are not fully supported. (see issue #28979) +error[E0658]: non-ascii idents are not fully supported. (see issue #28979) --> $DIR/feature-gate-non_ascii_idents.rs:15:1 | 15 | mod föö { //~ ERROR non-ascii idents @@ -22,7 +22,7 @@ error: non-ascii idents are not fully supported. (see issue #28979) | = help: add #![feature(non_ascii_idents)] to the crate attributes to enable -error: non-ascii idents are not fully supported. (see issue #28979) +error[E0658]: non-ascii idents are not fully supported. (see issue #28979) --> $DIR/feature-gate-non_ascii_idents.rs:19:1 | 19 | / fn bär( //~ ERROR non-ascii idents @@ -36,7 +36,7 @@ error: non-ascii idents are not fully supported. (see issue #28979) | = help: add #![feature(non_ascii_idents)] to the crate attributes to enable -error: non-ascii idents are not fully supported. (see issue #28979) +error[E0658]: non-ascii idents are not fully supported. (see issue #28979) --> $DIR/feature-gate-non_ascii_idents.rs:20:5 | 20 | bäz: isize //~ ERROR non-ascii idents @@ -44,7 +44,7 @@ error: non-ascii idents are not fully supported. (see issue #28979) | = help: add #![feature(non_ascii_idents)] to the crate attributes to enable -error: non-ascii idents are not fully supported. (see issue #28979) +error[E0658]: non-ascii idents are not fully supported. (see issue #28979) --> $DIR/feature-gate-non_ascii_idents.rs:22:9 | 22 | let _ö: isize; //~ ERROR non-ascii idents @@ -52,7 +52,7 @@ error: non-ascii idents are not fully supported. (see issue #28979) | = help: add #![feature(non_ascii_idents)] to the crate attributes to enable -error: non-ascii idents are not fully supported. (see issue #28979) +error[E0658]: non-ascii idents are not fully supported. (see issue #28979) --> $DIR/feature-gate-non_ascii_idents.rs:25:10 | 25 | (_ä, _) => {} //~ ERROR non-ascii idents @@ -60,7 +60,7 @@ error: non-ascii idents are not fully supported. (see issue #28979) | = help: add #![feature(non_ascii_idents)] to the crate attributes to enable -error: non-ascii idents are not fully supported. (see issue #28979) +error[E0658]: non-ascii idents are not fully supported. (see issue #28979) --> $DIR/feature-gate-non_ascii_idents.rs:29:1 | 29 | struct Föö { //~ ERROR non-ascii idents @@ -68,7 +68,7 @@ error: non-ascii idents are not fully supported. (see issue #28979) | = help: add #![feature(non_ascii_idents)] to the crate attributes to enable -error: non-ascii idents are not fully supported. (see issue #28979) +error[E0658]: non-ascii idents are not fully supported. (see issue #28979) --> $DIR/feature-gate-non_ascii_idents.rs:30:5 | 30 | föö: isize //~ ERROR non-ascii idents @@ -76,7 +76,7 @@ error: non-ascii idents are not fully supported. (see issue #28979) | = help: add #![feature(non_ascii_idents)] to the crate attributes to enable -error: non-ascii idents are not fully supported. (see issue #28979) +error[E0658]: non-ascii idents are not fully supported. (see issue #28979) --> $DIR/feature-gate-non_ascii_idents.rs:33:1 | 33 | enum Bär { //~ ERROR non-ascii idents @@ -84,7 +84,7 @@ error: non-ascii idents are not fully supported. (see issue #28979) | = help: add #![feature(non_ascii_idents)] to the crate attributes to enable -error: non-ascii idents are not fully supported. (see issue #28979) +error[E0658]: non-ascii idents are not fully supported. (see issue #28979) --> $DIR/feature-gate-non_ascii_idents.rs:34:5 | 34 | Bäz { //~ ERROR non-ascii idents @@ -92,7 +92,7 @@ error: non-ascii idents are not fully supported. (see issue #28979) | = help: add #![feature(non_ascii_idents)] to the crate attributes to enable -error: non-ascii idents are not fully supported. (see issue #28979) +error[E0658]: non-ascii idents are not fully supported. (see issue #28979) --> $DIR/feature-gate-non_ascii_idents.rs:35:9 | 35 | qüx: isize //~ ERROR non-ascii idents @@ -100,7 +100,7 @@ error: non-ascii idents are not fully supported. (see issue #28979) | = help: add #![feature(non_ascii_idents)] to the crate attributes to enable -error: non-ascii idents are not fully supported. (see issue #28979) +error[E0658]: non-ascii idents are not fully supported. (see issue #28979) --> $DIR/feature-gate-non_ascii_idents.rs:40:5 | 40 | fn qüx(); //~ ERROR non-ascii idents diff --git a/src/test/ui/feature-gate-repr128.stderr b/src/test/ui/feature-gate-repr128.stderr index c59964887b58f..982ebb0101662 100644 --- a/src/test/ui/feature-gate-repr128.stderr +++ b/src/test/ui/feature-gate-repr128.stderr @@ -1,4 +1,4 @@ -error: repr with 128-bit type is unstable (see issue #35118) +error[E0658]: repr with 128-bit type is unstable (see issue #35118) --> $DIR/feature-gate-repr128.rs:12:1 | 12 | / enum A { //~ ERROR repr with 128-bit type is unstable diff --git a/src/test/ui/feature-gate-unboxed-closures.stderr b/src/test/ui/feature-gate-unboxed-closures.stderr index b79165147e590..ca8a59249463d 100644 --- a/src/test/ui/feature-gate-unboxed-closures.stderr +++ b/src/test/ui/feature-gate-unboxed-closures.stderr @@ -1,4 +1,4 @@ -error: rust-call ABI is subject to change (see issue #29625) +error[E0658]: rust-call ABI is subject to change (see issue #29625) --> $DIR/feature-gate-unboxed-closures.rs:16:5 | 16 | / extern "rust-call" fn call_once(self, (a, b): (u32, u32)) -> u32 { diff --git a/src/test/ui/feature-gate-untagged_unions.stderr b/src/test/ui/feature-gate-untagged_unions.stderr index 26b698912bc95..14b66cb5c815a 100644 --- a/src/test/ui/feature-gate-untagged_unions.stderr +++ b/src/test/ui/feature-gate-untagged_unions.stderr @@ -1,4 +1,4 @@ -error: unions with non-`Copy` fields are unstable (see issue #32836) +error[E0658]: unions with non-`Copy` fields are unstable (see issue #32836) --> $DIR/feature-gate-untagged_unions.rs:19:1 | 19 | / union U3 { //~ ERROR unions with non-`Copy` fields are unstable @@ -8,7 +8,7 @@ error: unions with non-`Copy` fields are unstable (see issue #32836) | = help: add #![feature(untagged_unions)] to the crate attributes to enable -error: unions with non-`Copy` fields are unstable (see issue #32836) +error[E0658]: unions with non-`Copy` fields are unstable (see issue #32836) --> $DIR/feature-gate-untagged_unions.rs:23:1 | 23 | / union U4 { //~ ERROR unions with non-`Copy` fields are unstable @@ -18,7 +18,7 @@ error: unions with non-`Copy` fields are unstable (see issue #32836) | = help: add #![feature(untagged_unions)] to the crate attributes to enable -error: unions with `Drop` implementations are unstable (see issue #32836) +error[E0658]: unions with `Drop` implementations are unstable (see issue #32836) --> $DIR/feature-gate-untagged_unions.rs:27:1 | 27 | / union U5 { //~ ERROR unions with `Drop` implementations are unstable diff --git a/src/test/ui/fmt/send-sync.stderr b/src/test/ui/fmt/send-sync.stderr index 9e0e563c35f65..4ec5c9ebd2712 100644 --- a/src/test/ui/fmt/send-sync.stderr +++ b/src/test/ui/fmt/send-sync.stderr @@ -12,7 +12,11 @@ error[E0277]: the trait bound `*mut std::ops::Fn() + 'static: std::marker::Sync` = note: required because it appears within the type `[std::fmt::ArgumentV1<'_>]` = note: required because of the requirements on the impl of `std::marker::Send` for `&[std::fmt::ArgumentV1<'_>]` = note: required because it appears within the type `std::fmt::Arguments<'_>` - = note: required by `send` +note: required by `send` + --> $DIR/send-sync.rs:11:1 + | +11 | fn send(_: T) {} + | ^^^^^^^^^^^^^^^^^^^^^^ error[E0277]: the trait bound `*mut std::ops::Fn() + 'static: std::marker::Sync` is not satisfied in `std::fmt::Arguments<'_>` --> $DIR/send-sync.rs:19:5 @@ -28,7 +32,11 @@ error[E0277]: the trait bound `*mut std::ops::Fn() + 'static: std::marker::Sync` = note: required because it appears within the type `[std::fmt::ArgumentV1<'_>]` = note: required because it appears within the type `&[std::fmt::ArgumentV1<'_>]` = note: required because it appears within the type `std::fmt::Arguments<'_>` - = note: required by `sync` +note: required by `sync` + --> $DIR/send-sync.rs:12:1 + | +12 | fn sync(_: T) {} + | ^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/src/test/ui/generator/not-send-sync.stderr b/src/test/ui/generator/not-send-sync.stderr index fd8f3b8e6463d..e65c8f1546e82 100644 --- a/src/test/ui/generator/not-send-sync.stderr +++ b/src/test/ui/generator/not-send-sync.stderr @@ -7,7 +7,11 @@ error[E0277]: the trait bound `std::cell::Cell: std::marker::Sync` is not s = help: the trait `std::marker::Sync` is not implemented for `std::cell::Cell` = note: required because of the requirements on the impl of `std::marker::Send` for `&std::cell::Cell` = note: required because it appears within the type `[generator@$DIR/not-send-sync.rs:26:17: 30:6 a:&std::cell::Cell _]` - = note: required by `main::assert_send` +note: required by `main::assert_send` + --> $DIR/not-send-sync.rs:17:5 + | +17 | fn assert_send(_: T) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0277]: the trait bound `std::cell::Cell: std::marker::Sync` is not satisfied in `[generator@$DIR/not-send-sync.rs:19:17: 23:6 {std::cell::Cell, ()}]` --> $DIR/not-send-sync.rs:19:5 diff --git a/src/test/ui/impl-trait/auto-trait-leak.stderr b/src/test/ui/impl-trait/auto-trait-leak.stderr index ffd6a3fe4ffb1..838a3002e3aa7 100644 --- a/src/test/ui/impl-trait/auto-trait-leak.stderr +++ b/src/test/ui/impl-trait/auto-trait-leak.stderr @@ -7,7 +7,11 @@ error[E0277]: the trait bound `std::rc::Rc>: std::marker::S = help: within `impl std::ops::Fn<(i32,)>`, the trait `std::marker::Send` is not implemented for `std::rc::Rc>` = note: required because it appears within the type `[closure@$DIR/auto-trait-leak.rs:21:5: 21:22 p:std::rc::Rc>]` = note: required because it appears within the type `impl std::ops::Fn<(i32,)>` - = note: required by `send` +note: required by `send` + --> $DIR/auto-trait-leak.rs:24:1 + | +24 | fn send(_: T) {} + | ^^^^^^^^^^^^^^^^^^^^^^ error[E0277]: the trait bound `std::rc::Rc>: std::marker::Send` is not satisfied in `impl std::ops::Fn<(i32,)>` --> $DIR/auto-trait-leak.rs:30:5 @@ -18,7 +22,11 @@ error[E0277]: the trait bound `std::rc::Rc>: std::marker::S = help: within `impl std::ops::Fn<(i32,)>`, the trait `std::marker::Send` is not implemented for `std::rc::Rc>` = note: required because it appears within the type `[closure@$DIR/auto-trait-leak.rs:38:5: 38:22 p:std::rc::Rc>]` = note: required because it appears within the type `impl std::ops::Fn<(i32,)>` - = note: required by `send` +note: required by `send` + --> $DIR/auto-trait-leak.rs:24:1 + | +24 | fn send(_: T) {} + | ^^^^^^^^^^^^^^^^^^^^^^ error[E0391]: unsupported cyclic reference between types/traits detected --> $DIR/auto-trait-leak.rs:44:1 diff --git a/src/test/ui/issue-24424.stderr b/src/test/ui/issue-24424.stderr index acdf348791b20..55af26dd91ea3 100644 --- a/src/test/ui/issue-24424.stderr +++ b/src/test/ui/issue-24424.stderr @@ -4,7 +4,11 @@ error[E0283]: type annotations required: cannot resolve `T0: Trait0<'l0>` 14 | impl <'l0, 'l1, T0> Trait1<'l0, T0> for bool where T0 : Trait0<'l0>, T0 : Trait0<'l1> {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: required by `Trait0` +note: required by `Trait0` + --> $DIR/issue-24424.rs:12:1 + | +12 | trait Trait0<'l0> {} + | ^^^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/lint/suggestions.stderr b/src/test/ui/lint/suggestions.stderr index 701a95222183a..8b30f552d3771 100644 --- a/src/test/ui/lint/suggestions.stderr +++ b/src/test/ui/lint/suggestions.stderr @@ -1,7 +1,7 @@ warning: unnecessary parentheses around assigned value - --> $DIR/suggestions.rs:36:21 + --> $DIR/suggestions.rs:46:21 | -36 | let mut a = (1); // should suggest no `mut`, no parens +46 | let mut a = (1); // should suggest no `mut`, no parens | ^^^ help: remove these parentheses | note: lint level defined here @@ -11,17 +11,17 @@ note: lint level defined here | ^^^^^^^^^^^^^ warning: use of deprecated attribute `no_debug`: the `#[no_debug]` attribute was an experimental feature that has been deprecated due to lack of demand. See https://github.com/rust-lang/rust/issues/29721 - --> $DIR/suggestions.rs:31:1 + --> $DIR/suggestions.rs:41:1 | -31 | #[no_debug] // should suggest removal of deprecated attribute +41 | #[no_debug] // should suggest removal of deprecated attribute | ^^^^^^^^^^^ help: remove this attribute | = note: #[warn(deprecated)] on by default warning: variable does not need to be mutable - --> $DIR/suggestions.rs:36:13 + --> $DIR/suggestions.rs:46:13 | -36 | let mut a = (1); // should suggest no `mut`, no parens +46 | let mut a = (1); // should suggest no `mut`, no parens | ---^^ | | | help: remove this `mut` @@ -72,18 +72,30 @@ warning: function is marked #[no_mangle], but not exported | = note: #[warn(private_no_mangle_fns)] on by default +warning: static is marked #[no_mangle], but not exported + --> $DIR/suggestions.rs:31:18 + | +31 | #[no_mangle] pub static DAUNTLESS: bool = true; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: function is marked #[no_mangle], but not exported + --> $DIR/suggestions.rs:33:18 + | +33 | #[no_mangle] pub fn val_jean() {} + | ^^^^^^^^^^^^^^^^^^^^ + warning: denote infinite loops with `loop { ... }` - --> $DIR/suggestions.rs:34:5 + --> $DIR/suggestions.rs:44:5 | -34 | while true { // should suggest `loop` +44 | while true { // should suggest `loop` | ^^^^^^^^^^ help: use `loop` | = note: #[warn(while_true)] on by default warning: the `warp_factor:` in this pattern is redundant - --> $DIR/suggestions.rs:41:23 + --> $DIR/suggestions.rs:51:23 | -41 | Equinox { warp_factor: warp_factor } => {} // should suggest shorthand +51 | Equinox { warp_factor: warp_factor } => {} // should suggest shorthand | ------------^^^^^^^^^^^^ | | | help: remove this diff --git a/src/test/ui/macros/format-foreign.stderr b/src/test/ui/macros/format-foreign.stderr index d0229957b682e..f9852c5477332 100644 --- a/src/test/ui/macros/format-foreign.stderr +++ b/src/test/ui/macros/format-foreign.stderr @@ -1,12 +1,8 @@ error: multiple unused formatting arguments - --> $DIR/format-foreign.rs:12:5 + --> $DIR/format-foreign.rs:12:30 | -12 | println!("%.*3$s %s!/n", "Hello,", "World", 4); - | ^^^^^^^^^^^^^^^^^^^^^^^^^--------^^-------^^-^^ - | | | | - | | | unused - | | unused - | unused +12 | println!("%.*3$s %s!/n", "Hello,", "World", 4); //~ ERROR multiple unused formatting arguments + | -------------------------^^^^^^^^--^^^^^^^--^-- multiple unused arguments in this statement | = help: `%.*3$s` should be written as `{:.2$}` = help: `%s` should be written as `{}` diff --git a/src/test/ui/macros/format-unused-lables.stderr b/src/test/ui/macros/format-unused-lables.stderr index 9efdca12dea03..64ea5626c1d62 100644 --- a/src/test/ui/macros/format-unused-lables.stderr +++ b/src/test/ui/macros/format-unused-lables.stderr @@ -1,49 +1,43 @@ error: multiple unused formatting arguments - --> $DIR/format-unused-lables.rs:12:5 + --> $DIR/format-unused-lables.rs:12:22 | 12 | println!("Test", 123, 456, 789); - | ^^^^^^^^^^^^^^^^^---^^---^^---^^ - | | | | - | | | unused - | | unused - | unused + | -----------------^^^--^^^--^^^-- multiple unused arguments in this statement | = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) error: multiple unused formatting arguments - --> $DIR/format-unused-lables.rs:14:5 + --> $DIR/format-unused-lables.rs:16:9 | -14 | / println!("Test2", -15 | | 123, - | | --- unused -16 | | 456, - | | --- unused -17 | | 789 - | | --- unused -18 | | ); - | |______^ +15 | / println!("Test2", +16 | | 123, //~ ERROR multiple unused formatting arguments + | | ^^^ +17 | | 456, + | | ^^^ +18 | | 789 + | | ^^^ +19 | | ); + | |______- multiple unused arguments in this statement | = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) error: named argument never used - --> $DIR/format-unused-lables.rs:20:35 + --> $DIR/format-unused-lables.rs:21:35 | -20 | println!("Some stuff", UNUSED="args"); //~ ERROR named argument never used +21 | println!("Some stuff", UNUSED="args"); //~ ERROR named argument never used | ^^^^^^ error: multiple unused formatting arguments - --> $DIR/format-unused-lables.rs:22:5 + --> $DIR/format-unused-lables.rs:24:9 | -22 | / println!("Some more $STUFF", -23 | | "woo!", - | | ------ unused -24 | | STUFF= -25 | | "things" - | | -------- unused -26 | | , UNUSED="args"); - | |_______________________------_^ - | | - | unused +23 | / println!("Some more $STUFF", +24 | | "woo!", //~ ERROR multiple unused formatting arguments + | | ^^^^^^ +25 | | STUFF= +26 | | "things" + | | ^^^^^^^^ +27 | | , UNUSED="args"); + | |_______________________^^^^^^_- multiple unused arguments in this statement | = help: `$STUFF` should be written as `{STUFF}` = note: shell formatting not supported; see the documentation for `std::fmt` diff --git a/src/test/ui/mismatched_types/E0631.stderr b/src/test/ui/mismatched_types/E0631.stderr index 442900e0a836a..53f2f54325d57 100644 --- a/src/test/ui/mismatched_types/E0631.stderr +++ b/src/test/ui/mismatched_types/E0631.stderr @@ -6,7 +6,11 @@ error[E0631]: type mismatch in closure arguments | | | expected signature of `fn(usize) -> _` | - = note: required by `foo` +note: required by `foo` + --> $DIR/E0631.rs:13:1 + | +13 | fn foo(_: F) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0631]: type mismatch in closure arguments --> $DIR/E0631.rs:18:5 @@ -16,7 +20,11 @@ error[E0631]: type mismatch in closure arguments | | | expected signature of `fn(usize) -> _` | - = note: required by `bar` +note: required by `bar` + --> $DIR/E0631.rs:14:1 + | +14 | fn bar>(_: F) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0631]: type mismatch in function arguments --> $DIR/E0631.rs:19:5 @@ -27,7 +35,11 @@ error[E0631]: type mismatch in function arguments 19 | foo(f); //~ ERROR type mismatch | ^^^ expected signature of `fn(usize) -> _` | - = note: required by `foo` +note: required by `foo` + --> $DIR/E0631.rs:13:1 + | +13 | fn foo(_: F) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0631]: type mismatch in function arguments --> $DIR/E0631.rs:20:5 @@ -38,7 +50,11 @@ error[E0631]: type mismatch in function arguments 20 | bar(f); //~ ERROR type mismatch | ^^^ expected signature of `fn(usize) -> _` | - = note: required by `bar` +note: required by `bar` + --> $DIR/E0631.rs:14:1 + | +14 | fn bar>(_: F) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 4 previous errors diff --git a/src/test/ui/mismatched_types/closure-arg-count.stderr b/src/test/ui/mismatched_types/closure-arg-count.stderr index d904831ba4e32..4e1523c79d2d4 100644 --- a/src/test/ui/mismatched_types/closure-arg-count.stderr +++ b/src/test/ui/mismatched_types/closure-arg-count.stderr @@ -14,7 +14,7 @@ error[E0593]: closure is expected to take 2 arguments, but it takes 1 argument | | | expected closure that takes 2 arguments -error[E0593]: closure is expected to take 2 distinct arguments, but it takes a single 2-tuple as argument +error[E0593]: closure is expected to take 2 arguments, but it takes 1 argument --> $DIR/closure-arg-count.rs:19:15 | 19 | [1, 2, 3].sort_by(|(tuple, tuple2)| panic!()); @@ -39,62 +39,58 @@ help: change the closure to take multiple arguments instead of a single tuple | ^^^^^^^^^^^^^^^ error[E0593]: closure is expected to take 1 argument, but it takes 0 arguments - --> $DIR/closure-arg-count.rs:23:5 + --> $DIR/closure-arg-count.rs:21:5 | -23 | f(|| panic!()); +21 | f(|| panic!()); | ^ -- takes 0 arguments | | | expected closure that takes 1 argument | - = note: required by `f` +note: required by `f` + --> $DIR/closure-arg-count.rs:13:1 + | +13 | fn f>(_: F) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0593]: closure is expected to take a single 2-tuple as argument, but it takes 2 distinct arguments - --> $DIR/closure-arg-count.rs:26:53 +error[E0593]: closure is expected to take a single tuple as argument, but it takes 2 distinct arguments + --> $DIR/closure-arg-count.rs:24:53 | -26 | let _it = vec![1, 2, 3].into_iter().enumerate().map(|i, x| i); - | ^^^ ------ takes 2 distinct arguments +24 | let _it = vec![1, 2, 3].into_iter().enumerate().map(|i, x| i); + | ^^^ ------ help: consider changing the closure to accept a tuple: `|(i, x)|` | | - | expected closure that takes a single 2-tuple as argument -help: change the closure to accept a tuple instead of individual arguments - | -26 | let _it = vec![1, 2, 3].into_iter().enumerate().map(|(i, x)| i); - | ^^^^^^^^ + | expected closure that takes a single tuple as argument -error[E0593]: closure is expected to take a single 2-tuple as argument, but it takes 2 distinct arguments - --> $DIR/closure-arg-count.rs:28:53 +error[E0593]: closure is expected to take a single tuple as argument, but it takes 2 distinct arguments + --> $DIR/closure-arg-count.rs:26:53 | -28 | let _it = vec![1, 2, 3].into_iter().enumerate().map(|i: usize, x| i); - | ^^^ ------------- takes 2 distinct arguments +26 | let _it = vec![1, 2, 3].into_iter().enumerate().map(|i: usize, x| i); + | ^^^ ------------- help: consider changing the closure to accept a tuple: `|(i, x): (usize, _)|` | | - | expected closure that takes a single 2-tuple as argument -help: change the closure to accept a tuple instead of individual arguments - | -28 | let _it = vec![1, 2, 3].into_iter().enumerate().map(|(i, x)| i); - | ^^^^^^^^ + | expected closure that takes a single tuple as argument error[E0593]: closure is expected to take a single 2-tuple as argument, but it takes 3 distinct arguments - --> $DIR/closure-arg-count.rs:30:53 + --> $DIR/closure-arg-count.rs:28:53 | -30 | let _it = vec![1, 2, 3].into_iter().enumerate().map(|i, x, y| i); +28 | let _it = vec![1, 2, 3].into_iter().enumerate().map(|i, x, y| i); | ^^^ --------- takes 3 distinct arguments | | | expected closure that takes a single 2-tuple as argument error[E0593]: function is expected to take a single 2-tuple as argument, but it takes 0 arguments - --> $DIR/closure-arg-count.rs:32:53 + --> $DIR/closure-arg-count.rs:30:53 | -32 | let _it = vec![1, 2, 3].into_iter().enumerate().map(foo); +30 | let _it = vec![1, 2, 3].into_iter().enumerate().map(foo); | ^^^ expected function that takes a single 2-tuple as argument ... -41 | fn foo() {} +37 | fn foo() {} | -------- takes 0 arguments error[E0593]: closure is expected to take a single 2-tuple as argument, but it takes 3 distinct arguments - --> $DIR/closure-arg-count.rs:35:53 + --> $DIR/closure-arg-count.rs:33:53 | -34 | let bar = |i, x, y| i; +32 | let bar = |i, x, y| i; | --------- takes 3 distinct arguments -35 | let _it = vec![1, 2, 3].into_iter().enumerate().map(bar); +33 | let _it = vec![1, 2, 3].into_iter().enumerate().map(bar); | ^^^ expected closure that takes a single 2-tuple as argument error[E0593]: function is expected to take a single 2-tuple as argument, but it takes 2 distinct arguments diff --git a/src/test/ui/mismatched_types/closure-arg-type-mismatch.stderr b/src/test/ui/mismatched_types/closure-arg-type-mismatch.stderr index 77d3a33276737..dfd02fe23b686 100644 --- a/src/test/ui/mismatched_types/closure-arg-type-mismatch.stderr +++ b/src/test/ui/mismatched_types/closure-arg-type-mismatch.stderr @@ -31,7 +31,11 @@ error[E0631]: type mismatch in function arguments | expected signature of `for<'r> fn(*mut &'r u32) -> _` | found signature of `fn(*mut &'a u32) -> _` | - = note: required by `baz` +note: required by `baz` + --> $DIR/closure-arg-type-mismatch.rs:18:1 + | +18 | fn baz(_: F) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0271]: type mismatch resolving `for<'r> >::Output == ()` --> $DIR/closure-arg-type-mismatch.rs:20:5 @@ -39,7 +43,11 @@ error[E0271]: type mismatch resolving `for<'r> $DIR/closure-arg-type-mismatch.rs:18:1 + | +18 | fn baz(_: F) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 5 previous errors diff --git a/src/test/ui/mismatched_types/closure-mismatch.stderr b/src/test/ui/mismatched_types/closure-mismatch.stderr index 99767ba1afaef..01de7e0749500 100644 --- a/src/test/ui/mismatched_types/closure-mismatch.stderr +++ b/src/test/ui/mismatched_types/closure-mismatch.stderr @@ -5,7 +5,11 @@ error[E0271]: type mismatch resolving `for<'r> <[closure@$DIR/closure-mismatch.r | ^^^ expected bound lifetime parameter, found concrete lifetime | = note: required because of the requirements on the impl of `Foo` for `[closure@$DIR/closure-mismatch.rs:18:9: 18:15]` - = note: required by `baz` +note: required by `baz` + --> $DIR/closure-mismatch.rs:15:1 + | +15 | fn baz(_: T) {} + | ^^^^^^^^^^^^^^^^^^^^ error[E0631]: type mismatch in closure arguments --> $DIR/closure-mismatch.rs:18:5 @@ -16,7 +20,11 @@ error[E0631]: type mismatch in closure arguments | expected signature of `for<'r> fn(&'r ()) -> _` | = note: required because of the requirements on the impl of `Foo` for `[closure@$DIR/closure-mismatch.rs:18:9: 18:15]` - = note: required by `baz` +note: required by `baz` + --> $DIR/closure-mismatch.rs:15:1 + | +15 | fn baz(_: T) {} + | ^^^^^^^^^^^^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/src/test/ui/mismatched_types/fn-variance-1.stderr b/src/test/ui/mismatched_types/fn-variance-1.stderr index 2a27ffd106247..64c260c30ed49 100644 --- a/src/test/ui/mismatched_types/fn-variance-1.stderr +++ b/src/test/ui/mismatched_types/fn-variance-1.stderr @@ -7,7 +7,11 @@ error[E0631]: type mismatch in function arguments 21 | apply(&3, takes_mut); | ^^^^^ expected signature of `fn(&{integer}) -> _` | - = note: required by `apply` +note: required by `apply` + --> $DIR/fn-variance-1.rs:15:1 + | +15 | fn apply(t: T, f: F) where F: FnOnce(T) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0631]: type mismatch in function arguments --> $DIR/fn-variance-1.rs:25:5 @@ -18,7 +22,11 @@ error[E0631]: type mismatch in function arguments 25 | apply(&mut 3, takes_imm); | ^^^^^ expected signature of `fn(&mut {integer}) -> _` | - = note: required by `apply` +note: required by `apply` + --> $DIR/fn-variance-1.rs:15:1 + | +15 | fn apply(t: T, f: F) where F: FnOnce(T) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/src/test/ui/mismatched_types/unboxed-closures-vtable-mismatch.stderr b/src/test/ui/mismatched_types/unboxed-closures-vtable-mismatch.stderr index 8539c8818c025..9c9bbd19c7552 100644 --- a/src/test/ui/mismatched_types/unboxed-closures-vtable-mismatch.stderr +++ b/src/test/ui/mismatched_types/unboxed-closures-vtable-mismatch.stderr @@ -1,12 +1,17 @@ error[E0631]: type mismatch in closure arguments - --> $DIR/unboxed-closures-vtable-mismatch.rs:23:13 + --> $DIR/unboxed-closures-vtable-mismatch.rs:25:13 | -22 | let f = to_fn_mut(|x: usize, y: isize| -> isize { (x as isize) + y }); +23 | let f = to_fn_mut(|x: usize, y: isize| -> isize { (x as isize) + y }); | ----------------------------- found signature of `fn(usize, isize) -> _` -23 | let z = call_it(3, f); +24 | //~^ NOTE found signature of `fn(usize, isize) -> _` +25 | let z = call_it(3, f); | ^^^^^^^ expected signature of `fn(isize, isize) -> _` | - = note: required by `call_it` +note: required by `call_it` + --> $DIR/unboxed-closures-vtable-mismatch.rs:17:1 + | +17 | fn call_itisize>(y: isize, mut f: F) -> isize { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/on-unimplemented/multiple-impls-complex-filtering.rs b/src/test/ui/on-unimplemented/multiple-impls-complex-filtering.rs new file mode 100644 index 0000000000000..b48b08daa1963 --- /dev/null +++ b/src/test/ui/on-unimplemented/multiple-impls-complex-filtering.rs @@ -0,0 +1,61 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test if the on_unimplemented message override works + +#![feature(on_unimplemented)] +#![feature(rustc_attrs)] + +struct Foo(T); +struct Bar(T); + +#[rustc_on_unimplemented( + on(_Self="[i32]", label="trait label if i32"), + label="trait label", + message="trait message", +)] +trait Index { + type Output: ?Sized; + fn index(&self, index: Idx) -> &Self::Output; +} + +#[rustc_on_unimplemented( + label="impl foo {Self} {Idx} {Index}", +)] +impl Index> for [i32] { + type Output = i32; + fn index(&self, _index: Foo) -> &i32 { + loop {} + } +} + +#[rustc_on_unimplemented = "on impl for Bar"] +impl Index> for [i32] { + type Output = i32; + fn index(&self, _index: Bar) -> &i32 { + loop {} + } +} + +#[rustc_error] +fn main() { + Index::index(&[] as &[i32], 2usize); + Index::index(&[] as &[i32], 2u32); + Index::index(&[] as &[u32], 2u32); + //~^ ERROR E0277 + //~| ERROR E0277 + Index::index(&[] as &[i32], Foo(2usize)); + Index::index(&[] as &[i32], Foo(2u32)); + //~^ ERROR E0277 + //~| ERROR E0277 + Index::index(&[] as &[i32], Bar(2u32)); + //~^ ERROR E0277 + //~| ERROR E0277 +} diff --git a/src/test/ui/on-unimplemented/multiple-impls-complex-filtering.stderr b/src/test/ui/on-unimplemented/multiple-impls-complex-filtering.stderr new file mode 100644 index 0000000000000..2ea9b67f26025 --- /dev/null +++ b/src/test/ui/on-unimplemented/multiple-impls-complex-filtering.stderr @@ -0,0 +1,44 @@ +error[E0277]: trait message `[i32]` + --> $DIR/multiple-impls-complex-filtering.rs:46:5 + | +46 | Index::index(&[] as &[i32], 2usize); + | ^^^^^^^^^^^^ u32 message + | + = help: the trait `Index<_>` is not implemented for `[i32]` +note: required by `Index::index` + --> $DIR/multiple-impls-complex-filtering.rs:25:5 + | +25 | fn index(&self, index: Idx) -> &Self::Output; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: trait message `[i32]` + --> $DIR/multiple-impls-complex-filtering.rs:46:5 + | +46 | Index::index(&[] as &[i32], 2usize); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u32 message + | + = help: the trait `Index<_>` is not implemented for `[i32]` + +error[E0277]: trait message `[i32]` + --> $DIR/multiple-impls-complex-filtering.rs:47:5 + | +47 | Index::index(&[] as &[i32], 2u32); + | ^^^^^^^^^^^^ u32 message + | + = help: the trait `Index<_>` is not implemented for `[i32]` +note: required by `Index::index` + --> $DIR/multiple-impls-complex-filtering.rs:25:5 + | +25 | fn index(&self, index: Idx) -> &Self::Output; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: trait message `[i32]` + --> $DIR/multiple-impls-complex-filtering.rs:47:5 + | +47 | Index::index(&[] as &[i32], 2u32); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u32 message + | + = help: the trait `Index<_>` is not implemented for `[i32]` + +error: aborting due to 4 previous errors + diff --git a/src/test/ui/on-unimplemented/multiple-impls.stderr b/src/test/ui/on-unimplemented/multiple-impls.stderr index 1f71be446efb5..cfac3981be284 100644 --- a/src/test/ui/on-unimplemented/multiple-impls.stderr +++ b/src/test/ui/on-unimplemented/multiple-impls.stderr @@ -5,7 +5,11 @@ error[E0277]: the trait bound `[i32]: Index` is not satisfied | ^^^^^^^^^^^^ trait message | = help: the trait `Index` is not implemented for `[i32]` - = note: required by `Index::index` +note: required by `Index::index` + --> $DIR/multiple-impls.rs:22:5 + | +22 | fn index(&self, index: Idx) -> &Self::Output; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0277]: the trait bound `[i32]: Index` is not satisfied --> $DIR/multiple-impls.rs:43:5 @@ -22,7 +26,11 @@ error[E0277]: the trait bound `[i32]: Index>` is not satisfied | ^^^^^^^^^^^^ on impl for Foo | = help: the trait `Index>` is not implemented for `[i32]` - = note: required by `Index::index` +note: required by `Index::index` + --> $DIR/multiple-impls.rs:22:5 + | +22 | fn index(&self, index: Idx) -> &Self::Output; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0277]: the trait bound `[i32]: Index>` is not satisfied --> $DIR/multiple-impls.rs:46:5 @@ -39,7 +47,11 @@ error[E0277]: the trait bound `[i32]: Index>` is not satisfied | ^^^^^^^^^^^^ on impl for Bar | = help: the trait `Index>` is not implemented for `[i32]` - = note: required by `Index::index` +note: required by `Index::index` + --> $DIR/multiple-impls.rs:22:5 + | +22 | fn index(&self, index: Idx) -> &Self::Output; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0277]: the trait bound `[i32]: Index>` is not satisfied --> $DIR/multiple-impls.rs:49:5 diff --git a/src/test/ui/on-unimplemented/on-impl.stderr b/src/test/ui/on-unimplemented/on-impl.stderr index c8c06bf44fd6f..ed2da68f08167 100644 --- a/src/test/ui/on-unimplemented/on-impl.stderr +++ b/src/test/ui/on-unimplemented/on-impl.stderr @@ -5,7 +5,11 @@ error[E0277]: the trait bound `[i32]: Index` is not satisfied | ^^^^^^^^^^^^^^^^^^^ a usize is required to index into a slice | = help: the trait `Index` is not implemented for `[i32]` - = note: required by `Index::index` +note: required by `Index::index` + --> $DIR/on-impl.rs:19:5 + | +19 | fn index(&self, index: Idx) -> &Self::Output; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0277]: the trait bound `[i32]: Index` is not satisfied --> $DIR/on-impl.rs:32:5 diff --git a/src/test/ui/on-unimplemented/on-trait.stderr b/src/test/ui/on-unimplemented/on-trait.stderr index cde56022faea2..028200a5558c8 100644 --- a/src/test/ui/on-unimplemented/on-trait.stderr +++ b/src/test/ui/on-unimplemented/on-trait.stderr @@ -5,7 +5,11 @@ error[E0277]: the trait bound `std::option::Option>: MyFromIte | ^^^^^^^ a collection of type `std::option::Option>` cannot be built from an iterator over elements of type `&u8` | = help: the trait `MyFromIterator<&u8>` is not implemented for `std::option::Option>` - = note: required by `collect` +note: required by `collect` + --> $DIR/on-trait.rs:31:1 + | +31 | fn collect, B: MyFromIterator>(it: I) -> B { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0277]: the trait bound `std::string::String: Bar::Foo` is not satisfied --> $DIR/on-trait.rs:40:21 @@ -14,7 +18,11 @@ error[E0277]: the trait bound `std::string::String: Bar::Foo` is not | ^^^^^^ test error `std::string::String` with `u8` `_` `u32` in `Bar::Foo` | = help: the trait `Bar::Foo` is not implemented for `std::string::String` - = note: required by `foobar` +note: required by `foobar` + --> $DIR/on-trait.rs:21:1 + | +21 | fn foobar>() -> T { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/src/test/ui/span/issue-29595.stderr b/src/test/ui/span/issue-29595.stderr index 81ba0057d7173..9046b90f0e9c3 100644 --- a/src/test/ui/span/issue-29595.stderr +++ b/src/test/ui/span/issue-29595.stderr @@ -4,7 +4,11 @@ error[E0277]: the trait bound `u8: Tr` is not satisfied 17 | let a: u8 = Tr::C; //~ ERROR the trait bound `u8: Tr` is not satisfied | ^^^^^ the trait `Tr` is not implemented for `u8` | - = note: required by `Tr::C` +note: required by `Tr::C` + --> $DIR/issue-29595.rs:13:5 + | +13 | const C: Self; + | ^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/suggestions/try-operator-on-main.stderr b/src/test/ui/suggestions/try-operator-on-main.stderr index 36cdd558b0faf..e97823a3d5d5b 100644 --- a/src/test/ui/suggestions/try-operator-on-main.stderr +++ b/src/test/ui/suggestions/try-operator-on-main.stderr @@ -22,7 +22,11 @@ error[E0277]: the trait bound `(): std::ops::Try` is not satisfied 25 | try_trait_generic::<()>(); //~ ERROR the trait bound | ^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::ops::Try` is not implemented for `()` | - = note: required by `try_trait_generic` +note: required by `try_trait_generic` + --> $DIR/try-operator-on-main.rs:30:1 + | +30 | fn try_trait_generic() -> T { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0277]: the `?` operator can only be applied to values that implement `std::ops::Try` --> $DIR/try-operator-on-main.rs:32:5 diff --git a/src/test/ui/type-check/issue-40294.stderr b/src/test/ui/type-check/issue-40294.stderr index 2ca97aa3ef067..cf270afdeb173 100644 --- a/src/test/ui/type-check/issue-40294.stderr +++ b/src/test/ui/type-check/issue-40294.stderr @@ -10,7 +10,11 @@ error[E0283]: type annotations required: cannot resolve `&'a T: Foo` 21 | | } | |_^ | - = note: required by `Foo` +note: required by `Foo` + --> $DIR/issue-40294.rs:11:1 + | +11 | trait Foo: Sized { + | ^^^^^^^^^^^^^^^^ error: aborting due to previous error From 621e61bff92554d784aab13a507afcc0acdde53b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Sat, 20 Jan 2018 01:33:39 -0800 Subject: [PATCH 3/8] Add filter to detect local crates for rustc_on_unimplemented --- src/libcore/fmt/mod.rs | 17 ++- src/libcore/iter/iterator.rs | 9 +- src/librustc/traits/error_reporting.rs | 4 + src/librustc/traits/on_unimplemented.rs | 3 +- src/test/ui/impl-trait/equality.rs | 2 +- src/test/ui/lint/use_suggestion_json.stderr | 67 ++++++++++- src/test/ui/mismatched_types/binops.rs | 8 +- src/test/ui/mismatched_types/binops.stderr | 8 +- .../ui/on-unimplemented/auxiliary/no_debug.rs | 14 +++ .../multiple-impls-complex-filtering.stderr | 113 ++++++++++++++---- src/test/ui/on-unimplemented/no-debug.rs | 27 +++++ src/test/ui/on-unimplemented/no-debug.stderr | 38 ++++++ src/test/ui/span/multiline-span-simple.rs | 2 +- src/test/ui/span/multiline-span-simple.stderr | 2 +- src/test/ui/suggestions/iterate-str.rs | 19 +++ src/test/ui/suggestions/iterate-str.stderr | 13 ++ 16 files changed, 299 insertions(+), 47 deletions(-) create mode 100644 src/test/ui/on-unimplemented/auxiliary/no_debug.rs create mode 100644 src/test/ui/on-unimplemented/no-debug.rs create mode 100644 src/test/ui/on-unimplemented/no-debug.stderr create mode 100644 src/test/ui/suggestions/iterate-str.rs create mode 100644 src/test/ui/suggestions/iterate-str.stderr diff --git a/src/libcore/fmt/mod.rs b/src/libcore/fmt/mod.rs index 6c8a1c3062b00..8ad5a9861a02f 100644 --- a/src/libcore/fmt/mod.rs +++ b/src/libcore/fmt/mod.rs @@ -530,9 +530,12 @@ impl<'a> Display for Arguments<'a> { /// } /// ``` #[stable(feature = "rust1", since = "1.0.0")] -#[rustc_on_unimplemented = "`{Self}` cannot be formatted using `:?`; if it is \ - defined in your crate, add `#[derive(Debug)]` or \ - manually implement it"] +#[rustc_on_unimplemented( + on(crate_local, label="`{Self}` cannot be formatted using `:?`; \ + add `#[derive(Debug)]` or manually implement `{Debug}`"), + message="`{Self}` doesn't implement `{Debug}`", + label="`{Self}` cannot be formatted using `:?` because it doesn't implement `{Debug}`", +)] #[lang = "debug_trait"] pub trait Debug { /// Formats the value using the given formatter. @@ -593,9 +596,11 @@ pub trait Debug { /// /// println!("The origin is: {}", origin); /// ``` -#[rustc_on_unimplemented = "`{Self}` cannot be formatted with the default \ - formatter; try using `:?` instead if you are using \ - a format string"] +#[rustc_on_unimplemented( + message="`{Self}` doesn't implement `{Display}`", + label="`{Self}` cannot be formatted with the default formatter; \ + try using `:?` instead if you are using a format string", +)] #[stable(feature = "rust1", since = "1.0.0")] pub trait Display { /// Formats the value using the given formatter. diff --git a/src/libcore/iter/iterator.rs b/src/libcore/iter/iterator.rs index 35cd7441c66bc..296fb8733ba6c 100644 --- a/src/libcore/iter/iterator.rs +++ b/src/libcore/iter/iterator.rs @@ -28,8 +28,13 @@ fn _assert_is_object_safe(_: &Iterator) {} /// [module-level documentation]: index.html /// [impl]: index.html#implementing-iterator #[stable(feature = "rust1", since = "1.0.0")] -#[rustc_on_unimplemented = "`{Self}` is not an iterator; maybe try calling \ - `.iter()` or a similar method"] +#[rustc_on_unimplemented( + on( + _Self="&str", + label="`{Self}` is not an iterator; try calling `.chars()` or `.bytes()`" + ), + label="`{Self}` is not an iterator; maybe try calling `.iter()` or a similar method" +)] #[doc(spotlight)] pub trait Iterator { /// The type of the elements being iterated over. diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs index f5ff122668558..be7ecbce8af73 100644 --- a/src/librustc/traits/error_reporting.rs +++ b/src/librustc/traits/error_reporting.rs @@ -384,6 +384,10 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { Some(ty_str.clone()))); } + if let Some(true) = self_ty.ty_to_def_id().map(|def_id| def_id.is_local()) { + flags.push(("crate_local".to_string(), None)); + } + if let Ok(Some(command)) = OnUnimplementedDirective::of_item( self.tcx, trait_ref.def_id, def_id ) { diff --git a/src/librustc/traits/on_unimplemented.rs b/src/librustc/traits/on_unimplemented.rs index a493b7f0bb603..8c2c1cfa45472 100644 --- a/src/librustc/traits/on_unimplemented.rs +++ b/src/librustc/traits/on_unimplemented.rs @@ -185,8 +185,7 @@ impl<'a, 'gcx, 'tcx> OnUnimplementedDirective { let mut message = None; let mut label = None; let mut note = None; - info!("evaluate({:?}, trait_ref={:?}, options={:?})", - self, trait_ref, options); + info!("evaluate({:?}, trait_ref={:?}, options={:?})", self, trait_ref, options); for command in self.subcommands.iter().chain(Some(self)).rev() { if let Some(ref condition) = command.condition { diff --git a/src/test/ui/impl-trait/equality.rs b/src/test/ui/impl-trait/equality.rs index 36df4f0eb4d46..9d9d4cef3119a 100644 --- a/src/test/ui/impl-trait/equality.rs +++ b/src/test/ui/impl-trait/equality.rs @@ -32,7 +32,7 @@ fn sum_to(n: u32) -> impl Foo { 0 } else { n + sum_to(n - 1) - //~^ ERROR the trait bound `u32: std::ops::Add` is not satisfied + //~^ ERROR cannot add `impl Foo` to `u32` } } diff --git a/src/test/ui/lint/use_suggestion_json.stderr b/src/test/ui/lint/use_suggestion_json.stderr index abbf3da513a6f..86c2ad4c0e7a4 100644 --- a/src/test/ui/lint/use_suggestion_json.stderr +++ b/src/test/ui/lint/use_suggestion_json.stderr @@ -2,7 +2,72 @@ "message": "cannot find type `Iter` in this scope", "code": { "code": "E0412", - "explanation": null + "explanation": " +The type name used is not in scope. + +Erroneous code examples: + +```compile_fail,E0412 +impl Something {} // error: type name `Something` is not in scope + +// or: + +trait Foo { + fn bar(N); // error: type name `N` is not in scope +} + +// or: + +fn foo(x: T) {} // type name `T` is not in scope +``` + +To fix this error, please verify you didn't misspell the type name, you did +declare it or imported it into the scope. Examples: + +``` +struct Something; + +impl Something {} // ok! + +// or: + +trait Foo { + type N; + + fn bar(_: Self::N); // ok! +} + +// or: + +fn foo(x: T) {} // ok! +``` + +Another case that causes this error is when a type is imported into a parent +module. To fix this, you can follow the suggestion and use File directly or +`use super::File;` which will import the types from the parent namespace. An +example that causes this error is below: + +```compile_fail,E0412 +use std::fs::File; + +mod foo { + fn some_function(f: File) {} +} +``` + +``` +use std::fs::File; + +mod foo { + // either + use super::File; + // or + // use std::fs::File; + fn foo(f: File) {} +} +# fn main() {} // don't insert it for us; that'll break imports +``` +" }, "level": "error", "spans": [ diff --git a/src/test/ui/mismatched_types/binops.rs b/src/test/ui/mismatched_types/binops.rs index e45616cd67a81..5144b59955cc9 100644 --- a/src/test/ui/mismatched_types/binops.rs +++ b/src/test/ui/mismatched_types/binops.rs @@ -9,10 +9,10 @@ // except according to those terms. fn main() { - 1 + Some(1); //~ ERROR is not satisfied - 2 as usize - Some(1); //~ ERROR is not satisfied - 3 * (); //~ ERROR is not satisfied - 4 / ""; //~ ERROR is not satisfied + 1 + Some(1); //~ ERROR cannot add `std::option::Option<{integer}>` to `{integer}` + 2 as usize - Some(1); //~ ERROR cannot substract `std::option::Option<{integer}>` from `usize` + 3 * (); //~ ERROR cannot multiply `()` to `{integer}` + 4 / ""; //~ ERROR cannot divide `{integer}` by `&str` 5 < String::new(); //~ ERROR is not satisfied 6 == Ok(1); //~ ERROR is not satisfied } diff --git a/src/test/ui/mismatched_types/binops.stderr b/src/test/ui/mismatched_types/binops.stderr index 57e66794a58a9..1b7fba050636f 100644 --- a/src/test/ui/mismatched_types/binops.stderr +++ b/src/test/ui/mismatched_types/binops.stderr @@ -1,7 +1,7 @@ error[E0277]: cannot add `std::option::Option<{integer}>` to `{integer}` --> $DIR/binops.rs:12:7 | -12 | 1 + Some(1); //~ ERROR is not satisfied +12 | 1 + Some(1); //~ ERROR cannot add `std::option::Option<{integer}>` to `{integer}` | ^ no implementation for `{integer} + std::option::Option<{integer}>` | = help: the trait `std::ops::Add>` is not implemented for `{integer}` @@ -9,7 +9,7 @@ error[E0277]: cannot add `std::option::Option<{integer}>` to `{integer}` error[E0277]: cannot substract `std::option::Option<{integer}>` from `usize` --> $DIR/binops.rs:13:16 | -13 | 2 as usize - Some(1); //~ ERROR is not satisfied +13 | 2 as usize - Some(1); //~ ERROR cannot substract `std::option::Option<{integer}>` from `usize` | ^ no implementation for `usize - std::option::Option<{integer}>` | = help: the trait `std::ops::Sub>` is not implemented for `usize` @@ -17,7 +17,7 @@ error[E0277]: cannot substract `std::option::Option<{integer}>` from `usize` error[E0277]: cannot multiply `()` to `{integer}` --> $DIR/binops.rs:14:7 | -14 | 3 * (); //~ ERROR is not satisfied +14 | 3 * (); //~ ERROR cannot multiply `()` to `{integer}` | ^ no implementation for `{integer} * ()` | = help: the trait `std::ops::Mul<()>` is not implemented for `{integer}` @@ -25,7 +25,7 @@ error[E0277]: cannot multiply `()` to `{integer}` error[E0277]: cannot divide `{integer}` by `&str` --> $DIR/binops.rs:15:7 | -15 | 4 / ""; //~ ERROR is not satisfied +15 | 4 / ""; //~ ERROR cannot divide `{integer}` by `&str` | ^ no implementation for `{integer} / &str` | = help: the trait `std::ops::Div<&str>` is not implemented for `{integer}` diff --git a/src/test/ui/on-unimplemented/auxiliary/no_debug.rs b/src/test/ui/on-unimplemented/auxiliary/no_debug.rs new file mode 100644 index 0000000000000..0f833c6263722 --- /dev/null +++ b/src/test/ui/on-unimplemented/auxiliary/no_debug.rs @@ -0,0 +1,14 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. +// ignore-tidy-linelength + +#![crate_type = "lib"] + +pub struct Bar; diff --git a/src/test/ui/on-unimplemented/multiple-impls-complex-filtering.stderr b/src/test/ui/on-unimplemented/multiple-impls-complex-filtering.stderr index 2ea9b67f26025..c4bac12eebdbe 100644 --- a/src/test/ui/on-unimplemented/multiple-impls-complex-filtering.stderr +++ b/src/test/ui/on-unimplemented/multiple-impls-complex-filtering.stderr @@ -1,44 +1,107 @@ -error[E0277]: trait message `[i32]` - --> $DIR/multiple-impls-complex-filtering.rs:46:5 +error[E0277]: trait message + --> $DIR/multiple-impls-complex-filtering.rs:49:5 | -46 | Index::index(&[] as &[i32], 2usize); - | ^^^^^^^^^^^^ u32 message +49 | Index::index(&[] as &[i32], 2usize); + | ^^^^^^^^^^^^ trait label if i32 | - = help: the trait `Index<_>` is not implemented for `[i32]` + = help: the trait `Index` is not implemented for `[i32]` note: required by `Index::index` - --> $DIR/multiple-impls-complex-filtering.rs:25:5 + --> $DIR/multiple-impls-complex-filtering.rs:26:5 | -25 | fn index(&self, index: Idx) -> &Self::Output; +26 | fn index(&self, index: Idx) -> &Self::Output; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0277]: trait message `[i32]` - --> $DIR/multiple-impls-complex-filtering.rs:46:5 +error[E0277]: trait message + --> $DIR/multiple-impls-complex-filtering.rs:49:5 | -46 | Index::index(&[] as &[i32], 2usize); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u32 message +49 | Index::index(&[] as &[i32], 2usize); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ trait label if i32 | - = help: the trait `Index<_>` is not implemented for `[i32]` + = help: the trait `Index` is not implemented for `[i32]` -error[E0277]: trait message `[i32]` - --> $DIR/multiple-impls-complex-filtering.rs:47:5 +error[E0277]: trait message + --> $DIR/multiple-impls-complex-filtering.rs:50:5 | -47 | Index::index(&[] as &[i32], 2u32); - | ^^^^^^^^^^^^ u32 message +50 | Index::index(&[] as &[i32], 2u32); + | ^^^^^^^^^^^^ trait label if i32 | - = help: the trait `Index<_>` is not implemented for `[i32]` + = help: the trait `Index` is not implemented for `[i32]` note: required by `Index::index` - --> $DIR/multiple-impls-complex-filtering.rs:25:5 + --> $DIR/multiple-impls-complex-filtering.rs:26:5 | -25 | fn index(&self, index: Idx) -> &Self::Output; +26 | fn index(&self, index: Idx) -> &Self::Output; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0277]: trait message `[i32]` - --> $DIR/multiple-impls-complex-filtering.rs:47:5 +error[E0277]: trait message + --> $DIR/multiple-impls-complex-filtering.rs:50:5 | -47 | Index::index(&[] as &[i32], 2u32); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u32 message +50 | Index::index(&[] as &[i32], 2u32); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ trait label if i32 | - = help: the trait `Index<_>` is not implemented for `[i32]` + = help: the trait `Index` is not implemented for `[i32]` -error: aborting due to 4 previous errors +error[E0277]: trait message + --> $DIR/multiple-impls-complex-filtering.rs:51:5 + | +51 | Index::index(&[] as &[u32], 2u32); + | ^^^^^^^^^^^^ trait label + | + = help: the trait `Index<_>` is not implemented for `[u32]` +note: required by `Index::index` + --> $DIR/multiple-impls-complex-filtering.rs:26:5 + | +26 | fn index(&self, index: Idx) -> &Self::Output; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: trait message + --> $DIR/multiple-impls-complex-filtering.rs:51:5 + | +51 | Index::index(&[] as &[u32], 2u32); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ trait label + | + = help: the trait `Index<_>` is not implemented for `[u32]` + +error[E0277]: the trait bound `[i32]: Index>` is not satisfied + --> $DIR/multiple-impls-complex-filtering.rs:55:5 + | +55 | Index::index(&[] as &[i32], Foo(2u32)); + | ^^^^^^^^^^^^ impl foo [i32] Foo Index + | + = help: the trait `Index>` is not implemented for `[i32]` +note: required by `Index::index` + --> $DIR/multiple-impls-complex-filtering.rs:26:5 + | +26 | fn index(&self, index: Idx) -> &Self::Output; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `[i32]: Index>` is not satisfied + --> $DIR/multiple-impls-complex-filtering.rs:55:5 + | +55 | Index::index(&[] as &[i32], Foo(2u32)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl foo [i32] Foo Index + | + = help: the trait `Index>` is not implemented for `[i32]` + +error[E0277]: the trait bound `[i32]: Index>` is not satisfied + --> $DIR/multiple-impls-complex-filtering.rs:58:5 + | +58 | Index::index(&[] as &[i32], Bar(2u32)); + | ^^^^^^^^^^^^ on impl for Bar + | + = help: the trait `Index>` is not implemented for `[i32]` +note: required by `Index::index` + --> $DIR/multiple-impls-complex-filtering.rs:26:5 + | +26 | fn index(&self, index: Idx) -> &Self::Output; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `[i32]: Index>` is not satisfied + --> $DIR/multiple-impls-complex-filtering.rs:58:5 + | +58 | Index::index(&[] as &[i32], Bar(2u32)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ on impl for Bar + | + = help: the trait `Index>` is not implemented for `[i32]` + +error: aborting due to 10 previous errors diff --git a/src/test/ui/on-unimplemented/no-debug.rs b/src/test/ui/on-unimplemented/no-debug.rs new file mode 100644 index 0000000000000..fff6122c6b34b --- /dev/null +++ b/src/test/ui/on-unimplemented/no-debug.rs @@ -0,0 +1,27 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:no_debug.rs + +extern crate no_debug; + +use no_debug::Bar; + +struct Foo; + +fn main() { + println!("{:?} {:?}", Foo, Bar); + println!("{} {}", Foo, Bar); +} +//~^^^ ERROR `Foo` doesn't implement `std::fmt::Debug` +//~| ERROR `no_debug::Bar` doesn't implement `std::fmt::Debug` +//~^^^^ ERROR `Foo` doesn't implement `std::fmt::Display` +//~| ERROR `no_debug::Bar` doesn't implement `std::fmt::Display` + diff --git a/src/test/ui/on-unimplemented/no-debug.stderr b/src/test/ui/on-unimplemented/no-debug.stderr new file mode 100644 index 0000000000000..af5b1e91211fb --- /dev/null +++ b/src/test/ui/on-unimplemented/no-debug.stderr @@ -0,0 +1,38 @@ +error[E0277]: `Foo` doesn't implement `std::fmt::Debug` + --> $DIR/no-debug.rs:20:27 + | +20 | println!("{:?} {:?}", Foo, Bar); + | ^^^ `Foo` cannot be formatted using `:?`; add `#[derive(Debug)]` or manually implement `std::fmt::Debug` + | + = help: the trait `std::fmt::Debug` is not implemented for `Foo` + = note: required by `std::fmt::Debug::fmt` + +error[E0277]: `no_debug::Bar` doesn't implement `std::fmt::Debug` + --> $DIR/no-debug.rs:20:32 + | +20 | println!("{:?} {:?}", Foo, Bar); + | ^^^ `no_debug::Bar` cannot be formatted using `:?` because it doesn't implement `std::fmt::Debug` + | + = help: the trait `std::fmt::Debug` is not implemented for `no_debug::Bar` + = note: required by `std::fmt::Debug::fmt` + +error[E0277]: `Foo` doesn't implement `std::fmt::Display` + --> $DIR/no-debug.rs:21:23 + | +21 | println!("{} {}", Foo, Bar); + | ^^^ `Foo` cannot be formatted with the default formatter; try using `:?` instead if you are using a format string + | + = help: the trait `std::fmt::Display` is not implemented for `Foo` + = note: required by `std::fmt::Display::fmt` + +error[E0277]: `no_debug::Bar` doesn't implement `std::fmt::Display` + --> $DIR/no-debug.rs:21:28 + | +21 | println!("{} {}", Foo, Bar); + | ^^^ `no_debug::Bar` cannot be formatted with the default formatter; try using `:?` instead if you are using a format string + | + = help: the trait `std::fmt::Display` is not implemented for `no_debug::Bar` + = note: required by `std::fmt::Display::fmt` + +error: aborting due to 4 previous errors + diff --git a/src/test/ui/span/multiline-span-simple.rs b/src/test/ui/span/multiline-span-simple.rs index f8e4cbcbf191f..dd09534480e10 100644 --- a/src/test/ui/span/multiline-span-simple.rs +++ b/src/test/ui/span/multiline-span-simple.rs @@ -20,7 +20,7 @@ fn main() { let x = 1; let y = 2; let z = 3; - foo(1 as u32 + //~ ERROR not satisfied + foo(1 as u32 + //~ ERROR cannot add `()` to `u32` bar(x, diff --git a/src/test/ui/span/multiline-span-simple.stderr b/src/test/ui/span/multiline-span-simple.stderr index b6182825fc278..a18dfeb31d9ef 100644 --- a/src/test/ui/span/multiline-span-simple.stderr +++ b/src/test/ui/span/multiline-span-simple.stderr @@ -1,7 +1,7 @@ error[E0277]: cannot add `()` to `u32` --> $DIR/multiline-span-simple.rs:23:18 | -23 | foo(1 as u32 + //~ ERROR not satisfied +23 | foo(1 as u32 + //~ ERROR cannot add `()` to `u32` | ^ no implementation for `u32 + ()` | = help: the trait `std::ops::Add<()>` is not implemented for `u32` diff --git a/src/test/ui/suggestions/iterate-str.rs b/src/test/ui/suggestions/iterate-str.rs new file mode 100644 index 0000000000000..1022491b84a36 --- /dev/null +++ b/src/test/ui/suggestions/iterate-str.rs @@ -0,0 +1,19 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + for c in "foobarbaz" { + println!("{}", c); + } + //~^^^ ERROR the trait bound `&str: std::iter::Iterator` is not satisfied + //~| NOTE `&str` is not an iterator; try calling `.chars()` or `.bytes()` + //~| HELP the trait `std::iter::Iterator` is not implemented for `&str` + //~| NOTE required by `std::iter::IntoIterator::into_iter` +} diff --git a/src/test/ui/suggestions/iterate-str.stderr b/src/test/ui/suggestions/iterate-str.stderr new file mode 100644 index 0000000000000..59da6d70c0236 --- /dev/null +++ b/src/test/ui/suggestions/iterate-str.stderr @@ -0,0 +1,13 @@ +error[E0277]: the trait bound `&str: std::iter::Iterator` is not satisfied + --> $DIR/iterate-str.rs:12:5 + | +12 | / for c in "foobarbaz" { +13 | | println!("{}", c); +14 | | } + | |_____^ `&str` is not an iterator; try calling `.chars()` or `.bytes()` + | + = help: the trait `std::iter::Iterator` is not implemented for `&str` + = note: required by `std::iter::IntoIterator::into_iter` + +error: aborting due to previous error + From 2dee07b12a2dd08a281a84146dc7085299389add Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Sat, 20 Jan 2018 02:36:39 -0800 Subject: [PATCH 4/8] Remove cast suggestions --- src/libcore/ops/arith.rs | 72 ------------ .../multiple-impls-complex-filtering.rs | 61 ---------- .../multiple-impls-complex-filtering.stderr | 107 ------------------ 3 files changed, 240 deletions(-) delete mode 100644 src/test/ui/on-unimplemented/multiple-impls-complex-filtering.rs delete mode 100644 src/test/ui/on-unimplemented/multiple-impls-complex-filtering.stderr diff --git a/src/libcore/ops/arith.rs b/src/libcore/ops/arith.rs index 47617b22dd34d..d0d0c09869e9d 100644 --- a/src/libcore/ops/arith.rs +++ b/src/libcore/ops/arith.rs @@ -76,78 +76,6 @@ #[lang = "add"] #[stable(feature = "rust1", since = "1.0.0")] #[rustc_on_unimplemented( - on( - any( - all(_Self="i128", RHS="i64"), - all(_Self="i128", RHS="i32"), - all(_Self="i128", RHS="i16"), - all(_Self="i128", RHS="i8"), - all(_Self="i64", RHS="i32"), - all(_Self="i64", RHS="i16"), - all(_Self="i64", RHS="i8"), - all(_Self="i32", RHS="i16"), - all(_Self="i32", RHS="i8"), - all(_Self="i16", RHS="i8"), - all(_Self="u128", RHS="u64"), - all(_Self="u128", RHS="u32"), - all(_Self="u128", RHS="u16"), - all(_Self="u128", RHS="u8"), - all(_Self="u64", RHS="u32"), - all(_Self="u64", RHS="u16"), - all(_Self="u64", RHS="u8"), - all(_Self="u32", RHS="u16"), - all(_Self="u32", RHS="u8"), - all(_Self="u16", RHS="u8"), - all(_Self="f64", RHS="i32"), - all(_Self="f64", RHS="i16"), - all(_Self="f64", RHS="i8"), - all(_Self="f64", RHS="u32"), - all(_Self="f64", RHS="u16"), - all(_Self="f64", RHS="u8"), - all(_Self="f32", RHS="i16"), - all(_Self="f32", RHS="i8"), - all(_Self="f32", RHS="u16"), - all(_Self="f32", RHS="u8"), - ), - label="no implementation for `{Self} + {RHS}`, but you can safely cast \ - `{RHS}` into `{Self}` using `as {Self}`", - ), - on( - any( - all(RHS="i128", _Self="i64"), - all(RHS="i128", _Self="i32"), - all(RHS="i128", _Self="i16"), - all(RHS="i128", _Self="i8"), - all(RHS="i64", _Self="i32"), - all(RHS="i64", _Self="i16"), - all(RHS="i64", _Self="i8"), - all(RHS="i32", _Self="i16"), - all(RHS="i32", _Self="i8"), - all(RHS="i16", _Self="i8"), - all(RHS="u128", _Self="u64"), - all(RHS="u128", _Self="u32"), - all(RHS="u128", _Self="u16"), - all(RHS="u128", _Self="u8"), - all(RHS="u64", _Self="u32"), - all(RHS="u64", _Self="u16"), - all(RHS="u64", _Self="u8"), - all(RHS="u32", _Self="u16"), - all(RHS="u32", _Self="u8"), - all(RHS="u16", _Self="u8"), - all(RHS="f64", _Self="i32"), - all(RHS="f64", _Self="i16"), - all(RHS="f64", _Self="i8"), - all(RHS="f64", _Self="u32"), - all(RHS="f64", _Self="u16"), - all(RHS="f64", _Self="u8"), - all(RHS="f32", _Self="i16"), - all(RHS="f32", _Self="i8"), - all(RHS="f32", _Self="u16"), - all(RHS="f32", _Self="u8"), - ), - label="no implementation for `{Self} + {RHS}`, but you can safely cast \ - `{Self}` into `{RHS}` using `as {RHS}`", - ), on( all(_Self="{integer}", RHS="{float}"), message="cannot add a float to an integer", diff --git a/src/test/ui/on-unimplemented/multiple-impls-complex-filtering.rs b/src/test/ui/on-unimplemented/multiple-impls-complex-filtering.rs deleted file mode 100644 index b48b08daa1963..0000000000000 --- a/src/test/ui/on-unimplemented/multiple-impls-complex-filtering.rs +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test if the on_unimplemented message override works - -#![feature(on_unimplemented)] -#![feature(rustc_attrs)] - -struct Foo(T); -struct Bar(T); - -#[rustc_on_unimplemented( - on(_Self="[i32]", label="trait label if i32"), - label="trait label", - message="trait message", -)] -trait Index { - type Output: ?Sized; - fn index(&self, index: Idx) -> &Self::Output; -} - -#[rustc_on_unimplemented( - label="impl foo {Self} {Idx} {Index}", -)] -impl Index> for [i32] { - type Output = i32; - fn index(&self, _index: Foo) -> &i32 { - loop {} - } -} - -#[rustc_on_unimplemented = "on impl for Bar"] -impl Index> for [i32] { - type Output = i32; - fn index(&self, _index: Bar) -> &i32 { - loop {} - } -} - -#[rustc_error] -fn main() { - Index::index(&[] as &[i32], 2usize); - Index::index(&[] as &[i32], 2u32); - Index::index(&[] as &[u32], 2u32); - //~^ ERROR E0277 - //~| ERROR E0277 - Index::index(&[] as &[i32], Foo(2usize)); - Index::index(&[] as &[i32], Foo(2u32)); - //~^ ERROR E0277 - //~| ERROR E0277 - Index::index(&[] as &[i32], Bar(2u32)); - //~^ ERROR E0277 - //~| ERROR E0277 -} diff --git a/src/test/ui/on-unimplemented/multiple-impls-complex-filtering.stderr b/src/test/ui/on-unimplemented/multiple-impls-complex-filtering.stderr deleted file mode 100644 index c4bac12eebdbe..0000000000000 --- a/src/test/ui/on-unimplemented/multiple-impls-complex-filtering.stderr +++ /dev/null @@ -1,107 +0,0 @@ -error[E0277]: trait message - --> $DIR/multiple-impls-complex-filtering.rs:49:5 - | -49 | Index::index(&[] as &[i32], 2usize); - | ^^^^^^^^^^^^ trait label if i32 - | - = help: the trait `Index` is not implemented for `[i32]` -note: required by `Index::index` - --> $DIR/multiple-impls-complex-filtering.rs:26:5 - | -26 | fn index(&self, index: Idx) -> &Self::Output; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0277]: trait message - --> $DIR/multiple-impls-complex-filtering.rs:49:5 - | -49 | Index::index(&[] as &[i32], 2usize); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ trait label if i32 - | - = help: the trait `Index` is not implemented for `[i32]` - -error[E0277]: trait message - --> $DIR/multiple-impls-complex-filtering.rs:50:5 - | -50 | Index::index(&[] as &[i32], 2u32); - | ^^^^^^^^^^^^ trait label if i32 - | - = help: the trait `Index` is not implemented for `[i32]` -note: required by `Index::index` - --> $DIR/multiple-impls-complex-filtering.rs:26:5 - | -26 | fn index(&self, index: Idx) -> &Self::Output; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0277]: trait message - --> $DIR/multiple-impls-complex-filtering.rs:50:5 - | -50 | Index::index(&[] as &[i32], 2u32); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ trait label if i32 - | - = help: the trait `Index` is not implemented for `[i32]` - -error[E0277]: trait message - --> $DIR/multiple-impls-complex-filtering.rs:51:5 - | -51 | Index::index(&[] as &[u32], 2u32); - | ^^^^^^^^^^^^ trait label - | - = help: the trait `Index<_>` is not implemented for `[u32]` -note: required by `Index::index` - --> $DIR/multiple-impls-complex-filtering.rs:26:5 - | -26 | fn index(&self, index: Idx) -> &Self::Output; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0277]: trait message - --> $DIR/multiple-impls-complex-filtering.rs:51:5 - | -51 | Index::index(&[] as &[u32], 2u32); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ trait label - | - = help: the trait `Index<_>` is not implemented for `[u32]` - -error[E0277]: the trait bound `[i32]: Index>` is not satisfied - --> $DIR/multiple-impls-complex-filtering.rs:55:5 - | -55 | Index::index(&[] as &[i32], Foo(2u32)); - | ^^^^^^^^^^^^ impl foo [i32] Foo Index - | - = help: the trait `Index>` is not implemented for `[i32]` -note: required by `Index::index` - --> $DIR/multiple-impls-complex-filtering.rs:26:5 - | -26 | fn index(&self, index: Idx) -> &Self::Output; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0277]: the trait bound `[i32]: Index>` is not satisfied - --> $DIR/multiple-impls-complex-filtering.rs:55:5 - | -55 | Index::index(&[] as &[i32], Foo(2u32)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl foo [i32] Foo Index - | - = help: the trait `Index>` is not implemented for `[i32]` - -error[E0277]: the trait bound `[i32]: Index>` is not satisfied - --> $DIR/multiple-impls-complex-filtering.rs:58:5 - | -58 | Index::index(&[] as &[i32], Bar(2u32)); - | ^^^^^^^^^^^^ on impl for Bar - | - = help: the trait `Index>` is not implemented for `[i32]` -note: required by `Index::index` - --> $DIR/multiple-impls-complex-filtering.rs:26:5 - | -26 | fn index(&self, index: Idx) -> &Self::Output; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0277]: the trait bound `[i32]: Index>` is not satisfied - --> $DIR/multiple-impls-complex-filtering.rs:58:5 - | -58 | Index::index(&[] as &[i32], Bar(2u32)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ on impl for Bar - | - = help: the trait `Index>` is not implemented for `[i32]` - -error: aborting due to 10 previous errors - From 27a23db66032be9be96e697fdda50e73b0b90cc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Mon, 22 Jan 2018 19:03:51 -0800 Subject: [PATCH 5/8] Rework `parse_ident_attr` --- src/libsyntax/parse/parser.rs | 51 ++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 9e8c4d3de2220..5b55f0f232877 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -761,29 +761,37 @@ impl<'a> Parser<'a> { }) } + fn expected_ident_found(&self) -> DiagnosticBuilder<'a> { + let mut err = self.struct_span_err(self.span, + &format!("expected identifier, found {}", + self.this_token_descr())); + if let Some(token_descr) = self.token_descr() { + err.span_label(self.span, format!("expected identifier, found {}", token_descr)); + } else { + err.span_label(self.span, "expected identifier"); + } + err + } + pub fn parse_ident(&mut self) -> PResult<'a, ast::Ident> { - self.parse_ident_common(true, false) + self.parse_ident_common(true) } pub fn parse_ident_attr(&mut self) -> PResult<'a, ast::Ident> { - self.parse_ident_common(true, true) + match self.token { + token::Ident(i) if i.name == keywords::SelfType.name() { + self.bump(); + Ok(i) + } + _ => self.parse_ident(), + } } - fn parse_ident_common(&mut self, recover: bool, accept_self: bool) -> PResult<'a, ast::Ident> { + fn parse_ident_common(&mut self, recover: bool) -> PResult<'a, ast::Ident> { match self.token { token::Ident(i) => { - if self.token.is_reserved_ident() - && !(accept_self && i.name == keywords::SelfType.name()) - { - let mut err = self.struct_span_err(self.span, - &format!("expected identifier, found {}", - self.this_token_descr())); - if let Some(token_descr) = self.token_descr() { - err.span_label(self.span, format!("expected identifier, found {}", - token_descr)); - } else { - err.span_label(self.span, "expected identifier"); - } + if self.token.is_reserved_ident() { + let mut err = self.expected_ident_found(); if recover { err.emit(); } else { @@ -797,14 +805,7 @@ impl<'a> Parser<'a> { Err(if self.prev_token_kind == PrevTokenKind::DocComment { self.span_fatal_err(self.prev_span, Error::UselessDocComment) } else { - let mut err = self.fatal(&format!("expected identifier, found `{}`", - self.this_token_to_string())); - if let Some(token_descr) = self.token_descr() { - err.span_label(self.span, format!("expected identifier, found {}", - token_descr)); - } else { - err.span_label(self.span, "expected identifier"); - } + let mut err = self.expected_ident_found(); if self.token == token::Underscore { err.note("`_` is a wildcard pattern, not an identifier"); } @@ -2117,7 +2118,7 @@ impl<'a> Parser<'a> { self.bump(); Ok(Ident::with_empty_ctxt(name)) } else { - self.parse_ident_common(false, false) + self.parse_ident_common(false) } } @@ -2134,7 +2135,7 @@ impl<'a> Parser<'a> { hi = self.prev_span; (fieldname, self.parse_expr()?, false) } else { - let fieldname = self.parse_ident_common(false, false)?; + let fieldname = self.parse_ident_common(false)?; hi = self.prev_span; // Mimic `x: x` for the `x` field shorthand. From f7c61783e4cbc169955c7e633ecf629ed901a54e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Mon, 22 Jan 2018 19:13:06 -0800 Subject: [PATCH 6/8] Fix tests --- src/libsyntax/parse/parser.rs | 2 +- src/test/compile-fail/const-eval-overflow-4b.rs | 2 +- src/test/compile-fail/ufcs-qpath-self-mismatch.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 5b55f0f232877..380170207301a 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -779,7 +779,7 @@ impl<'a> Parser<'a> { pub fn parse_ident_attr(&mut self) -> PResult<'a, ast::Ident> { match self.token { - token::Ident(i) if i.name == keywords::SelfType.name() { + token::Ident(i) if i.name == keywords::SelfType.name() => { self.bump(); Ok(i) } diff --git a/src/test/compile-fail/const-eval-overflow-4b.rs b/src/test/compile-fail/const-eval-overflow-4b.rs index 02072e9a1a1f6..6028df1883967 100644 --- a/src/test/compile-fail/const-eval-overflow-4b.rs +++ b/src/test/compile-fail/const-eval-overflow-4b.rs @@ -22,7 +22,7 @@ const A_I8_T : [u32; (i8::MAX as i8 + 1u8) as usize] //~^ ERROR mismatched types //~| expected i8, found u8 - //~| ERROR the trait bound `i8: std::ops::Add` is not satisfied + //~| ERROR cannot add `u8` to `i8` = [0; (i8::MAX as usize) + 1]; diff --git a/src/test/compile-fail/ufcs-qpath-self-mismatch.rs b/src/test/compile-fail/ufcs-qpath-self-mismatch.rs index 94a98b1582af1..caf510071bd68 100644 --- a/src/test/compile-fail/ufcs-qpath-self-mismatch.rs +++ b/src/test/compile-fail/ufcs-qpath-self-mismatch.rs @@ -12,7 +12,7 @@ use std::ops::Add; fn main() { >::add(1, 2); - //~^ ERROR `i32: std::ops::Add` is not satisfied + //~^ ERROR cannot add `u32` to `i32` >::add(1u32, 2); //~^ ERROR mismatched types >::add(1, 2u32); From 378e73e6db0b4d47586f4e3ec975e43ef530ac99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Thu, 1 Feb 2018 12:12:55 -0800 Subject: [PATCH 7/8] Remove support for `Self` in attributes --- src/librustc/traits/error_reporting.rs | 2 -- src/libsyntax/parse/parser.rs | 8 +------- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs index be7ecbce8af73..d5ac63431445e 100644 --- a/src/librustc/traits/error_reporting.rs +++ b/src/librustc/traits/error_reporting.rs @@ -372,9 +372,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { let generics = self.tcx.generics_of(def_id); let self_ty = trait_ref.self_ty(); let self_ty_str = self_ty.to_string(); - // FIXME: remove once `Self` is accepted by the compiler flags.push(("_Self".to_string(), Some(self_ty_str.clone()))); - flags.push(("Self".to_string(), Some(self_ty_str.clone()))); for param in generics.types.iter() { let name = param.name.as_str().to_string(); diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 380170207301a..9d573ea0e7c03 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -778,13 +778,7 @@ impl<'a> Parser<'a> { } pub fn parse_ident_attr(&mut self) -> PResult<'a, ast::Ident> { - match self.token { - token::Ident(i) if i.name == keywords::SelfType.name() => { - self.bump(); - Ok(i) - } - _ => self.parse_ident(), - } + self.parse_ident() } fn parse_ident_common(&mut self, recover: bool) -> PResult<'a, ast::Ident> { From fd3f2312a75bcc4c8121ad324a012c3b8befb61c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Thu, 1 Feb 2018 14:16:53 -0800 Subject: [PATCH 8/8] Fix test after rebase --- src/libsyntax/parse/attr.rs | 2 +- src/libsyntax/parse/parser.rs | 4 -- .../mismatched_types/closure-arg-count.stderr | 50 +++++++++++-------- src/test/ui/suggestions/for-c-in-str.stderr | 2 +- src/test/ui/suggestions/iterate-str.rs | 19 ------- src/test/ui/suggestions/iterate-str.stderr | 13 ----- 6 files changed, 31 insertions(+), 59 deletions(-) delete mode 100644 src/test/ui/suggestions/iterate-str.rs delete mode 100644 src/test/ui/suggestions/iterate-str.stderr diff --git a/src/libsyntax/parse/attr.rs b/src/libsyntax/parse/attr.rs index b01f479895b10..053746b579dcb 100644 --- a/src/libsyntax/parse/attr.rs +++ b/src/libsyntax/parse/attr.rs @@ -235,7 +235,7 @@ impl<'a> Parser<'a> { } let lo = self.span; - let ident = self.parse_ident_attr()?; + let ident = self.parse_ident()?; let node = self.parse_meta_item_kind()?; Ok(ast::MetaItem { name: ident.name, node: node, span: lo.to(self.prev_span) }) } diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 9d573ea0e7c03..4c61ab6bd7810 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -777,10 +777,6 @@ impl<'a> Parser<'a> { self.parse_ident_common(true) } - pub fn parse_ident_attr(&mut self) -> PResult<'a, ast::Ident> { - self.parse_ident() - } - fn parse_ident_common(&mut self, recover: bool) -> PResult<'a, ast::Ident> { match self.token { token::Ident(i) => { diff --git a/src/test/ui/mismatched_types/closure-arg-count.stderr b/src/test/ui/mismatched_types/closure-arg-count.stderr index 4e1523c79d2d4..be00ee4d74e7e 100644 --- a/src/test/ui/mismatched_types/closure-arg-count.stderr +++ b/src/test/ui/mismatched_types/closure-arg-count.stderr @@ -14,7 +14,7 @@ error[E0593]: closure is expected to take 2 arguments, but it takes 1 argument | | | expected closure that takes 2 arguments -error[E0593]: closure is expected to take 2 arguments, but it takes 1 argument +error[E0593]: closure is expected to take 2 distinct arguments, but it takes a single 2-tuple as argument --> $DIR/closure-arg-count.rs:19:15 | 19 | [1, 2, 3].sort_by(|(tuple, tuple2)| panic!()); @@ -39,9 +39,9 @@ help: change the closure to take multiple arguments instead of a single tuple | ^^^^^^^^^^^^^^^ error[E0593]: closure is expected to take 1 argument, but it takes 0 arguments - --> $DIR/closure-arg-count.rs:21:5 + --> $DIR/closure-arg-count.rs:23:5 | -21 | f(|| panic!()); +23 | f(|| panic!()); | ^ -- takes 0 arguments | | | expected closure that takes 1 argument @@ -52,45 +52,53 @@ note: required by `f` 13 | fn f>(_: F) {} | ^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0593]: closure is expected to take a single tuple as argument, but it takes 2 distinct arguments - --> $DIR/closure-arg-count.rs:24:53 +error[E0593]: closure is expected to take a single 2-tuple as argument, but it takes 2 distinct arguments + --> $DIR/closure-arg-count.rs:26:53 | -24 | let _it = vec![1, 2, 3].into_iter().enumerate().map(|i, x| i); - | ^^^ ------ help: consider changing the closure to accept a tuple: `|(i, x)|` +26 | let _it = vec![1, 2, 3].into_iter().enumerate().map(|i, x| i); + | ^^^ ------ takes 2 distinct arguments | | - | expected closure that takes a single tuple as argument + | expected closure that takes a single 2-tuple as argument +help: change the closure to accept a tuple instead of individual arguments + | +26 | let _it = vec![1, 2, 3].into_iter().enumerate().map(|(i, x)| i); + | ^^^^^^^^ -error[E0593]: closure is expected to take a single tuple as argument, but it takes 2 distinct arguments - --> $DIR/closure-arg-count.rs:26:53 +error[E0593]: closure is expected to take a single 2-tuple as argument, but it takes 2 distinct arguments + --> $DIR/closure-arg-count.rs:28:53 | -26 | let _it = vec![1, 2, 3].into_iter().enumerate().map(|i: usize, x| i); - | ^^^ ------------- help: consider changing the closure to accept a tuple: `|(i, x): (usize, _)|` +28 | let _it = vec![1, 2, 3].into_iter().enumerate().map(|i: usize, x| i); + | ^^^ ------------- takes 2 distinct arguments | | - | expected closure that takes a single tuple as argument + | expected closure that takes a single 2-tuple as argument +help: change the closure to accept a tuple instead of individual arguments + | +28 | let _it = vec![1, 2, 3].into_iter().enumerate().map(|(i, x)| i); + | ^^^^^^^^ error[E0593]: closure is expected to take a single 2-tuple as argument, but it takes 3 distinct arguments - --> $DIR/closure-arg-count.rs:28:53 + --> $DIR/closure-arg-count.rs:30:53 | -28 | let _it = vec![1, 2, 3].into_iter().enumerate().map(|i, x, y| i); +30 | let _it = vec![1, 2, 3].into_iter().enumerate().map(|i, x, y| i); | ^^^ --------- takes 3 distinct arguments | | | expected closure that takes a single 2-tuple as argument error[E0593]: function is expected to take a single 2-tuple as argument, but it takes 0 arguments - --> $DIR/closure-arg-count.rs:30:53 + --> $DIR/closure-arg-count.rs:32:53 | -30 | let _it = vec![1, 2, 3].into_iter().enumerate().map(foo); +32 | let _it = vec![1, 2, 3].into_iter().enumerate().map(foo); | ^^^ expected function that takes a single 2-tuple as argument ... -37 | fn foo() {} +41 | fn foo() {} | -------- takes 0 arguments error[E0593]: closure is expected to take a single 2-tuple as argument, but it takes 3 distinct arguments - --> $DIR/closure-arg-count.rs:33:53 + --> $DIR/closure-arg-count.rs:35:53 | -32 | let bar = |i, x, y| i; +34 | let bar = |i, x, y| i; | --------- takes 3 distinct arguments -33 | let _it = vec![1, 2, 3].into_iter().enumerate().map(bar); +35 | let _it = vec![1, 2, 3].into_iter().enumerate().map(bar); | ^^^ expected closure that takes a single 2-tuple as argument error[E0593]: function is expected to take a single 2-tuple as argument, but it takes 2 distinct arguments diff --git a/src/test/ui/suggestions/for-c-in-str.stderr b/src/test/ui/suggestions/for-c-in-str.stderr index 7a6dc9a504029..88a7b1b49d62d 100644 --- a/src/test/ui/suggestions/for-c-in-str.stderr +++ b/src/test/ui/suggestions/for-c-in-str.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `&str: std::iter::Iterator` is not satisfied --> $DIR/for-c-in-str.rs:14:14 | 14 | for c in "asdf" { - | ^^^^^^ `&str` is not an iterator; maybe try calling `.iter()` or a similar method + | ^^^^^^ `&str` is not an iterator; try calling `.chars()` or `.bytes()` | = help: the trait `std::iter::Iterator` is not implemented for `&str` = note: required by `std::iter::IntoIterator::into_iter` diff --git a/src/test/ui/suggestions/iterate-str.rs b/src/test/ui/suggestions/iterate-str.rs deleted file mode 100644 index 1022491b84a36..0000000000000 --- a/src/test/ui/suggestions/iterate-str.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - for c in "foobarbaz" { - println!("{}", c); - } - //~^^^ ERROR the trait bound `&str: std::iter::Iterator` is not satisfied - //~| NOTE `&str` is not an iterator; try calling `.chars()` or `.bytes()` - //~| HELP the trait `std::iter::Iterator` is not implemented for `&str` - //~| NOTE required by `std::iter::IntoIterator::into_iter` -} diff --git a/src/test/ui/suggestions/iterate-str.stderr b/src/test/ui/suggestions/iterate-str.stderr deleted file mode 100644 index 59da6d70c0236..0000000000000 --- a/src/test/ui/suggestions/iterate-str.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0277]: the trait bound `&str: std::iter::Iterator` is not satisfied - --> $DIR/iterate-str.rs:12:5 - | -12 | / for c in "foobarbaz" { -13 | | println!("{}", c); -14 | | } - | |_____^ `&str` is not an iterator; try calling `.chars()` or `.bytes()` - | - = help: the trait `std::iter::Iterator` is not implemented for `&str` - = note: required by `std::iter::IntoIterator::into_iter` - -error: aborting due to previous error -