about summary refs log tree commit diff
diff options
context:
space:
mode:
authorStanislav Tkach <stanislav.tkach@gmail.com>2020-05-26 23:06:46 +0300
committerStanislav Tkach <stanislav.tkach@gmail.com>2020-05-26 23:06:46 +0300
commit6ddbef170bf0b79b868088580e28c862b691bff3 (patch)
treead94de25e60b91306da929952f52e398d32c9e66
parenta9199de34d0ad78fe1ff0d072f6bd5c01906bdb3 (diff)
downloadrust-6ddbef170bf0b79b868088580e28c862b691bff3.tar.gz
rust-6ddbef170bf0b79b868088580e28c862b691bff3.zip
Simplify suggestion
-rw-r--r--src/librustc_typeck/check/callee.rs11
-rw-r--r--src/test/ui/error-codes/E0040.stderr8
-rw-r--r--src/test/ui/explicit/explicit-call-to-dtor.stderr8
-rw-r--r--src/test/ui/explicit/explicit-call-to-supertrait-dtor.stderr8
4 files changed, 16 insertions, 19 deletions
diff --git a/src/librustc_typeck/check/callee.rs b/src/librustc_typeck/check/callee.rs
index a32174a8333..f4e46a04931 100644
--- a/src/librustc_typeck/check/callee.rs
+++ b/src/librustc_typeck/check/callee.rs
@@ -38,14 +38,11 @@ pub fn check_legal_trait_for_method_call(
         let suggestion =
             if snippet.is_empty() { "drop".to_string() } else { format!("drop({})", snippet) };
 
-        let suggestion_span =
-            receiver.and_then(|s| tcx.sess.source_map().merge_spans(s, span)).unwrap_or(span);
-
         err.span_suggestion(
-            suggestion_span,
-            "consider using `drop` function",
-            suggestion,
-            Applicability::MaybeIncorrect,
+            span,
+            &format!("consider using `drop` function: `{}`", suggestion),
+            String::new(),
+            Applicability::Unspecified,
         );
 
         err.emit();
diff --git a/src/test/ui/error-codes/E0040.stderr b/src/test/ui/error-codes/E0040.stderr
index 3b864d4ea4b..69cf28b2970 100644
--- a/src/test/ui/error-codes/E0040.stderr
+++ b/src/test/ui/error-codes/E0040.stderr
@@ -2,10 +2,10 @@ error[E0040]: explicit use of destructor method
   --> $DIR/E0040.rs:13:7
    |
 LL |     x.drop();
-   |     --^^^^
-   |     | |
-   |     | explicit destructor calls not allowed
-   |     help: consider using `drop` function: `drop(x)`
+   |       ^^^^
+   |       |
+   |       explicit destructor calls not allowed
+   |       help: consider using `drop` function: `drop(x)`
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/explicit/explicit-call-to-dtor.stderr b/src/test/ui/explicit/explicit-call-to-dtor.stderr
index 33ce235b30f..5ebe4ee4b90 100644
--- a/src/test/ui/explicit/explicit-call-to-dtor.stderr
+++ b/src/test/ui/explicit/explicit-call-to-dtor.stderr
@@ -2,10 +2,10 @@ error[E0040]: explicit use of destructor method
   --> $DIR/explicit-call-to-dtor.rs:13:7
    |
 LL |     x.drop();
-   |     --^^^^
-   |     | |
-   |     | explicit destructor calls not allowed
-   |     help: consider using `drop` function: `drop(x)`
+   |       ^^^^
+   |       |
+   |       explicit destructor calls not allowed
+   |       help: consider using `drop` function: `drop(x)`
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/explicit/explicit-call-to-supertrait-dtor.stderr b/src/test/ui/explicit/explicit-call-to-supertrait-dtor.stderr
index 2e7bfac71cd..cd3fb3119a5 100644
--- a/src/test/ui/explicit/explicit-call-to-supertrait-dtor.stderr
+++ b/src/test/ui/explicit/explicit-call-to-supertrait-dtor.stderr
@@ -2,10 +2,10 @@ error[E0040]: explicit use of destructor method
   --> $DIR/explicit-call-to-supertrait-dtor.rs:17:14
    |
 LL |         self.drop();
-   |         -----^^^^
-   |         |    |
-   |         |    explicit destructor calls not allowed
-   |         help: consider using `drop` function: `drop(self)`
+   |              ^^^^
+   |              |
+   |              explicit destructor calls not allowed
+   |              help: consider using `drop` function: `drop(self)`
 
 error: aborting due to previous error