about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2019-09-02 22:11:29 -0700
committerEsteban Küber <esteban@kuber.com.ar>2019-09-02 22:11:29 -0700
commitefe85943b3a5e7b3920db5a5a53183c75fc80d0c (patch)
tree6ad4646e21995f1227fec9c905c02c7926c16a42
parentbb99fc31d0a8f962662e636938cf96f0f70d3803 (diff)
downloadrust-efe85943b3a5e7b3920db5a5a53183c75fc80d0c.tar.gz
rust-efe85943b3a5e7b3920db5a5a53183c75fc80d0c.zip
account for DUMMY_SP and correct wording
-rw-r--r--src/librustc/error_codes.rs2
-rw-r--r--src/librustc/traits/object_safety.rs8
-rw-r--r--src/test/ui/coherence/coherence-impl-trait-for-trait-object-safe.old.stderr2
-rw-r--r--src/test/ui/coherence/coherence-impl-trait-for-trait-object-safe.re.stderr2
-rw-r--r--src/test/ui/error-codes/E0038.stderr2
-rw-r--r--src/test/ui/object-safety/object-safety-mentions-Self.stderr4
-rw-r--r--src/test/ui/resolve/issue-3907-2.stderr2
-rw-r--r--src/test/ui/traits/trait-test-2.stderr4
-rw-r--r--src/test/ui/type/type-parameter-defaults-referencing-Self-ppaux.stderr2
-rw-r--r--src/test/ui/wf/wf-object-safe.stderr2
10 files changed, 16 insertions, 14 deletions
diff --git a/src/librustc/error_codes.rs b/src/librustc/error_codes.rs
index 2d09013f675..937a9ea6c1b 100644
--- a/src/librustc/error_codes.rs
+++ b/src/librustc/error_codes.rs
@@ -39,7 +39,7 @@ Generally, `Self: Sized` is used to indicate that the trait should not be used
 as a trait object. If the trait comes from your own crate, consider removing
 this restriction.
 
-### Method references the `Self` type in its arguments or return type
+### Method references the `Self` type in its parameters or return type
 
 This happens when a trait has a method like the following:
 
diff --git a/src/librustc/traits/object_safety.rs b/src/librustc/traits/object_safety.rs
index 50f497e302e..5392e9100c6 100644
--- a/src/librustc/traits/object_safety.rs
+++ b/src/librustc/traits/object_safety.rs
@@ -20,7 +20,7 @@ use std::borrow::Cow;
 use std::iter::{self};
 use syntax::ast::{self};
 use syntax::symbol::InternedString;
