mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-24 05:33:27 +00:00
76 lines
1.9 KiB
Rust
76 lines
1.9 KiB
Rust
// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT
|
|
// file at the top-level directory of this distribution.
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
// option. This file may not be copied, modified, or distributed
|
|
// except according to those terms.
|
|
|
|
#![feature(box_syntax)]
|
|
#![allow(clippy::deref_addrof)]
|
|
#![warn(clippy::unnecessary_operation)]
|
|
|
|
struct Tuple(i32);
|
|
struct Struct {
|
|
field: i32
|
|
}
|
|
enum Enum {
|
|
Tuple(i32),
|
|
Struct { field: i32 },
|
|
}
|
|
struct DropStruct {
|
|
field: i32
|
|
}
|
|
impl Drop for DropStruct {
|
|
fn drop(&mut self) {}
|
|
}
|
|
struct DropTuple(i32);
|
|
impl Drop for DropTuple {
|
|
fn drop(&mut self) {}
|
|
}
|
|
enum DropEnum {
|
|
Tuple(i32),
|
|
Struct { field: i32 },
|
|
}
|
|
impl Drop for DropEnum {
|
|
fn drop(&mut self) {}
|
|
}
|
|
struct FooString {
|
|
s: String,
|
|
}
|
|
|
|
fn get_number() -> i32 { 0 }
|
|
fn get_struct() -> Struct { Struct { field: 0 } }
|
|
fn get_drop_struct() -> DropStruct { DropStruct { field: 0 } }
|
|
|
|
fn main() {
|
|
Tuple(get_number());
|
|
Struct { field: get_number() };
|
|
Struct { ..get_struct() };
|
|
Enum::Tuple(get_number());
|
|
Enum::Struct { field: get_number() };
|
|
5 + get_number();
|
|
*&get_number();
|
|
&get_number();
|
|
(5, 6, get_number());
|
|
box get_number();
|
|
get_number()..;
|
|
..get_number();
|
|
5..get_number();
|
|
[42, get_number()];
|
|
[42, 55][get_number() as usize];
|
|
(42, get_number()).1;
|
|
[get_number(); 55];
|
|
[42; 55][get_number() as usize];
|
|
{get_number()};
|
|
FooString { s: String::from("blah"), };
|
|
|
|
// Do not warn
|
|
DropTuple(get_number());
|
|
DropStruct { field: get_number() };
|
|
DropStruct { field: get_number() };
|
|
DropStruct { ..get_drop_struct() };
|
|
DropEnum::Tuple(get_number());
|
|
DropEnum::Struct { field: get_number() };
|
|
}
|