2019-01-13 19:59:00 +01:00
|
|
|
// run-rustfix
|
|
|
|
#![warn(clippy::unit_arg)]
|
|
|
|
#![allow(clippy::no_effect, unused_must_use)]
|
|
|
|
|
|
|
|
use std::fmt::Debug;
|
|
|
|
|
|
|
|
fn foo<T: Debug>(t: T) {
|
|
|
|
println!("{:?}", t);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn foo3<T1: Debug, T2: Debug, T3: Debug>(t1: T1, t2: T2, t3: T3) {
|
|
|
|
println!("{:?}, {:?}, {:?}", t1, t2, t3);
|
|
|
|
}
|
|
|
|
|
|
|
|
struct Bar;
|
|
|
|
|
|
|
|
impl Bar {
|
|
|
|
fn bar<T: Debug>(&self, t: T) {
|
|
|
|
println!("{:?}", t);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn bad() {
|
|
|
|
foo(());
|
|
|
|
foo(());
|
|
|
|
foo(());
|
|
|
|
foo(());
|
|
|
|
foo3((), 2, 2);
|
|
|
|
let b = Bar;
|
|
|
|
b.bar(());
|
|
|
|
}
|
|
|
|
|
|
|
|
fn ok() {
|
|
|
|
foo(());
|
|
|
|
foo(1);
|
|
|
|
foo({ 1 });
|
|
|
|
foo3("a", 3, vec![3]);
|
|
|
|
let b = Bar;
|
|
|
|
b.bar({ 1 });
|
|
|
|
b.bar(());
|
|
|
|
question_mark();
|
|
|
|
}
|
|
|
|
|
|
|
|
fn question_mark() -> Result<(), ()> {
|
|
|
|
Ok(Ok(())?)?;
|
|
|
|
Ok(Ok(()))??;
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
2019-01-29 06:22:08 +01:00
|
|
|
#[allow(dead_code)]
|
|
|
|
mod issue_2945 {
|
|
|
|
fn unit_fn() -> Result<(), i32> {
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
fn fallible() -> Result<(), i32> {
|
|
|
|
Ok(unit_fn()?)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-13 19:59:00 +01:00
|
|
|
fn main() {
|
|
|
|
bad();
|
|
|
|
ok();
|
|
|
|
}
|