Skip to content

Commit a9199de

Browse files
Merge spans for the suggestion
1 parent 34b5118 commit a9199de

File tree

5 files changed

+24
-19
lines changed

5 files changed

+24
-19
lines changed

src/librustc_typeck/check/callee.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,18 @@ pub fn check_legal_trait_for_method_call(
3535
.and_then(|s| tcx.sess.source_map().span_to_snippet(s).ok())
3636
.unwrap_or_default();
3737

38-
let (suggestion, applicability) = if snippet.is_empty() {
39-
(snippet, Applicability::Unspecified)
40-
} else {
41-
(format!("drop({})", snippet), Applicability::MachineApplicable)
42-
};
38+
let suggestion =
39+
if snippet.is_empty() { "drop".to_string() } else { format!("drop({})", snippet) };
40+
41+
let suggestion_span =
42+
receiver.and_then(|s| tcx.sess.source_map().merge_spans(s, span)).unwrap_or(span);
4343

44-
err.span_suggestion(span, "consider using `drop` function", suggestion, applicability);
44+
err.span_suggestion(
45+
suggestion_span,
46+
"consider using `drop` function",
47+
suggestion,
48+
Applicability::MaybeIncorrect,
49+
);
4550

4651
err.emit();
4752
}

src/test/ui/error-codes/E0040.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ error[E0040]: explicit use of destructor method
22
--> $DIR/E0040.rs:13:7
33
|
44
LL | x.drop();
5-
| ^^^^
6-
| |
7-
| explicit destructor calls not allowed
8-
| help: consider using `drop` function: `drop(x)`
5+
| --^^^^
6+
| | |
7+
| | explicit destructor calls not allowed
8+
| help: consider using `drop` function: `drop(x)`
99

1010
error: aborting due to previous error
1111

src/test/ui/explicit/explicit-call-to-dtor.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ error[E0040]: explicit use of destructor method
22
--> $DIR/explicit-call-to-dtor.rs:13:7
33
|
44
LL | x.drop();
5-
| ^^^^
6-
| |
7-
| explicit destructor calls not allowed
8-
| help: consider using `drop` function: `drop(x)`
5+
| --^^^^
6+
| | |
7+
| | explicit destructor calls not allowed
8+
| help: consider using `drop` function: `drop(x)`
99

1010
error: aborting due to previous error
1111

src/test/ui/explicit/explicit-call-to-supertrait-dtor.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ error[E0040]: explicit use of destructor method
22
--> $DIR/explicit-call-to-supertrait-dtor.rs:17:14
33
|
44
LL | self.drop();
5-
| ^^^^
6-
| |
7-
| explicit destructor calls not allowed
8-
| help: consider using `drop` function: `drop(self)`
5+
| -----^^^^
6+
| | |
7+
| | explicit destructor calls not allowed
8+
| help: consider using `drop` function: `drop(self)`
99

1010
error: aborting due to previous error
1111

src/test/ui/illegal-ufcs-drop.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ LL | Drop::drop(&mut Foo)
55
| ^^^^^^^^^^
66
| |
77
| explicit destructor calls not allowed
8-
| help: consider using `drop` function
8+
| help: consider using `drop` function: `drop`
99

1010
error: aborting due to previous error
1111

0 commit comments

Comments
 (0)