You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
error: calls to `std::mem::drop` with a value that implements Copy. Dropping a copy leaves the original intact.
--> rls-rustc/src/lib.rs:22:5
|
22 | drop(env_logger::init());
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: #[deny(clippy::drop_copy)] on by default
code:
pubfnrun(){drop(env_logger::init());let result = rustc_driver::report_ices_to_stderr_if_any(|| {let args = env::args_os().enumerate().map(|(i, arg)| {
arg.into_string().unwrap_or_else(|arg| {early_error(ErrorOutputType::default(),&format!("Argument {} is not valid Unicode: {:?}", i, arg),)})}).collect::<Vec<_>>();run_compiler(&args,&mutShimCalls,None,None)}).and_then(|result| result);
process::exit(result.is_err()asi32);}structShimCalls;implCallbacksforShimCalls{fnconfig(&mutself,config:&mut interface::Config){
config.opts.debugging_opts.continue_parse_after_error = true;
config.opts.debugging_opts.save_analysis = true;}}
I think this might be a false positive in this case because the value has no binding / is created inside the drop()?
I tried to come up with some example code
pubfna(x:i32){
std::mem::drop(A::new());}#[derive(Copy,Clone)]structA{a:i32,}implA{fnnew() -> Self{println!("yay, side effects preventing compiler from optimizing this away");A{a:4}}}
I think what the user originally wanted to do is make sure that A::new() works/is executed (it may have side effects) and is not optimized away by the compiler. However since the created object is not needed further, throw it away with drop() immediately.
Should the lint not warn in case there is no variable binding?
The text was updated successfully, but these errors were encountered:
drop(env_logger::init()); -> env_logger::init(); looks fine, but drop(A::new()); -> A::new(); looks like a typo. I think it would be better to suggest let _ = env_logger::init(); and let _ = A::new();
I was looking at rls which has this warning
code:
I think this might be a false positive in this case because the value has no binding / is created inside the
drop()
?I tried to come up with some example code
I think what the user originally wanted to do is make sure that
A::new()
works/is executed (it may have side effects) and is not optimized away by the compiler. However since the created object is not needed further, throw it away withdrop()
immediately.Should the lint not warn in case there is no variable binding?
The text was updated successfully, but these errors were encountered: