2023-04-23 11:03:09 +00:00
|
|
|
//@run-rustfix
|
2020-07-14 12:59:59 +00:00
|
|
|
|
|
|
|
#![allow(
|
|
|
|
unused,
|
|
|
|
clippy::redundant_clone,
|
|
|
|
clippy::deref_addrof,
|
|
|
|
clippy::no_effect,
|
2021-01-15 09:56:44 +00:00
|
|
|
clippy::unnecessary_operation,
|
2021-04-08 15:50:13 +00:00
|
|
|
clippy::vec_init_then_push,
|
2022-01-27 14:12:45 +00:00
|
|
|
clippy::toplevel_ref_arg,
|
|
|
|
clippy::needless_borrow
|
2020-07-14 12:59:59 +00:00
|
|
|
)]
|
|
|
|
|
|
|
|
use std::cell::RefCell;
|
|
|
|
use std::rc::{self, Rc};
|
|
|
|
use std::sync::{self, Arc};
|
|
|
|
|
|
|
|
fn main() {}
|
|
|
|
|
|
|
|
fn is_ascii(ch: char) -> bool {
|
|
|
|
ch.is_ascii()
|
|
|
|
}
|
|
|
|
|
2022-08-11 17:42:16 +00:00
|
|
|
fn clone_on_copy() -> Option<(i32)> {
|
2020-07-14 12:59:59 +00:00
|
|
|
42;
|
|
|
|
|
|
|
|
vec![1].clone(); // ok, not a Copy type
|
|
|
|
Some(vec![1]).clone(); // ok, not a Copy type
|
|
|
|
*(&42);
|
|
|
|
|
|
|
|
let rc = RefCell::new(0);
|
|
|
|
*rc.borrow();
|
|
|
|
|
2021-04-08 15:50:13 +00:00
|
|
|
let x = 0u32;
|
|
|
|
x.rotate_left(1);
|
|
|
|
|
|
|
|
#[derive(Clone, Copy)]
|
|
|
|
struct Foo;
|
|
|
|
impl Foo {
|
|
|
|
fn clone(&self) -> u32 {
|
|
|
|
0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Foo.clone(); // ok, this is not the clone trait
|
|
|
|
|
|
|
|
macro_rules! m {
|
|
|
|
($e:expr) => {{ $e }};
|
|
|
|
}
|
|
|
|
m!(42);
|
|
|
|
|
|
|
|
struct Wrap([u32; 2]);
|
|
|
|
impl core::ops::Deref for Wrap {
|
|
|
|
type Target = [u32; 2];
|
|
|
|
fn deref(&self) -> &[u32; 2] {
|
|
|
|
&self.0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
let x = Wrap([0, 0]);
|
|
|
|
(*x)[0];
|
|
|
|
|
|
|
|
let x = 42;
|
|
|
|
let ref y = x.clone(); // ok, binds by reference
|
|
|
|
let ref mut y = x.clone(); // ok, binds by reference
|
|
|
|
|
2020-07-14 12:59:59 +00:00
|
|
|
// Issue #4348
|
|
|
|
let mut x = 43;
|
|
|
|
let _ = &x.clone(); // ok, getting a ref
|
|
|
|
'a'.clone().make_ascii_uppercase(); // ok, clone and then mutate
|
|
|
|
is_ascii('z');
|
|
|
|
|
|
|
|
// Issue #5436
|
|
|
|
let mut vec = Vec::new();
|
|
|
|
vec.push(42);
|
2022-08-11 17:42:16 +00:00
|
|
|
|
|
|
|
// Issue #9277
|
|
|
|
let opt: &Option<i32> = &None;
|
|
|
|
let value = (*opt)?; // operator precedence needed (*opt)?
|
|
|
|
None
|
2020-07-14 12:59:59 +00:00
|
|
|
}
|