Adjust UI tests for unit_bindings

- Either explicitly annotate `let x: () = expr;` where `x` has unit
  type, or remove the unit binding to leave only `expr;` instead.
- Fix disjoint-capture-in-same-closure test
This commit is contained in:
许杰友 Jieyou Xu (Joe) 2023-06-12 16:55:36 +08:00
parent 37998ab508
commit edafbaffb2
No known key found for this signature in database
GPG Key ID: C5FD5D32014FDB47
61 changed files with 117 additions and 117 deletions

View File

@ -6,7 +6,7 @@ fn test_assign() {
let y: () = x = 10; let y: () = x = 10;
assert_eq!(x, 10); assert_eq!(x, 10);
assert_eq!(y, ()); assert_eq!(y, ());
let mut z = x = 11; let mut z: () = x = 11;
assert_eq!(x, 11); assert_eq!(x, 11);
assert_eq!(z, ()); assert_eq!(z, ());
z = x = 12; z = x = 12;
@ -19,7 +19,7 @@ fn test_assign_op() {
let y: () = x += 10; let y: () = x += 10;
assert_eq!(x, 10); assert_eq!(x, 10);
assert_eq!(y, ()); assert_eq!(y, ());
let mut z = x += 11; let mut z: () = x += 11;
assert_eq!(x, 21); assert_eq!(x, 21);
assert_eq!(z, ()); assert_eq!(z, ());
z = x += 12; z = x += 12;

View File

@ -59,8 +59,8 @@ fn def_et4() -> Et4 {
pub fn use_et4() { assert_forall_tr2(def_et4().mk()); } pub fn use_et4() { assert_forall_tr2(def_et4().mk()); }
fn main() { fn main() {
let _ = use_et1(); use_et1();
let _ = use_et2(); use_et2();
let _ = use_et3(); use_et3();
let _ = use_et4(); use_et4();
} }

View File

@ -66,8 +66,8 @@ fn def_et4() -> Box<dyn Tr1<As1: for<'a> Tr2<'a>>> {
pub fn use_et4() { assert_forall_tr2(def_et4().mk()); } pub fn use_et4() { assert_forall_tr2(def_et4().mk()); }
fn main() { fn main() {
let _ = use_et1(); use_et1();
let _ = use_et2(); use_et2();
let _ = use_et3(); use_et3();
let _ = use_et4(); use_et4();
} }

View File

@ -57,8 +57,8 @@ fn def_et4() -> impl Tr1<As1: for<'a> Tr2<'a>> {
pub fn use_et4() { assert_forall_tr2(def_et4().mk()); } pub fn use_et4() { assert_forall_tr2(def_et4().mk()); }
fn main() { fn main() {
let _ = use_et1(); use_et1();
let _ = use_et2(); use_et2();
let _ = use_et3(); use_et3();
let _ = use_et4(); use_et4();
} }

View File

@ -89,8 +89,8 @@ pub fn use_et4() {
} }
fn main() { fn main() {
let _ = use_et1(); use_et1();
let _ = use_et2(); use_et2();
let _ = use_et3(); use_et3();
let _ = use_et4(); use_et4();
} }

View File

@ -6,10 +6,10 @@
use std::future::{Future, Ready}; use std::future::{Future, Ready};
async fn read() { async fn read() {
let _ = connect(&()).await; connect(&()).await;
} }
async fn connect<A: ToSocketAddr>(addr: A) { async fn connect<A: ToSocketAddr>(addr: A) {
let _ = addr.to_socket_addr().await; addr.to_socket_addr().await;
} }
pub trait ToSocketAddr { pub trait ToSocketAddr {
type Future: Future<Output = ()>; type Future: Future<Output = ()>;

View File

@ -21,7 +21,7 @@ impl Agent {
let mut info = self.info_result.clone(); let mut info = self.info_result.clone();
info.node = Some("bar".into()); info.node = Some("bar".into());
let element = parse_info(info); let element = parse_info(info);
let _ = send_element(element).await; send_element(element).await;
} }
} }

View File

@ -21,7 +21,7 @@ impl Agent {
let mut info = self.info_result.clone(); let mut info = self.info_result.clone();
info.node = Some("bar".into()); info.node = Some("bar".into());
let element = parse_info(info); let element = parse_info(info);
let _ = send_element(element).await; send_element(element).await;
} }
} }

