From edafbaffb26d8be00f6dd8ad0dbaa57f1caf1610 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AE=B8=E6=9D=B0=E5=8F=8B=20Jieyou=20Xu=20=28Joe=29?= Date: Mon, 12 Jun 2023 16:55:36 +0800 Subject: [PATCH] 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 --- tests/ui/assign-assign.rs | 4 ++-- .../ui/associated-type-bounds/dyn-impl-trait-type.rs | 8 ++++---- tests/ui/associated-type-bounds/dyn-rpit-and-let.rs | 8 ++++---- tests/ui/associated-type-bounds/rpit.rs | 8 ++++---- .../associated-type-bounds/trait-alias-impl-trait.rs | 8 ++++---- .../ui/associated-types/normalization-debruijn-3.rs | 4 ++-- tests/ui/async-await/drop-track-field-assign.rs | 2 +- tests/ui/async-await/field-assign.rs | 2 +- .../issue-64130-4-async-move.no_drop_tracking.stderr | 6 +++--- tests/ui/async-await/issue-64130-4-async-move.rs | 2 +- tests/ui/async-await/non-trivial-drop.rs | 2 +- tests/ui/cfg/cfg_stmt_expr.rs | 2 +- .../run_pass/disjoint-capture-in-same-closure.rs | 2 +- .../generic_const_exprs/issue-86710.rs | 2 +- .../ui/const-generics/issues/issue-70273-assoc-fn.rs | 2 +- tests/ui/consts/assoc_const_generic_impl.rs | 2 +- tests/ui/consts/const-eval/erroneous-const.rs | 2 +- tests/ui/consts/const-eval/erroneous-const.stderr | 6 +++--- tests/ui/consts/const-eval/erroneous-const2.rs | 2 +- tests/ui/consts/const-eval/erroneous-const2.stderr | 6 +++--- tests/ui/consts/const-eval/promoted_errors.rs | 2 +- tests/ui/consts/const-eval/unwind-abort.rs | 2 +- tests/ui/consts/large_const_alloc.rs | 4 ++-- tests/ui/empty-allocation-rvalue-non-null.rs | 2 +- .../feature-gates/feature-gate-generic_arg_infer.rs | 2 +- tests/ui/for-loop-while/loop-break-value.rs | 10 +++++----- .../post_monomorphization_error_backtrace.rs | 2 +- .../normalize-under-binder/issue-62529-6.rs | 2 +- tests/ui/intrinsics/panic-uninitialized-zeroed.rs | 2 +- tests/ui/issues/issue-11047.rs | 4 ++-- tests/ui/issues/issue-11709.rs | 4 ++-- tests/ui/issues/issue-11740.rs | 2 +- tests/ui/issues/issue-20644.rs | 2 +- tests/ui/issues/issue-23808.rs | 8 ++++---- tests/ui/lint/lint-attr-everywhere-early.rs | 2 +- tests/ui/lint/lint-attr-everywhere-late.rs | 2 +- tests/ui/lint/unused/lint-unused-extern-crate.rs | 2 +- tests/ui/lint/unused/lint-unused-imports.rs | 2 +- tests/ui/lint/unused/lint-unused-variables.rs | 4 ++-- tests/ui/lint/unused_import_warning_issue_45268.rs | 8 ++++---- tests/ui/macros/format-args-temporaries.rs | 10 +++++----- tests/ui/macros/macro-comma-support-rpass.rs | 4 ++-- tests/ui/mir/issue-101844.rs | 2 +- tests/ui/mir/issue-80949.rs | 2 +- tests/ui/mir/issue66339.rs | 2 +- .../ui/never_type/diverging-fallback-control-flow.rs | 12 ++++++------ tests/ui/nll/assign-while-to-immutable.rs | 4 ++-- tests/ui/nll/issue-54943-3.rs | 2 +- tests/ui/polymorphization/drop_shims/simple.rs | 2 +- tests/ui/polymorphization/drop_shims/transitive.rs | 2 +- tests/ui/reachable/expr_return.rs | 2 +- tests/ui/reachable/expr_return.stderr | 12 ++++++------ tests/ui/resolve/extern-prelude.rs | 2 +- tests/ui/resolve/resolve-pseudo-shadowing.rs | 2 +- tests/ui/return-nil.rs | 4 ++-- .../rfcs/rfc-2565-param-attrs/param-attrs-allowed.rs | 2 +- .../ui/rfcs/rfc-2565-param-attrs/param-attrs-cfg.rs | 4 ++-- tests/ui/traits/bound/generic_trait.rs | 2 +- tests/ui/try-block/issue-45124.rs | 2 +- tests/ui/tuple/index-float.rs | 6 +++--- tests/ui/weird-exprs.rs | 6 +++--- 61 files changed, 117 insertions(+), 117 deletions(-) diff --git a/tests/ui/assign-assign.rs b/tests/ui/assign-assign.rs index bcf506b398b9e..9db8fb008cf2e 100644 --- a/tests/ui/assign-assign.rs +++ b/tests/ui/assign-assign.rs @@ -6,7 +6,7 @@ fn test_assign() { let y: () = x = 10; assert_eq!(x, 10); assert_eq!(y, ()); - let mut z = x = 11; + let mut z: () = x = 11; assert_eq!(x, 11); assert_eq!(z, ()); z = x = 12; @@ -19,7 +19,7 @@ fn test_assign_op() { let y: () = x += 10; assert_eq!(x, 10); assert_eq!(y, ()); - let mut z = x += 11; + let mut z: () = x += 11; assert_eq!(x, 21); assert_eq!(z, ()); z = x += 12; diff --git a/tests/ui/associated-type-bounds/dyn-impl-trait-type.rs b/tests/ui/associated-type-bounds/dyn-impl-trait-type.rs index a8d00803a534a..a3f4717791abd 100644 --- a/tests/ui/associated-type-bounds/dyn-impl-trait-type.rs +++ b/tests/ui/associated-type-bounds/dyn-impl-trait-type.rs @@ -59,8 +59,8 @@ fn def_et4() -> Et4 { pub fn use_et4() { assert_forall_tr2(def_et4().mk()); } fn main() { - let _ = use_et1(); - let _ = use_et2(); - let _ = use_et3(); - let _ = use_et4(); + use_et1(); + use_et2(); + use_et3(); + use_et4(); } diff --git a/tests/ui/associated-type-bounds/dyn-rpit-and-let.rs b/tests/ui/associated-type-bounds/dyn-rpit-and-let.rs index 08f965452ef48..52199124ea3b5 100644 --- a/tests/ui/associated-type-bounds/dyn-rpit-and-let.rs +++ b/tests/ui/associated-type-bounds/dyn-rpit-and-let.rs @@ -66,8 +66,8 @@ fn def_et4() -> Box Tr2<'a>>> { pub fn use_et4() { assert_forall_tr2(def_et4().mk()); } fn main() { - let _ = use_et1(); - let _ = use_et2(); - let _ = use_et3(); - let _ = use_et4(); + use_et1(); + use_et2(); + use_et3(); + use_et4(); } diff --git a/tests/ui/associated-type-bounds/rpit.rs b/tests/ui/associated-type-bounds/rpit.rs index 47cadf3310bd8..59c7733fbe4ba 100644 --- a/tests/ui/associated-type-bounds/rpit.rs +++ b/tests/ui/associated-type-bounds/rpit.rs @@ -57,8 +57,8 @@ fn def_et4() -> impl Tr1 Tr2<'a>> { pub fn use_et4() { assert_forall_tr2(def_et4().mk()); } fn main() { - let _ = use_et1(); - let _ = use_et2(); - let _ = use_et3(); - let _ = use_et4(); + use_et1(); + use_et2(); + use_et3(); + use_et4(); } diff --git a/tests/ui/associated-type-bounds/trait-alias-impl-trait.rs b/tests/ui/associated-type-bounds/trait-alias-impl-trait.rs index e223a89574170..93a44c01ce053 100644 --- a/tests/ui/associated-type-bounds/trait-alias-impl-trait.rs +++ b/tests/ui/associated-type-bounds/trait-alias-impl-trait.rs @@ -89,8 +89,8 @@ pub fn use_et4() { } fn main() { - let _ = use_et1(); - let _ = use_et2(); - let _ = use_et3(); - let _ = use_et4(); + use_et1(); + use_et2(); + use_et3(); + use_et4(); } diff --git a/tests/ui/associated-types/normalization-debruijn-3.rs b/tests/ui/associated-types/normalization-debruijn-3.rs index 2bea78cf7bd69..bd9a8fcf4925f 100644 --- a/tests/ui/associated-types/normalization-debruijn-3.rs +++ b/tests/ui/associated-types/normalization-debruijn-3.rs @@ -6,10 +6,10 @@ use std::future::{Future, Ready}; async fn read() { - let _ = connect(&()).await; + connect(&()).await; } async fn connect(addr: A) { - let _ = addr.to_socket_addr().await; + addr.to_socket_addr().await; } pub trait ToSocketAddr { type Future: Future; diff --git a/tests/ui/async-await/drop-track-field-assign.rs b/tests/ui/async-await/drop-track-field-assign.rs index dd0e3f11ccc01..b79d2af066a37 100644 --- a/tests/ui/async-await/drop-track-field-assign.rs +++ b/tests/ui/async-await/drop-track-field-assign.rs @@ -21,7 +21,7 @@ impl Agent { let mut info = self.info_result.clone(); info.node = Some("bar".into()); let element = parse_info(info); - let _ = send_element(element).await; + send_element(element).await; } } diff --git a/tests/ui/async-await/field-assign.rs b/tests/ui/async-await/field-assign.rs index dd0e3f11ccc01..b79d2af066a37 100644 --- a/tests/ui/async-await/field-assign.rs +++ b/tests/ui/async-await/field-assign.rs @@ -21,7 +21,7 @@ impl Agent { let mut info = self.info_result.clone(); info.node = Some("bar".into()); let element = parse_info(info); - let _ = send_element(element).await; + send_element(element).await; } } diff --git a/tests/ui/async-await/issue-64130-4-async-move.no_drop_tracking.stderr b/tests/ui/async-await/issue-64130-4-async-move.no_drop_tracking.stderr index 4b575a3d3b47a..60b7551ff8ad5 100644 --- a/tests/ui/async-await/issue-64130-4-async-move.no_drop_tracking.stderr +++ b/tests/ui/async-await/issue-64130-4-async-move.no_drop_tracking.stderr @@ -6,13 +6,13 @@ LL | pub fn foo() -> impl Future + Send { | = 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 - --> $DIR/issue-64130-4-async-move.rs:27:32 + --> $DIR/issue-64130-4-async-move.rs:27:23 | LL | match client.status() { | ------ has type `&Client` which is not `Send` LL | 200 => { -LL | let _x = get().await; - | ^^^^^ await occurs here, with `client` maybe used later +LL | get().await; + | ^^^^^ await occurs here, with `client` maybe used later ... LL | } | - `client` is later dropped here diff --git a/tests/ui/async-await/issue-64130-4-async-move.rs b/tests/ui/async-await/issue-64130-4-async-move.rs index bcb297aaa0258..5d68a808b1769 100644 --- a/tests/ui/async-await/issue-64130-4-async-move.rs +++ b/tests/ui/async-await/issue-64130-4-async-move.rs @@ -24,7 +24,7 @@ pub fn foo() -> impl Future + Send { async move { match client.status() { 200 => { - let _x = get().await; + get().await; } _ => (), } diff --git a/tests/ui/async-await/non-trivial-drop.rs b/tests/ui/async-await/non-trivial-drop.rs index d4df9d439c5f1..258da0756de31 100644 --- a/tests/ui/async-await/non-trivial-drop.rs +++ b/tests/ui/async-await/non-trivial-drop.rs @@ -7,7 +7,7 @@ #![feature(generators)] fn main() { - let _ = foo(); + foo(); } fn foo() { diff --git a/tests/ui/cfg/cfg_stmt_expr.rs b/tests/ui/cfg/cfg_stmt_expr.rs index 6381bb2d58877..f9f4c98102c99 100644 --- a/tests/ui/cfg/cfg_stmt_expr.rs +++ b/tests/ui/cfg/cfg_stmt_expr.rs @@ -81,7 +81,7 @@ fn main() { // check that lints work #[allow(non_snake_case)] - let FOOBAR = { + let FOOBAR: () = { fn SYLADEX() {} }; diff --git a/tests/ui/closures/2229_closure_analysis/run_pass/disjoint-capture-in-same-closure.rs b/tests/ui/closures/2229_closure_analysis/run_pass/disjoint-capture-in-same-closure.rs index 03400e0ee8d56..6d4cf6fa553b7 100644 --- a/tests/ui/closures/2229_closure_analysis/run_pass/disjoint-capture-in-same-closure.rs +++ b/tests/ui/closures/2229_closure_analysis/run_pass/disjoint-capture-in-same-closure.rs @@ -15,7 +15,7 @@ struct Struct { fn main() { let mut s = Struct { x: 10, y: 10, s: String::new() }; - let mut c = { + let mut c = || { s.x += 10; s.y += 42; s.s = String::from("new"); diff --git a/tests/ui/const-generics/generic_const_exprs/issue-86710.rs b/tests/ui/const-generics/generic_const_exprs/issue-86710.rs index bdd8a21b3b991..281b12458e3d9 100644 --- a/tests/ui/const-generics/generic_const_exprs/issue-86710.rs +++ b/tests/ui/const-generics/generic_const_exprs/issue-86710.rs @@ -7,7 +7,7 @@ use std::marker::PhantomData; fn main() { let x = FooImpl::> { phantom: PhantomData }; - let _ = x.foo::>(); + x.foo::>(); } trait Foo diff --git a/tests/ui/const-generics/issues/issue-70273-assoc-fn.rs b/tests/ui/const-generics/issues/issue-70273-assoc-fn.rs index a76488249173a..f02ab355f9bb6 100644 --- a/tests/ui/const-generics/issues/issue-70273-assoc-fn.rs +++ b/tests/ui/const-generics/issues/issue-70273-assoc-fn.rs @@ -10,5 +10,5 @@ impl T<0usize> for S { } fn main() { - let _err = >::f(); + >::f(); } diff --git a/tests/ui/consts/assoc_const_generic_impl.rs b/tests/ui/consts/assoc_const_generic_impl.rs index 3475c862bfc2d..ba358628d15dc 100644 --- a/tests/ui/consts/assoc_const_generic_impl.rs +++ b/tests/ui/consts/assoc_const_generic_impl.rs @@ -8,7 +8,7 @@ trait ZeroSized: Sized { impl ZeroSized for T { const I_AM_ZERO_SIZED: () = [()][std::mem::size_of::()]; //~ ERROR evaluation of `::I_AM_ZERO_SIZED` failed fn requires_zero_size(self) { - let () = Self::I_AM_ZERO_SIZED; + Self::I_AM_ZERO_SIZED; println!("requires_zero_size called"); } } diff --git a/tests/ui/consts/const-eval/erroneous-const.rs b/tests/ui/consts/const-eval/erroneous-const.rs index e0fd057a241a5..74d44c5259a3e 100644 --- a/tests/ui/consts/const-eval/erroneous-const.rs +++ b/tests/ui/consts/const-eval/erroneous-const.rs @@ -10,7 +10,7 @@ const fn no_codegen() { if false { // 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. - let _ = PrintName::::VOID; //~ constant + PrintName::::VOID; //~ constant } } diff --git a/tests/ui/consts/const-eval/erroneous-const.stderr b/tests/ui/consts/const-eval/erroneous-const.stderr index 03030392a5132..770f95062ab30 100644 --- a/tests/ui/consts/const-eval/erroneous-const.stderr +++ b/tests/ui/consts/const-eval/erroneous-const.stderr @@ -5,10 +5,10 @@ LL | const VOID: () = [()][2]; | ^^^^^^^ index out of bounds: the length is 1 but the index is 2 note: erroneous constant used - --> $DIR/erroneous-const.rs:13:17 + --> $DIR/erroneous-const.rs:13:13 | -LL | let _ = PrintName::::VOID; - | ^^^^^^^^^^^^^^^^^^^^ +LL | PrintName::::VOID; + | ^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/tests/ui/consts/const-eval/erroneous-const2.rs b/tests/ui/consts/const-eval/erroneous-const2.rs index 15c0f910728a9..61f2955f2d822 100644 --- a/tests/ui/consts/const-eval/erroneous-const2.rs +++ b/tests/ui/consts/const-eval/erroneous-const2.rs @@ -10,7 +10,7 @@ pub static FOO: () = { if false { // This bad constant is only used in dead code in a static initializer... and yet we still // must make sure that the build fails. - let _ = PrintName::::VOID; //~ constant + PrintName::::VOID; //~ constant } }; diff --git a/tests/ui/consts/const-eval/erroneous-const2.stderr b/tests/ui/consts/const-eval/erroneous-const2.stderr index 8626f4d783397..082c2876575a6 100644 --- a/tests/ui/consts/const-eval/erroneous-const2.stderr +++ b/tests/ui/consts/const-eval/erroneous-const2.stderr @@ -5,10 +5,10 @@ LL | const VOID: () = [()][2]; | ^^^^^^^ index out of bounds: the length is 1 but the index is 2 note: erroneous constant used - --> $DIR/erroneous-const2.rs:13:17 + --> $DIR/erroneous-const2.rs:13:9 | -LL | let _ = PrintName::::VOID; - | ^^^^^^^^^^^^^^^^^^^^^^ +LL | PrintName::::VOID; + | ^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/tests/ui/consts/const-eval/promoted_errors.rs b/tests/ui/consts/const-eval/promoted_errors.rs index 2c42d035629a0..5e67dc6f6c32e 100644 --- a/tests/ui/consts/const-eval/promoted_errors.rs +++ b/tests/ui/consts/const-eval/promoted_errors.rs @@ -48,5 +48,5 @@ const Y: () = { }; fn main() { - let _y = Y; + Y; } diff --git a/tests/ui/consts/const-eval/unwind-abort.rs b/tests/ui/consts/const-eval/unwind-abort.rs index 2b0e58166c254..57959e7db6ad9 100644 --- a/tests/ui/consts/const-eval/unwind-abort.rs +++ b/tests/ui/consts/const-eval/unwind-abort.rs @@ -8,5 +8,5 @@ const _: () = foo(); // Ensure that the CTFE engine handles calls to `extern "C"` aborting gracefully fn main() { - let _ = foo(); + foo(); } diff --git a/tests/ui/consts/large_const_alloc.rs b/tests/ui/consts/large_const_alloc.rs index 54abaab224730..298ed38d180e6 100644 --- a/tests/ui/consts/large_const_alloc.rs +++ b/tests/ui/consts/large_const_alloc.rs @@ -13,6 +13,6 @@ static FOO2: () = { }; fn main() { - let _ = FOO; - let _ = FOO2; + FOO; + FOO2; } diff --git a/tests/ui/empty-allocation-rvalue-non-null.rs b/tests/ui/empty-allocation-rvalue-non-null.rs index 2f5a5c4bbc6db..ad0f22031067e 100644 --- a/tests/ui/empty-allocation-rvalue-non-null.rs +++ b/tests/ui/empty-allocation-rvalue-non-null.rs @@ -4,5 +4,5 @@ // pretty-expanded FIXME #23616 pub fn main() { - let x = *Box::new(()); + let x: () = *Box::new(()); } diff --git a/tests/ui/feature-gates/feature-gate-generic_arg_infer.rs b/tests/ui/feature-gates/feature-gate-generic_arg_infer.rs index afd14b7843e20..be66560fd921c 100644 --- a/tests/ui/feature-gates/feature-gate-generic_arg_infer.rs +++ b/tests/ui/feature-gates/feature-gate-generic_arg_infer.rs @@ -19,5 +19,5 @@ fn bar() { fn main() { let _x = foo::<_>([1,2]); //[normal]~^ ERROR: type provided when a constant was expected - let _y = bar(); + bar(); } diff --git a/tests/ui/for-loop-while/loop-break-value.rs b/tests/ui/for-loop-while/loop-break-value.rs index d7209fc4de867..65207fb7fb54e 100644 --- a/tests/ui/for-loop-while/loop-break-value.rs +++ b/tests/ui/for-loop-while/loop-break-value.rs @@ -64,7 +64,7 @@ pub fn main() { }; assert_eq!(trait_unified_3, ["Yes"]); - let regular_break = loop { + let regular_break: () = loop { if true { break; } else { @@ -73,7 +73,7 @@ pub fn main() { }; assert_eq!(regular_break, ()); - let regular_break_2 = loop { + let regular_break_2: () = loop { if true { break Default::default(); } else { @@ -82,7 +82,7 @@ pub fn main() { }; assert_eq!(regular_break_2, ()); - let regular_break_3 = loop { + let regular_break_3: () = loop { break if true { Default::default() } else { @@ -91,13 +91,13 @@ pub fn main() { }; assert_eq!(regular_break_3, ()); - let regular_break_4 = loop { + let regular_break_4: () = loop { break (); break; }; assert_eq!(regular_break_4, ()); - let regular_break_5 = loop { + let regular_break_5: () = loop { break; break (); }; diff --git a/tests/ui/generics/post_monomorphization_error_backtrace.rs b/tests/ui/generics/post_monomorphization_error_backtrace.rs index 1fd9b6b3b9dba..a1316688075d1 100644 --- a/tests/ui/generics/post_monomorphization_error_backtrace.rs +++ b/tests/ui/generics/post_monomorphization_error_backtrace.rs @@ -11,7 +11,7 @@ fn assert_zst() { //~| NOTE: in this expansion of assert! //~| NOTE: the evaluated program panicked } - let _ = F::::V; + F::::V; } fn foo() { diff --git a/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-62529-6.rs b/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-62529-6.rs index 74a4785e478b8..0ea736deeaa84 100644 --- a/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-62529-6.rs +++ b/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-62529-6.rs @@ -71,7 +71,7 @@ impl<'a, 'b, U: Unpack<'b>> Backed<'a, U> { where F: for<'f> FnOnce(>::Unpacked) -> (), { - let result = f(self.1.unpack()); + let result: () = f(self.1.unpack()); Backed(self.0, result) } } diff --git a/tests/ui/intrinsics/panic-uninitialized-zeroed.rs b/tests/ui/intrinsics/panic-uninitialized-zeroed.rs index 1a0104b859e53..6db2ebb9754bc 100644 --- a/tests/ui/intrinsics/panic-uninitialized-zeroed.rs +++ b/tests/ui/intrinsics/panic-uninitialized-zeroed.rs @@ -391,7 +391,7 @@ fn main() { let _val = mem::zeroed::(); let _val = mem::uninitialized::>(); let _val = mem::uninitialized::<[!; 0]>(); - let _val = mem::uninitialized::<()>(); + let _val: () = mem::uninitialized::<()>(); let _val = mem::uninitialized::(); } } diff --git a/tests/ui/issues/issue-11047.rs b/tests/ui/issues/issue-11047.rs index 1fb2b5bb3a1d5..7a4acea453757 100644 --- a/tests/ui/issues/issue-11047.rs +++ b/tests/ui/issues/issue-11047.rs @@ -18,8 +18,8 @@ pub mod foo { fn main() { type Ham = foo::bar::baz::Qux; - let foo = foo::bar::baz::Qux::new(); // invoke directly - let bar = Ham::new(); // invoke via type alias + let foo: () = foo::bar::baz::Qux::new(); // invoke directly + let bar: () = Ham::new(); // invoke via type alias type StringVec = Vec; let sv = StringVec::new(); diff --git a/tests/ui/issues/issue-11709.rs b/tests/ui/issues/issue-11709.rs index 58424f9e4c583..2d6956649a283 100644 --- a/tests/ui/issues/issue-11709.rs +++ b/tests/ui/issues/issue-11709.rs @@ -10,7 +10,7 @@ struct S {x:()} fn test(slot: &mut Option Box>>) -> () { let a = slot.take(); - let _a = match a { + let _a: () = match a { // `{let .. a(); }` would break Some(mut a) => { let _a = a(); }, None => (), @@ -28,7 +28,7 @@ fn not(b: bool) -> bool { pub fn main() { // {} would break - let _r = {}; + let _r: () = {}; let mut slot = None; // `{ test(...); }` would break let _s : S = S{ x: { test(&mut slot); } }; diff --git a/tests/ui/issues/issue-11740.rs b/tests/ui/issues/issue-11740.rs index 9faeb7770a75a..fa80f509b3229 100644 --- a/tests/ui/issues/issue-11740.rs +++ b/tests/ui/issues/issue-11740.rs @@ -24,5 +24,5 @@ impl Element { fn main() { let element = Element { attrs: Vec::new() }; - let _ = unsafe { element.get_attr("foo") }; + unsafe { let () = element.get_attr("foo"); }; } diff --git a/tests/ui/issues/issue-20644.rs b/tests/ui/issues/issue-20644.rs index 1b90727fbc0a6..a3a9ea7405f29 100644 --- a/tests/ui/issues/issue-20644.rs +++ b/tests/ui/issues/issue-20644.rs @@ -26,7 +26,7 @@ fn foo() { let cwd = env::current_dir().unwrap(); let src = cwd.clone(); let summary = File::open(&src.join("SUMMARY.md")).unwrap(); - let _ = parse_summary(summary, &src); + parse_summary(summary, &src); } fn main() {} diff --git a/tests/ui/issues/issue-23808.rs b/tests/ui/issues/issue-23808.rs index 0988b09fce99a..b10682521a4b0 100644 --- a/tests/ui/issues/issue-23808.rs +++ b/tests/ui/issues/issue-23808.rs @@ -45,14 +45,14 @@ impl_Const!(ConstStruct, ConstEnum, AliasedConstStruct, AliasedConstEnum); impl_StaticFn!(StaticFnStruct, StaticFnEnum, AliasedStaticFnStruct, AliasedStaticFnEnum); fn main() { - let _ = ConstStruct::C; - let _ = ConstEnum::C; + let () = ConstStruct::C; + let () = ConstEnum::C; StaticFnStruct::sfn(); StaticFnEnum::sfn(); - let _ = AliasConstStruct::C; - let _ = AliasConstEnum::C; + let () = AliasConstStruct::C; + let () = AliasConstEnum::C; AliasStaticFnStruct::sfn(); AliasStaticFnEnum::sfn(); diff --git a/tests/ui/lint/lint-attr-everywhere-early.rs b/tests/ui/lint/lint-attr-everywhere-early.rs index 0c820ef9a29a9..ae32ec426f232 100644 --- a/tests/ui/lint/lint-attr-everywhere-early.rs +++ b/tests/ui/lint/lint-attr-everywhere-early.rs @@ -147,7 +147,7 @@ fn expressions() { #![deny(unsafe_code)] unsafe {} //~ ERROR usage of an `unsafe` block } - let block_tail = { + let block_tail: () = { #[deny(unsafe_code)] unsafe {} //~ ERROR usage of an `unsafe` block }; diff --git a/tests/ui/lint/lint-attr-everywhere-late.rs b/tests/ui/lint/lint-attr-everywhere-late.rs index a24355babb63e..c3acdeda43a9b 100644 --- a/tests/ui/lint/lint-attr-everywhere-late.rs +++ b/tests/ui/lint/lint-attr-everywhere-late.rs @@ -172,7 +172,7 @@ fn expressions() { #![deny(enum_intrinsics_non_enums)] discriminant::(&123); //~ ERROR the return value of } - let block_tail = { + let block_tail: () = { #[deny(enum_intrinsics_non_enums)] discriminant::(&123); //~ ERROR the return value of }; diff --git a/tests/ui/lint/unused/lint-unused-extern-crate.rs b/tests/ui/lint/unused/lint-unused-extern-crate.rs index d5e4da526a1d5..79df58b704247 100644 --- a/tests/ui/lint/unused/lint-unused-extern-crate.rs +++ b/tests/ui/lint/unused/lint-unused-extern-crate.rs @@ -31,5 +31,5 @@ mod foo { fn main() { lint_unused_extern_crate3::foo(); - let y = foo(); + foo(); } diff --git a/tests/ui/lint/unused/lint-unused-imports.rs b/tests/ui/lint/unused/lint-unused-imports.rs index 4754d8880763a..953992ecf7147 100644 --- a/tests/ui/lint/unused/lint-unused-imports.rs +++ b/tests/ui/lint/unused/lint-unused-imports.rs @@ -86,5 +86,5 @@ fn main() { let mut b = 4; swap(&mut a, &mut b); test::C.b(); - let _a = foo(); + foo(); } diff --git a/tests/ui/lint/unused/lint-unused-variables.rs b/tests/ui/lint/unused/lint-unused-variables.rs index 6850e999242ea..621c6ef84140f 100644 --- a/tests/ui/lint/unused/lint-unused-variables.rs +++ b/tests/ui/lint/unused/lint-unused-variables.rs @@ -74,6 +74,6 @@ fn main() { b: i32, //~^ ERROR unused variable: `b` | {}; - let _ = a(1, 2); - let _ = b(1, 2); + a(1, 2); + b(1, 2); } diff --git a/tests/ui/lint/unused_import_warning_issue_45268.rs b/tests/ui/lint/unused_import_warning_issue_45268.rs index 5ae4828634091..7aa4d4959e7a6 100644 --- a/tests/ui/lint/unused_import_warning_issue_45268.rs +++ b/tests/ui/lint/unused_import_warning_issue_45268.rs @@ -31,15 +31,15 @@ use test::B; // This is used by the test2::func() through import of super mod test2 { use super::*; pub fn func() { - let _ = <()>::a(); - let _ = ().b(); + <()>::a(); + ().b(); test3::inner_func(); } mod test3 { use super::*; pub fn inner_func() { - let _ = <()>::a(); - let _ = ().b(); + <()>::a(); + ().b(); } } } diff --git a/tests/ui/macros/format-args-temporaries.rs b/tests/ui/macros/format-args-temporaries.rs index 59323828bc37f..1ff6e3f80d6d5 100644 --- a/tests/ui/macros/format-args-temporaries.rs +++ b/tests/ui/macros/format-args-temporaries.rs @@ -27,27 +27,27 @@ impl<'a> Display for MutexGuard<'a> { } fn main() { - let _print = { + let _print: () = { let mutex = Mutex; print!("{}", mutex.lock()) /* no semicolon */ }; - let _println = { + let _println: () = { let mutex = Mutex; println!("{}", mutex.lock()) /* no semicolon */ }; - let _eprint = { + let _eprint: () = { let mutex = Mutex; eprint!("{}", mutex.lock()) /* no semicolon */ }; - let _eprintln = { + let _eprintln: () = { let mutex = Mutex; eprintln!("{}", mutex.lock()) /* no semicolon */ }; - let _panic = { + let _panic: () = { let mutex = Mutex; panic!("{}", mutex.lock()) /* no semicolon */ }; diff --git a/tests/ui/macros/macro-comma-support-rpass.rs b/tests/ui/macros/macro-comma-support-rpass.rs index cb019792e656f..2f08ad3c343ab 100644 --- a/tests/ui/macros/macro-comma-support-rpass.rs +++ b/tests/ui/macros/macro-comma-support-rpass.rs @@ -170,8 +170,8 @@ fn format_args() { #[test] fn include() { - let _ = include!("auxiliary/macro-comma-support.rs"); - let _ = include!("auxiliary/macro-comma-support.rs",); + include!("auxiliary/macro-comma-support.rs"); + include!("auxiliary/macro-comma-support.rs",); } #[test] diff --git a/tests/ui/mir/issue-101844.rs b/tests/ui/mir/issue-101844.rs index da8a25f5f822f..72ceefa4f4a40 100644 --- a/tests/ui/mir/issue-101844.rs +++ b/tests/ui/mir/issue-101844.rs @@ -67,7 +67,7 @@ where MS::Item: Into<()>, { // Error: Apparently Balance::new doesn't exist during MIR validation - let _ = ImplShoulExist::::access_fn(ms); + ImplShoulExist::::access_fn(ms); } fn main() {} diff --git a/tests/ui/mir/issue-80949.rs b/tests/ui/mir/issue-80949.rs index 7e34a4f5c2737..96b63e93a9ab8 100644 --- a/tests/ui/mir/issue-80949.rs +++ b/tests/ui/mir/issue-80949.rs @@ -28,7 +28,7 @@ fn may_panic(_: X) { } fn main() { let dyn_trait = make_dyn_trait(&()); let storage = vec![()]; - let _x = may_panic(()); + may_panic(()); let storage_ref = &storage; diff(dyn_trait, storage_ref); } diff --git a/tests/ui/mir/issue66339.rs b/tests/ui/mir/issue66339.rs index 2507af38cdf73..f25afd5602d34 100644 --- a/tests/ui/mir/issue66339.rs +++ b/tests/ui/mir/issue66339.rs @@ -5,7 +5,7 @@ fn foo() { let bar = |_| { }; - let _ = bar("a"); + bar("a"); } fn main() { diff --git a/tests/ui/never_type/diverging-fallback-control-flow.rs b/tests/ui/never_type/diverging-fallback-control-flow.rs index 45a3362fa6d8e..9f6cfc7999a6a 100644 --- a/tests/ui/never_type/diverging-fallback-control-flow.rs +++ b/tests/ui/never_type/diverging-fallback-control-flow.rs @@ -48,7 +48,7 @@ fn assignment_rev() { } fn if_then_else() { - let _x = if true { + let _x: () = if true { UnitDefault::default() } else { return; @@ -56,7 +56,7 @@ fn if_then_else() { } fn if_then_else_rev() { - let _x = if true { + let _x: () = if true { return; } else { UnitDefault::default() @@ -64,21 +64,21 @@ fn if_then_else_rev() { } fn match_arm() { - let _x = match Ok(UnitDefault::default()) { + let _x: () = match Ok(UnitDefault::default()) { Ok(v) => v, Err(()) => return, }; } fn match_arm_rev() { - let _x = match Ok(UnitDefault::default()) { + let _x: () = match Ok(UnitDefault::default()) { Err(()) => return, Ok(v) => v, }; } fn loop_break() { - let _x = loop { + let _x: () = loop { if false { break return; } else { @@ -88,7 +88,7 @@ fn loop_break() { } fn loop_break_rev() { - let _x = loop { + let _x: () = loop { if false { break return; } else { diff --git a/tests/ui/nll/assign-while-to-immutable.rs b/tests/ui/nll/assign-while-to-immutable.rs index c803321b5087a..24eaa8a23883d 100644 --- a/tests/ui/nll/assign-while-to-immutable.rs +++ b/tests/ui/nll/assign-while-to-immutable.rs @@ -4,8 +4,8 @@ // check-pass fn main() { - let x = while false { + let x: () = while false { break; }; - let y = 'l: while break 'l {}; + let y: () = 'l: while break 'l {}; } diff --git a/tests/ui/nll/issue-54943-3.rs b/tests/ui/nll/issue-54943-3.rs index 077eb156316f5..348b48dbabb5b 100644 --- a/tests/ui/nll/issue-54943-3.rs +++ b/tests/ui/nll/issue-54943-3.rs @@ -13,7 +13,7 @@ fn foo(_: T) { } fn bar<'a>() { return; - let _x = foo::>(Vec::<&'a u32>::new()); + foo::>(Vec::<&'a u32>::new()); } fn main() {} diff --git a/tests/ui/polymorphization/drop_shims/simple.rs b/tests/ui/polymorphization/drop_shims/simple.rs index 2695dc6d4f177..5f10d5e831cd3 100644 --- a/tests/ui/polymorphization/drop_shims/simple.rs +++ b/tests/ui/polymorphization/drop_shims/simple.rs @@ -14,7 +14,7 @@ fn foo( let bar = || { let _ = OnDrop(|| ()); }; - let _ = bar(); + bar(); } fn main() { diff --git a/tests/ui/polymorphization/drop_shims/transitive.rs b/tests/ui/polymorphization/drop_shims/transitive.rs index c22891171091a..283b8da132947 100644 --- a/tests/ui/polymorphization/drop_shims/transitive.rs +++ b/tests/ui/polymorphization/drop_shims/transitive.rs @@ -19,7 +19,7 @@ fn foo( let bar = || { bar(|| {}) }; - let _ = bar(); + bar(); } fn main() { diff --git a/tests/ui/reachable/expr_return.rs b/tests/ui/reachable/expr_return.rs index 0fc43f45075da..0dbeb660eedea 100644 --- a/tests/ui/reachable/expr_return.rs +++ b/tests/ui/reachable/expr_return.rs @@ -7,7 +7,7 @@ fn a() { // Here we issue that the "2nd-innermost" return is unreachable, // but we stop there. - let x = {return {return {return;}}}; //~ ERROR unreachable + let x: () = {return {return {return;}}}; //~ ERROR unreachable } fn main() { } diff --git a/tests/ui/reachable/expr_return.stderr b/tests/ui/reachable/expr_return.stderr index e1bef80aeb00e..3791559f44000 100644 --- a/tests/ui/reachable/expr_return.stderr +++ b/tests/ui/reachable/expr_return.stderr @@ -1,11 +1,11 @@ error: unreachable expression - --> $DIR/expr_return.rs:10:22 + --> $DIR/expr_return.rs:10:26 | -LL | let x = {return {return {return;}}}; - | ^^^^^^^^------^^ - | | | - | | any code following this expression is unreachable - | unreachable expression +LL | let x: () = {return {return {return;}}}; + | ^^^^^^^^------^^ + | | | + | | any code following this expression is unreachable + | unreachable expression | note: the lint level is defined here --> $DIR/expr_return.rs:4:9 diff --git a/tests/ui/resolve/extern-prelude.rs b/tests/ui/resolve/extern-prelude.rs index 50fed6034aa02..b5f1d5d35b2dd 100644 --- a/tests/ui/resolve/extern-prelude.rs +++ b/tests/ui/resolve/extern-prelude.rs @@ -25,7 +25,7 @@ fn shadow_mod() { fn shadow_prelude() { // Extern prelude shadows standard library prelude - let x = Vec::new(0f32, ()); // OK + let x: () = Vec::new(0f32, ()); // OK } fn main() {} diff --git a/tests/ui/resolve/resolve-pseudo-shadowing.rs b/tests/ui/resolve/resolve-pseudo-shadowing.rs index 85c684ca0328e..0ee0d0efad6c9 100644 --- a/tests/ui/resolve/resolve-pseudo-shadowing.rs +++ b/tests/ui/resolve/resolve-pseudo-shadowing.rs @@ -3,7 +3,7 @@ fn check(_c: Clone) { fn check2() { - let _ = <() as std::clone::Clone>::clone(&()); + let () = <() as std::clone::Clone>::clone(&()); } check2(); } diff --git a/tests/ui/return-nil.rs b/tests/ui/return-nil.rs index fd5203ff0ed60..4fc937f96a1f4 100644 --- a/tests/ui/return-nil.rs +++ b/tests/ui/return-nil.rs @@ -1,6 +1,6 @@ // run-pass // 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(); } diff --git a/tests/ui/rfcs/rfc-2565-param-attrs/param-attrs-allowed.rs b/tests/ui/rfcs/rfc-2565-param-attrs/param-attrs-allowed.rs index a547d09d04822..2de37c859c97a 100644 --- a/tests/ui/rfcs/rfc-2565-param-attrs/param-attrs-allowed.rs +++ b/tests/ui/rfcs/rfc-2565-param-attrs/param-attrs-allowed.rs @@ -97,5 +97,5 @@ fn main() { #[cfg_attr(something, cfg(nothing))] #[deny(unused_mut)] c: i32, | {}; - let _ = c(1, 2); + c(1, 2); } diff --git a/tests/ui/rfcs/rfc-2565-param-attrs/param-attrs-cfg.rs b/tests/ui/rfcs/rfc-2565-param-attrs/param-attrs-cfg.rs index a4d9d32b514ac..14539d4b6d8fa 100644 --- a/tests/ui/rfcs/rfc-2565-param-attrs/param-attrs-cfg.rs +++ b/tests/ui/rfcs/rfc-2565-param-attrs/param-attrs-cfg.rs @@ -116,6 +116,6 @@ fn main() { //~^ ERROR unused variable: `c` #[cfg_attr(something, cfg(nothing))] d: i32, | {}; - let _ = a(1); - let _ = c(1, 2); + a(1); + c(1, 2); } diff --git a/tests/ui/traits/bound/generic_trait.rs b/tests/ui/traits/bound/generic_trait.rs index 18382bb59a4e5..2484c5a88fb31 100644 --- a/tests/ui/traits/bound/generic_trait.rs +++ b/tests/ui/traits/bound/generic_trait.rs @@ -24,7 +24,7 @@ impl connection_factory for my_connection_factory { pub fn main() { let factory = (); - let connection = factory.create(); + let connection: () = factory.create(); let result = connection.read(); assert_eq!(result, 43); } diff --git a/tests/ui/try-block/issue-45124.rs b/tests/ui/try-block/issue-45124.rs index 942014c9184d8..2cf2ade65e91f 100644 --- a/tests/ui/try-block/issue-45124.rs +++ b/tests/ui/try-block/issue-45124.rs @@ -8,7 +8,7 @@ fn main() { let mut a = 0; let () = { let _: Result<(), ()> = try { - let _ = Err(())?; + let () = Err(())?; return }; a += 1; diff --git a/tests/ui/tuple/index-float.rs b/tests/ui/tuple/index-float.rs index eda2bf48581a0..53b025c9135b2 100644 --- a/tests/ui/tuple/index-float.rs +++ b/tests/ui/tuple/index-float.rs @@ -3,8 +3,8 @@ fn main() { 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 } diff --git a/tests/ui/weird-exprs.rs b/tests/ui/weird-exprs.rs index c4fa850a4f9d1..59b4bb8ef8598 100644 --- a/tests/ui/weird-exprs.rs +++ b/tests/ui/weird-exprs.rs @@ -81,7 +81,7 @@ fn angrydome() { break; } } -fn evil_lincoln() { let _evil = println!("lincoln"); } +fn evil_lincoln() { let _evil: () = println!("lincoln"); } fn dots() { assert_eq!(String::from(".................................................."), @@ -137,7 +137,7 @@ fn punch_card() -> impl std::fmt::Debug { } 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() { - let val = ()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=(); + let val: () = ()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=(); assert_eq!(val, ()); }