From ff67b9072b66fc0ba2473accadccd66cef32bd9f Mon Sep 17 00:00:00 2001 From: Marcel Hellwig <921462+hellow554@users.noreply.github.com> Date: Fri, 5 Jul 2019 12:55:05 +0200 Subject: [PATCH 01/17] Remove never_type feature requirement for exhaustive patterns --- src/librustc_mir/build/matches/simplify.rs | 1 - .../uninhabited/exhaustive-wo-nevertype-issue-51221.rs | 9 +++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 src/test/ui/uninhabited/exhaustive-wo-nevertype-issue-51221.rs diff --git a/src/librustc_mir/build/matches/simplify.rs b/src/librustc_mir/build/matches/simplify.rs index 7125eb6850bb6..d9b748f71f011 100644 --- a/src/librustc_mir/build/matches/simplify.rs +++ b/src/librustc_mir/build/matches/simplify.rs @@ -161,7 +161,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { PatternKind::Variant { adt_def, substs, variant_index, ref subpatterns } => { let irrefutable = adt_def.variants.iter_enumerated().all(|(i, v)| { i == variant_index || { - self.hir.tcx().features().never_type && self.hir.tcx().features().exhaustive_patterns && !v.uninhabited_from(self.hir.tcx(), substs, adt_def.adt_kind()).is_empty() } diff --git a/src/test/ui/uninhabited/exhaustive-wo-nevertype-issue-51221.rs b/src/test/ui/uninhabited/exhaustive-wo-nevertype-issue-51221.rs new file mode 100644 index 0000000000000..b59432078350e --- /dev/null +++ b/src/test/ui/uninhabited/exhaustive-wo-nevertype-issue-51221.rs @@ -0,0 +1,9 @@ +// check-pass + +#![feature(exhaustive_patterns)] + +enum Void {} +fn main() { + let a: Option = None; + let None = a; +} From 224757f912008b42d22e3543a668a5314b3836cd Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 8 Jul 2019 13:20:49 +0200 Subject: [PATCH 02/17] Fix Pin urls in Option documentation --- src/libcore/option.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/libcore/option.rs b/src/libcore/option.rs index 29169951e469d..142df9ba7c1a1 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -290,6 +290,8 @@ impl Option { /// Converts from [`Pin`]`<&Option>` to `Option<`[`Pin`]`<&T>>`. + /// + /// [`Pin`]: ../pin/struct.Pin.html #[inline] #[stable(feature = "pin", since = "1.33.0")] pub fn as_pin_ref<'a>(self: Pin<&'a Option>) -> Option> { @@ -299,6 +301,8 @@ impl Option { } /// Converts from [`Pin`]`<&mut Option>` to `Option<`[`Pin`]`<&mut T>>`. + /// + /// [`Pin`]: ../pin/struct.Pin.html #[inline] #[stable(feature = "pin", since = "1.33.0")] pub fn as_pin_mut<'a>(self: Pin<&'a mut Option>) -> Option> { From 4c1332afd93cf57e9cd02ded906c5d141f9a6353 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Tue, 9 Jul 2019 16:21:59 +0200 Subject: [PATCH 03/17] Add missing links for CannotReallocInPlace type --- src/libcore/alloc.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/libcore/alloc.rs b/src/libcore/alloc.rs index f25631e028eec..487f3b76fc75f 100644 --- a/src/libcore/alloc.rs +++ b/src/libcore/alloc.rs @@ -359,9 +359,12 @@ impl fmt::Display for AllocErr { } } -/// The `CannotReallocInPlace` error is used when `grow_in_place` or -/// `shrink_in_place` were unable to reuse the given memory block for +/// The `CannotReallocInPlace` error is used when [`grow_in_place`] or +/// [`shrink_in_place`] were unable to reuse the given memory block for /// a requested layout. +/// +/// [`grow_in_place`]: ./trait.Alloc.html#method.grow_in_place +/// [`shrink_in_place`]: ./trait.Alloc.html#method.shrink_in_place #[unstable(feature = "allocator_api", issue = "32838")] #[derive(Clone, PartialEq, Eq, Debug)] pub struct CannotReallocInPlace; From 4e1d467700d9be5341f98662ee6ca329e2875d51 Mon Sep 17 00:00:00 2001 From: Dodo Date: Sat, 13 Jul 2019 17:15:16 +0200 Subject: [PATCH 04/17] add spaces in front of trait requirements --- src/libcore/cell.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/libcore/cell.rs b/src/libcore/cell.rs index beafddc5a1019..f74e945b3cc1b 100644 --- a/src/libcore/cell.rs +++ b/src/libcore/cell.rs @@ -290,7 +290,7 @@ impl Clone for Cell { } #[stable(feature = "rust1", since = "1.0.0")] -impl Default for Cell { +impl Default for Cell { /// Creates a `Cell`, with the `Default` value for T. #[inline] fn default() -> Cell { @@ -299,7 +299,7 @@ impl Default for Cell { } #[stable(feature = "rust1", since = "1.0.0")] -impl PartialEq for Cell { +impl PartialEq for Cell { #[inline] fn eq(&self, other: &Cell) -> bool { self.get() == other.get() @@ -307,10 +307,10 @@ impl PartialEq for Cell { } #[stable(feature = "cell_eq", since = "1.2.0")] -impl Eq for Cell {} +impl Eq for Cell {} #[stable(feature = "cell_ord", since = "1.10.0")] -impl PartialOrd for Cell { +impl PartialOrd for Cell { #[inline] fn partial_cmp(&self, other: &Cell) -> Option { self.get().partial_cmp(&other.get()) @@ -338,7 +338,7 @@ impl PartialOrd for Cell { } #[stable(feature = "cell_ord", since = "1.10.0")] -impl Ord for Cell { +impl Ord for Cell { #[inline] fn cmp(&self, other: &Cell) -> Ordering { self.get().cmp(&other.get()) @@ -1008,7 +1008,7 @@ impl Clone for RefCell { } #[stable(feature = "rust1", since = "1.0.0")] -impl Default for RefCell { +impl Default for RefCell { /// Creates a `RefCell`, with the `Default` value for T. #[inline] fn default() -> RefCell { From 84dfb2c4d7570fad03101bf4931000d029ec3419 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Fri, 12 Jul 2019 19:33:51 -0700 Subject: [PATCH 05/17] Tweak wording in feature gate errors --- src/librustc_resolve/macros.rs | 2 +- src/libsyntax/feature_gate.rs | 6 ++-- src/test/ui/attributes/obsolete-attr.stderr | 4 +-- src/test/ui/attributes/unknown-attr.stderr | 6 ++-- ...r-unknown-attribute-macro-expansion.stderr | 2 +- .../cfg-generic-params.stderr | 10 +++--- src/test/ui/custom_attribute.rs | 6 ++-- src/test/ui/custom_attribute.stderr | 6 ++-- .../feature-gate-custom_attribute.stderr | 26 +++++++------- .../feature-gate-custom_attribute2.rs | 34 +++++++++---------- .../feature-gate-custom_attribute2.stderr | 34 +++++++++---------- .../feature-gates/feature-gate-may-dangle.rs | 2 +- .../feature-gate-may-dangle.stderr | 2 +- .../feature-gate-rustc-attrs.stderr | 2 +- src/test/ui/issues/issue-32655.stderr | 4 +-- src/test/ui/issues/issue-49074.rs | 2 +- src/test/ui/issues/issue-49074.stderr | 2 +- .../ui/macros/macro-reexport-removed.stderr | 2 +- .../proc-macro/derive-helper-shadowing.stderr | 2 +- .../ui/proc-macro/derive-still-gated.stderr | 2 +- .../ui/proc-macro/expand-to-unstable-2.stderr | 2 +- src/test/ui/proc-macro/issue-41211.stderr | 2 +- .../macro-namespace-reserved-2.stderr | 2 +- .../proc-macro/proc-macro-attributes.stderr | 2 +- .../ui/proc-macro/proc-macro-gates2.stderr | 4 +-- src/test/ui/proc-macro/resolve-error.stderr | 4 +-- .../ui/reserved/reserved-attr-on-macro.stderr | 2 +- .../param-attrs-builtin-attrs.rs | 16 ++++----- .../param-attrs-builtin-attrs.stderr | 16 ++++----- src/test/ui/span/issue-36530.stderr | 4 +-- .../ui/suggestions/attribute-typos.stderr | 6 ++-- .../tool-attributes-misplaced-1.stderr | 2 +- 32 files changed, 109 insertions(+), 109 deletions(-) diff --git a/src/librustc_resolve/macros.rs b/src/librustc_resolve/macros.rs index fc1becfe30960..7f25d81982a64 100644 --- a/src/librustc_resolve/macros.rs +++ b/src/librustc_resolve/macros.rs @@ -328,7 +328,7 @@ impl<'a> Resolver<'a> { if attr_kind == NonMacroAttrKind::Custom { assert!(path.segments.len() == 1); if !features.custom_attribute { - let msg = format!("The attribute `{}` is currently unknown to the \ + let msg = format!("the attribute `{}` is currently unknown to the \ compiler and may have meaning added to it in the \ future", path); self.report_unknown_attribute( diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index e3628d908fb1e..ed7d6c35fb97a 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -1451,7 +1451,7 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[ template!(Word), Gated(Stability::Unstable, sym::dropck_eyepatch, - "may_dangle has unstable semantics and may be removed in the future", + "`may_dangle` has unstable semantics and may be removed in the future", cfg_fn!(dropck_eyepatch))), (sym::unwind, Whitelisted, template!(List: "allowed|aborts"), Gated(Stability::Unstable, sym::unwind_attributes, @@ -1693,8 +1693,8 @@ impl<'a> Context<'a> { // Only run the custom attribute lint during regular feature gate // checking. Macro gating runs before the plugin attributes are // registered, so we skip this in that case. - let msg = format!("The attribute `{}` is currently unknown to the compiler and \ - may have meaning added to it in the future", attr.path); + let msg = format!("the attribute `{}` is currently unknown to the compiler and \ + may have meaning added to it in the future", attr.path); gate_feature!(self, custom_attribute, attr.span, &msg); } } diff --git a/src/test/ui/attributes/obsolete-attr.stderr b/src/test/ui/attributes/obsolete-attr.stderr index 6021700dfbb1d..1d5caa81a5049 100644 --- a/src/test/ui/attributes/obsolete-attr.stderr +++ b/src/test/ui/attributes/obsolete-attr.stderr @@ -1,4 +1,4 @@ -error[E0658]: The attribute `fixed_stack_segment` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: the attribute `fixed_stack_segment` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/obsolete-attr.rs:5:3 | LL | #[fixed_stack_segment] fn f() {} @@ -7,7 +7,7 @@ LL | #[fixed_stack_segment] fn f() {} = note: for more information, see https://github.com/rust-lang/rust/issues/29642 = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: The attribute `ab_isize` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: the attribute `ab_isize` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/obsolete-attr.rs:3:3 | LL | #[ab_isize="stdcall"] extern {} diff --git a/src/test/ui/attributes/unknown-attr.stderr b/src/test/ui/attributes/unknown-attr.stderr index b46db5662932c..19e0e0a6b6303 100644 --- a/src/test/ui/attributes/unknown-attr.stderr +++ b/src/test/ui/attributes/unknown-attr.stderr @@ -1,4 +1,4 @@ -error[E0658]: The attribute `mutable_doc` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: the attribute `mutable_doc` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/unknown-attr.rs:5:4 | LL | #![mutable_doc] @@ -7,7 +7,7 @@ LL | #![mutable_doc] = note: for more information, see https://github.com/rust-lang/rust/issues/29642 = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: The attribute `dance` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: the attribute `dance` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/unknown-attr.rs:7:3 | LL | #[dance] mod a {} @@ -16,7 +16,7 @@ LL | #[dance] mod a {} = note: for more information, see https://github.com/rust-lang/rust/issues/29642 = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: The attribute `dance` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: the attribute `dance` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/unknown-attr.rs:9:3 | LL | #[dance] fn main() {} diff --git a/src/test/ui/conditional-compilation/cfg-attr-unknown-attribute-macro-expansion.stderr b/src/test/ui/conditional-compilation/cfg-attr-unknown-attribute-macro-expansion.stderr index cf4d0fc5ad07f..199227c048151 100644 --- a/src/test/ui/conditional-compilation/cfg-attr-unknown-attribute-macro-expansion.stderr +++ b/src/test/ui/conditional-compilation/cfg-attr-unknown-attribute-macro-expansion.stderr @@ -1,4 +1,4 @@ -error[E0658]: The attribute `unknown` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: the attribute `unknown` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/cfg-attr-unknown-attribute-macro-expansion.rs:3:27 | LL | #[cfg_attr(all(), unknown)] diff --git a/src/test/ui/conditional-compilation/cfg-generic-params.stderr b/src/test/ui/conditional-compilation/cfg-generic-params.stderr index b73d7da30b8ac..1f9731fcfbefb 100644 --- a/src/test/ui/conditional-compilation/cfg-generic-params.stderr +++ b/src/test/ui/conditional-compilation/cfg-generic-params.stderr @@ -16,7 +16,7 @@ error: only lifetime parameters can be used in this context LL | struct WhereBad where for<#[cfg(no)] 'a, #[cfg(yes)] T> u8: Copy; | ^ -error[E0658]: The attribute `unknown` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: the attribute `unknown` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/cfg-generic-params.rs:19:29 | LL | fn f_lt_yes<#[cfg_attr(yes, unknown)] 'a>() {} @@ -25,7 +25,7 @@ LL | fn f_lt_yes<#[cfg_attr(yes, unknown)] 'a>() {} = note: for more information, see https://github.com/rust-lang/rust/issues/29642 = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: The attribute `unknown` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: the attribute `unknown` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/cfg-generic-params.rs:21:29 | LL | fn f_ty_yes<#[cfg_attr(yes, unknown)] T>() {} @@ -34,7 +34,7 @@ LL | fn f_ty_yes<#[cfg_attr(yes, unknown)] T>() {} = note: for more information, see https://github.com/rust-lang/rust/issues/29642 = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: The attribute `unknown` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: the attribute `unknown` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/cfg-generic-params.rs:24:34 | LL | type FnYes = for<#[cfg_attr(yes, unknown)] 'a> fn(); @@ -43,7 +43,7 @@ LL | type FnYes = for<#[cfg_attr(yes, unknown)] 'a> fn(); = note: for more information, see https://github.com/rust-lang/rust/issues/29642 = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: The attribute `unknown` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: the attribute `unknown` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/cfg-generic-params.rs:28:40 | LL | type PolyYes = dyn for<#[cfg_attr(yes, unknown)] 'a> Copy; @@ -52,7 +52,7 @@ LL | type PolyYes = dyn for<#[cfg_attr(yes, unknown)] 'a> Copy; = note: for more information, see https://github.com/rust-lang/rust/issues/29642 = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: The attribute `unknown` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: the attribute `unknown` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/cfg-generic-params.rs:32:43 | LL | struct WhereYes where for<#[cfg_attr(yes, unknown)] 'a> u8: Copy; diff --git a/src/test/ui/custom_attribute.rs b/src/test/ui/custom_attribute.rs index 9cb43ab07ad6d..37834c0206137 100644 --- a/src/test/ui/custom_attribute.rs +++ b/src/test/ui/custom_attribute.rs @@ -1,9 +1,9 @@ #![feature(stmt_expr_attributes)] -#[foo] //~ ERROR The attribute `foo` +#[foo] //~ ERROR the attribute `foo` fn main() { - #[foo] //~ ERROR The attribute `foo` + #[foo] //~ ERROR the attribute `foo` let x = (); - #[foo] //~ ERROR The attribute `foo` + #[foo] //~ ERROR the attribute `foo` x } diff --git a/src/test/ui/custom_attribute.stderr b/src/test/ui/custom_attribute.stderr index 84c4e33e55a1a..e273c064ac41c 100644 --- a/src/test/ui/custom_attribute.stderr +++ b/src/test/ui/custom_attribute.stderr @@ -1,4 +1,4 @@ -error[E0658]: The attribute `foo` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: the attribute `foo` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/custom_attribute.rs:3:3 | LL | #[foo] @@ -7,7 +7,7 @@ LL | #[foo] = note: for more information, see https://github.com/rust-lang/rust/issues/29642 = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: The attribute `foo` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: the attribute `foo` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/custom_attribute.rs:5:7 | LL | #[foo] @@ -16,7 +16,7 @@ LL | #[foo] = note: for more information, see https://github.com/rust-lang/rust/issues/29642 = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: The attribute `foo` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: the attribute `foo` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/custom_attribute.rs:7:7 | LL | #[foo] diff --git a/src/test/ui/feature-gates/feature-gate-custom_attribute.stderr b/src/test/ui/feature-gates/feature-gate-custom_attribute.stderr index 12175feadd63a..11619a5dbd83f 100644 --- a/src/test/ui/feature-gates/feature-gate-custom_attribute.stderr +++ b/src/test/ui/feature-gates/feature-gate-custom_attribute.stderr @@ -1,4 +1,4 @@ -error[E0658]: The attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: the attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/feature-gate-custom_attribute.rs:7:3 | LL | #[fake_attr] @@ -7,7 +7,7 @@ LL | #[fake_attr] = note: for more information, see https://github.com/rust-lang/rust/issues/29642 = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: The attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: the attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/feature-gate-custom_attribute.rs:8:3 | LL | #[fake_attr(100)] @@ -16,7 +16,7 @@ LL | #[fake_attr(100)] = note: for more information, see https://github.com/rust-lang/rust/issues/29642 = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: The attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: the attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/feature-gate-custom_attribute.rs:9:3 | LL | #[fake_attr(1, 2, 3)] @@ -25,7 +25,7 @@ LL | #[fake_attr(1, 2, 3)] = note: for more information, see https://github.com/rust-lang/rust/issues/29642 = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: The attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: the attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/feature-gate-custom_attribute.rs:10:3 | LL | #[fake_attr("hello")] @@ -34,7 +34,7 @@ LL | #[fake_attr("hello")] = note: for more information, see https://github.com/rust-lang/rust/issues/29642 = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: The attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: the attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/feature-gate-custom_attribute.rs:11:3 | LL | #[fake_attr(name = "hello")] @@ -43,7 +43,7 @@ LL | #[fake_attr(name = "hello")] = note: for more information, see https://github.com/rust-lang/rust/issues/29642 = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: The attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: the attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/feature-gate-custom_attribute.rs:12:3 | LL | #[fake_attr(1, "hi", key = 12, true, false)] @@ -52,7 +52,7 @@ LL | #[fake_attr(1, "hi", key = 12, true, false)] = note: for more information, see https://github.com/rust-lang/rust/issues/29642 = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: The attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: the attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/feature-gate-custom_attribute.rs:13:3 | LL | #[fake_attr(key = "hello", val = 10)] @@ -61,7 +61,7 @@ LL | #[fake_attr(key = "hello", val = 10)] = note: for more information, see https://github.com/rust-lang/rust/issues/29642 = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: The attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: the attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/feature-gate-custom_attribute.rs:14:3 | LL | #[fake_attr(key("hello"), val(10))] @@ -70,7 +70,7 @@ LL | #[fake_attr(key("hello"), val(10))] = note: for more information, see https://github.com/rust-lang/rust/issues/29642 = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: The attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: the attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/feature-gate-custom_attribute.rs:15:3 | LL | #[fake_attr(enabled = true, disabled = false)] @@ -79,7 +79,7 @@ LL | #[fake_attr(enabled = true, disabled = false)] = note: for more information, see https://github.com/rust-lang/rust/issues/29642 = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: The attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: the attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/feature-gate-custom_attribute.rs:16:3 | LL | #[fake_attr(true)] @@ -88,7 +88,7 @@ LL | #[fake_attr(true)] = note: for more information, see https://github.com/rust-lang/rust/issues/29642 = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: The attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: the attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/feature-gate-custom_attribute.rs:17:3 | LL | #[fake_attr(pi = 3.14159)] @@ -97,7 +97,7 @@ LL | #[fake_attr(pi = 3.14159)] = note: for more information, see https://github.com/rust-lang/rust/issues/29642 = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: The attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: the attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/feature-gate-custom_attribute.rs:18:3 | LL | #[fake_attr(b"hi")] @@ -106,7 +106,7 @@ LL | #[fake_attr(b"hi")] = note: for more information, see https://github.com/rust-lang/rust/issues/29642 = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: The attribute `fake_doc` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: the attribute `fake_doc` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/feature-gate-custom_attribute.rs:19:3 | LL | #[fake_doc(r"doc")] diff --git a/src/test/ui/feature-gates/feature-gate-custom_attribute2.rs b/src/test/ui/feature-gates/feature-gate-custom_attribute2.rs index 2137a2a003adf..8fe11cb02a021 100644 --- a/src/test/ui/feature-gates/feature-gate-custom_attribute2.rs +++ b/src/test/ui/feature-gates/feature-gate-custom_attribute2.rs @@ -4,54 +4,54 @@ // gate-test-custom_attribute struct StLt<#[lt_struct] 'a>(&'a u32); -//~^ ERROR The attribute `lt_struct` is currently unknown to the compiler +//~^ ERROR the attribute `lt_struct` is currently unknown to the compiler struct StTy<#[ty_struct] I>(I); -//~^ ERROR The attribute `ty_struct` is currently unknown to the compiler +//~^ ERROR the attribute `ty_struct` is currently unknown to the compiler enum EnLt<#[lt_enum] 'b> { A(&'b u32), B } -//~^ ERROR The attribute `lt_enum` is currently unknown to the compiler +//~^ ERROR the attribute `lt_enum` is currently unknown to the compiler enum EnTy<#[ty_enum] J> { A(J), B } -//~^ ERROR The attribute `ty_enum` is currently unknown to the compiler +//~^ ERROR the attribute `ty_enum` is currently unknown to the compiler trait TrLt<#[lt_trait] 'c> { fn foo(&self, _: &'c [u32]) -> &'c u32; } -//~^ ERROR The attribute `lt_trait` is currently unknown to the compiler +//~^ ERROR the attribute `lt_trait` is currently unknown to the compiler trait TrTy<#[ty_trait] K> { fn foo(&self, _: K); } -//~^ ERROR The attribute `ty_trait` is currently unknown to the compiler +//~^ ERROR the attribute `ty_trait` is currently unknown to the compiler type TyLt<#[lt_type] 'd> = &'d u32; -//~^ ERROR The attribute `lt_type` is currently unknown to the compiler +//~^ ERROR the attribute `lt_type` is currently unknown to the compiler type TyTy<#[ty_type] L> = (L, ); -//~^ ERROR The attribute `ty_type` is currently unknown to the compiler +//~^ ERROR the attribute `ty_type` is currently unknown to the compiler impl<#[lt_inherent] 'e> StLt<'e> { } -//~^ ERROR The attribute `lt_inherent` is currently unknown to the compiler +//~^ ERROR the attribute `lt_inherent` is currently unknown to the compiler impl<#[ty_inherent] M> StTy { } -//~^ ERROR The attribute `ty_inherent` is currently unknown to the compiler +//~^ ERROR the attribute `ty_inherent` is currently unknown to the compiler impl<#[lt_impl_for] 'f> TrLt<'f> for StLt<'f> { - //~^ ERROR The attribute `lt_impl_for` is currently unknown to the compiler + //~^ ERROR the attribute `lt_impl_for` is currently unknown to the compiler fn foo(&self, _: &'f [u32]) -> &'f u32 { loop { } } } impl<#[ty_impl_for] N> TrTy for StTy { - //~^ ERROR The attribute `ty_impl_for` is currently unknown to the compiler + //~^ ERROR the attribute `ty_impl_for` is currently unknown to the compiler fn foo(&self, _: N) { } } fn f_lt<#[lt_fn] 'g>(_: &'g [u32]) -> &'g u32 { loop { } } -//~^ ERROR The attribute `lt_fn` is currently unknown to the compiler +//~^ ERROR the attribute `lt_fn` is currently unknown to the compiler fn f_ty<#[ty_fn] O>(_: O) { } -//~^ ERROR The attribute `ty_fn` is currently unknown to the compiler +//~^ ERROR the attribute `ty_fn` is currently unknown to the compiler impl StTy { fn m_lt<#[lt_meth] 'h>(_: &'h [u32]) -> &'h u32 { loop { } } - //~^ ERROR The attribute `lt_meth` is currently unknown to the compiler + //~^ ERROR the attribute `lt_meth` is currently unknown to the compiler fn m_ty<#[ty_meth] P>(_: P) { } - //~^ ERROR The attribute `ty_meth` is currently unknown to the compiler + //~^ ERROR the attribute `ty_meth` is currently unknown to the compiler } fn hof_lt(_: Q) where Q: for <#[lt_hof] 'i> Fn(&'i [u32]) -> &'i u32 - //~^ ERROR The attribute `lt_hof` is currently unknown to the compiler + //~^ ERROR the attribute `lt_hof` is currently unknown to the compiler { } diff --git a/src/test/ui/feature-gates/feature-gate-custom_attribute2.stderr b/src/test/ui/feature-gates/feature-gate-custom_attribute2.stderr index f159308dcb829..15e0c41b90637 100644 --- a/src/test/ui/feature-gates/feature-gate-custom_attribute2.stderr +++ b/src/test/ui/feature-gates/feature-gate-custom_attribute2.stderr @@ -1,4 +1,4 @@ -error[E0658]: The attribute `lt_struct` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: the attribute `lt_struct` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/feature-gate-custom_attribute2.rs:6:13 | LL | struct StLt<#[lt_struct] 'a>(&'a u32); @@ -7,7 +7,7 @@ LL | struct StLt<#[lt_struct] 'a>(&'a u32); = note: for more information, see https://github.com/rust-lang/rust/issues/29642 = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: The attribute `ty_struct` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: the attribute `ty_struct` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/feature-gate-custom_attribute2.rs:8:13 | LL | struct StTy<#[ty_struct] I>(I); @@ -16,7 +16,7 @@ LL | struct StTy<#[ty_struct] I>(I); = note: for more information, see https://github.com/rust-lang/rust/issues/29642 = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: The attribute `lt_enum` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: the attribute `lt_enum` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/feature-gate-custom_attribute2.rs:11:11 | LL | enum EnLt<#[lt_enum] 'b> { A(&'b u32), B } @@ -25,7 +25,7 @@ LL | enum EnLt<#[lt_enum] 'b> { A(&'b u32), B } = note: for more information, see https://github.com/rust-lang/rust/issues/29642 = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: The attribute `ty_enum` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: the attribute `ty_enum` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/feature-gate-custom_attribute2.rs:13:11 | LL | enum EnTy<#[ty_enum] J> { A(J), B } @@ -34,7 +34,7 @@ LL | enum EnTy<#[ty_enum] J> { A(J), B } = note: for more information, see https://github.com/rust-lang/rust/issues/29642 = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: The attribute `lt_trait` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: the attribute `lt_trait` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/feature-gate-custom_attribute2.rs:16:12 | LL | trait TrLt<#[lt_trait] 'c> { fn foo(&self, _: &'c [u32]) -> &'c u32; } @@ -43,7 +43,7 @@ LL | trait TrLt<#[lt_trait] 'c> { fn foo(&self, _: &'c [u32]) -> &'c u32; } = note: for more information, see https://github.com/rust-lang/rust/issues/29642 = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: The attribute `ty_trait` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: the attribute `ty_trait` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/feature-gate-custom_attribute2.rs:18:12 | LL | trait TrTy<#[ty_trait] K> { fn foo(&self, _: K); } @@ -52,7 +52,7 @@ LL | trait TrTy<#[ty_trait] K> { fn foo(&self, _: K); } = note: for more information, see https://github.com/rust-lang/rust/issues/29642 = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: The attribute `lt_type` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: the attribute `lt_type` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/feature-gate-custom_attribute2.rs:21:11 | LL | type TyLt<#[lt_type] 'd> = &'d u32; @@ -61,7 +61,7 @@ LL | type TyLt<#[lt_type] 'd> = &'d u32; = note: for more information, see https://github.com/rust-lang/rust/issues/29642 = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: The attribute `ty_type` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: the attribute `ty_type` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/feature-gate-custom_attribute2.rs:23:11 | LL | type TyTy<#[ty_type] L> = (L, ); @@ -70,7 +70,7 @@ LL | type TyTy<#[ty_type] L> = (L, ); = note: for more information, see https://github.com/rust-lang/rust/issues/29642 = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: The attribute `lt_inherent` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: the attribute `lt_inherent` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/feature-gate-custom_attribute2.rs:26:6 | LL | impl<#[lt_inherent] 'e> StLt<'e> { } @@ -79,7 +79,7 @@ LL | impl<#[lt_inherent] 'e> StLt<'e> { } = note: for more information, see https://github.com/rust-lang/rust/issues/29642 = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: The attribute `ty_inherent` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: the attribute `ty_inherent` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/feature-gate-custom_attribute2.rs:28:6 | LL | impl<#[ty_inherent] M> StTy { } @@ -88,7 +88,7 @@ LL | impl<#[ty_inherent] M> StTy { } = note: for more information, see https://github.com/rust-lang/rust/issues/29642 = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: The attribute `lt_impl_for` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: the attribute `lt_impl_for` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/feature-gate-custom_attribute2.rs:31:6 | LL | impl<#[lt_impl_for] 'f> TrLt<'f> for StLt<'f> { @@ -97,7 +97,7 @@ LL | impl<#[lt_impl_for] 'f> TrLt<'f> for StLt<'f> { = note: for more information, see https://github.com/rust-lang/rust/issues/29642 = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: The attribute `ty_impl_for` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: the attribute `ty_impl_for` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/feature-gate-custom_attribute2.rs:35:6 | LL | impl<#[ty_impl_for] N> TrTy for StTy { @@ -106,7 +106,7 @@ LL | impl<#[ty_impl_for] N> TrTy for StTy { = note: for more information, see https://github.com/rust-lang/rust/issues/29642 = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: The attribute `lt_fn` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: the attribute `lt_fn` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/feature-gate-custom_attribute2.rs:40:9 | LL | fn f_lt<#[lt_fn] 'g>(_: &'g [u32]) -> &'g u32 { loop { } } @@ -115,7 +115,7 @@ LL | fn f_lt<#[lt_fn] 'g>(_: &'g [u32]) -> &'g u32 { loop { } } = note: for more information, see https://github.com/rust-lang/rust/issues/29642 = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: The attribute `ty_fn` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: the attribute `ty_fn` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/feature-gate-custom_attribute2.rs:42:9 | LL | fn f_ty<#[ty_fn] O>(_: O) { } @@ -124,7 +124,7 @@ LL | fn f_ty<#[ty_fn] O>(_: O) { } = note: for more information, see https://github.com/rust-lang/rust/issues/29642 = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: The attribute `lt_meth` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: the attribute `lt_meth` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/feature-gate-custom_attribute2.rs:46:13 | LL | fn m_lt<#[lt_meth] 'h>(_: &'h [u32]) -> &'h u32 { loop { } } @@ -133,7 +133,7 @@ LL | fn m_lt<#[lt_meth] 'h>(_: &'h [u32]) -> &'h u32 { loop { } } = note: for more information, see https://github.com/rust-lang/rust/issues/29642 = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: The attribute `ty_meth` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: the attribute `ty_meth` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/feature-gate-custom_attribute2.rs:48:13 | LL | fn m_ty<#[ty_meth] P>(_: P) { } @@ -142,7 +142,7 @@ LL | fn m_ty<#[ty_meth] P>(_: P) { } = note: for more information, see https://github.com/rust-lang/rust/issues/29642 = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: The attribute `lt_hof` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: the attribute `lt_hof` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/feature-gate-custom_attribute2.rs:53:19 | LL | where Q: for <#[lt_hof] 'i> Fn(&'i [u32]) -> &'i u32 diff --git a/src/test/ui/feature-gates/feature-gate-may-dangle.rs b/src/test/ui/feature-gates/feature-gate-may-dangle.rs index 20896e426f65d..23db92c15df65 100644 --- a/src/test/ui/feature-gates/feature-gate-may-dangle.rs +++ b/src/test/ui/feature-gates/feature-gate-may-dangle.rs @@ -4,7 +4,7 @@ struct Pt(A); unsafe impl<#[may_dangle] A> Drop for Pt { - //~^ ERROR may_dangle has unstable semantics and may be removed in the future + //~^ ERROR `may_dangle` has unstable semantics and may be removed in the future fn drop(&mut self) { } } diff --git a/src/test/ui/feature-gates/feature-gate-may-dangle.stderr b/src/test/ui/feature-gates/feature-gate-may-dangle.stderr index c47bb75e6bc07..b344d73757473 100644 --- a/src/test/ui/feature-gates/feature-gate-may-dangle.stderr +++ b/src/test/ui/feature-gates/feature-gate-may-dangle.stderr @@ -1,4 +1,4 @@ -error[E0658]: may_dangle has unstable semantics and may be removed in the future +error[E0658]: `may_dangle` has unstable semantics and may be removed in the future --> $DIR/feature-gate-may-dangle.rs:6:13 | LL | unsafe impl<#[may_dangle] A> Drop for Pt { diff --git a/src/test/ui/feature-gates/feature-gate-rustc-attrs.stderr b/src/test/ui/feature-gates/feature-gate-rustc-attrs.stderr index 7c5aa5381e8c7..3501aa8486032 100644 --- a/src/test/ui/feature-gates/feature-gate-rustc-attrs.stderr +++ b/src/test/ui/feature-gates/feature-gate-rustc-attrs.stderr @@ -37,7 +37,7 @@ LL | #[rustc_unknown] = note: for more information, see https://github.com/rust-lang/rust/issues/29642 = help: add `#![feature(rustc_attrs)]` to the crate attributes to enable -error[E0658]: The attribute `rustc_unknown` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: the attribute `rustc_unknown` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/feature-gate-rustc-attrs.rs:20:3 | LL | #[rustc_unknown] diff --git a/src/test/ui/issues/issue-32655.stderr b/src/test/ui/issues/issue-32655.stderr index 43bb4105c8dbf..d7fda09c31a05 100644 --- a/src/test/ui/issues/issue-32655.stderr +++ b/src/test/ui/issues/issue-32655.stderr @@ -1,4 +1,4 @@ -error[E0658]: The attribute `derive_Clone` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: the attribute `derive_Clone` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/issue-32655.rs:6:11 | LL | #[derive_Clone] @@ -10,7 +10,7 @@ LL | foo!(); = note: for more information, see https://github.com/rust-lang/rust/issues/29642 = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: The attribute `derive_Clone` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: the attribute `derive_Clone` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/issue-32655.rs:18:7 | LL | #[derive_Clone] diff --git a/src/test/ui/issues/issue-49074.rs b/src/test/ui/issues/issue-49074.rs index ad66e421c6b9d..24d9c03fa625e 100644 --- a/src/test/ui/issues/issue-49074.rs +++ b/src/test/ui/issues/issue-49074.rs @@ -1,7 +1,7 @@ // Check that unknown attribute error is shown even if there are unresolved macros. #[marco_use] // typo -//~^ ERROR The attribute `marco_use` is currently unknown to the compiler +//~^ ERROR the attribute `marco_use` is currently unknown to the compiler mod foo { macro_rules! bar { () => (); diff --git a/src/test/ui/issues/issue-49074.stderr b/src/test/ui/issues/issue-49074.stderr index 3ab876dbf4254..244a949d69899 100644 --- a/src/test/ui/issues/issue-49074.stderr +++ b/src/test/ui/issues/issue-49074.stderr @@ -1,4 +1,4 @@ -error[E0658]: The attribute `marco_use` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: the attribute `marco_use` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/issue-49074.rs:3:3 | LL | #[marco_use] // typo diff --git a/src/test/ui/macros/macro-reexport-removed.stderr b/src/test/ui/macros/macro-reexport-removed.stderr index 44233d7b7dda3..0d7295dcef63b 100644 --- a/src/test/ui/macros/macro-reexport-removed.stderr +++ b/src/test/ui/macros/macro-reexport-removed.stderr @@ -10,7 +10,7 @@ note: subsumed by `pub use` LL | #![feature(macro_reexport)] | ^^^^^^^^^^^^^^ -error[E0658]: The attribute `macro_reexport` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: the attribute `macro_reexport` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/macro-reexport-removed.rs:5:3 | LL | #[macro_reexport(macro_one)] diff --git a/src/test/ui/proc-macro/derive-helper-shadowing.stderr b/src/test/ui/proc-macro/derive-helper-shadowing.stderr index 984ea4fb8addd..cb0a8a119e2ee 100644 --- a/src/test/ui/proc-macro/derive-helper-shadowing.stderr +++ b/src/test/ui/proc-macro/derive-helper-shadowing.stderr @@ -1,4 +1,4 @@ -error[E0658]: The attribute `empty_helper` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: the attribute `empty_helper` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/derive-helper-shadowing.rs:22:15 | LL | #[empty_helper] diff --git a/src/test/ui/proc-macro/derive-still-gated.stderr b/src/test/ui/proc-macro/derive-still-gated.stderr index a6c0ce6260a4d..bde9814dc660d 100644 --- a/src/test/ui/proc-macro/derive-still-gated.stderr +++ b/src/test/ui/proc-macro/derive-still-gated.stderr @@ -1,4 +1,4 @@ -error[E0658]: The attribute `derive_Empty` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: the attribute `derive_Empty` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/derive-still-gated.rs:6:3 | LL | #[derive_Empty] diff --git a/src/test/ui/proc-macro/expand-to-unstable-2.stderr b/src/test/ui/proc-macro/expand-to-unstable-2.stderr index 3a729846d7852..719156cba5c9f 100644 --- a/src/test/ui/proc-macro/expand-to-unstable-2.stderr +++ b/src/test/ui/proc-macro/expand-to-unstable-2.stderr @@ -7,7 +7,7 @@ LL | #[derive(Unstable)] = note: for more information, see https://github.com/rust-lang/rust/issues/29642 = help: add `#![feature(rustc_attrs)]` to the crate attributes to enable -error[E0658]: The attribute `rustc_foo` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: the attribute `rustc_foo` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/expand-to-unstable-2.rs:6:10 | LL | #[derive(Unstable)] diff --git a/src/test/ui/proc-macro/issue-41211.stderr b/src/test/ui/proc-macro/issue-41211.stderr index b5c08587e1958..9dd3ac27cf809 100644 --- a/src/test/ui/proc-macro/issue-41211.stderr +++ b/src/test/ui/proc-macro/issue-41211.stderr @@ -1,4 +1,4 @@ -error[E0658]: The attribute `identity_attr` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: the attribute `identity_attr` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/issue-41211.rs:8:4 | LL | #![identity_attr] diff --git a/src/test/ui/proc-macro/macro-namespace-reserved-2.stderr b/src/test/ui/proc-macro/macro-namespace-reserved-2.stderr index 8a5e346c2b59f..c180de083799f 100644 --- a/src/test/ui/proc-macro/macro-namespace-reserved-2.stderr +++ b/src/test/ui/proc-macro/macro-namespace-reserved-2.stderr @@ -76,7 +76,7 @@ error: can't use a procedural macro from the same crate that defines it LL | #[derive(MyTrait)] | ^^^^^^^ -error[E0658]: The attribute `my_macro` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: the attribute `my_macro` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/macro-namespace-reserved-2.rs:38:3 | LL | #[my_macro] diff --git a/src/test/ui/proc-macro/proc-macro-attributes.stderr b/src/test/ui/proc-macro/proc-macro-attributes.stderr index 02dfce1a73584..7a9bfc4e72e6d 100644 --- a/src/test/ui/proc-macro/proc-macro-attributes.stderr +++ b/src/test/ui/proc-macro/proc-macro-attributes.stderr @@ -1,4 +1,4 @@ -error[E0658]: The attribute `C` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: the attribute `C` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/proc-macro-attributes.rs:7:3 | LL | #[C] diff --git a/src/test/ui/proc-macro/proc-macro-gates2.stderr b/src/test/ui/proc-macro/proc-macro-gates2.stderr index 88847193884bc..a7f6f8bfb13d6 100644 --- a/src/test/ui/proc-macro/proc-macro-gates2.stderr +++ b/src/test/ui/proc-macro/proc-macro-gates2.stderr @@ -1,4 +1,4 @@ -error[E0658]: The attribute `empty_attr` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: the attribute `empty_attr` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/proc-macro-gates2.rs:12:11 | LL | fn _test6<#[empty_attr] T>() {} @@ -7,7 +7,7 @@ LL | fn _test6<#[empty_attr] T>() {} = note: for more information, see https://github.com/rust-lang/rust/issues/29642 = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: The attribute `empty_attr` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: the attribute `empty_attr` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/proc-macro-gates2.rs:17:9 | LL | #[empty_attr] diff --git a/src/test/ui/proc-macro/resolve-error.stderr b/src/test/ui/proc-macro/resolve-error.stderr index 02cf7cdb964e6..6f3f4c939f4bb 100644 --- a/src/test/ui/proc-macro/resolve-error.stderr +++ b/src/test/ui/proc-macro/resolve-error.stderr @@ -1,4 +1,4 @@ -error[E0658]: The attribute `attr_proc_macra` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: the attribute `attr_proc_macra` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/resolve-error.rs:27:3 | LL | #[attr_proc_macra] @@ -7,7 +7,7 @@ LL | #[attr_proc_macra] = note: for more information, see https://github.com/rust-lang/rust/issues/29642 = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: The attribute `FooWithLongNan` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: the attribute `FooWithLongNan` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/resolve-error.rs:31:3 | LL | #[FooWithLongNan] diff --git a/src/test/ui/reserved/reserved-attr-on-macro.stderr b/src/test/ui/reserved/reserved-attr-on-macro.stderr index cbd111b47bf12..0718da1027376 100644 --- a/src/test/ui/reserved/reserved-attr-on-macro.stderr +++ b/src/test/ui/reserved/reserved-attr-on-macro.stderr @@ -7,7 +7,7 @@ LL | #[rustc_attribute_should_be_reserved] = note: for more information, see https://github.com/rust-lang/rust/issues/29642 = help: add `#![feature(rustc_attrs)]` to the crate attributes to enable -error[E0658]: The attribute `rustc_attribute_should_be_reserved` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: the attribute `rustc_attribute_should_be_reserved` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/reserved-attr-on-macro.rs:1:3 | LL | #[rustc_attribute_should_be_reserved] diff --git a/src/test/ui/rfc-2565-param-attrs/param-attrs-builtin-attrs.rs b/src/test/ui/rfc-2565-param-attrs/param-attrs-builtin-attrs.rs index 352375729bd45..b957c673a41f1 100644 --- a/src/test/ui/rfc-2565-param-attrs/param-attrs-builtin-attrs.rs +++ b/src/test/ui/rfc-2565-param-attrs/param-attrs-builtin-attrs.rs @@ -5,7 +5,7 @@ extern "C" { /// Foo //~^ ERROR documentation comments cannot be applied to function #[test] a: i32, - //~^ ERROR The attribute `test` is currently unknown to the compiler and may have + //~^ ERROR the attribute `test` is currently unknown to the compiler and may have /// Bar //~^ ERROR documentation comments cannot be applied to function #[must_use] @@ -21,7 +21,7 @@ type FnType = fn( /// Foo //~^ ERROR documentation comments cannot be applied to function #[test] a: u32, - //~^ ERROR The attribute `test` is currently unknown to the compiler and may have + //~^ ERROR the attribute `test` is currently unknown to the compiler and may have /// Bar //~^ ERROR documentation comments cannot be applied to function #[must_use] @@ -36,7 +36,7 @@ pub fn foo( /// Foo //~^ ERROR documentation comments cannot be applied to function #[test] a: u32, - //~^ ERROR The attribute `test` is currently unknown to the compiler and may have + //~^ ERROR the attribute `test` is currently unknown to the compiler and may have /// Bar //~^ ERROR documentation comments cannot be applied to function #[must_use] @@ -56,7 +56,7 @@ impl SelfStruct { /// Bar //~^ ERROR documentation comments cannot be applied to function #[test] a: i32, - //~^ ERROR The attribute `test` is currently unknown to the compiler and may have + //~^ ERROR the attribute `test` is currently unknown to the compiler and may have /// Baz //~^ ERROR documentation comments cannot be applied to function #[must_use] @@ -77,7 +77,7 @@ impl RefStruct { /// Bar //~^ ERROR documentation comments cannot be applied to function #[test] a: i32, - //~^ ERROR The attribute `test` is currently unknown to the compiler and may have + //~^ ERROR the attribute `test` is currently unknown to the compiler and may have /// Baz //~^ ERROR documentation comments cannot be applied to function #[must_use] @@ -96,7 +96,7 @@ trait RefTrait { /// Bar //~^ ERROR documentation comments cannot be applied to function #[test] a: i32, - //~^ ERROR The attribute `test` is currently unknown to the compiler and may have + //~^ ERROR the attribute `test` is currently unknown to the compiler and may have /// Baz //~^ ERROR documentation comments cannot be applied to function #[must_use] @@ -115,7 +115,7 @@ impl RefTrait for RefStruct { /// Bar //~^ ERROR documentation comments cannot be applied to function #[test] a: i32, - //~^ ERROR The attribute `test` is currently unknown to the compiler and may have + //~^ ERROR the attribute `test` is currently unknown to the compiler and may have /// Baz //~^ ERROR documentation comments cannot be applied to function #[must_use] @@ -132,7 +132,7 @@ fn main() { /// Foo //~^ ERROR documentation comments cannot be applied to function #[test] a: u32, - //~^ ERROR The attribute `test` is currently unknown to the compiler and may have + //~^ ERROR the attribute `test` is currently unknown to the compiler and may have /// Bar //~^ ERROR documentation comments cannot be applied to function #[must_use] diff --git a/src/test/ui/rfc-2565-param-attrs/param-attrs-builtin-attrs.stderr b/src/test/ui/rfc-2565-param-attrs/param-attrs-builtin-attrs.stderr index a4db4b6207d14..a57572abb3513 100644 --- a/src/test/ui/rfc-2565-param-attrs/param-attrs-builtin-attrs.stderr +++ b/src/test/ui/rfc-2565-param-attrs/param-attrs-builtin-attrs.stderr @@ -262,7 +262,7 @@ error: allow, cfg, cfg_attr, deny, forbid, and warn are the only allowed built-i LL | #[no_mangle] b: i32 | ^^^^^^^^^^^^ -error[E0658]: The attribute `test` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: the attribute `test` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/param-attrs-builtin-attrs.rs:7:9 | LL | #[test] a: i32, @@ -271,7 +271,7 @@ LL | #[test] a: i32, = note: for more information, see https://github.com/rust-lang/rust/issues/29642 = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: The attribute `test` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: the attribute `test` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/param-attrs-builtin-attrs.rs:23:5 | LL | #[test] a: u32, @@ -280,7 +280,7 @@ LL | #[test] a: u32, = note: for more information, see https://github.com/rust-lang/rust/issues/29642 = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: The attribute `test` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: the attribute `test` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/param-attrs-builtin-attrs.rs:38:5 | LL | #[test] a: u32, @@ -289,7 +289,7 @@ LL | #[test] a: u32, = note: for more information, see https://github.com/rust-lang/rust/issues/29642 = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: The attribute `test` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: the attribute `test` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/param-attrs-builtin-attrs.rs:58:9 | LL | #[test] a: i32, @@ -298,7 +298,7 @@ LL | #[test] a: i32, = note: for more information, see https://github.com/rust-lang/rust/issues/29642 = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: The attribute `test` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: the attribute `test` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/param-attrs-builtin-attrs.rs:79:9 | LL | #[test] a: i32, @@ -307,7 +307,7 @@ LL | #[test] a: i32, = note: for more information, see https://github.com/rust-lang/rust/issues/29642 = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: The attribute `test` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: the attribute `test` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/param-attrs-builtin-attrs.rs:98:9 | LL | #[test] a: i32, @@ -316,7 +316,7 @@ LL | #[test] a: i32, = note: for more information, see https://github.com/rust-lang/rust/issues/29642 = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: The attribute `test` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: the attribute `test` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/param-attrs-builtin-attrs.rs:117:9 | LL | #[test] a: i32, @@ -325,7 +325,7 @@ LL | #[test] a: i32, = note: for more information, see https://github.com/rust-lang/rust/issues/29642 = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: The attribute `test` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: the attribute `test` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/param-attrs-builtin-attrs.rs:134:9 | LL | #[test] a: u32, diff --git a/src/test/ui/span/issue-36530.stderr b/src/test/ui/span/issue-36530.stderr index 65f03e756a2bf..8ff8fcb2a0607 100644 --- a/src/test/ui/span/issue-36530.stderr +++ b/src/test/ui/span/issue-36530.stderr @@ -1,4 +1,4 @@ -error[E0658]: The attribute `foo` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: the attribute `foo` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/issue-36530.rs:3:3 | LL | #[foo] @@ -16,7 +16,7 @@ LL | #![foo] = note: for more information, see https://github.com/rust-lang/rust/issues/54726 = help: add `#![feature(custom_inner_attributes)]` to the crate attributes to enable -error[E0658]: The attribute `foo` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: the attribute `foo` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/issue-36530.rs:5:8 | LL | #![foo] diff --git a/src/test/ui/suggestions/attribute-typos.stderr b/src/test/ui/suggestions/attribute-typos.stderr index 7c28e88272829..4cc51561b31a1 100644 --- a/src/test/ui/suggestions/attribute-typos.stderr +++ b/src/test/ui/suggestions/attribute-typos.stderr @@ -7,7 +7,7 @@ LL | #[rustc_err] = note: for more information, see https://github.com/rust-lang/rust/issues/29642 = help: add `#![feature(rustc_attrs)]` to the crate attributes to enable -error[E0658]: The attribute `rustc_err` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: the attribute `rustc_err` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/attribute-typos.rs:7:3 | LL | #[rustc_err] @@ -16,7 +16,7 @@ LL | #[rustc_err] = note: for more information, see https://github.com/rust-lang/rust/issues/29642 = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: The attribute `tests` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: the attribute `tests` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/attribute-typos.rs:4:3 | LL | #[tests] @@ -25,7 +25,7 @@ LL | #[tests] = note: for more information, see https://github.com/rust-lang/rust/issues/29642 = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: The attribute `deprcated` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: the attribute `deprcated` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/attribute-typos.rs:1:3 | LL | #[deprcated] diff --git a/src/test/ui/tool-attributes/tool-attributes-misplaced-1.stderr b/src/test/ui/tool-attributes/tool-attributes-misplaced-1.stderr index 32c9a1e8b6ed1..3ac8c4186e164 100644 --- a/src/test/ui/tool-attributes/tool-attributes-misplaced-1.stderr +++ b/src/test/ui/tool-attributes/tool-attributes-misplaced-1.stderr @@ -1,4 +1,4 @@ -error[E0658]: The attribute `rustfmt` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: the attribute `rustfmt` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/tool-attributes-misplaced-1.rs:8:3 | LL | #[rustfmt] From b7459f329f3a0a601cb1852358a85c6edd3057ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Sat, 13 Jul 2019 13:37:31 -0700 Subject: [PATCH 06/17] review comments --- src/librustc_resolve/macros.rs | 2 +- src/test/ui/attributes/obsolete-attr.stderr | 4 +-- src/test/ui/attributes/unknown-attr.stderr | 6 ++--- ...r-unknown-attribute-macro-expansion.stderr | 2 +- src/test/ui/custom_attribute.rs | 6 ++--- src/test/ui/custom_attribute.stderr | 6 ++--- .../feature-gate-custom_attribute.stderr | 26 +++++++++---------- .../feature-gate-rustc-attrs.stderr | 2 +- src/test/ui/issues/issue-32655.stderr | 4 +-- src/test/ui/issues/issue-49074.rs | 2 +- src/test/ui/issues/issue-49074.stderr | 2 +- .../ui/macros/macro-reexport-removed.stderr | 2 +- .../proc-macro/derive-helper-shadowing.stderr | 2 +- .../ui/proc-macro/derive-still-gated.stderr | 2 +- .../ui/proc-macro/expand-to-unstable-2.stderr | 2 +- src/test/ui/proc-macro/issue-41211.stderr | 2 +- .../macro-namespace-reserved-2.stderr | 2 +- .../proc-macro/proc-macro-attributes.stderr | 2 +- src/test/ui/proc-macro/resolve-error.stderr | 4 +-- .../ui/reserved/reserved-attr-on-macro.stderr | 2 +- src/test/ui/span/issue-36530.stderr | 4 +-- .../ui/suggestions/attribute-typos.stderr | 6 ++--- .../tool-attributes-misplaced-1.stderr | 2 +- 23 files changed, 47 insertions(+), 47 deletions(-) diff --git a/src/librustc_resolve/macros.rs b/src/librustc_resolve/macros.rs index 7f25d81982a64..fc1becfe30960 100644 --- a/src/librustc_resolve/macros.rs +++ b/src/librustc_resolve/macros.rs @@ -328,7 +328,7 @@ impl<'a> Resolver<'a> { if attr_kind == NonMacroAttrKind::Custom { assert!(path.segments.len() == 1); if !features.custom_attribute { - let msg = format!("the attribute `{}` is currently unknown to the \ + let msg = format!("The attribute `{}` is currently unknown to the \ compiler and may have meaning added to it in the \ future", path); self.report_unknown_attribute( diff --git a/src/test/ui/attributes/obsolete-attr.stderr b/src/test/ui/attributes/obsolete-attr.stderr index 1d5caa81a5049..6021700dfbb1d 100644 --- a/src/test/ui/attributes/obsolete-attr.stderr +++ b/src/test/ui/attributes/obsolete-attr.stderr @@ -1,4 +1,4 @@ -error[E0658]: the attribute `fixed_stack_segment` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: The attribute `fixed_stack_segment` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/obsolete-attr.rs:5:3 | LL | #[fixed_stack_segment] fn f() {} @@ -7,7 +7,7 @@ LL | #[fixed_stack_segment] fn f() {} = note: for more information, see https://github.com/rust-lang/rust/issues/29642 = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: the attribute `ab_isize` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: The attribute `ab_isize` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/obsolete-attr.rs:3:3 | LL | #[ab_isize="stdcall"] extern {} diff --git a/src/test/ui/attributes/unknown-attr.stderr b/src/test/ui/attributes/unknown-attr.stderr index 19e0e0a6b6303..b46db5662932c 100644 --- a/src/test/ui/attributes/unknown-attr.stderr +++ b/src/test/ui/attributes/unknown-attr.stderr @@ -1,4 +1,4 @@ -error[E0658]: the attribute `mutable_doc` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: The attribute `mutable_doc` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/unknown-attr.rs:5:4 | LL | #![mutable_doc] @@ -7,7 +7,7 @@ LL | #![mutable_doc] = note: for more information, see https://github.com/rust-lang/rust/issues/29642 = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: the attribute `dance` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: The attribute `dance` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/unknown-attr.rs:7:3 | LL | #[dance] mod a {} @@ -16,7 +16,7 @@ LL | #[dance] mod a {} = note: for more information, see https://github.com/rust-lang/rust/issues/29642 = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: the attribute `dance` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: The attribute `dance` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/unknown-attr.rs:9:3 | LL | #[dance] fn main() {} diff --git a/src/test/ui/conditional-compilation/cfg-attr-unknown-attribute-macro-expansion.stderr b/src/test/ui/conditional-compilation/cfg-attr-unknown-attribute-macro-expansion.stderr index 199227c048151..cf4d0fc5ad07f 100644 --- a/src/test/ui/conditional-compilation/cfg-attr-unknown-attribute-macro-expansion.stderr +++ b/src/test/ui/conditional-compilation/cfg-attr-unknown-attribute-macro-expansion.stderr @@ -1,4 +1,4 @@ -error[E0658]: the attribute `unknown` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: The attribute `unknown` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/cfg-attr-unknown-attribute-macro-expansion.rs:3:27 | LL | #[cfg_attr(all(), unknown)] diff --git a/src/test/ui/custom_attribute.rs b/src/test/ui/custom_attribute.rs index 37834c0206137..9cb43ab07ad6d 100644 --- a/src/test/ui/custom_attribute.rs +++ b/src/test/ui/custom_attribute.rs @@ -1,9 +1,9 @@ #![feature(stmt_expr_attributes)] -#[foo] //~ ERROR the attribute `foo` +#[foo] //~ ERROR The attribute `foo` fn main() { - #[foo] //~ ERROR the attribute `foo` + #[foo] //~ ERROR The attribute `foo` let x = (); - #[foo] //~ ERROR the attribute `foo` + #[foo] //~ ERROR The attribute `foo` x } diff --git a/src/test/ui/custom_attribute.stderr b/src/test/ui/custom_attribute.stderr index e273c064ac41c..84c4e33e55a1a 100644 --- a/src/test/ui/custom_attribute.stderr +++ b/src/test/ui/custom_attribute.stderr @@ -1,4 +1,4 @@ -error[E0658]: the attribute `foo` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: The attribute `foo` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/custom_attribute.rs:3:3 | LL | #[foo] @@ -7,7 +7,7 @@ LL | #[foo] = note: for more information, see https://github.com/rust-lang/rust/issues/29642 = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: the attribute `foo` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: The attribute `foo` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/custom_attribute.rs:5:7 | LL | #[foo] @@ -16,7 +16,7 @@ LL | #[foo] = note: for more information, see https://github.com/rust-lang/rust/issues/29642 = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: the attribute `foo` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: The attribute `foo` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/custom_attribute.rs:7:7 | LL | #[foo] diff --git a/src/test/ui/feature-gates/feature-gate-custom_attribute.stderr b/src/test/ui/feature-gates/feature-gate-custom_attribute.stderr index 11619a5dbd83f..12175feadd63a 100644 --- a/src/test/ui/feature-gates/feature-gate-custom_attribute.stderr +++ b/src/test/ui/feature-gates/feature-gate-custom_attribute.stderr @@ -1,4 +1,4 @@ -error[E0658]: the attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: The attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/feature-gate-custom_attribute.rs:7:3 | LL | #[fake_attr] @@ -7,7 +7,7 @@ LL | #[fake_attr] = note: for more information, see https://github.com/rust-lang/rust/issues/29642 = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: the attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: The attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/feature-gate-custom_attribute.rs:8:3 | LL | #[fake_attr(100)] @@ -16,7 +16,7 @@ LL | #[fake_attr(100)] = note: for more information, see https://github.com/rust-lang/rust/issues/29642 = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: the attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: The attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/feature-gate-custom_attribute.rs:9:3 | LL | #[fake_attr(1, 2, 3)] @@ -25,7 +25,7 @@ LL | #[fake_attr(1, 2, 3)] = note: for more information, see https://github.com/rust-lang/rust/issues/29642 = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: the attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: The attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/feature-gate-custom_attribute.rs:10:3 | LL | #[fake_attr("hello")] @@ -34,7 +34,7 @@ LL | #[fake_attr("hello")] = note: for more information, see https://github.com/rust-lang/rust/issues/29642 = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: the attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: The attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/feature-gate-custom_attribute.rs:11:3 | LL | #[fake_attr(name = "hello")] @@ -43,7 +43,7 @@ LL | #[fake_attr(name = "hello")] = note: for more information, see https://github.com/rust-lang/rust/issues/29642 = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: the attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: The attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/feature-gate-custom_attribute.rs:12:3 | LL | #[fake_attr(1, "hi", key = 12, true, false)] @@ -52,7 +52,7 @@ LL | #[fake_attr(1, "hi", key = 12, true, false)] = note: for more information, see https://github.com/rust-lang/rust/issues/29642 = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: the attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: The attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/feature-gate-custom_attribute.rs:13:3 | LL | #[fake_attr(key = "hello", val = 10)] @@ -61,7 +61,7 @@ LL | #[fake_attr(key = "hello", val = 10)] = note: for more information, see https://github.com/rust-lang/rust/issues/29642 = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: the attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: The attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/feature-gate-custom_attribute.rs:14:3 | LL | #[fake_attr(key("hello"), val(10))] @@ -70,7 +70,7 @@ LL | #[fake_attr(key("hello"), val(10))] = note: for more information, see https://github.com/rust-lang/rust/issues/29642 = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: the attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: The attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/feature-gate-custom_attribute.rs:15:3 | LL | #[fake_attr(enabled = true, disabled = false)] @@ -79,7 +79,7 @@ LL | #[fake_attr(enabled = true, disabled = false)] = note: for more information, see https://github.com/rust-lang/rust/issues/29642 = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: the attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: The attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/feature-gate-custom_attribute.rs:16:3 | LL | #[fake_attr(true)] @@ -88,7 +88,7 @@ LL | #[fake_attr(true)] = note: for more information, see https://github.com/rust-lang/rust/issues/29642 = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: the attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: The attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/feature-gate-custom_attribute.rs:17:3 | LL | #[fake_attr(pi = 3.14159)] @@ -97,7 +97,7 @@ LL | #[fake_attr(pi = 3.14159)] = note: for more information, see https://github.com/rust-lang/rust/issues/29642 = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: the attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: The attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/feature-gate-custom_attribute.rs:18:3 | LL | #[fake_attr(b"hi")] @@ -106,7 +106,7 @@ LL | #[fake_attr(b"hi")] = note: for more information, see https://github.com/rust-lang/rust/issues/29642 = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: the attribute `fake_doc` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: The attribute `fake_doc` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/feature-gate-custom_attribute.rs:19:3 | LL | #[fake_doc(r"doc")] diff --git a/src/test/ui/feature-gates/feature-gate-rustc-attrs.stderr b/src/test/ui/feature-gates/feature-gate-rustc-attrs.stderr index 3501aa8486032..7c5aa5381e8c7 100644 --- a/src/test/ui/feature-gates/feature-gate-rustc-attrs.stderr +++ b/src/test/ui/feature-gates/feature-gate-rustc-attrs.stderr @@ -37,7 +37,7 @@ LL | #[rustc_unknown] = note: for more information, see https://github.com/rust-lang/rust/issues/29642 = help: add `#![feature(rustc_attrs)]` to the crate attributes to enable -error[E0658]: the attribute `rustc_unknown` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: The attribute `rustc_unknown` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/feature-gate-rustc-attrs.rs:20:3 | LL | #[rustc_unknown] diff --git a/src/test/ui/issues/issue-32655.stderr b/src/test/ui/issues/issue-32655.stderr index d7fda09c31a05..43bb4105c8dbf 100644 --- a/src/test/ui/issues/issue-32655.stderr +++ b/src/test/ui/issues/issue-32655.stderr @@ -1,4 +1,4 @@ -error[E0658]: the attribute `derive_Clone` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: The attribute `derive_Clone` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/issue-32655.rs:6:11 | LL | #[derive_Clone] @@ -10,7 +10,7 @@ LL | foo!(); = note: for more information, see https://github.com/rust-lang/rust/issues/29642 = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: the attribute `derive_Clone` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: The attribute `derive_Clone` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/issue-32655.rs:18:7 | LL | #[derive_Clone] diff --git a/src/test/ui/issues/issue-49074.rs b/src/test/ui/issues/issue-49074.rs index 24d9c03fa625e..ad66e421c6b9d 100644 --- a/src/test/ui/issues/issue-49074.rs +++ b/src/test/ui/issues/issue-49074.rs @@ -1,7 +1,7 @@ // Check that unknown attribute error is shown even if there are unresolved macros. #[marco_use] // typo -//~^ ERROR the attribute `marco_use` is currently unknown to the compiler +//~^ ERROR The attribute `marco_use` is currently unknown to the compiler mod foo { macro_rules! bar { () => (); diff --git a/src/test/ui/issues/issue-49074.stderr b/src/test/ui/issues/issue-49074.stderr index 244a949d69899..3ab876dbf4254 100644 --- a/src/test/ui/issues/issue-49074.stderr +++ b/src/test/ui/issues/issue-49074.stderr @@ -1,4 +1,4 @@ -error[E0658]: the attribute `marco_use` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: The attribute `marco_use` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/issue-49074.rs:3:3 | LL | #[marco_use] // typo diff --git a/src/test/ui/macros/macro-reexport-removed.stderr b/src/test/ui/macros/macro-reexport-removed.stderr index 0d7295dcef63b..44233d7b7dda3 100644 --- a/src/test/ui/macros/macro-reexport-removed.stderr +++ b/src/test/ui/macros/macro-reexport-removed.stderr @@ -10,7 +10,7 @@ note: subsumed by `pub use` LL | #![feature(macro_reexport)] | ^^^^^^^^^^^^^^ -error[E0658]: the attribute `macro_reexport` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: The attribute `macro_reexport` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/macro-reexport-removed.rs:5:3 | LL | #[macro_reexport(macro_one)] diff --git a/src/test/ui/proc-macro/derive-helper-shadowing.stderr b/src/test/ui/proc-macro/derive-helper-shadowing.stderr index cb0a8a119e2ee..984ea4fb8addd 100644 --- a/src/test/ui/proc-macro/derive-helper-shadowing.stderr +++ b/src/test/ui/proc-macro/derive-helper-shadowing.stderr @@ -1,4 +1,4 @@ -error[E0658]: the attribute `empty_helper` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: The attribute `empty_helper` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/derive-helper-shadowing.rs:22:15 | LL | #[empty_helper] diff --git a/src/test/ui/proc-macro/derive-still-gated.stderr b/src/test/ui/proc-macro/derive-still-gated.stderr index bde9814dc660d..a6c0ce6260a4d 100644 --- a/src/test/ui/proc-macro/derive-still-gated.stderr +++ b/src/test/ui/proc-macro/derive-still-gated.stderr @@ -1,4 +1,4 @@ -error[E0658]: the attribute `derive_Empty` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: The attribute `derive_Empty` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/derive-still-gated.rs:6:3 | LL | #[derive_Empty] diff --git a/src/test/ui/proc-macro/expand-to-unstable-2.stderr b/src/test/ui/proc-macro/expand-to-unstable-2.stderr index 719156cba5c9f..3a729846d7852 100644 --- a/src/test/ui/proc-macro/expand-to-unstable-2.stderr +++ b/src/test/ui/proc-macro/expand-to-unstable-2.stderr @@ -7,7 +7,7 @@ LL | #[derive(Unstable)] = note: for more information, see https://github.com/rust-lang/rust/issues/29642 = help: add `#![feature(rustc_attrs)]` to the crate attributes to enable -error[E0658]: the attribute `rustc_foo` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: The attribute `rustc_foo` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/expand-to-unstable-2.rs:6:10 | LL | #[derive(Unstable)] diff --git a/src/test/ui/proc-macro/issue-41211.stderr b/src/test/ui/proc-macro/issue-41211.stderr index 9dd3ac27cf809..b5c08587e1958 100644 --- a/src/test/ui/proc-macro/issue-41211.stderr +++ b/src/test/ui/proc-macro/issue-41211.stderr @@ -1,4 +1,4 @@ -error[E0658]: the attribute `identity_attr` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: The attribute `identity_attr` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/issue-41211.rs:8:4 | LL | #![identity_attr] diff --git a/src/test/ui/proc-macro/macro-namespace-reserved-2.stderr b/src/test/ui/proc-macro/macro-namespace-reserved-2.stderr index c180de083799f..8a5e346c2b59f 100644 --- a/src/test/ui/proc-macro/macro-namespace-reserved-2.stderr +++ b/src/test/ui/proc-macro/macro-namespace-reserved-2.stderr @@ -76,7 +76,7 @@ error: can't use a procedural macro from the same crate that defines it LL | #[derive(MyTrait)] | ^^^^^^^ -error[E0658]: the attribute `my_macro` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: The attribute `my_macro` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/macro-namespace-reserved-2.rs:38:3 | LL | #[my_macro] diff --git a/src/test/ui/proc-macro/proc-macro-attributes.stderr b/src/test/ui/proc-macro/proc-macro-attributes.stderr index 7a9bfc4e72e6d..02dfce1a73584 100644 --- a/src/test/ui/proc-macro/proc-macro-attributes.stderr +++ b/src/test/ui/proc-macro/proc-macro-attributes.stderr @@ -1,4 +1,4 @@ -error[E0658]: the attribute `C` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: The attribute `C` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/proc-macro-attributes.rs:7:3 | LL | #[C] diff --git a/src/test/ui/proc-macro/resolve-error.stderr b/src/test/ui/proc-macro/resolve-error.stderr index 6f3f4c939f4bb..02cf7cdb964e6 100644 --- a/src/test/ui/proc-macro/resolve-error.stderr +++ b/src/test/ui/proc-macro/resolve-error.stderr @@ -1,4 +1,4 @@ -error[E0658]: the attribute `attr_proc_macra` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: The attribute `attr_proc_macra` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/resolve-error.rs:27:3 | LL | #[attr_proc_macra] @@ -7,7 +7,7 @@ LL | #[attr_proc_macra] = note: for more information, see https://github.com/rust-lang/rust/issues/29642 = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: the attribute `FooWithLongNan` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: The attribute `FooWithLongNan` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/resolve-error.rs:31:3 | LL | #[FooWithLongNan] diff --git a/src/test/ui/reserved/reserved-attr-on-macro.stderr b/src/test/ui/reserved/reserved-attr-on-macro.stderr index 0718da1027376..cbd111b47bf12 100644 --- a/src/test/ui/reserved/reserved-attr-on-macro.stderr +++ b/src/test/ui/reserved/reserved-attr-on-macro.stderr @@ -7,7 +7,7 @@ LL | #[rustc_attribute_should_be_reserved] = note: for more information, see https://github.com/rust-lang/rust/issues/29642 = help: add `#![feature(rustc_attrs)]` to the crate attributes to enable -error[E0658]: the attribute `rustc_attribute_should_be_reserved` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: The attribute `rustc_attribute_should_be_reserved` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/reserved-attr-on-macro.rs:1:3 | LL | #[rustc_attribute_should_be_reserved] diff --git a/src/test/ui/span/issue-36530.stderr b/src/test/ui/span/issue-36530.stderr index 8ff8fcb2a0607..65f03e756a2bf 100644 --- a/src/test/ui/span/issue-36530.stderr +++ b/src/test/ui/span/issue-36530.stderr @@ -1,4 +1,4 @@ -error[E0658]: the attribute `foo` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: The attribute `foo` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/issue-36530.rs:3:3 | LL | #[foo] @@ -16,7 +16,7 @@ LL | #![foo] = note: for more information, see https://github.com/rust-lang/rust/issues/54726 = help: add `#![feature(custom_inner_attributes)]` to the crate attributes to enable -error[E0658]: the attribute `foo` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: The attribute `foo` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/issue-36530.rs:5:8 | LL | #![foo] diff --git a/src/test/ui/suggestions/attribute-typos.stderr b/src/test/ui/suggestions/attribute-typos.stderr index 4cc51561b31a1..7c28e88272829 100644 --- a/src/test/ui/suggestions/attribute-typos.stderr +++ b/src/test/ui/suggestions/attribute-typos.stderr @@ -7,7 +7,7 @@ LL | #[rustc_err] = note: for more information, see https://github.com/rust-lang/rust/issues/29642 = help: add `#![feature(rustc_attrs)]` to the crate attributes to enable -error[E0658]: the attribute `rustc_err` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: The attribute `rustc_err` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/attribute-typos.rs:7:3 | LL | #[rustc_err] @@ -16,7 +16,7 @@ LL | #[rustc_err] = note: for more information, see https://github.com/rust-lang/rust/issues/29642 = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: the attribute `tests` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: The attribute `tests` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/attribute-typos.rs:4:3 | LL | #[tests] @@ -25,7 +25,7 @@ LL | #[tests] = note: for more information, see https://github.com/rust-lang/rust/issues/29642 = help: add `#![feature(custom_attribute)]` to the crate attributes to enable -error[E0658]: the attribute `deprcated` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: The attribute `deprcated` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/attribute-typos.rs:1:3 | LL | #[deprcated] diff --git a/src/test/ui/tool-attributes/tool-attributes-misplaced-1.stderr b/src/test/ui/tool-attributes/tool-attributes-misplaced-1.stderr index 3ac8c4186e164..32c9a1e8b6ed1 100644 --- a/src/test/ui/tool-attributes/tool-attributes-misplaced-1.stderr +++ b/src/test/ui/tool-attributes/tool-attributes-misplaced-1.stderr @@ -1,4 +1,4 @@ -error[E0658]: the attribute `rustfmt` is currently unknown to the compiler and may have meaning added to it in the future +error[E0658]: The attribute `rustfmt` is currently unknown to the compiler and may have meaning added to it in the future --> $DIR/tool-attributes-misplaced-1.rs:8:3 | LL | #[rustfmt] From 7111328556e0580f1323cde3d5193eb8d2767693 Mon Sep 17 00:00:00 2001 From: Jonathan Goodman Date: Sat, 13 Jul 2019 19:34:06 -0500 Subject: [PATCH 07/17] Don't drop DiagnosticBuilder if parsing fails If the explicitly given type of a `self` parameter fails to parse correctly, we need to propagate the error rather than dropping it and causing an ICE. Fixes #62660. --- src/libsyntax/parse/parser.rs | 2 +- src/test/ui/parser/issue-62660.rs | 11 +++++++++++ src/test/ui/parser/issue-62660.stderr | 8 ++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 src/test/ui/parser/issue-62660.rs create mode 100644 src/test/ui/parser/issue-62660.stderr diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 83030e89af310..aca63705f3d00 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -1498,7 +1498,7 @@ impl<'a> Parser<'a> { F: Fn(&token::Token) -> bool { let attrs = self.parse_arg_attributes()?; - if let Ok(Some(mut arg)) = self.parse_self_arg() { + if let Some(mut arg) = self.parse_self_arg()? { arg.attrs = attrs.into(); return self.recover_bad_self_arg(arg, is_trait_item); } diff --git a/src/test/ui/parser/issue-62660.rs b/src/test/ui/parser/issue-62660.rs new file mode 100644 index 0000000000000..33c8a9fa328ca --- /dev/null +++ b/src/test/ui/parser/issue-62660.rs @@ -0,0 +1,11 @@ +// Regression test for issue #62660: if a receiver's type does not +// successfully parse, emit the correct error instead of ICE-ing the compiler. + +struct Foo; + +impl Foo { + pub fn foo(_: i32, self: Box`, found `)` +} + +fn main() {} diff --git a/src/test/ui/parser/issue-62660.stderr b/src/test/ui/parser/issue-62660.stderr new file mode 100644 index 0000000000000..3a8f6797b82fb --- /dev/null +++ b/src/test/ui/parser/issue-62660.stderr @@ -0,0 +1,8 @@ +error: expected one of `!`, `(`, `+`, `,`, `::`, `<`, or `>`, found `)` + --> $DIR/issue-62660.rs:7:38 + | +LL | pub fn foo(_: i32, self: Box Date: Sun, 14 Jul 2019 11:39:10 +0200 Subject: [PATCH 08/17] miri validation: better error messages for dangling references --- src/librustc_mir/interpret/validity.rs | 4 ++-- src/test/ui/consts/const-eval/ub-ref.stderr | 2 +- src/test/ui/consts/const-eval/union-ub-fat-ptr.stderr | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/librustc_mir/interpret/validity.rs b/src/librustc_mir/interpret/validity.rs index b1b8e9751381a..da9780ac0a305 100644 --- a/src/librustc_mir/interpret/validity.rs +++ b/src/librustc_mir/interpret/validity.rs @@ -414,12 +414,12 @@ impl<'rt, 'mir, 'tcx, M: Machine<'mir, 'tcx>> ValueVisitor<'mir, 'tcx, M> required.bytes(), has.bytes()), self.path), InterpError::ReadBytesAsPointer => return validation_failure!( - "integer pointer in non-ZST reference", + "dangling reference (created from integer)", self.path ), _ => return validation_failure!( - "dangling (not entirely in bounds) reference", + "dangling reference (not entirely in bounds)", self.path ), } diff --git a/src/test/ui/consts/const-eval/ub-ref.stderr b/src/test/ui/consts/const-eval/ub-ref.stderr index 33535c235e3a3..f1702955ed7b1 100644 --- a/src/test/ui/consts/const-eval/ub-ref.stderr +++ b/src/test/ui/consts/const-eval/ub-ref.stderr @@ -34,7 +34,7 @@ error[E0080]: it is undefined behavior to use this value --> $DIR/ub-ref.rs:20:1 | LL | const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered integer pointer in non-ZST reference + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered dangling reference (created from integer) | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior diff --git a/src/test/ui/consts/const-eval/union-ub-fat-ptr.stderr b/src/test/ui/consts/const-eval/union-ub-fat-ptr.stderr index 19db90c1cb53e..aac32ecc5b747 100644 --- a/src/test/ui/consts/const-eval/union-ub-fat-ptr.stderr +++ b/src/test/ui/consts/const-eval/union-ub-fat-ptr.stderr @@ -2,7 +2,7 @@ error[E0080]: it is undefined behavior to use this value --> $DIR/union-ub-fat-ptr.rs:78:1 | LL | const B: &str = unsafe { SliceTransmute { repr: SliceRepr { ptr: &42, len: 999 } }.str}; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered dangling (not entirely in bounds) reference + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered dangling reference (not entirely in bounds) | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior @@ -26,7 +26,7 @@ error[E0080]: it is undefined behavior to use this value --> $DIR/union-ub-fat-ptr.rs:90:1 | LL | const B2: &[u8] = unsafe { SliceTransmute { repr: SliceRepr { ptr: &42, len: 999 } }.slice}; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered dangling (not entirely in bounds) reference + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered dangling reference (not entirely in bounds) | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior From cb3aa4ce2c5de3ffb38afb2ca6d7cf19cb3e9be7 Mon Sep 17 00:00:00 2001 From: Andre Bogus Date: Fri, 12 Jul 2019 22:13:48 +0200 Subject: [PATCH 09/17] Less unsafe in the array example of MaybeUninit docs --- src/libcore/mem/maybe_uninit.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/libcore/mem/maybe_uninit.rs b/src/libcore/mem/maybe_uninit.rs index 407691662d14e..f6f7ccffdb005 100644 --- a/src/libcore/mem/maybe_uninit.rs +++ b/src/libcore/mem/maybe_uninit.rs @@ -112,7 +112,6 @@ use crate::mem::ManuallyDrop; /// /// ``` /// use std::mem::{self, MaybeUninit}; -/// use std::ptr; /// /// let data = { /// // Create an uninitialized array of `MaybeUninit`. The `assume_init` is @@ -122,10 +121,13 @@ use crate::mem::ManuallyDrop; /// MaybeUninit::uninit().assume_init() /// }; /// -/// // Dropping a `MaybeUninit` does nothing, so if there is a panic during this loop, -/// // we have a memory leak, but there is no memory safety issue. +/// // Dropping a `MaybeUninit` does nothing. Thus using raw pointer +/// // assignment instead of `ptr::write` does not cause the old +/// // uninitialized value to be dropped. Also if there is a panic during +/// // this loop, we have a memory leak, but there is no memory safety +/// // issue. /// for elem in &mut data[..] { -/// unsafe { ptr::write(elem.as_mut_ptr(), vec![42]); } +/// *elem = MaybeUninit::new(vec![42]); /// } /// /// // Everything is initialized. Transmute the array to the @@ -151,7 +153,7 @@ use crate::mem::ManuallyDrop; /// let mut data_len: usize = 0; /// /// for elem in &mut data[0..500] { -/// unsafe { ptr::write(elem.as_mut_ptr(), String::from("hello")); } +/// *elem = MaybeUninit::new(String::from("hello")); /// data_len += 1; /// } /// From 2ce227dcc6213947b0dab34cc4139b80525670db Mon Sep 17 00:00:00 2001 From: Dylan MacKenzie Date: Tue, 9 Jul 2019 14:28:02 -0700 Subject: [PATCH 10/17] Actually call `visit_block_entry` in `DataflowResultsConsumer` Previously, this callback was never actually called. --- src/librustc_mir/dataflow/mod.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/librustc_mir/dataflow/mod.rs b/src/librustc_mir/dataflow/mod.rs index 5433a9013aa85..f05dfad32572d 100644 --- a/src/librustc_mir/dataflow/mod.rs +++ b/src/librustc_mir/dataflow/mod.rs @@ -333,6 +333,8 @@ pub(crate) trait DataflowResultsConsumer<'a, 'tcx: 'a> { } fn process_basic_block(&mut self, bb: BasicBlock, flow_state: &mut Self::FlowState) { + self.visit_block_entry(bb, flow_state); + let BasicBlockData { ref statements, ref terminator, is_cleanup: _ } = self.body()[bb]; let mut location = Location { block: bb, statement_index: 0 }; From 0c981e0a8a01426dbcac895d67dd33db7f5b6ff4 Mon Sep 17 00:00:00 2001 From: Andrei Homescu Date: Fri, 12 Jul 2019 15:32:46 -0700 Subject: [PATCH 11/17] Make VaListImpl<'f> invariant over the 'f lifetime --- src/libcore/ffi.rs | 13 +- .../ui/c-variadic/variadic-ffi-4.nll.stderr | 34 ++++- src/test/ui/c-variadic/variadic-ffi-4.rs | 4 +- src/test/ui/c-variadic/variadic-ffi-4.stderr | 122 ++++++++++++------ 4 files changed, 124 insertions(+), 49 deletions(-) diff --git a/src/libcore/ffi.rs b/src/libcore/ffi.rs index 4f87cc506efae..eda0e7c518c58 100644 --- a/src/libcore/ffi.rs +++ b/src/libcore/ffi.rs @@ -60,7 +60,10 @@ impl fmt::Debug for c_void { #[lang = "va_list"] pub struct VaListImpl<'f> { ptr: *mut c_void, - _marker: PhantomData<&'f c_void>, + + // Invariant over `'f`, so each `VaListImpl<'f>` object is tied to + // the region of the function it's defined in + _marker: PhantomData<&'f mut &'f c_void>, } #[cfg(any(all(not(target_arch = "aarch64"), not(target_arch = "powerpc"), @@ -96,7 +99,7 @@ pub struct VaListImpl<'f> { vr_top: *mut c_void, gr_offs: i32, vr_offs: i32, - _marker: PhantomData<&'f c_void>, + _marker: PhantomData<&'f mut &'f c_void>, } /// PowerPC ABI implementation of a `va_list`. @@ -114,7 +117,7 @@ pub struct VaListImpl<'f> { reserved: u16, overflow_arg_area: *mut c_void, reg_save_area: *mut c_void, - _marker: PhantomData<&'f c_void>, + _marker: PhantomData<&'f mut &'f c_void>, } /// x86_64 ABI implementation of a `va_list`. @@ -131,7 +134,7 @@ pub struct VaListImpl<'f> { fp_offset: i32, overflow_arg_area: *mut c_void, reg_save_area: *mut c_void, - _marker: PhantomData<&'f c_void>, + _marker: PhantomData<&'f mut &'f c_void>, } /// asm.js ABI implementation of a `va_list`. @@ -148,7 +151,7 @@ pub struct VaListImpl<'f> { #[lang = "va_list"] pub struct VaListImpl<'f> { inner: [crate::mem::MaybeUninit; 4], - _marker: PhantomData<&'f c_void>, + _marker: PhantomData<&'f mut &'f c_void>, } #[cfg(all(target_arch = "asmjs", not(windows)))] diff --git a/src/test/ui/c-variadic/variadic-ffi-4.nll.stderr b/src/test/ui/c-variadic/variadic-ffi-4.nll.stderr index 3c5131835b572..4947d6e529108 100644 --- a/src/test/ui/c-variadic/variadic-ffi-4.nll.stderr +++ b/src/test/ui/c-variadic/variadic-ffi-4.nll.stderr @@ -23,6 +23,16 @@ LL | let _ = ap.with_copy(|ap| { ap }); | | return type of closure is core::ffi::VaList<'2, '_> | has type `core::ffi::VaList<'1, '_>` +error: lifetime may not live long enough + --> $DIR/variadic-ffi-4.rs:20:5 + | +LL | pub unsafe extern "C" fn no_escape3(_: usize, mut ap0: &mut VaListImpl, mut ap1: ...) { + | ------- ------- has type `core::ffi::VaListImpl<'2>` + | | + | has type `&mut core::ffi::VaListImpl<'1>` +LL | *ap0 = ap1; + | ^^^^ assignment requires that `'1` must outlive `'2` + error: lifetime may not live long enough --> $DIR/variadic-ffi-4.rs:20:5 | @@ -34,7 +44,7 @@ LL | *ap0 = ap1; | ^^^^ assignment requires that `'1` must outlive `'2` error: lifetime may not live long enough - --> $DIR/variadic-ffi-4.rs:24:5 + --> $DIR/variadic-ffi-4.rs:25:5 | LL | pub unsafe extern "C" fn no_escape4(_: usize, ap0: &mut VaListImpl, mut ap1: ...) { | --- ------- has type `core::ffi::VaListImpl<'2>` @@ -44,7 +54,7 @@ LL | ap0 = &mut ap1; | ^^^^^^^^^^^^^^ assignment requires that `'1` must outlive `'2` error: lifetime may not live long enough - --> $DIR/variadic-ffi-4.rs:24:5 + --> $DIR/variadic-ffi-4.rs:25:5 | LL | pub unsafe extern "C" fn no_escape4(_: usize, ap0: &mut VaListImpl, mut ap1: ...) { | --- ------- has type `core::ffi::VaListImpl<'1>` @@ -54,7 +64,7 @@ LL | ap0 = &mut ap1; | ^^^^^^^^^^^^^^ assignment requires that `'1` must outlive `'2` error[E0384]: cannot assign to immutable argument `ap0` - --> $DIR/variadic-ffi-4.rs:24:5 + --> $DIR/variadic-ffi-4.rs:25:5 | LL | pub unsafe extern "C" fn no_escape4(_: usize, ap0: &mut VaListImpl, mut ap1: ...) { | --- help: make this binding mutable: `mut ap0` @@ -62,7 +72,7 @@ LL | ap0 = &mut ap1; | ^^^^^^^^^^^^^^ cannot assign to immutable argument error[E0597]: `ap1` does not live long enough - --> $DIR/variadic-ffi-4.rs:24:11 + --> $DIR/variadic-ffi-4.rs:25:11 | LL | pub unsafe extern "C" fn no_escape4(_: usize, ap0: &mut VaListImpl, mut ap1: ...) { | - let's call the lifetime of this reference `'1` @@ -76,16 +86,26 @@ LL | } | - `ap1` dropped here while still borrowed error: lifetime may not live long enough - --> $DIR/variadic-ffi-4.rs:32:5 + --> $DIR/variadic-ffi-4.rs:33:12 + | +LL | pub unsafe extern "C" fn no_escape5(_: usize, mut ap0: &mut VaListImpl, mut ap1: ...) { + | ------- ------- has type `core::ffi::VaListImpl<'2>` + | | + | has type `&mut core::ffi::VaListImpl<'1>` +LL | *ap0 = ap1.clone(); + | ^^^^^^^^^^^ argument requires that `'1` must outlive `'2` + +error: lifetime may not live long enough + --> $DIR/variadic-ffi-4.rs:33:12 | LL | pub unsafe extern "C" fn no_escape5(_: usize, mut ap0: &mut VaListImpl, mut ap1: ...) { | ------- ------- has type `core::ffi::VaListImpl<'1>` | | | has type `&mut core::ffi::VaListImpl<'2>` LL | *ap0 = ap1.clone(); - | ^^^^ assignment requires that `'1` must outlive `'2` + | ^^^^^^^^^^^ argument requires that `'1` must outlive `'2` -error: aborting due to 9 previous errors +error: aborting due to 11 previous errors Some errors have detailed explanations: E0384, E0597, E0621. For more information about an error, try `rustc --explain E0384`. diff --git a/src/test/ui/c-variadic/variadic-ffi-4.rs b/src/test/ui/c-variadic/variadic-ffi-4.rs index 07c32ecbfc2dc..4a50d352a5b20 100644 --- a/src/test/ui/c-variadic/variadic-ffi-4.rs +++ b/src/test/ui/c-variadic/variadic-ffi-4.rs @@ -18,6 +18,7 @@ pub unsafe extern "C" fn no_escape2(_: usize, ap: ...) { pub unsafe extern "C" fn no_escape3(_: usize, mut ap0: &mut VaListImpl, mut ap1: ...) { *ap0 = ap1; //~ ERROR: mismatched types + //~^ ERROR: mismatched types } pub unsafe extern "C" fn no_escape4(_: usize, ap0: &mut VaListImpl, mut ap1: ...) { @@ -29,5 +30,6 @@ pub unsafe extern "C" fn no_escape4(_: usize, ap0: &mut VaListImpl, mut ap1: ... } pub unsafe extern "C" fn no_escape5(_: usize, mut ap0: &mut VaListImpl, mut ap1: ...) { - *ap0 = ap1.clone(); //~ ERROR: cannot infer an appropriate lifetime + *ap0 = ap1.clone(); //~ ERROR: mismatched types + //~^ ERROR: mismatched types } diff --git a/src/test/ui/c-variadic/variadic-ffi-4.stderr b/src/test/ui/c-variadic/variadic-ffi-4.stderr index 72d4d8b63445a..7aa510e611304 100644 --- a/src/test/ui/c-variadic/variadic-ffi-4.stderr +++ b/src/test/ui/c-variadic/variadic-ffi-4.stderr @@ -52,6 +52,7 @@ note: the anonymous lifetime #3 defined on the function body at 19:1... | LL | / pub unsafe extern "C" fn no_escape3(_: usize, mut ap0: &mut VaListImpl, mut ap1: ...) { LL | | *ap0 = ap1; +LL | | LL | | } | |_^ note: ...does not necessarily outlive the anonymous lifetime #2 defined on the function body at 19:1 @@ -59,17 +60,43 @@ note: ...does not necessarily outlive the anonymous lifetime #2 defined on the f | LL | / pub unsafe extern "C" fn no_escape3(_: usize, mut ap0: &mut VaListImpl, mut ap1: ...) { LL | | *ap0 = ap1; +LL | | +LL | | } + | |_^ + +error[E0308]: mismatched types + --> $DIR/variadic-ffi-4.rs:20:12 + | +LL | *ap0 = ap1; + | ^^^ lifetime mismatch + | + = note: expected type `core::ffi::VaListImpl<'_>` + found type `core::ffi::VaListImpl<'_>` +note: the anonymous lifetime #2 defined on the function body at 19:1... + --> $DIR/variadic-ffi-4.rs:19:1 + | +LL | / pub unsafe extern "C" fn no_escape3(_: usize, mut ap0: &mut VaListImpl, mut ap1: ...) { +LL | | *ap0 = ap1; +LL | | +LL | | } + | |_^ +note: ...does not necessarily outlive the anonymous lifetime #3 defined on the function body at 19:1 + --> $DIR/variadic-ffi-4.rs:19:1 + | +LL | / pub unsafe extern "C" fn no_escape3(_: usize, mut ap0: &mut VaListImpl, mut ap1: ...) { +LL | | *ap0 = ap1; +LL | | LL | | } | |_^ error[E0490]: a value of type `core::ffi::VaListImpl<'_>` is borrowed for too long - --> $DIR/variadic-ffi-4.rs:24:11 + --> $DIR/variadic-ffi-4.rs:25:11 | LL | ap0 = &mut ap1; | ^^^^^^^^ | -note: the type is valid for the anonymous lifetime #1 defined on the function body at 23:1 - --> $DIR/variadic-ffi-4.rs:23:1 +note: the type is valid for the anonymous lifetime #1 defined on the function body at 24:1 + --> $DIR/variadic-ffi-4.rs:24:1 | LL | / pub unsafe extern "C" fn no_escape4(_: usize, ap0: &mut VaListImpl, mut ap1: ...) { LL | | ap0 = &mut ap1; @@ -79,8 +106,8 @@ LL | | LL | | LL | | } | |_^ -note: but the borrow lasts for the anonymous lifetime #3 defined on the function body at 23:1 - --> $DIR/variadic-ffi-4.rs:23:1 +note: but the borrow lasts for the anonymous lifetime #3 defined on the function body at 24:1 + --> $DIR/variadic-ffi-4.rs:24:1 | LL | / pub unsafe extern "C" fn no_escape4(_: usize, ap0: &mut VaListImpl, mut ap1: ...) { LL | | ap0 = &mut ap1; @@ -92,15 +119,15 @@ LL | | } | |_^ error[E0308]: mismatched types - --> $DIR/variadic-ffi-4.rs:24:11 + --> $DIR/variadic-ffi-4.rs:25:11 | LL | ap0 = &mut ap1; | ^^^^^^^^ lifetime mismatch | = note: expected type `&mut core::ffi::VaListImpl<'_>` found type `&mut core::ffi::VaListImpl<'_>` -note: the anonymous lifetime #3 defined on the function body at 23:1... - --> $DIR/variadic-ffi-4.rs:23:1 +note: the anonymous lifetime #3 defined on the function body at 24:1... + --> $DIR/variadic-ffi-4.rs:24:1 | LL | / pub unsafe extern "C" fn no_escape4(_: usize, ap0: &mut VaListImpl, mut ap1: ...) { LL | | ap0 = &mut ap1; @@ -110,8 +137,8 @@ LL | | LL | | LL | | } | |_^ -note: ...does not necessarily outlive the anonymous lifetime #2 defined on the function body at 23:1 - --> $DIR/variadic-ffi-4.rs:23:1 +note: ...does not necessarily outlive the anonymous lifetime #2 defined on the function body at 24:1 + --> $DIR/variadic-ffi-4.rs:24:1 | LL | / pub unsafe extern "C" fn no_escape4(_: usize, ap0: &mut VaListImpl, mut ap1: ...) { LL | | ap0 = &mut ap1; @@ -123,15 +150,15 @@ LL | | } | |_^ error[E0308]: mismatched types - --> $DIR/variadic-ffi-4.rs:24:11 + --> $DIR/variadic-ffi-4.rs:25:11 | LL | ap0 = &mut ap1; | ^^^^^^^^ lifetime mismatch | = note: expected type `&mut core::ffi::VaListImpl<'_>` found type `&mut core::ffi::VaListImpl<'_>` -note: the anonymous lifetime #2 defined on the function body at 23:1... - --> $DIR/variadic-ffi-4.rs:23:1 +note: the anonymous lifetime #2 defined on the function body at 24:1... + --> $DIR/variadic-ffi-4.rs:24:1 | LL | / pub unsafe extern "C" fn no_escape4(_: usize, ap0: &mut VaListImpl, mut ap1: ...) { LL | | ap0 = &mut ap1; @@ -141,8 +168,8 @@ LL | | LL | | LL | | } | |_^ -note: ...does not necessarily outlive the anonymous lifetime #3 defined on the function body at 23:1 - --> $DIR/variadic-ffi-4.rs:23:1 +note: ...does not necessarily outlive the anonymous lifetime #3 defined on the function body at 24:1 + --> $DIR/variadic-ffi-4.rs:24:1 | LL | / pub unsafe extern "C" fn no_escape4(_: usize, ap0: &mut VaListImpl, mut ap1: ...) { LL | | ap0 = &mut ap1; @@ -154,13 +181,13 @@ LL | | } | |_^ error[E0495]: cannot infer an appropriate lifetime for borrow expression due to conflicting requirements - --> $DIR/variadic-ffi-4.rs:24:11 + --> $DIR/variadic-ffi-4.rs:25:11 | LL | ap0 = &mut ap1; | ^^^^^^^^ | -note: first, the lifetime cannot outlive the anonymous lifetime #3 defined on the function body at 23:1... - --> $DIR/variadic-ffi-4.rs:23:1 +note: first, the lifetime cannot outlive the anonymous lifetime #3 defined on the function body at 24:1... + --> $DIR/variadic-ffi-4.rs:24:1 | LL | / pub unsafe extern "C" fn no_escape4(_: usize, ap0: &mut VaListImpl, mut ap1: ...) { LL | | ap0 = &mut ap1; @@ -171,12 +198,12 @@ LL | | LL | | } | |_^ note: ...so that the type `core::ffi::VaListImpl<'_>` is not borrowed for too long - --> $DIR/variadic-ffi-4.rs:24:11 + --> $DIR/variadic-ffi-4.rs:25:11 | LL | ap0 = &mut ap1; | ^^^^^^^^ -note: but, the lifetime must be valid for the anonymous lifetime #1 defined on the function body at 23:1... - --> $DIR/variadic-ffi-4.rs:23:1 +note: but, the lifetime must be valid for the anonymous lifetime #1 defined on the function body at 24:1... + --> $DIR/variadic-ffi-4.rs:24:1 | LL | / pub unsafe extern "C" fn no_escape4(_: usize, ap0: &mut VaListImpl, mut ap1: ...) { LL | | ap0 = &mut ap1; @@ -187,39 +214,62 @@ LL | | LL | | } | |_^ note: ...so that reference does not outlive borrowed content - --> $DIR/variadic-ffi-4.rs:24:11 + --> $DIR/variadic-ffi-4.rs:25:11 | LL | ap0 = &mut ap1; | ^^^^^^^^ -error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements - --> $DIR/variadic-ffi-4.rs:32:16 +error[E0308]: mismatched types + --> $DIR/variadic-ffi-4.rs:33:12 | LL | *ap0 = ap1.clone(); - | ^^^^^ + | ^^^^^^^^^^^ lifetime mismatch | -note: first, the lifetime cannot outlive the anonymous lifetime #3 defined on the function body at 31:1... - --> $DIR/variadic-ffi-4.rs:31:1 + = note: expected type `core::ffi::VaListImpl<'_>` + found type `core::ffi::VaListImpl<'_>` +note: the anonymous lifetime #3 defined on the function body at 32:1... + --> $DIR/variadic-ffi-4.rs:32:1 | LL | / pub unsafe extern "C" fn no_escape5(_: usize, mut ap0: &mut VaListImpl, mut ap1: ...) { LL | | *ap0 = ap1.clone(); +LL | | LL | | } | |_^ - = note: ...so that the types are compatible: - expected &core::ffi::VaListImpl<'_> - found &core::ffi::VaListImpl<'_> -note: but, the lifetime must be valid for the anonymous lifetime #2 defined on the function body at 31:1... - --> $DIR/variadic-ffi-4.rs:31:1 +note: ...does not necessarily outlive the anonymous lifetime #2 defined on the function body at 32:1 + --> $DIR/variadic-ffi-4.rs:32:1 | LL | / pub unsafe extern "C" fn no_escape5(_: usize, mut ap0: &mut VaListImpl, mut ap1: ...) { LL | | *ap0 = ap1.clone(); +LL | | +LL | | } + | |_^ + +error[E0308]: mismatched types + --> $DIR/variadic-ffi-4.rs:33:12 + | +LL | *ap0 = ap1.clone(); + | ^^^^^^^^^^^ lifetime mismatch + | + = note: expected type `core::ffi::VaListImpl<'_>` + found type `core::ffi::VaListImpl<'_>` +note: the anonymous lifetime #2 defined on the function body at 32:1... + --> $DIR/variadic-ffi-4.rs:32:1 + | +LL | / pub unsafe extern "C" fn no_escape5(_: usize, mut ap0: &mut VaListImpl, mut ap1: ...) { +LL | | *ap0 = ap1.clone(); +LL | | +LL | | } + | |_^ +note: ...does not necessarily outlive the anonymous lifetime #3 defined on the function body at 32:1 + --> $DIR/variadic-ffi-4.rs:32:1 + | +LL | / pub unsafe extern "C" fn no_escape5(_: usize, mut ap0: &mut VaListImpl, mut ap1: ...) { +LL | | *ap0 = ap1.clone(); +LL | | LL | | } | |_^ - = note: ...so that the expression is assignable: - expected core::ffi::VaListImpl<'_> - found core::ffi::VaListImpl<'_> -error: aborting due to 9 previous errors +error: aborting due to 11 previous errors Some errors have detailed explanations: E0308, E0621. For more information about an error, try `rustc --explain E0308`. From c221e93fcd967fc93323e7efe094a7471a043a7d Mon Sep 17 00:00:00 2001 From: nathanwhit Date: Sun, 14 Jul 2019 15:05:25 -0400 Subject: [PATCH 12/17] Add info about undefined behavior to as_ref suggestions --- src/librustc_typeck/check/method/suggest.rs | 3 +++ src/test/ui/issues/issue-21596.stderr | 1 + 2 files changed, 4 insertions(+) diff --git a/src/librustc_typeck/check/method/suggest.rs b/src/librustc_typeck/check/method/suggest.rs index 8dcfa184d7dad..5febc694def0c 100644 --- a/src/librustc_typeck/check/method/suggest.rs +++ b/src/librustc_typeck/check/method/suggest.rs @@ -331,6 +331,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { err.note("try using `<*const T>::as_ref()` to get a reference to the \ type behind the pointer: https://doc.rust-lang.org/std/\ primitive.pointer.html#method.as_ref"); + err.note("using `<*const T>::as_ref()` on a pointer \ + which is unaligned or points to invalid \ + or uninitialized memory is undefined behavior"); } err } diff --git a/src/test/ui/issues/issue-21596.stderr b/src/test/ui/issues/issue-21596.stderr index 07d29f30e988a..8e4e09b13a9bd 100644 --- a/src/test/ui/issues/issue-21596.stderr +++ b/src/test/ui/issues/issue-21596.stderr @@ -5,6 +5,7 @@ LL | println!("{}", z.to_string()); | ^^^^^^^^^ | = note: try using `<*const T>::as_ref()` to get a reference to the type behind the pointer: https://doc.rust-lang.org/std/primitive.pointer.html#method.as_ref + = note: using `<*const T>::as_ref()` on a pointer which is unaligned or points to invalid or uninitialized memory is undefined behavior = note: the method `to_string` exists but the following trait bounds were not satisfied: `*const u8 : std::string::ToString` From 009c4a7efe034cf08fc9fcaf249e1ec951246c19 Mon Sep 17 00:00:00 2001 From: Valentin Tolmer Date: Wed, 27 Feb 2019 17:10:59 +0100 Subject: [PATCH 13/17] Add debug assertions to write_bytes and copy* --- src/libcore/intrinsics.rs | 33 ++++++++++++++++++++++++++++++++- src/libcore/slice/mod.rs | 6 +++--- 2 files changed, 35 insertions(+), 4 deletions(-) diff --git a/src/libcore/intrinsics.rs b/src/libcore/intrinsics.rs index 513e22a788cdf..56e45c3695f61 100644 --- a/src/libcore/intrinsics.rs +++ b/src/libcore/intrinsics.rs @@ -36,6 +36,8 @@ issue = "0")] #![allow(missing_docs)] +use crate::mem; + #[stable(feature = "drop_in_place", since = "1.8.0")] #[rustc_deprecated(reason = "no longer an intrinsic - use `ptr::drop_in_place` directly", since = "1.18.0")] @@ -1323,6 +1325,26 @@ extern "rust-intrinsic" { // (`transmute` also falls into this category, but it cannot be wrapped due to the // check that `T` and `U` have the same size.) +/// Checks whether `ptr` is properly aligned with respect to +/// `align_of::()`. +pub(crate) fn is_aligned_and_not_null(ptr: *const T) -> bool { + !ptr.is_null() && ptr as usize % mem::align_of::() == 0 +} + +/// Checks whether the regions of memory starting at `src` and `dst` of size +/// `count * size_of::()` overlap. +fn overlaps(src: *const T, dst: *const T, count: usize) -> bool { + let src_usize = src as usize; + let dst_usize = dst as usize; + let size = mem::size_of::().checked_mul(count).unwrap(); + let diff = if src_usize > dst_usize { + src_usize - dst_usize + } else { + dst_usize - src_usize + }; + size > diff +} + /// Copies `count * size_of::()` bytes from `src` to `dst`. The source /// and destination must *not* overlap. /// @@ -1412,7 +1434,11 @@ pub unsafe fn copy_nonoverlapping(src: *const T, dst: *mut T, count: usize) { extern "rust-intrinsic" { fn copy_nonoverlapping(src: *const T, dst: *mut T, count: usize); } - copy_nonoverlapping(src, dst, count); + + debug_assert!(is_aligned_and_not_null(src), "attempt to copy from unaligned or null pointer"); + debug_assert!(is_aligned_and_not_null(dst), "attempt to copy to unaligned or null pointer"); + debug_assert!(!overlaps(src, dst, count), "attempt to copy to overlapping memory"); + copy_nonoverlapping(src, dst, count) } /// Copies `count * size_of::()` bytes from `src` to `dst`. The source @@ -1472,6 +1498,9 @@ pub unsafe fn copy(src: *const T, dst: *mut T, count: usize) { extern "rust-intrinsic" { fn copy(src: *const T, dst: *mut T, count: usize); } + + debug_assert!(is_aligned_and_not_null(src), "attempt to copy from unaligned or null pointer"); + debug_assert!(is_aligned_and_not_null(dst), "attempt to copy to unaligned or null pointer"); copy(src, dst, count) } @@ -1553,5 +1582,7 @@ pub unsafe fn write_bytes(dst: *mut T, val: u8, count: usize) { extern "rust-intrinsic" { fn write_bytes(dst: *mut T, val: u8, count: usize); } + + debug_assert!(is_aligned_and_not_null(dst), "attempt to write to unaligned or null pointer"); write_bytes(dst, val, count) } diff --git a/src/libcore/slice/mod.rs b/src/libcore/slice/mod.rs index 363ae08827558..1397a52fbbefc 100644 --- a/src/libcore/slice/mod.rs +++ b/src/libcore/slice/mod.rs @@ -25,7 +25,7 @@ use crate::cmp::Ordering::{self, Less, Equal, Greater}; use crate::cmp; use crate::fmt; -use crate::intrinsics::{assume, exact_div, unchecked_sub}; +use crate::intrinsics::{assume, exact_div, unchecked_sub, is_aligned_and_not_null}; use crate::isize; use crate::iter::*; use crate::ops::{FnMut, Try, self}; @@ -5228,7 +5228,7 @@ unsafe impl<'a, T> TrustedRandomAccess for RChunksExactMut<'a, T> { #[inline] #[stable(feature = "rust1", since = "1.0.0")] pub unsafe fn from_raw_parts<'a, T>(data: *const T, len: usize) -> &'a [T] { - debug_assert!(data as usize % mem::align_of::() == 0, "attempt to create unaligned slice"); + debug_assert!(is_aligned_and_not_null(data), "attempt to create unaligned or null slice"); debug_assert!(mem::size_of::().saturating_mul(len) <= isize::MAX as usize, "attempt to create slice covering half the address space"); &*ptr::slice_from_raw_parts(data, len) @@ -5249,7 +5249,7 @@ pub unsafe fn from_raw_parts<'a, T>(data: *const T, len: usize) -> &'a [T] { #[inline] #[stable(feature = "rust1", since = "1.0.0")] pub unsafe fn from_raw_parts_mut<'a, T>(data: *mut T, len: usize) -> &'a mut [T] { - debug_assert!(data as usize % mem::align_of::() == 0, "attempt to create unaligned slice"); + debug_assert!(is_aligned_and_not_null(data), "attempt to create unaligned or null slice"); debug_assert!(mem::size_of::().saturating_mul(len) <= isize::MAX as usize, "attempt to create slice covering half the address space"); &mut *ptr::slice_from_raw_parts_mut(data, len) From 6e8e18e3fc108999fc15741a7a1825156bb14162 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Tue, 25 Jun 2019 09:40:50 +0200 Subject: [PATCH 14/17] ignore some codegen tests in debug mode --- src/test/codegen/issue-45222.rs | 1 + src/test/codegen/issue-45466.rs | 1 + src/test/codegen/swap-small-types.rs | 1 + 3 files changed, 3 insertions(+) diff --git a/src/test/codegen/issue-45222.rs b/src/test/codegen/issue-45222.rs index da65f2dfca5d1..7f99ca724cf73 100644 --- a/src/test/codegen/issue-45222.rs +++ b/src/test/codegen/issue-45222.rs @@ -1,4 +1,5 @@ // compile-flags: -O +// ignore-debug: the debug assertions get in the way #![crate_type = "lib"] diff --git a/src/test/codegen/issue-45466.rs b/src/test/codegen/issue-45466.rs index 7d6e31cc740f5..c79542767774a 100644 --- a/src/test/codegen/issue-45466.rs +++ b/src/test/codegen/issue-45466.rs @@ -1,4 +1,5 @@ // compile-flags: -O +// ignore-debug: the debug assertions get in the way #![crate_type="rlib"] diff --git a/src/test/codegen/swap-small-types.rs b/src/test/codegen/swap-small-types.rs index c8466fed7d1bd..6205e6a6559c9 100644 --- a/src/test/codegen/swap-small-types.rs +++ b/src/test/codegen/swap-small-types.rs @@ -1,5 +1,6 @@ // compile-flags: -O // only-x86_64 +// ignore-debug: the debug assertions get in the way #![crate_type = "lib"] From 85d76a1b481dfabf49a1dead04996705f0d489d1 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Mon, 15 Jul 2019 16:58:07 +0200 Subject: [PATCH 15/17] bump compiler_builtins --- Cargo.lock | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9a9c89cd9c199..70337f79d500d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -25,7 +25,7 @@ dependencies = [ name = "alloc" version = "0.0.0" dependencies = [ - "compiler_builtins 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", + "compiler_builtins 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", "core 0.0.0", "rand 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_xorshift 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -131,7 +131,7 @@ dependencies = [ "autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "backtrace-sys 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "compiler_builtins 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", + "compiler_builtins 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-demangle 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-std-workspace-core 1.0.0", @@ -143,7 +143,7 @@ version = "0.1.27" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cc 1.0.35 (registry+https://github.com/rust-lang/crates.io-index)", - "compiler_builtins 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", + "compiler_builtins 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-std-workspace-core 1.0.0", ] @@ -373,7 +373,7 @@ name = "cfg-if" version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "compiler_builtins 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", + "compiler_builtins 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-std-workspace-core 1.0.0", ] @@ -502,7 +502,7 @@ dependencies = [ [[package]] name = "compiler_builtins" -version = "0.1.16" +version = "0.1.17" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cc 1.0.35 (registry+https://github.com/rust-lang/crates.io-index)", @@ -834,7 +834,7 @@ name = "dlmalloc" version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "compiler_builtins 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", + "compiler_builtins 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-std-workspace-core 1.0.0", ] @@ -1008,7 +1008,7 @@ name = "fortanix-sgx-abi" version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "compiler_builtins 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", + "compiler_builtins 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-std-workspace-core 1.0.0", ] @@ -1199,7 +1199,7 @@ name = "hashbrown" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "compiler_builtins 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", + "compiler_builtins 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-std-workspace-alloc 1.0.0", "rustc-std-workspace-core 1.0.0", ] @@ -2066,7 +2066,7 @@ dependencies = [ name = "panic_abort" version = "0.0.0" dependencies = [ - "compiler_builtins 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", + "compiler_builtins 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", "core 0.0.0", "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2077,7 +2077,7 @@ version = "0.0.0" dependencies = [ "alloc 0.0.0", "cfg-if 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "compiler_builtins 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", + "compiler_builtins 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", "core 0.0.0", "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", "unwind 0.0.0", @@ -2263,7 +2263,7 @@ name = "profiler_builtins" version = "0.0.0" dependencies = [ "cc 1.0.35 (registry+https://github.com/rust-lang/crates.io-index)", - "compiler_builtins 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", + "compiler_builtins 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", "core 0.0.0", ] @@ -2835,7 +2835,7 @@ name = "rustc-demangle" version = "0.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "compiler_builtins 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", + "compiler_builtins 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-std-workspace-core 1.0.0", ] @@ -2941,7 +2941,7 @@ dependencies = [ "alloc 0.0.0", "build_helper 0.1.0", "cmake 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)", - "compiler_builtins 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", + "compiler_builtins 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", "core 0.0.0", ] @@ -3160,7 +3160,7 @@ dependencies = [ "alloc 0.0.0", "build_helper 0.1.0", "cmake 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)", - "compiler_builtins 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", + "compiler_builtins 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", "core 0.0.0", ] @@ -3223,7 +3223,7 @@ dependencies = [ "alloc 0.0.0", "build_helper 0.1.0", "cmake 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)", - "compiler_builtins 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", + "compiler_builtins 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", "core 0.0.0", ] @@ -3341,7 +3341,7 @@ dependencies = [ "alloc 0.0.0", "build_helper 0.1.0", "cmake 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)", - "compiler_builtins 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", + "compiler_builtins 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", "core 0.0.0", ] @@ -3648,7 +3648,7 @@ dependencies = [ "backtrace 0.3.29 (registry+https://github.com/rust-lang/crates.io-index)", "cc 1.0.35 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "compiler_builtins 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", + "compiler_builtins 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", "core 0.0.0", "dlmalloc 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "fortanix-sgx-abi 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4309,7 +4309,7 @@ version = "0.0.0" dependencies = [ "cc 1.0.35 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "compiler_builtins 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", + "compiler_builtins 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", "core 0.0.0", "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -4527,7 +4527,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum colored 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b0aa3473e85a3161b59845d6096b289bb577874cafeaf75ea1b1beaa6572c7fc" "checksum commoncrypto 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d056a8586ba25a1e4d61cb090900e495952c7886786fc55f909ab2f819b69007" "checksum commoncrypto-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1fed34f46747aa73dfaa578069fd8279d2818ade2b55f38f22a9401c7f4083e2" -"checksum compiler_builtins 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "e79ed19793c99771b386d76e08c3419409bb3d418b81a8b8afc73524247461cf" +"checksum compiler_builtins 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)" = "ad9b4731b9e701aefe9e6bd1e9173f30526661508f9aaadaa5caec25ddf95585" "checksum compiletest_rs 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)" = "f40ecc9332b68270998995c00f8051ee856121764a0d3230e64c9efd059d27b6" "checksum constant_time_eq 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8ff012e225ce166d4422e0e78419d901719760f62ae2b7969ca6b564d1b54a9e" "checksum core-foundation 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4e2640d6d0bf22e82bed1b73c6aef8d5dd31e5abe6666c57e6d45e2649f4f887" From 04cb314ab994673b2c82dbbc748216653d736ae8 Mon Sep 17 00:00:00 2001 From: 0e4ef622 <0e4ef622@gmail.com> Date: Mon, 15 Jul 2019 10:03:53 -0500 Subject: [PATCH 16/17] Fix typo in RawWaker::new documentation poiner -> pointer --- src/libcore/task/wake.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcore/task/wake.rs b/src/libcore/task/wake.rs index f1247239f4f50..6f841bd2adf41 100644 --- a/src/libcore/task/wake.rs +++ b/src/libcore/task/wake.rs @@ -31,7 +31,7 @@ impl RawWaker { /// The `data` pointer can be used to store arbitrary data as required /// by the executor. This could be e.g. a type-erased pointer to an `Arc` /// that is associated with the task. - /// The value of this poiner will get passed to all functions that are part + /// The value of this pointer will get passed to all functions that are part /// of the `vtable` as the first parameter. /// /// The `vtable` customizes the behavior of a `Waker` which gets created From 35c248f6f0d8b7fc010cb429937df0dd17fa6fc4 Mon Sep 17 00:00:00 2001 From: Jethro Beekman Date: Mon, 15 Jul 2019 11:23:39 -0700 Subject: [PATCH 17/17] SGX target: don't pretend to be GNU/Linux to LLVM --- src/librustc_target/spec/x86_64_fortanix_unknown_sgx.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc_target/spec/x86_64_fortanix_unknown_sgx.rs b/src/librustc_target/spec/x86_64_fortanix_unknown_sgx.rs index 46cf4cd8ae353..7c24c88f7aee0 100644 --- a/src/librustc_target/spec/x86_64_fortanix_unknown_sgx.rs +++ b/src/librustc_target/spec/x86_64_fortanix_unknown_sgx.rs @@ -65,7 +65,7 @@ pub fn target() -> Result { ..Default::default() }; Ok(Target { - llvm_target: "x86_64-unknown-linux-gnu".into(), + llvm_target: "x86_64-elf".into(), target_endian: "little".into(), target_pointer_width: "64".into(), target_c_int_width: "32".into(),