View File

@ -6,13 +6,13 @@ LL | pub fn foo() -> impl Future + Send {
| |
= help: the trait `Sync` is not implemented for `(dyn Any + Send + 'static)` = help: the trait `Sync` is not implemented for `(dyn Any + Send + 'static)`
note: future is not `Send` as this value is used across an await note: future is not `Send` as this value is used across an await
--> $DIR/issue-64130-4-async-move.rs:27:32 --> $DIR/issue-64130-4-async-move.rs:27:23
| |
LL | match client.status() { LL | match client.status() {
| ------ has type `&Client` which is not `Send` | ------ has type `&Client` which is not `Send`
LL | 200 => { LL | 200 => {
LL | let _x = get().await; LL | get().await;
| ^^^^^ await occurs here, with `client` maybe used later | ^^^^^ await occurs here, with `client` maybe used later
... ...
LL | } LL | }
| - `client` is later dropped here | - `client` is later dropped here

View File

@ -24,7 +24,7 @@ pub fn foo() -> impl Future + Send {
async move { async move {
match client.status() { match client.status() {
200 => { 200 => {
let _x = get().await; get().await;
} }
_ => (), _ => (),
} }

View File

@ -7,7 +7,7 @@
#![feature(generators)] #![feature(generators)]
fn main() { fn main() {
let _ = foo(); foo();
} }
fn foo() { fn foo() {

View File

@ -81,7 +81,7 @@ fn main() {
// check that lints work // check that lints work
#[allow(non_snake_case)] #[allow(non_snake_case)]
let FOOBAR = { let FOOBAR: () = {
fn SYLADEX() {} fn SYLADEX() {}
}; };

View File

@ -15,7 +15,7 @@ struct Struct {
fn main() { fn main() {
let mut s = Struct { x: 10, y: 10, s: String::new() }; let mut s = Struct { x: 10, y: 10, s: String::new() };
let mut c = { let mut c = || {
s.x += 10; s.x += 10;
s.y += 42; s.y += 42;
s.s = String::from("new"); s.s = String::from("new");

View File

@ -7,7 +7,7 @@ use std::marker::PhantomData;
fn main() { fn main() {
let x = FooImpl::<BarImpl<1>> { phantom: PhantomData }; let x = FooImpl::<BarImpl<1>> { phantom: PhantomData };
let _ = x.foo::<BarImpl<1>>(); x.foo::<BarImpl<1>>();
} }
trait Foo<T> trait Foo<T>

View File

@ -10,5 +10,5 @@ impl T<0usize> for S {
} }
fn main() { fn main() {
let _err = <S as T<0usize>>::f(); <S as T<0usize>>::f();
} }

View File

@ -8,7 +8,7 @@ trait ZeroSized: Sized {
impl<T: Sized> ZeroSized for T { impl<T: Sized> ZeroSized for T {
const I_AM_ZERO_SIZED: () = [()][std::mem::size_of::<Self>()]; //~ ERROR evaluation of `<u32 as ZeroSized>::I_AM_ZERO_SIZED` failed const I_AM_ZERO_SIZED: () = [()][std::mem::size_of::<Self>()]; //~ ERROR evaluation of `<u32 as ZeroSized>::I_AM_ZERO_SIZED` failed
fn requires_zero_size(self) { fn requires_zero_size(self) {
let () = Self::I_AM_ZERO_SIZED; Self::I_AM_ZERO_SIZED;
println!("requires_zero_size called"); println!("requires_zero_size called");
} }
} }

View File

@ -10,7 +10,7 @@ const fn no_codegen<T>() {
if false { if false {
// This bad constant is only used in dead code in a no-codegen function... and yet we still // This bad constant is only used in dead code in a no-codegen function... and yet we still
// must make sure that the build fails. // must make sure that the build fails.
let _ = PrintName::<T>::VOID; //~ constant PrintName::<T>::VOID; //~ constant
} }
} }

View File

@ -5,10 +5,10 @@ LL | const VOID: () = [()][2];
| ^^^^^^^ index out of bounds: the length is 1 but the index is 2 | ^^^^^^^ index out of bounds: the length is 1 but the index is 2
note: erroneous constant used note: erroneous constant used
--> $DIR/erroneous-const.rs:13:17 --> $DIR/erroneous-const.rs:13:13
| |
LL | let _ = PrintName::<T>::VOID; LL | PrintName::<T>::VOID;
| ^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^
error: aborting due to previous error error: aborting due to previous error

View File

@ -10,7 +10,7 @@ pub static FOO: () = {
if false { if false {
// This bad constant is only used in dead code in a static initializer... and yet we still // This bad constant is only used in dead code in a static initializer... and yet we still
// must make sure that the build fails. // must make sure that the build fails.
let _ = PrintName::<i32>::VOID; //~ constant PrintName::<i32>::VOID; //~ constant
} }
}; };

View File

@ -5,10 +5,10 @@ LL | const VOID: () = [()][2];
| ^^^^^^^ index out of bounds: the length is 1 but the index is 2 | ^^^^^^^ index out of bounds: the length is 1 but the index is 2
note: erroneous constant used note: erroneous constant used
--> $DIR/erroneous-const2.rs:13:17 --> $DIR/erroneous-const2.rs:13:9
| |
LL | let _ = PrintName::<i32>::VOID; LL | PrintName::<i32>::VOID;
| ^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to previous error error: aborting due to previous error

View File

@ -48,5 +48,5 @@ const Y: () = {
}; };
fn main() { fn main() {
let _y = Y; Y;
} }

View File

@ -8,5 +8,5 @@ const _: () = foo();
// Ensure that the CTFE engine handles calls to `extern "C"` aborting gracefully // Ensure that the CTFE engine handles calls to `extern "C"` aborting gracefully
fn main() { fn main() {
let _ = foo(); foo();
} }

View File

@ -13,6 +13,6 @@ static FOO2: () = {
}; };
fn main() { fn main() {
let _ = FOO; FOO;
let _ = FOO2; FOO2;
} }

View File

@ -4,5 +4,5 @@
// pretty-expanded FIXME #23616 // pretty-expanded FIXME #23616
pub fn main() { pub fn main() {
let x = *Box::new(()); let x: () = *Box::new(());
} }

View File

@ -19,5 +19,5 @@ fn bar() {
fn main() { fn main() {
let _x = foo::<_>([1,2]); let _x = foo::<_>([1,2]);
//[normal]~^ ERROR: type provided when a constant was expected //[normal]~^ ERROR: type provided when a constant was expected
let _y = bar(); bar();
} }

View File

@ -64,7 +64,7 @@ pub fn main() {
}; };
assert_eq!(trait_unified_3, ["Yes"]); assert_eq!(trait_unified_3, ["Yes"]);
let regular_break = loop { let regular_break: () = loop {
if true { if true {
break; break;
} else { } else {
@ -73,7 +73,7 @@ pub fn main() {
}; };
assert_eq!(regular_break, ()); assert_eq!(regular_break, ());
let regular_break_2 = loop { let regular_break_2: () = loop {
if true { if true {
break Default::default(); break Default::default();
} else { } else {
@ -82,7 +82,7 @@ pub fn main() {
}; };
assert_eq!(regular_break_2, ()); assert_eq!(regular_break_2, ());
let regular_break_3 = loop { let regular_break_3: () = loop {
break if true { break if true {
Default::default() Default::default()
} else { } else {
@ -91,13 +91,13 @@ pub fn main() {
}; };
assert_eq!(regular_break_3, ()); assert_eq!(regular_break_3, ());
let regular_break_4 = loop { let regular_break_4: () = loop {
break (); break ();
break; break;
}; };
assert_eq!(regular_break_4, ()); assert_eq!(regular_break_4, ());
let regular_break_5 = loop { let regular_break_5: () = loop {
break; break;
break (); break ();
}; };

View File

@ -11,7 +11,7 @@ fn assert_zst<T>() {
//~| NOTE: in this expansion of assert! //~| NOTE: in this expansion of assert!
//~| NOTE: the evaluated program panicked //~| NOTE: the evaluated program panicked
} }
let _ = F::<T>::V; F::<T>::V;
} }
fn foo<U>() { fn foo<U>() {

View File

@ -71,7 +71,7 @@ impl<'a, 'b, U: Unpack<'b>> Backed<'a, U> {
where where
F: for<'f> FnOnce(<U as Unpack<'f>>::Unpacked) -> (), F: for<'f> FnOnce(<U as Unpack<'f>>::Unpacked) -> (),
{ {
let result = f(self.1.unpack()); let result: () = f(self.1.unpack());
Backed(self.0, result) Backed(self.0, result)
} }
} }

View File

@ -391,7 +391,7 @@ fn main() {
let _val = mem::zeroed::<ZeroIsValid>(); let _val = mem::zeroed::<ZeroIsValid>();
let _val = mem::uninitialized::<MaybeUninit<bool>>(); let _val = mem::uninitialized::<MaybeUninit<bool>>();
let _val = mem::uninitialized::<[!; 0]>(); let _val = mem::uninitialized::<[!; 0]>();
let _val = mem::uninitialized::<()>(); let _val: () = mem::uninitialized::<()>();
let _val = mem::uninitialized::<ZeroSized>(); let _val = mem::uninitialized::<ZeroSized>();
} }
} }

View File

@ -18,8 +18,8 @@ pub mod foo {
fn main() { fn main() {
type Ham = foo::bar::baz::Qux; type Ham = foo::bar::baz::Qux;
let foo = foo::bar::baz::Qux::new(); // invoke directly let foo: () = foo::bar::baz::Qux::new(); // invoke directly
let bar = Ham::new(); // invoke via type alias let bar: () = Ham::new(); // invoke via type alias
type StringVec = Vec<String>; type StringVec = Vec<String>;
let sv = StringVec::new(); let sv = StringVec::new();

View File

@ -10,7 +10,7 @@ struct S {x:()}
fn test(slot: &mut Option<Box<dyn FnMut() -> Box<dyn FnMut()>>>) -> () { fn test(slot: &mut Option<Box<dyn FnMut() -> Box<dyn FnMut()>>>) -> () {
let a = slot.take(); let a = slot.take();
let _a = match a { let _a: () = match a {
// `{let .. a(); }` would break // `{let .. a(); }` would break
Some(mut a) => { let _a = a(); }, Some(mut a) => { let _a = a(); },
None => (), None => (),
@ -28,7 +28,7 @@ fn not(b: bool) -> bool {
pub fn main() { pub fn main() {
// {} would break // {} would break
let _r = {}; let _r: () = {};
let mut slot = None; let mut slot = None;
// `{ test(...); }` would break // `{ test(...); }` would break
let _s : S = S{ x: { test(&mut slot); } }; let _s : S = S{ x: { test(&mut slot); } };

View File

@ -24,5 +24,5 @@ impl Element {
fn main() { fn main() {
let element = Element { attrs: Vec::new() }; let element = Element { attrs: Vec::new() };
let _ = unsafe { element.get_attr("foo") }; unsafe { let () = element.get_attr("foo"); };
} }

View File

@ -26,7 +26,7 @@ fn foo() {
let cwd = env::current_dir().unwrap(); let cwd = env::current_dir().unwrap();
let src = cwd.clone(); let src = cwd.clone();
let summary = File::open(&src.join("SUMMARY.md")).unwrap(); let summary = File::open(&src.join("SUMMARY.md")).unwrap();
let _ = parse_summary(summary, &src); parse_summary(summary, &src);
} }
fn main() {} fn main() {}

View File

@ -45,14 +45,14 @@ impl_Const!(ConstStruct, ConstEnum, AliasedConstStruct, AliasedConstEnum);
impl_StaticFn!(StaticFnStruct, StaticFnEnum, AliasedStaticFnStruct, AliasedStaticFnEnum); impl_StaticFn!(StaticFnStruct, StaticFnEnum, AliasedStaticFnStruct, AliasedStaticFnEnum);
fn main() { fn main() {
let _ = ConstStruct::C; let () = ConstStruct::C;
let _ = ConstEnum::C; let () = ConstEnum::C;
StaticFnStruct::sfn(); StaticFnStruct::sfn();
StaticFnEnum::sfn(); StaticFnEnum::sfn();
let _ = AliasConstStruct::C; let () = AliasConstStruct::C;
let _ = AliasConstEnum::C; let () = AliasConstEnum::C;
AliasStaticFnStruct::sfn(); AliasStaticFnStruct::sfn();
AliasStaticFnEnum::sfn(); AliasStaticFnEnum::sfn();

View File

@ -147,7 +147,7 @@ fn expressions() {
#![deny(unsafe_code)] #![deny(unsafe_code)]
unsafe {} //~ ERROR usage of an `unsafe` block unsafe {} //~ ERROR usage of an `unsafe` block
} }
let block_tail = { let block_tail: () = {
#[deny(unsafe_code)] #[deny(unsafe_code)]
unsafe {} //~ ERROR usage of an `unsafe` block unsafe {} //~ ERROR usage of an `unsafe` block
}; };

View File

@ -172,7 +172,7 @@ fn expressions() {
#![deny(enum_intrinsics_non_enums)] #![deny(enum_intrinsics_non_enums)]
discriminant::<i32>(&123); //~ ERROR the return value of discriminant::<i32>(&123); //~ ERROR the return value of
} }
let block_tail = { let block_tail: () = {
#[deny(enum_intrinsics_non_enums)] #[deny(enum_intrinsics_non_enums)]
discriminant::<i32>(&123); //~ ERROR the return value of discriminant::<i32>(&123); //~ ERROR the return value of
}; };

View File

@ -31,5 +31,5 @@ mod foo {
fn main() { fn main() {
lint_unused_extern_crate3::foo(); lint_unused_extern_crate3::foo();
let y = foo(); foo();
} }

View File

@ -86,5 +86,5 @@ fn main() {
let mut b = 4; let mut b = 4;
swap(&mut a, &mut b); swap(&mut a, &mut b);
test::C.b(); test::C.b();
let _a = foo(); foo();
} }

View File

@ -74,6 +74,6 @@ fn main() {
b: i32, b: i32,
//~^ ERROR unused variable: `b` //~^ ERROR unused variable: `b`
| {}; | {};
let _ = a(1, 2); a(1, 2);
let _ = b(1, 2); b(1, 2);
} }

View File

@ -31,15 +31,15 @@ use test::B; // This is used by the test2::func() through import of super
mod test2 { mod test2 {
use super::*; use super::*;
pub fn func() { pub fn func() {
let _ = <()>::a(); <()>::a();
let _ = ().b(); ().b();
test3::inner_func(); test3::inner_func();
} }
mod test3 { mod test3 {
use super::*; use super::*;
pub fn inner_func() { pub fn inner_func() {
let _ = <()>::a(); <()>::a();
let _ = ().b(); ().b();
} }
} }
} }

View File

@ -27,27 +27,27 @@ impl<'a> Display for MutexGuard<'a> {
} }
fn main() { fn main() {
let _print = { let _print: () = {
let mutex = Mutex; let mutex = Mutex;
print!("{}", mutex.lock()) /* no semicolon */ print!("{}", mutex.lock()) /* no semicolon */
}; };
let _println = { let _println: () = {
let mutex = Mutex; let mutex = Mutex;
println!("{}", mutex.lock()) /* no semicolon */ println!("{}", mutex.lock()) /* no semicolon */
}; };
let _eprint = { let _eprint: () = {
let mutex = Mutex; let mutex = Mutex;
eprint!("{}", mutex.lock()) /* no semicolon */ eprint!("{}", mutex.lock()) /* no semicolon */
}; };
let _eprintln = { let _eprintln: () = {
let mutex = Mutex; let mutex = Mutex;
eprintln!("{}", mutex.lock()) /* no semicolon */ eprintln!("{}", mutex.lock()) /* no semicolon */
}; };
let _panic = { let _panic: () = {
let mutex = Mutex; let mutex = Mutex;
panic!("{}", mutex.lock()) /* no semicolon */ panic!("{}", mutex.lock()) /* no semicolon */
}; };

View File

@ -170,8 +170,8 @@ fn format_args() {
#[test] #[test]
fn include() { fn include() {
let _ = include!("auxiliary/macro-comma-support.rs"); include!("auxiliary/macro-comma-support.rs");
let _ = include!("auxiliary/macro-comma-support.rs",); include!("auxiliary/macro-comma-support.rs",);
} }
#[test] #[test]

View File

@ -67,7 +67,7 @@ where
MS::Item: Into<()>, MS::Item: Into<()>,
{ {
// Error: Apparently Balance::new doesn't exist during MIR validation // Error: Apparently Balance::new doesn't exist during MIR validation
let _ = ImplShoulExist::<MS, ()>::access_fn(ms); ImplShoulExist::<MS, ()>::access_fn(ms);
} }
fn main() {} fn main() {}

View File

@ -28,7 +28,7 @@ fn may_panic<X>(_: X) { }
fn main() { fn main() {
let dyn_trait = make_dyn_trait(&()); let dyn_trait = make_dyn_trait(&());
let storage = vec![()]; let storage = vec![()];
let _x = may_panic(()); may_panic(());
let storage_ref = &storage; let storage_ref = &storage;
diff(dyn_trait, storage_ref); diff(dyn_trait, storage_ref);
} }

View File

@ -5,7 +5,7 @@
fn foo() { fn foo() {
let bar = |_| { }; let bar = |_| { };
let _ = bar("a"); bar("a");
} }
fn main() { fn main() {

View File

@ -48,7 +48,7 @@ fn assignment_rev() {
} }
fn if_then_else() { fn if_then_else() {
let _x = if true { let _x: () = if true {
UnitDefault::default() UnitDefault::default()
} else { } else {
return; return;
@ -56,7 +56,7 @@ fn if_then_else() {
} }
fn if_then_else_rev() { fn if_then_else_rev() {
let _x = if true { let _x: () = if true {
return; return;
} else { } else {
UnitDefault::default() UnitDefault::default()
@ -64,21 +64,21 @@ fn if_then_else_rev() {
} }
fn match_arm() { fn match_arm() {
let _x = match Ok(UnitDefault::default()) { let _x: () = match Ok(UnitDefault::default()) {
Ok(v) => v, Ok(v) => v,
Err(()) => return, Err(()) => return,
}; };
} }
fn match_arm_rev() { fn match_arm_rev() {
let _x = match Ok(UnitDefault::default()) { let _x: () = match Ok(UnitDefault::default()) {
Err(()) => return, Err(()) => return,
Ok(v) => v, Ok(v) => v,
}; };
} }
fn loop_break() { fn loop_break() {
let _x = loop { let _x: () = loop {
if false { if false {
break return; break return;
} else { } else {
@ -88,7 +88,7 @@ fn loop_break() {
} }
fn loop_break_rev() { fn loop_break_rev() {
let _x = loop { let _x: () = loop {
if false { if false {
break return; break return;
} else { } else {

View File

@ -4,8 +4,8 @@
// check-pass // check-pass
fn main() { fn main() {
let x = while false { let x: () = while false {
break; break;
}; };
let y = 'l: while break 'l {}; let y: () = 'l: while break 'l {};
} }

View File

@ -13,7 +13,7 @@ fn foo<T: 'static + Debug>(_: T) { }
fn bar<'a>() { fn bar<'a>() {
return; return;
let _x = foo::<Vec<_>>(Vec::<&'a u32>::new()); foo::<Vec<_>>(Vec::<&'a u32>::new());
} }
fn main() {} fn main() {}

View File

@ -14,7 +14,7 @@ fn foo<R, S: FnOnce()>(
let bar = || { let bar = || {
let _ = OnDrop(|| ()); let _ = OnDrop(|| ());
}; };
let _ = bar(); bar();
} }
fn main() { fn main() {

View File

@ -19,7 +19,7 @@ fn foo<R, S: FnOnce()>(
let bar = || { let bar = || {
bar(|| {}) bar(|| {})
}; };
let _ = bar(); bar();
} }
fn main() { fn main() {

View File

@ -7,7 +7,7 @@
fn a() { fn a() {
// Here we issue that the "2nd-innermost" return is unreachable, // Here we issue that the "2nd-innermost" return is unreachable,
// but we stop there. // but we stop there.
let x = {return {return {return;}}}; //~ ERROR unreachable let x: () = {return {return {return;}}}; //~ ERROR unreachable
} }
fn main() { } fn main() { }

View File

@ -1,11 +1,11 @@
error: unreachable expression error: unreachable expression
--> $DIR/expr_return.rs:10:22 --> $DIR/expr_return.rs:10:26
| |
LL | let x = {return {return {return;}}}; LL | let x: () = {return {return {return;}}};
| ^^^^^^^^------^^ | ^^^^^^^^------^^
| | | | | |
| | any code following this expression is unreachable | | any code following this expression is unreachable
| unreachable expression | unreachable expression
| |
note: the lint level is defined here note: the lint level is defined here
--> $DIR/expr_return.rs:4:9 --> $DIR/expr_return.rs:4:9

View File

@ -25,7 +25,7 @@ fn shadow_mod() {
fn shadow_prelude() { fn shadow_prelude() {
// Extern prelude shadows standard library prelude // Extern prelude shadows standard library prelude
let x = Vec::new(0f32, ()); // OK let x: () = Vec::new(0f32, ()); // OK
} }
fn main() {} fn main() {}

View File

@ -3,7 +3,7 @@
fn check<Clone>(_c: Clone) { fn check<Clone>(_c: Clone) {
fn check2() { fn check2() {
let _ = <() as std::clone::Clone>::clone(&()); let () = <() as std::clone::Clone>::clone(&());
} }
check2(); check2();
} }

View File

@ -1,6 +1,6 @@
// run-pass // run-pass
// pretty-expanded FIXME #23616 // pretty-expanded FIXME #23616
fn f() { let x: () = (); return x; } fn f() { let x = (); return x; }
pub fn main() { let _x = f(); } pub fn main() { f(); }

View File

@ -97,5 +97,5 @@ fn main() {
#[cfg_attr(something, cfg(nothing))] #[cfg_attr(something, cfg(nothing))]
#[deny(unused_mut)] c: i32, #[deny(unused_mut)] c: i32,
| {}; | {};
let _ = c(1, 2); c(1, 2);
} }

View File

@ -116,6 +116,6 @@ fn main() {
//~^ ERROR unused variable: `c` //~^ ERROR unused variable: `c`
#[cfg_attr(something, cfg(nothing))] d: i32, #[cfg_attr(something, cfg(nothing))] d: i32,
| {}; | {};
let _ = a(1); a(1);
let _ = c(1, 2); c(1, 2);
} }

View File

@ -24,7 +24,7 @@ impl connection_factory<my_connection> for my_connection_factory {
pub fn main() { pub fn main() {
let factory = (); let factory = ();
let connection = factory.create(); let connection: () = factory.create();
let result = connection.read(); let result = connection.read();
assert_eq!(result, 43); assert_eq!(result, 43);
} }

View File

@ -8,7 +8,7 @@ fn main() {
let mut a = 0; let mut a = 0;
let () = { let () = {
let _: Result<(), ()> = try { let _: Result<(), ()> = try {
let _ = Err(())?; let () = Err(())?;
return return
}; };
a += 1; a += 1;

View File

@ -3,8 +3,8 @@
fn main() { fn main() {
let tuple = (((),),); let tuple = (((),),);
let _ = tuple. 0.0; // OK, whitespace let () = tuple. 0.0; // OK, whitespace
let _ = tuple.0. 0; // OK, whitespace let () = tuple.0. 0; // OK, whitespace
let _ = tuple./*special cases*/0.0; // OK, comment let () = tuple./*special cases*/0.0; // OK, comment
} }

View File

@ -81,7 +81,7 @@ fn angrydome() {
break; } break; }
} }
fn evil_lincoln() { let _evil = println!("lincoln"); } fn evil_lincoln() { let _evil: () = println!("lincoln"); }
fn dots() { fn dots() {
assert_eq!(String::from(".................................................."), assert_eq!(String::from(".................................................."),
@ -137,7 +137,7 @@ fn punch_card() -> impl std::fmt::Debug {
} }
fn r#match() { fn r#match() {
let val = match match match match match () { let val: () = match match match match match () {
() => () () => ()
} { } {
() => () () => ()
@ -166,7 +166,7 @@ fn match_nested_if() {
} }
fn monkey_barrel() { fn monkey_barrel() {
let val = ()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=(); let val: () = ()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=();
assert_eq!(val, ()); assert_eq!(val, ());
} }