Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/rustc_lint/src/drop_forget_useless.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ impl<'tcx> LateLintPass<'tcx> for DropForgetUseless {
&& let Node::Stmt(stmt) = node
&& let StmtKind::Semi(e) = stmt.kind
&& e.hir_id == expr.hir_id
&& let Some(arg_span) = arg.span.find_ancestor_inside(expr.span)
&& let Some(arg_span) = arg.span.find_ancestor_inside_same_ctxt(expr.span)
{
UseLetUnderscoreIgnoreSuggestion::Suggestion {
start_span: expr.span.shrink_to_lo().until(arg_span),
Expand Down
3 changes: 3 additions & 0 deletions tests/ui/lint/dropping_copy_types-macros.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,7 @@ fn main() {
let mut msg = String::new();
let _ = writeln!(&mut msg, "test");
//~^ ERROR calls to `std::mem::drop`

let _ = format_args!("a");
//~^ ERROR calls to `std::mem::drop`
}
3 changes: 3 additions & 0 deletions tests/ui/lint/dropping_copy_types-macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,7 @@ fn main() {
let mut msg = String::new();
drop(writeln!(&mut msg, "test"));
//~^ ERROR calls to `std::mem::drop`

drop(format_args!("a"));
//~^ ERROR calls to `std::mem::drop`
}
16 changes: 15 additions & 1 deletion tests/ui/lint/dropping_copy_types-macros.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,19 @@ LL - drop(writeln!(&mut msg, "test"));
LL + let _ = writeln!(&mut msg, "test");
|

error: aborting due to 1 previous error
error: calls to `std::mem::drop` with a value that implements `Copy` does nothing
--> $DIR/dropping_copy_types-macros.rs:13:5
|
LL | drop(format_args!("a"));
| ^^^^^-----------------^
| |
| argument has type `Arguments<'_>`
|
help: use `let _ = ...` to ignore the expression or result
|
LL - drop(format_args!("a"));
LL + let _ = format_args!("a");
|

error: aborting due to 2 previous errors

Loading