Skip to content

Commit

Permalink
Simplify suggestion
Browse files Browse the repository at this point in the history
  • Loading branch information
stanislav-tkach committed May 26, 2020
1 parent a9199de commit 6ddbef1
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 19 deletions.
11 changes: 4 additions & 7 deletions src/librustc_typeck/check/callee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
8 changes: 4 additions & 4 deletions src/test/ui/error-codes/E0040.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 4 additions & 4 deletions src/test/ui/explicit/explicit-call-to-dtor.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 4 additions & 4 deletions src/test/ui/explicit/explicit-call-to-supertrait-dtor.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 6ddbef1

Please sign in to comment.