Merged drop_forget_ref.rs with drop_forget_copy.rs.

Moved constant message strings out of declare_lint! macros.
This commit is contained in:
Tristian Celestin 2017-02-26 21:32:41 -05:00
parent 3075b01d8c
commit 75e28610a7
5 changed files with 108 additions and 426 deletions

View File

@ -1,94 +0,0 @@
use rustc::lint::*;
use rustc::hir::*;
use utils::{match_def_path, paths, span_note_and_lint, is_copy};
const DROP_COPY_SUMMARY:&'static str = "calls to `std::mem::drop` with a value that implements Copy";
const FORGET_COPY_SUMMARY:&'static str = "calls to `std::mem::forget` with a value that implements Copy";
/// **What it does:** Checks for calls to `std::mem::drop` with a value
/// that derives the Copy trait
///
/// **Why is this bad?** Calling `std::mem::drop` [does nothing for types that
/// implement Copy](https://doc.rust-lang.org/std/mem/fn.drop.html), since the
/// value will be copied and moved into the function on invocation.
///
/// **Known problems:** None.
///
/// **Example:**
/// ```rust
/// let x:i32 = 42; // i32 implements Copy
/// std::mem::drop(x) // A copy of x is passed to the function, leaving the original unaffected
/// ```
declare_lint! {
pub DROP_COPY,
Warn,
DROP_COPY_SUMMARY
}
/// **What it does:** Checks for calls to `std::mem::forget` with a value that
/// derives the Copy trait
///
/// **Why is this bad?** Calling `std::mem::forget` [does nothing for types that
/// implement Copy](https://doc.rust-lang.org/std/mem/fn.drop.html) since the
/// value will be copied and moved into the function on invocation.
///
/// An alternative, but also valid, explanation is that Copy types do not implement
/// the Drop trait, which means they have no destructors. Without a destructor, there
/// is nothing for `std::mem::forget` to ignore.
///
/// **Known problems:** None.
///
/// **Example:**
/// ```rust
/// let x:i32 = 42; // i32 implements Copy
/// std::mem::forget(x) // A copy of x is passed to the function, leaving the original unaffected
/// ```
declare_lint! {
pub FORGET_COPY,
Warn,
FORGET_COPY_SUMMARY
}
#[allow(missing_copy_implementations)]
pub struct Pass;
impl LintPass for Pass {
fn get_lints(&self) -> LintArray {
lint_array!(DROP_COPY, FORGET_COPY)
}
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
if_let_chain!{[
let ExprCall(ref path, ref args) = expr.node,
let ExprPath(ref qpath) = path.node,
args.len() == 1,
], {
let def_id = cx.tables.qpath_def(qpath, path.id).def_id();
let lint;
let msg;
if match_def_path(cx.tcx, def_id, &paths::DROP) {
lint = DROP_COPY;
msg = DROP_COPY_SUMMARY.to_string() + ". Dropping a copy leaves the original intact.";
} else if match_def_path(cx.tcx, def_id, &paths::MEM_FORGET) {
lint = FORGET_COPY;
msg = FORGET_COPY_SUMMARY.to_string() + ". Forgetting a copy leaves the original intact.";
} else {
return;
}
let arg = &args[0];
let arg_ty = cx.tables.expr_ty(arg);
if is_copy(cx, arg_ty, cx.tcx.hir.get_parent(arg.id)) {
span_note_and_lint(cx,
lint,
expr.span,
&msg,
arg.span,
&format!("argument has type {}", arg_ty.sty));
}
}}
}
}

View File