-use syntax_pos::Span;
+use syntax_pos::{Span, DUMMY_SP};
 
 #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
 pub enum ObjectSafetyViolation {
@@ -49,7 +49,7 @@ impl ObjectSafetyViolation {
             ObjectSafetyViolation::Method(name, MethodViolationCode::StaticMethod, _) =>
                 format!("associated function `{}` has no `self` parameter", name).into(),
             ObjectSafetyViolation::Method(name, MethodViolationCode::ReferencesSelf, _) => format!(
-                "method `{}` references the `Self` type in its arguments or return type",
+                "method `{}` references the `Self` type in its parameters or return type",
                 name,
             ).into(),
             ObjectSafetyViolation::Method(
@@ -67,9 +67,9 @@ impl ObjectSafetyViolation {
     }
 
     pub fn span(&self) -> Option<Span> {
-        match self {
+        match *self {
             ObjectSafetyViolation::AssocConst(_, span) |
-            ObjectSafetyViolation::Method(_, _, span) => Some(*span),
+            ObjectSafetyViolation::Method(_, _, span) if span != DUMMY_SP => Some(span),
             _ => None,
         }
     }
diff --git a/src/test/ui/coherence/coherence-impl-trait-for-trait-object-safe.old.stderr b/src/test/ui/coherence/coherence-impl-trait-for-trait-object-safe.old.stderr
index 2626eab3cbf..18a7cea95bd 100644
--- a/src/test/ui/coherence/coherence-impl-trait-for-trait-object-safe.old.stderr
+++ b/src/test/ui/coherence/coherence-impl-trait-for-trait-object-safe.old.stderr
@@ -2,7 +2,7 @@ error[E0038]: the trait `NotObjectSafe` cannot be made into an object
   --> $DIR/coherence-impl-trait-for-trait-object-safe.rs:11:6
    |
 LL | trait NotObjectSafe { fn eq(&self, other: Self); }
-   |                          -- method `eq` references the `Self` type in its arguments or return type
+   |                          -- method `eq` references the `Self` type in its parameters or return type
 LL | impl NotObjectSafe for dyn NotObjectSafe { }
    |      ^^^^^^^^^^^^^ the trait `NotObjectSafe` cannot be made into an object
 
diff --git a/src/test/ui/coherence/coherence-impl-trait-for-trait-object-safe.re.stderr b/src/test/ui/coherence/coherence-impl-trait-for-trait-object-safe.re.stderr
index 2626eab3cbf..18a7cea95bd 100644
--- a/src/test/ui/coherence/coherence-impl-trait-for-trait-object-safe.re.stderr
+++ b/src/test/ui/coherence/coherence-impl-trait-for-trait-object-safe.re.stderr
@@ -2,7 +2,7 @@ error[E0038]: the trait `NotObjectSafe` cannot be made into an object
   --> $DIR/coherence-impl-trait-for-trait-object-safe.rs:11:6
    |
 LL | trait NotObjectSafe { fn eq(&self, other: Self); }
-   |                          -- method `eq` references the `Self` type in its arguments or return type
+   |                          -- method `eq` references the `Self` type in its parameters or return type
 LL | impl NotObjectSafe for dyn NotObjectSafe { }
    |      ^^^^^^^^^^^^^ the trait `NotObjectSafe` cannot be made into an object
 
diff --git a/src/test/ui/error-codes/E0038.stderr b/src/test/ui/error-codes/E0038.stderr
index 93a7681393b..5c4d6d53c46 100644
--- a/src/test/ui/error-codes/E0038.stderr
+++ b/src/test/ui/error-codes/E0038.stderr
@@ -2,7 +2,7 @@ error[E0038]: the trait `Trait` cannot be made into an object
   --> $DIR/E0038.rs:5:1
    |
 LL |     fn foo(&self) -> Self;
-   |        --- method `foo` references the `Self` type in its arguments or return type
+   |        --- method `foo` references the `Self` type in its parameters or return type
 ...
 LL | fn call_foo(x: Box<dyn Trait>) {
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Trait` cannot be made into an object
diff --git a/src/test/ui/object-safety/object-safety-mentions-Self.stderr b/src/test/ui/object-safety/object-safety-mentions-Self.stderr
index e2d1e773809..971e79cb021 100644
--- a/src/test/ui/object-safety/object-safety-mentions-Self.stderr
+++ b/src/test/ui/object-safety/object-safety-mentions-Self.stderr
@@ -2,7 +2,7 @@ error[E0038]: the trait `Bar` cannot be made into an object
   --> $DIR/object-safety-mentions-Self.rs:17:1
    |
 LL |     fn bar(&self, x: &Self);
-   |        --- method `bar` references the `Self` type in its arguments or return type
+   |        --- method `bar` references the `Self` type in its parameters or return type
 ...
 LL | fn make_bar<T:Bar>(t: &T) -> &dyn Bar {
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Bar` cannot be made into an object
@@ -11,7 +11,7 @@ error[E0038]: the trait `Baz` cannot be made into an object
   --> $DIR/object-safety-mentions-Self.rs:22:1
    |
 LL |     fn bar(&self) -> Self;
-   |        --- method `bar` references the `Self` type in its arguments or return type
+   |        --- method `bar` references the `Self` type in its parameters or return type
 ...
 LL | fn make_baz<T:Baz>(t: &T) -> &dyn Baz {
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Baz` cannot be made into an object
diff --git a/src/test/ui/resolve/issue-3907-2.stderr b/src/test/ui/resolve/issue-3907-2.stderr
index 087d1a5b9d3..63ac11dc8ae 100644
--- a/src/test/ui/resolve/issue-3907-2.stderr
+++ b/src/test/ui/resolve/issue-3907-2.stderr
@@ -3,6 +3,8 @@ error[E0038]: the trait `issue_3907::Foo` cannot be made into an object
    |
 LL | fn bar(_x: Foo) {}
    | ^^^^^^^^^^^^^^^ the trait `issue_3907::Foo` cannot be made into an object
+   |
+   = note: associated function `bar` has no `self` parameter
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/traits/trait-test-2.stderr b/src/test/ui/traits/trait-test-2.stderr
index 4d2aca0d409..83c2c065274 100644
--- a/src/test/ui/traits/trait-test-2.stderr
+++ b/src/test/ui/traits/trait-test-2.stderr
@@ -16,7 +16,7 @@ error[E0038]: the trait `bar` cannot be made into an object
 LL | trait bar { fn dup(&self) -> Self; fn blah<X>(&self); }
    |                ---                    ---- method `blah` has generic type parameters
    |                |
-   |                method `dup` references the `Self` type in its arguments or return type
+   |                method `dup` references the `Self` type in its parameters or return type
 ...
 LL |     (box 10 as Box<dyn bar>).dup();
    |                ^^^^^^^^^^^^ the trait `bar` cannot be made into an object
@@ -27,7 +27,7 @@ error[E0038]: the trait `bar` cannot be made into an object
 LL | trait bar { fn dup(&self) -> Self; fn blah<X>(&self); }
    |                ---                    ---- method `blah` has generic type parameters
    |                |
-   |                method `dup` references the `Self` type in its arguments or return type
+   |                method `dup` references the `Self` type in its parameters or return type
 ...
 LL |     (box 10 as Box<dyn bar>).dup();
    |      ^^^^^^ the trait `bar` cannot be made into an object
diff --git a/src/test/ui/type/type-parameter-defaults-referencing-Self-ppaux.stderr b/src/test/ui/type/type-parameter-defaults-referencing-Self-ppaux.stderr
index 03df5b82118..b315fe9df8a 100644
--- a/src/test/ui/type/type-parameter-defaults-referencing-Self-ppaux.stderr
+++ b/src/test/ui/type/type-parameter-defaults-referencing-Self-ppaux.stderr
@@ -14,7 +14,7 @@ error[E0038]: the trait `MyAdd` cannot be made into an object
   --> $DIR/type-parameter-defaults-referencing-Self-ppaux.rs:14:18
    |
 LL | trait MyAdd<Rhs=Self> { fn add(&self, other: &Rhs) -> Self; }
-   |                            --- method `add` references the `Self` type in its arguments or return type
+   |                            --- method `add` references the `Self` type in its parameters or return type
 ...
 LL |     let y = x as dyn MyAdd<i32>;
    |                  ^^^^^^^^^^^^^^ the trait `MyAdd` cannot be made into an object
diff --git a/src/test/ui/wf/wf-object-safe.stderr b/src/test/ui/wf/wf-object-safe.stderr
index d11af11f050..0d8441f87e7 100644
--- a/src/test/ui/wf/wf-object-safe.stderr
+++ b/src/test/ui/wf/wf-object-safe.stderr
@@ -2,7 +2,7 @@ error[E0038]: the trait `A` cannot be made into an object
   --> $DIR/wf-object-safe.rs:9:13
    |
 LL |     fn foo(&self, _x: &Self);
-   |        --- method `foo` references the `Self` type in its arguments or return type
+   |        --- method `foo` references the `Self` type in its parameters or return type
 ...
 LL |     let _x: &dyn A;
    |             ^^^^^^ the trait `A` cannot be made into an object