fork/rust
git clone https://git.julia.blue/fork/rust
3bcad65fbf6
master
1#![allow( 2 unused, 3 clippy::redundant_clone, 4 clippy::deref_addrof, 5 clippy::no_effect, 6 clippy::unnecessary_operation, 7 clippy::vec_init_then_push, 8 clippy::toplevel_ref_arg, 9 clippy::needless_borrow 10)] 11 12use std::cell::RefCell; 13use std::rc::{self, Rc}; 14use std::sync::{self, Arc}; 15 16fn main() {} 17 18fn is_ascii(ch: char) -> bool { 19 ch.is_ascii() 20} 21 22fn clone_on_copy() -> Option<(i32)> { 23 42; 24 25 vec![1].clone(); // ok, not a Copy type 26 Some(vec![1]).clone(); // ok, not a Copy type 27 *(&42); 28 29 let rc = RefCell::new(0); 30 *rc.borrow(); 31 32 let x = 0u32; 33 x.rotate_left(1); 34 35 #[derive(Clone, Copy)] 36 struct Foo; 37 impl Foo { 38 fn clone(&self) -> u32 { 39 0 40 } 41 } 42 Foo.clone(); // ok, this is not the clone trait 43 44 macro_rules! m { 45 ($e:expr) => {{ $e }}; 46 } 47 m!(42); 48 49 struct Wrap([u32; 2]); 50 impl core::ops::Deref for Wrap { 51 type Target = [u32; 2]; 52 fn deref(&self) -> &[u32; 2] { 53 &self.0 54 } 55 } 56 let x = Wrap([0, 0]); 57 (*x)[0]; 58 59 let x = 42; 60 let ref y = x.clone(); // ok, binds by reference 61 let ref mut y = x.clone(); // ok, binds by reference 62 63 // Issue #4348 64 let mut x = 43; 65 let _ = &x.clone(); // ok, getting a ref 66 'a'.clone().make_ascii_uppercase(); // ok, clone and then mutate 67 is_ascii('z'); 68 69 // Issue #5436 70 let mut vec = Vec::new(); 71 vec.push(42); 72 73 // Issue #9277 74 let opt: &Option<i32> = &None; 75 let value = (*opt)?; // operator precedence needed (*opt)? 76 None 77}