@ -1,7 +1,7 @@
use rustc::lint::*;
use rustc::ty;
use rustc::hir::*;
use utils::{match_def_path, paths, span_note_and_lint};
use utils::{match_def_path, paths, span_note_and_lint, is_copy};
/// **What it does:** Checks for calls to `std::mem::drop` with a reference
/// instead of an owned value.
@ -45,6 +45,59 @@ declare_lint! {
"calls to `std::mem::forget` with a reference instead of an owned value"
}
/// **What it does:** Checks for calls to `std::mem::drop` with a value
/// that derives the Copy trait
///
/// **Why is this bad?** Calling `std::mem::drop` [does nothing for types that
/// implement Copy](https://doc.rust-lang.org/std/mem/fn.drop.html), since the
/// value will be copied and moved into the function on invocation.
///
/// **Known problems:** None.
///
/// **Example:**
/// ```rust
/// let x:i32 = 42; // i32 implements Copy
/// std::mem::drop(x) // A copy of x is passed to the function, leaving the original unaffected
/// ```
declare_lint! {
pub DROP_COPY,
Warn,
"calls to `std::mem::drop` with a value that implements Copy"
}
/// **What it does:** Checks for calls to `std::mem::forget` with a value that
/// derives the Copy trait
///
/// **Why is this bad?** Calling `std::mem::forget` [does nothing for types that
/// implement Copy](https://doc.rust-lang.org/std/mem/fn.drop.html) since the
/// value will be copied and moved into the function on invocation.
///
/// An alternative, but also valid, explanation is that Copy types do not implement
/// the Drop trait, which means they have no destructors. Without a destructor, there
/// is nothing for `std::mem::forget` to ignore.
///
/// **Known problems:** None.
///
/// **Example:**
/// ```rust
/// let x:i32 = 42; // i32 implements Copy
/// std::mem::forget(x) // A copy of x is passed to the function, leaving the original unaffected
/// ```
declare_lint! {
pub FORGET_COPY,
Warn,
"calls to `std::mem::forget` with a value that implements Copy"
}
const DROP_REF_SUMMARY:&str = "calls to `std::mem::drop` with a reference instead of an owned value. \
Dropping a reference does nothing.";
const FORGET_REF_SUMMARY:&str = "calls to `std::mem::forget` with a reference instead of an owned value. \
Forgetting a reference does nothing.";
const DROP_COPY_SUMMARY:&str = "calls to `std::mem::drop` with a value that implements Copy. \
Dropping a copy leaves the original intact.";
const FORGET_COPY_SUMMARY:&str = "calls to `std::mem::forget` with a value that implements Copy. \
Forgetting a copy leaves the original intact.";
#[allow(missing_copy_implementations)]
pub struct Pass;
@ -64,24 +117,39 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
let def_id = cx.tables.qpath_def(qpath, path.id).def_id();
let lint;
let msg;
if match_def_path(cx.tcx, def_id, &paths::DROP) {
lint = DROP_REF;
msg = "call to `std::mem::drop` with a reference argument. \
Dropping a reference does nothing";
} else if match_def_path(cx.tcx, def_id, &paths::MEM_FORGET) {
lint = FORGET_REF;
msg = "call to `std::mem::forget` with a reference argument. \
Forgetting a reference does nothing";
} else {
return;
}
let arg = &args[0];
let arg_ty = cx.tables.expr_ty(arg);
if let ty::TyRef(..) = arg_ty.sty {
if match_def_path(cx.tcx, def_id, &paths::DROP) {
lint = DROP_REF;
msg = DROP_REF_SUMMARY.to_string();
} else if match_def_path(cx.tcx, def_id, &paths::MEM_FORGET) {
lint = FORGET_REF;
msg = FORGET_REF_SUMMARY.to_string();
} else {
return;
}
span_note_and_lint(cx,
lint,
expr.span,
msg,
&msg,
arg.span,
&format!("argument has type {}", arg_ty.sty));
} else if is_copy(cx, arg_ty, cx.tcx.hir.get_parent(arg.id)) {
if match_def_path(cx.tcx, def_id, &paths::DROP) {
lint = DROP_COPY;
msg = DROP_COPY_SUMMARY.to_string();
} else if match_def_path(cx.tcx, def_id, &paths::MEM_FORGET) {
lint = FORGET_COPY;
msg = FORGET_COPY_SUMMARY.to_string();
} else {
return;
}
span_note_and_lint(cx,
lint,
expr.span,
&msg,
arg.span,
&format!("argument has type {}", arg_ty.sty));
}

View File

