From ddc21d567e50437d70f7f56377834135a2d34e6e Mon Sep 17 00:00:00 2001 From: Michael Hewson Date: Thu, 9 Nov 2017 11:03:27 -0500 Subject: [PATCH] Don't emit the feature error if it's an invalid self type --- src/librustc_typeck/check/wfcheck.rs | 2 +- src/test/compile-fail/issue-26194.rs | 1 - src/test/compile-fail/ufcs-explicit-self-bad.rs | 3 --- src/test/ui/span/issue-27522.stderr | 11 +---------- 4 files changed, 2 insertions(+), 15 deletions(-) diff --git a/src/librustc_typeck/check/wfcheck.rs b/src/librustc_typeck/check/wfcheck.rs index 519392ab26c..37cf67fe53e 100644 --- a/src/librustc_typeck/check/wfcheck.rs +++ b/src/librustc_typeck/check/wfcheck.rs @@ -505,7 +505,7 @@ impl<'a, 'gcx> CheckTypeWellFormedVisitor<'a, 'gcx> { .help("consider changing to `self`, `&self`, `&mut self`, or `self: Box`") .code(DiagnosticId::Error("E0307".into())) .emit(); - break + return } } diff --git a/src/test/compile-fail/issue-26194.rs b/src/test/compile-fail/issue-26194.rs index 439115a258d..7ddd56229ce 100644 --- a/src/test/compile-fail/issue-26194.rs +++ b/src/test/compile-fail/issue-26194.rs @@ -13,7 +13,6 @@ struct S(String); impl S { fn f(self: *mut S) -> String { self.0 } //~^ ERROR invalid `self` type - //~| ERROR arbitrary `self` types are unstable } fn main() { S("".to_owned()).f(); } diff --git a/src/test/compile-fail/ufcs-explicit-self-bad.rs b/src/test/compile-fail/ufcs-explicit-self-bad.rs index 5160ceaf48e..a0d1f2dc331 100644 --- a/src/test/compile-fail/ufcs-explicit-self-bad.rs +++ b/src/test/compile-fail/ufcs-explicit-self-bad.rs @@ -17,7 +17,6 @@ struct Foo { impl Foo { fn foo(self: isize, x: isize) -> isize { //~^ ERROR invalid `self` type - //~| ERROR arbitrary `self` types are unstable self.f + x } } @@ -29,12 +28,10 @@ struct Bar { impl Bar { fn foo(self: Bar, x: isize) -> isize { //~^ ERROR invalid `self` type - //~| ERROR arbitrary `self` types are unstable x } fn bar(self: &Bar, x: isize) -> isize { //~^ ERROR invalid `self` type - //~| ERROR arbitrary `self` types are unstable x } } diff --git a/src/test/ui/span/issue-27522.stderr b/src/test/ui/span/issue-27522.stderr index e3191d7eb22..e12fb57f15d 100644 --- a/src/test/ui/span/issue-27522.stderr +++ b/src/test/ui/span/issue-27522.stderr @@ -7,14 +7,5 @@ error[E0307]: invalid `self` type: &SomeType = note: type must be `Self` or a type that dereferences to it` = help: consider changing to `self`, `&self`, `&mut self`, or `self: Box` -error: arbitrary `self` types are unstable (see issue #44874) - --> $DIR/issue-27522.rs:16:22 - | -16 | fn handler(self: &SomeType); - | ^^^^^^^^^ - | - = help: add #![feature(arbitrary_self_types)] to the crate attributes to enable - = help: consider changing to `self`, `&self`, `&mut self`, or `self: Box` - -error: aborting due to 2 previous errors +error: aborting due to previous error