@ -72,7 +72,6 @@ pub mod cyclomatic_complexity;
pub mod derive;
pub mod doc;
pub mod double_parens;
pub mod drop_forget_copy;
pub mod drop_forget_ref;
pub mod empty_enum;
pub mod entry;
@ -270,7 +269,6 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry) {
max_single_char_names: conf.max_single_char_names,
});
reg.register_late_lint_pass(box drop_forget_ref::Pass);
reg.register_late_lint_pass(box drop_forget_copy::Pass);
reg.register_late_lint_pass(box empty_enum::EmptyEnum);
reg.register_late_lint_pass(box types::AbsurdExtremeComparisons);
reg.register_late_lint_pass(box types::InvalidUpcastComparisons);
@ -377,9 +375,9 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry) {
derive::EXPL_IMPL_CLONE_ON_COPY,
doc::DOC_MARKDOWN,
double_parens::DOUBLE_PARENS,
drop_forget_copy::DROP_COPY,
drop_forget_copy::FORGET_COPY,
drop_forget_ref::DROP_COPY,
drop_forget_ref::DROP_REF,
drop_forget_ref::FORGET_COPY,
drop_forget_ref::FORGET_REF,
entry::MAP_ENTRY,
enum_clike::ENUM_CLIKE_UNPORTABLE_VARIANT,

View File

@ -1,4 +1,4 @@
error: call to `std::mem::drop` with a value that implements Copy. Dropping a copy leaves the original intact.
error: calls to `std::mem::drop` with a value that implements Copy. Dropping a copy leaves the original intact.
--> $DIR/drop_forget_copy.rs:33:5
|
33 | drop(s1);
@ -15,7 +15,7 @@ note: argument has type SomeStruct
33 | drop(s1);
| ^^
error: call to `std::mem::drop` with a value that implements Copy. Dropping a copy leaves the original intact.
error: calls to `std::mem::drop` with a value that implements Copy. Dropping a copy leaves the original intact.
--> $DIR/drop_forget_copy.rs:34:5
|
34 | drop(s2);
@ -27,19 +27,7 @@ note: argument has type SomeStruct
34 | drop(s2);
| ^^
error: call to `std::mem::drop` with a value that implements Copy. Dropping a copy leaves the original intact.
--> $DIR/drop_forget_copy.rs:35:5
|
35 | drop(s3);
| ^^^^^^^^
|
note: argument has type &SomeStruct
--> $DIR/drop_forget_copy.rs:35:10
|
35 | drop(s3);
| ^^
error: call to `std::mem::drop` with a value that implements Copy. Dropping a copy leaves the original intact.
error: calls to `std::mem::drop` with a value that implements Copy. Dropping a copy leaves the original intact.
--> $DIR/drop_forget_copy.rs:36:5
|
36 | drop(s4);
@ -51,19 +39,7 @@ note: argument has type SomeStruct
36 | drop(s4);
| ^^
error: call to `std::mem::drop` with a value that implements Copy. Dropping a copy leaves the original intact.
--> $DIR/drop_forget_copy.rs:37:5
|
37 | drop(s5);
| ^^^^^^^^
|
note: argument has type &SomeStruct
--> $DIR/drop_forget_copy.rs:37:10
|
37 | drop(s5);
| ^^
error: call to `std::mem::forget` with a value that implements Copy. Forgetting a copy leaves the original intact.
error: calls to `std::mem::forget` with a value that implements Copy. Forgetting a copy leaves the original intact.
--> $DIR/drop_forget_copy.rs:39:5
|
39 | forget(s1);
@ -80,7 +56,7 @@ note: argument has type SomeStruct
39 | forget(s1);
| ^^
error: call to `std::mem::forget` with a value that implements Copy. Forgetting a copy leaves the original intact.
error: calls to `std::mem::forget` with a value that implements Copy. Forgetting a copy leaves the original intact.
--> $DIR/drop_forget_copy.rs:40:5
|
40 | forget(s2);
@ -92,19 +68,7 @@ note: argument has type SomeStruct
40 | forget(s2);
| ^^
error: call to `std::mem::forget` with a value that implements Copy. Forgetting a copy leaves the original intact.
--> $DIR/drop_forget_copy.rs:41:5
|
41 | forget(s3);
| ^^^^^^^^^^
|
note: argument has type &SomeStruct
--> $DIR/drop_forget_copy.rs:41:12
|
41 | forget(s3);
| ^^
error: call to `std::mem::forget` with a value that implements Copy. Forgetting a copy leaves the original intact.
error: calls to `std::mem::forget` with a value that implements Copy. Forgetting a copy leaves the original intact.
--> $DIR/drop_forget_copy.rs:42:5
|
42 | forget(s4);
@ -116,77 +80,5 @@ note: argument has type SomeStruct
42 | forget(s4);
| ^^
error: call to `std::mem::forget` with a value that implements Copy. Forgetting a copy leaves the original intact.
--> $DIR/drop_forget_copy.rs:43:5
|
43 | forget(s5);
| ^^^^^^^^^^
|
note: argument has type &SomeStruct
--> $DIR/drop_forget_copy.rs:43:12
|
43 | forget(s5);
| ^^
error: call to `std::mem::drop` with a value that implements Copy. Dropping a copy leaves the original intact.
--> $DIR/drop_forget_copy.rs:51:5
|
51 | drop(a2);
| ^^^^^^^^
|
note: argument has type &AnotherStruct
--> $DIR/drop_forget_copy.rs:51:10
|
51 | drop(a2);
| ^^
error: call to `std::mem::drop` with a value that implements Copy. Dropping a copy leaves the original intact.
--> $DIR/drop_forget_copy.rs:53:5
|
53 | drop(a4);
| ^^^^^^^^
|
note: argument has type &AnotherStruct
--> $DIR/drop_forget_copy.rs:53:10
|
53 | drop(a4);
| ^^
error: call to `std::mem::forget` with a value that implements Copy. Forgetting a copy leaves the original intact.
--> $DIR/drop_forget_copy.rs:56:5
|
56 | forget(a2);
| ^^^^^^^^^^
|
note: argument has type &AnotherStruct
--> $DIR/drop_forget_copy.rs:56:12
|
56 | forget(a2);
| ^^
error: call to `std::mem::forget` with a value that implements Copy. Forgetting a copy leaves the original intact.
--> $DIR/drop_forget_copy.rs:58:5
|
58 | forget(a3);
| ^^^^^^^^^^
|
note: argument has type &AnotherStruct
--> $DIR/drop_forget_copy.rs:58:12
|
58 | forget(a3);
| ^^
error: call to `std::mem::forget` with a value that implements Copy. Forgetting a copy leaves the original intact.
--> $DIR/drop_forget_copy.rs:59:5
|
59 | forget(a4);
| ^^^^^^^^^^
|
note: argument has type &AnotherStruct
--> $DIR/drop_forget_copy.rs:59:12
|
59 | forget(a4);
| ^^
error: aborting due to 15 previous errors
error: aborting due to 6 previous errors

View File

@ -1,4 +1,4 @@
error: call to `std::mem::drop` with a reference argument. Dropping a reference does nothing
error: calls to `std::mem::drop` with a reference instead of an owned value. Dropping a reference does nothing
--> $DIR/drop_forget_ref.rs:12:5
|
12 | drop(&SomeStruct);
@ -15,20 +15,7 @@ note: argument has type &SomeStruct
12 | drop(&SomeStruct);
| ^^^^^^^^^^^
warning: call to `std::mem::drop` with a value that implements Copy. Dropping a copy leaves the original intact.
--> $DIR/drop_forget_ref.rs:12:5
|
12 | drop(&SomeStruct);
| ^^^^^^^^^^^^^^^^^
|
= note: #[warn(drop_copy)] on by default
note: argument has type &SomeStruct
--> $DIR/drop_forget_ref.rs:12:10
|
12 | drop(&SomeStruct);
| ^^^^^^^^^^^
error: call to `std::mem::forget` with a reference argument. Forgetting a reference does nothing
error: calls to `std::mem::forget` with a reference instead of an owned value. Forgetting a reference does nothing
--> $DIR/drop_forget_ref.rs:13:5
|
13 | forget(&SomeStruct);
@ -45,20 +32,7 @@ note: argument has type &SomeStruct
13 | forget(&SomeStruct);
| ^^^^^^^^^^^
warning: call to `std::mem::forget` with a value that implements Copy. Forgetting a copy leaves the original intact.
--> $DIR/drop_forget_ref.rs:13:5
|
13 | forget(&SomeStruct);
| ^^^^^^^^^^^^^^^^^^^
|
= note: #[warn(forget_copy)] on by default
note: argument has type &SomeStruct
--> $DIR/drop_forget_ref.rs:13:12
|
13 | forget(&SomeStruct);
| ^^^^^^^^^^^
error: call to `std::mem::drop` with a reference argument. Dropping a reference does nothing
error: calls to `std::mem::drop` with a reference instead of an owned value. Dropping a reference does nothing
--> $DIR/drop_forget_ref.rs:16:5
|
16 | drop(&owned1);
@ -70,20 +44,7 @@ note: argument has type &SomeStruct
16 | drop(&owned1);
| ^^^^^^^
warning: call to `std::mem::drop` with a value that implements Copy. Dropping a copy leaves the original intact.
--> $DIR/drop_forget_ref.rs:16:5
|
16 | drop(&owned1);
| ^^^^^^^^^^^^^
|
= note: #[warn(drop_copy)] on by default
note: argument has type &SomeStruct
--> $DIR/drop_forget_ref.rs:16:10
|
16 | drop(&owned1);
| ^^^^^^^
error: call to `std::mem::drop` with a reference argument. Dropping a reference does nothing
error: calls to `std::mem::drop` with a reference instead of an owned value. Dropping a reference does nothing
--> $DIR/drop_forget_ref.rs:17:5
|
17 | drop(&&owned1);
@ -95,20 +56,7 @@ note: argument has type &&SomeStruct
17 | drop(&&owned1);
| ^^^^^^^^
warning: call to `std::mem::drop` with a value that implements Copy. Dropping a copy leaves the original intact.
--> $DIR/drop_forget_ref.rs:17:5
|
17 | drop(&&owned1);
| ^^^^^^^^^^^^^^
|
= note: #[warn(drop_copy)] on by default
note: argument has type &&SomeStruct
--> $DIR/drop_forget_ref.rs:17:10
|
17 | drop(&&owned1);
| ^^^^^^^^
error: call to `std::mem::drop` with a reference argument. Dropping a reference does nothing
error: calls to `std::mem::drop` with a reference instead of an owned value. Dropping a reference does nothing
--> $DIR/drop_forget_ref.rs:18:5
|
18 | drop(&mut owned1);
@ -120,7 +68,7 @@ note: argument has type &mut SomeStruct
18 | drop(&mut owned1);
| ^^^^^^^^^^^
error: call to `std::mem::forget` with a reference argument. Forgetting a reference does nothing
error: calls to `std::mem::forget` with a reference instead of an owned value. Forgetting a reference does nothing
--> $DIR/drop_forget_ref.rs:21:5
|
21 | forget(&owned2);
@ -132,20 +80,7 @@ note: argument has type &SomeStruct
21 | forget(&owned2);
| ^^^^^^^
warning: call to `std::mem::forget` with a value that implements Copy. Forgetting a copy leaves the original intact.
--> $DIR/drop_forget_ref.rs:21:5
|
21 | forget(&owned2);
| ^^^^^^^^^^^^^^^
|
= note: #[warn(forget_copy)] on by default
note: argument has type &SomeStruct
--> $DIR/drop_forget_ref.rs:21:12
|
21 | forget(&owned2);
| ^^^^^^^
error: call to `std::mem::forget` with a reference argument. Forgetting a reference does nothing
error: calls to `std::mem::forget` with a reference instead of an owned value. Forgetting a reference does nothing
--> $DIR/drop_forget_ref.rs:22:5
|
22 | forget(&&owned2);
@ -157,20 +92,7 @@ note: argument has type &&SomeStruct
22 | forget(&&owned2);
| ^^^^^^^^
warning: call to `std::mem::forget` with a value that implements Copy. Forgetting a copy leaves the original intact.
--> $DIR/drop_forget_ref.rs:22:5
|
22 | forget(&&owned2);
| ^^^^^^^^^^^^^^^^
|
= note: #[warn(forget_copy)] on by default
note: argument has type &&SomeStruct
--> $DIR/drop_forget_ref.rs:22:12
|
22 | forget(&&owned2);
| ^^^^^^^^
error: call to `std::mem::forget` with a reference argument. Forgetting a reference does nothing
error: calls to `std::mem::forget` with a reference instead of an owned value. Forgetting a reference does nothing
--> $DIR/drop_forget_ref.rs:23:5
|
23 | forget(&mut owned2);
@ -182,7 +104,7 @@ note: argument has type &mut SomeStruct
23 | forget(&mut owned2);
| ^^^^^^^^^^^
error: call to `std::mem::drop` with a reference argument. Dropping a reference does nothing
error: calls to `std::mem::drop` with a reference instead of an owned value. Dropping a reference does nothing
--> $DIR/drop_forget_ref.rs:27:5
|
27 | drop(reference1);
@ -194,20 +116,7 @@ note: argument has type &SomeStruct
27 | drop(reference1);
| ^^^^^^^^^^
warning: call to `std::mem::drop` with a value that implements Copy. Dropping a copy leaves the original intact.
--> $DIR/drop_forget_ref.rs:27:5
|
27 | drop(reference1);
| ^^^^^^^^^^^^^^^^
|
= note: #[warn(drop_copy)] on by default
note: argument has type &SomeStruct
--> $DIR/drop_forget_ref.rs:27:10
|
27 | drop(reference1);
| ^^^^^^^^^^
error: call to `std::mem::forget` with a reference argument. Forgetting a reference does nothing
error: calls to `std::mem::forget` with a reference instead of an owned value. Forgetting a reference does nothing
--> $DIR/drop_forget_ref.rs:28:5
|
28 | forget(&*reference1);
@ -219,20 +128,7 @@ note: argument has type &SomeStruct
28 | forget(&*reference1);
| ^^^^^^^^^^^^
warning: call to `std::mem::forget` with a value that implements Copy. Forgetting a copy leaves the original intact.
--> $DIR/drop_forget_ref.rs:28:5
|
28 | forget(&*reference1);
| ^^^^^^^^^^^^^^^^^^^^
|
= note: #[warn(forget_copy)] on by default
note: argument has type &SomeStruct
--> $DIR/drop_forget_ref.rs:28:12
|
28 | forget(&*reference1);
| ^^^^^^^^^^^^
error: call to `std::mem::drop` with a reference argument. Dropping a reference does nothing
error: calls to `std::mem::drop` with a reference instead of an owned value. Dropping a reference does nothing
--> $DIR/drop_forget_ref.rs:31:5
|
31 | drop(reference2);
@ -244,7 +140,7 @@ note: argument has type &mut SomeStruct
31 | drop(reference2);
| ^^^^^^^^^^
error: call to `std::mem::forget` with a reference argument. Forgetting a reference does nothing
error: calls to `std::mem::forget` with a reference instead of an owned value. Forgetting a reference does nothing
--> $DIR/drop_forget_ref.rs:33:5
|
33 | forget(reference3);
@ -256,7 +152,7 @@ note: argument has type &mut SomeStruct
33 | forget(reference3);
| ^^^^^^^^^^
error: call to `std::mem::drop` with a reference argument. Dropping a reference does nothing
error: calls to `std::mem::drop` with a reference instead of an owned value. Dropping a reference does nothing
--> $DIR/drop_forget_ref.rs:36:5
|
36 | drop(reference4);
@ -268,20 +164,7 @@ note: argument has type &SomeStruct
36 | drop(reference4);
| ^^^^^^^^^^
warning: call to `std::mem::drop` with a value that implements Copy. Dropping a copy leaves the original intact.
--> $DIR/drop_forget_ref.rs:36:5
|
36 | drop(reference4);
| ^^^^^^^^^^^^^^^^
|
= note: #[warn(drop_copy)] on by default
note: argument has type &SomeStruct
--> $DIR/drop_forget_ref.rs:36:10
|
36 | drop(reference4);
| ^^^^^^^^^^
error: call to `std::mem::forget` with a reference argument. Forgetting a reference does nothing
error: calls to `std::mem::forget` with a reference instead of an owned value. Forgetting a reference does nothing
--> $DIR/drop_forget_ref.rs:37:5
|
37 | forget(reference4);
@ -293,20 +176,7 @@ note: argument has type &SomeStruct
37 | forget(reference4);
| ^^^^^^^^^^
warning: call to `std::mem::forget` with a value that implements Copy. Forgetting a copy leaves the original intact.
--> $DIR/drop_forget_ref.rs:37:5
|
37 | forget(reference4);
| ^^^^^^^^^^^^^^^^^^
|
= note: #[warn(forget_copy)] on by default
note: argument has type &SomeStruct
--> $DIR/drop_forget_ref.rs:37:12
|
37 | forget(reference4);
| ^^^^^^^^^^
error: call to `std::mem::drop` with a reference argument. Dropping a reference does nothing
error: calls to `std::mem::drop` with a reference instead of an owned value. Dropping a reference does nothing
--> $DIR/drop_forget_ref.rs:42:5
|
42 | drop(&val);
@ -318,20 +188,7 @@ note: argument has type &T
42 | drop(&val);
| ^^^^
warning: call to `std::mem::drop` with a value that implements Copy. Dropping a copy leaves the original intact.
--> $DIR/drop_forget_ref.rs:42:5
|
42 | drop(&val);
| ^^^^^^^^^^
|
= note: #[warn(drop_copy)] on by default
note: argument has type &T
--> $DIR/drop_forget_ref.rs:42:10
|
42 | drop(&val);
| ^^^^
error: call to `std::mem::forget` with a reference argument. Forgetting a reference does nothing
error: calls to `std::mem::forget` with a reference instead of an owned value. Forgetting a reference does nothing
--> $DIR/drop_forget_ref.rs:48:5
|
48 | forget(&val);
@ -343,20 +200,7 @@ note: argument has type &T
48 | forget(&val);
| ^^^^
warning: call to `std::mem::forget` with a value that implements Copy. Forgetting a copy leaves the original intact.
--> $DIR/drop_forget_ref.rs:48:5
|
48 | forget(&val);
| ^^^^^^^^^^^^
|
= note: #[warn(forget_copy)] on by default
note: argument has type &T
--> $DIR/drop_forget_ref.rs:48:12
|
48 | forget(&val);
| ^^^^
error: call to `std::mem::drop` with a reference argument. Dropping a reference does nothing
error: calls to `std::mem::drop` with a reference instead of an owned value. Dropping a reference does nothing
--> $DIR/drop_forget_ref.rs:56:5
|
56 | std::mem::drop(&SomeStruct);
@ -368,20 +212,7 @@ note: argument has type &SomeStruct
56 | std::mem::drop(&SomeStruct);
| ^^^^^^^^^^^
warning: call to `std::mem::drop` with a value that implements Copy. Dropping a copy leaves the original intact.
--> $DIR/drop_forget_ref.rs:56:5
|
56 | std::mem::drop(&SomeStruct);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: #[warn(drop_copy)] on by default
note: argument has type &SomeStruct
--> $DIR/drop_forget_ref.rs:56:20
|
56 | std::mem::drop(&SomeStruct);
| ^^^^^^^^^^^
error: call to `std::mem::forget` with a reference argument. Forgetting a reference does nothing
error: calls to `std::mem::forget` with a reference instead of an owned value. Forgetting a reference does nothing
--> $DIR/drop_forget_ref.rs:59:5
|
59 | std::mem::forget(&SomeStruct);
@ -393,18 +224,5 @@ note: argument has type &SomeStruct
59 | std::mem::forget(&SomeStruct);
| ^^^^^^^^^^^
warning: call to `std::mem::forget` with a value that implements Copy. Forgetting a copy leaves the original intact.
--> $DIR/drop_forget_ref.rs:59:5
|
59 | std::mem::forget(&SomeStruct);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: #[warn(forget_copy)] on by default
note: argument has type &SomeStruct
--> $DIR/drop_forget_ref.rs:59:22
|
59 | std::mem::forget(&SomeStruct);
| ^^^^^^^^^^^
error: aborting due to 18 previous errors