diff --git a/Cargo.lock b/Cargo.lock index b3b4284a56459..6e95fd6af273f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2149,11 +2149,14 @@ dependencies = [ [[package]] name = "measureme" -version = "9.0.0" +version = "9.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22bf8d885d073610aee20e7fa205c4341ed32a761dbde96da5fd96301a8d3e82" +checksum = "4a98e07fe802486895addb2b5467f33f205e82c426bfaf350f5d8109b137767c" dependencies = [ + "log", + "memmap", "parking_lot", + "perf-event-open-sys", "rustc-hash", "smallvec 1.6.1", ] @@ -2550,6 +2553,15 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" +[[package]] +name = "perf-event-open-sys" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce9bedf5da2c234fdf2391ede2b90fabf585355f33100689bc364a3ea558561a" +dependencies = [ + "libc", +] + [[package]] name = "pest" version = "2.1.3" diff --git a/RELEASES.md b/RELEASES.md index 25f9c802982c3..5dca7abcb2629 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -68,7 +68,7 @@ The following previously stable methods are now `const`. - `saturating_pow` for all integer types. - `wrapping_pow` for all integer types. - `next_power_of_two` for all unsigned integer types. -- `checked_power_of_two` for all unsigned integer types. +- `checked_next_power_of_two` for all unsigned integer types. Cargo ----------------------- diff --git a/compiler/rustc_codegen_llvm/Cargo.toml b/compiler/rustc_codegen_llvm/Cargo.toml index 260edd9570b2b..4999cb3c7ab42 100644 --- a/compiler/rustc_codegen_llvm/Cargo.toml +++ b/compiler/rustc_codegen_llvm/Cargo.toml @@ -12,7 +12,7 @@ doctest = false bitflags = "1.0" cstr = "0.2" libc = "0.2" -measureme = "9.0.0" +measureme = "9.1.0" snap = "1" tracing = "0.1" rustc_middle = { path = "../rustc_middle" } diff --git a/compiler/rustc_data_structures/Cargo.toml b/compiler/rustc_data_structures/Cargo.toml index e3476517de583..818c43642566c 100644 --- a/compiler/rustc_data_structures/Cargo.toml +++ b/compiler/rustc_data_structures/Cargo.toml @@ -25,7 +25,7 @@ rustc-hash = "1.1.0" smallvec = { version = "1.6.1", features = ["union", "may_dangle"] } rustc_index = { path = "../rustc_index", package = "rustc_index" } bitflags = "1.2.1" -measureme = "9.0.0" +measureme = "9.1.0" libc = "0.2" stacker = "0.1.12" tempfile = "3.0.5" diff --git a/compiler/rustc_lint/src/unused.rs b/compiler/rustc_lint/src/unused.rs index b611aebad01b0..e6b6fdeaae012 100644 --- a/compiler/rustc_lint/src/unused.rs +++ b/compiler/rustc_lint/src/unused.rs @@ -154,6 +154,9 @@ impl<'tcx> LateLintPass<'tcx> for UnusedResults { | hir::BinOpKind::Shl | hir::BinOpKind::Shr => Some("bitwise operation"), }, + + hir::ExprKind::AddrOf(..) => Some("borrow"), + hir::ExprKind::Unary(..) => Some("unary operation"), _ => None, }; diff --git a/compiler/rustc_macros/src/hash_stable.rs b/compiler/rustc_macros/src/hash_stable.rs index c955c13778276..3ca77d35c3300 100644 --- a/compiler/rustc_macros/src/hash_stable.rs +++ b/compiler/rustc_macros/src/hash_stable.rs @@ -54,7 +54,7 @@ pub fn hash_stable_generic_derive(mut s: synstructure::Structure<'_>) -> proc_ma quote! {} } else if let Some(project) = attrs.project { quote! { - &#bi.#project.hash_stable(__hcx, __hasher); + (&#bi.#project).hash_stable(__hcx, __hasher); } } else { quote! { @@ -95,7 +95,7 @@ pub fn hash_stable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::To quote! {} } else if let Some(project) = attrs.project { quote! { - &#bi.#project.hash_stable(__hcx, __hasher); + (&#bi.#project).hash_stable(__hcx, __hasher); } } else { quote! { diff --git a/compiler/rustc_middle/Cargo.toml b/compiler/rustc_middle/Cargo.toml index 7de398a1898e5..0674233165501 100644 --- a/compiler/rustc_middle/Cargo.toml +++ b/compiler/rustc_middle/Cargo.toml @@ -28,6 +28,6 @@ rustc_ast = { path = "../rustc_ast" } rustc_span = { path = "../rustc_span" } chalk-ir = "0.55.0" smallvec = { version = "1.6.1", features = ["union", "may_dangle"] } -measureme = "9.0.0" +measureme = "9.1.0" rustc_session = { path = "../rustc_session" } rustc_type_ir = { path = "../rustc_type_ir" } diff --git a/compiler/rustc_mir/src/monomorphize/partitioning/mod.rs b/compiler/rustc_mir/src/monomorphize/partitioning/mod.rs index b9fcd32250dcf..b68a8104fba72 100644 --- a/compiler/rustc_mir/src/monomorphize/partitioning/mod.rs +++ b/compiler/rustc_mir/src/monomorphize/partitioning/mod.rs @@ -239,17 +239,22 @@ where I: Iterator>, 'tcx: 'a, { - if cfg!(debug_assertions) { - debug!("{}", label); + let dump = move || { + use std::fmt::Write; + + let s = &mut String::new(); + let _ = writeln!(s, "{}", label); for cgu in cgus { - debug!("CodegenUnit {} estimated size {} :", cgu.name(), cgu.size_estimate()); + let _ = + writeln!(s, "CodegenUnit {} estimated size {} :", cgu.name(), cgu.size_estimate()); for (mono_item, linkage) in cgu.items() { let symbol_name = mono_item.symbol_name(tcx).name; let symbol_hash_start = symbol_name.rfind('h'); let symbol_hash = symbol_hash_start.map_or("", |i| &symbol_name[i..]); - debug!( + let _ = writeln!( + s, " - {} [{:?}] [{}] estimated size {}", mono_item, linkage, @@ -258,9 +263,13 @@ where ); } - debug!(""); + let _ = writeln!(s, ""); } - } + + std::mem::take(s) + }; + + debug!("{}", dump()); } #[inline(never)] // give this a place in the profiler diff --git a/compiler/rustc_parse/src/lexer/mod.rs b/compiler/rustc_parse/src/lexer/mod.rs index 4a638ec3f8020..4bf870eb7ce7e 100644 --- a/compiler/rustc_parse/src/lexer/mod.rs +++ b/compiler/rustc_parse/src/lexer/mod.rs @@ -268,6 +268,9 @@ impl<'a> StringReader<'a> { // tokens like `<<` from `rustc_lexer`, and then add fancier error recovery to it, // as there will be less overall work to do this way. let token = unicode_chars::check_for_substitution(self, start, c, &mut err); + if c == '\x00' { + err.help("source files must contain UTF-8 encoded text, unexpected null bytes might occur when a different encoding is used"); + } err.emit(); token? } diff --git a/compiler/rustc_target/src/spec/crt_objects.rs b/compiler/rustc_target/src/spec/crt_objects.rs index 32da16a2d8ca8..51a48147e6b62 100644 --- a/compiler/rustc_target/src/spec/crt_objects.rs +++ b/compiler/rustc_target/src/spec/crt_objects.rs @@ -64,17 +64,24 @@ pub(super) fn all(obj: &str) -> CrtObjects { pub(super) fn pre_musl_fallback() -> CrtObjects { new(&[ - (LinkOutputKind::DynamicNoPicExe, &["crt1.o", "crti.o"]), - (LinkOutputKind::DynamicPicExe, &["Scrt1.o", "crti.o"]), - (LinkOutputKind::StaticNoPicExe, &["crt1.o", "crti.o"]), - (LinkOutputKind::StaticPicExe, &["rcrt1.o", "crti.o"]), - (LinkOutputKind::DynamicDylib, &["crti.o"]), - (LinkOutputKind::StaticDylib, &["crti.o"]), + (LinkOutputKind::DynamicNoPicExe, &["crt1.o", "crti.o", "crtbegin.o"]), + (LinkOutputKind::DynamicPicExe, &["Scrt1.o", "crti.o", "crtbeginS.o"]), + (LinkOutputKind::StaticNoPicExe, &["crt1.o", "crti.o", "crtbegin.o"]), + (LinkOutputKind::StaticPicExe, &["rcrt1.o", "crti.o", "crtbeginS.o"]), + (LinkOutputKind::DynamicDylib, &["crti.o", "crtbeginS.o"]), + (LinkOutputKind::StaticDylib, &["crti.o", "crtbeginS.o"]), ]) } pub(super) fn post_musl_fallback() -> CrtObjects { - all("crtn.o") + new(&[ + (LinkOutputKind::DynamicNoPicExe, &["crtend.o", "crtn.o"]), + (LinkOutputKind::DynamicPicExe, &["crtendS.o", "crtn.o"]), + (LinkOutputKind::StaticNoPicExe, &["crtend.o", "crtn.o"]), + (LinkOutputKind::StaticPicExe, &["crtendS.o", "crtn.o"]), + (LinkOutputKind::DynamicDylib, &["crtendS.o", "crtn.o"]), + (LinkOutputKind::StaticDylib, &["crtendS.o", "crtn.o"]), + ]) } pub(super) fn pre_mingw_fallback() -> CrtObjects { diff --git a/compiler/rustc_typeck/src/check/method/suggest.rs b/compiler/rustc_typeck/src/check/method/suggest.rs index 721e8ec54f05f..e6c551ff4d41b 100644 --- a/compiler/rustc_typeck/src/check/method/suggest.rs +++ b/compiler/rustc_typeck/src/check/method/suggest.rs @@ -517,21 +517,21 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } if self.is_fn_ty(&rcvr_ty, span) { - macro_rules! report_function { - ($span:expr, $name:expr) => { - err.note(&format!( - "`{}` is a function, perhaps you wish to call it", - $name - )); - }; + fn report_function( + err: &mut DiagnosticBuilder<'_>, + name: T, + ) { + err.note( + &format!("`{}` is a function, perhaps you wish to call it", name,), + ); } if let SelfSource::MethodCall(expr) = source { if let Ok(expr_string) = tcx.sess.source_map().span_to_snippet(expr.span) { - report_function!(expr.span, expr_string); + report_function(&mut err, expr_string); } else if let ExprKind::Path(QPath::Resolved(_, ref path)) = expr.kind { if let Some(segment) = path.segments.last() { - report_function!(expr.span, segment.ident); + report_function(&mut err, segment.ident); } } } diff --git a/library/alloc/tests/str.rs b/library/alloc/tests/str.rs index 604835e6cc4a6..3279479fc2f9b 100644 --- a/library/alloc/tests/str.rs +++ b/library/alloc/tests/str.rs @@ -504,7 +504,7 @@ mod slice_index { #[test] #[should_panic] fn test_slice_fail() { - &"中华Việt Nam"[0..2]; + let _ = &"中华Việt Nam"[0..2]; } panic_cases! { @@ -684,13 +684,13 @@ mod slice_index { #[test] #[should_panic(expected = "byte index 1024 is out of bounds of `Lorem ipsum dolor sit amet")] fn test_slice_fail_truncated_1() { - &LOREM_PARAGRAPH[..1024]; + let _ = &LOREM_PARAGRAPH[..1024]; } // check the truncation in the panic message #[test] #[should_panic(expected = "luctus, im`[...]")] fn test_slice_fail_truncated_2() { - &LOREM_PARAGRAPH[..1024]; + let _ = &LOREM_PARAGRAPH[..1024]; } } @@ -705,7 +705,7 @@ fn test_str_slice_rangetoinclusive_ok() { #[should_panic] fn test_str_slice_rangetoinclusive_notok() { let s = "abcαβγ"; - &s[..=3]; + let _ = &s[..=3]; } #[test] @@ -721,7 +721,7 @@ fn test_str_slicemut_rangetoinclusive_ok() { fn test_str_slicemut_rangetoinclusive_notok() { let mut s = "abcαβγ".to_owned(); let s: &mut str = &mut s; - &mut s[..=3]; + let _ = &mut s[..=3]; } #[test] diff --git a/library/alloc/tests/vec.rs b/library/alloc/tests/vec.rs index 2969da58d4268..e48e827c45a90 100644 --- a/library/alloc/tests/vec.rs +++ b/library/alloc/tests/vec.rs @@ -541,35 +541,35 @@ fn test_index_out_of_bounds() { #[should_panic] fn test_slice_out_of_bounds_1() { let x = vec![1, 2, 3, 4, 5]; - &x[!0..]; + let _ = &x[!0..]; } #[test] #[should_panic] fn test_slice_out_of_bounds_2() { let x = vec![1, 2, 3, 4, 5]; - &x[..6]; + let _ = &x[..6]; } #[test] #[should_panic] fn test_slice_out_of_bounds_3() { let x = vec![1, 2, 3, 4, 5]; - &x[!0..4]; + let _ = &x[!0..4]; } #[test] #[should_panic] fn test_slice_out_of_bounds_4() { let x = vec![1, 2, 3, 4, 5]; - &x[1..6]; + let _ = &x[1..6]; } #[test] #[should_panic] fn test_slice_out_of_bounds_5() { let x = vec![1, 2, 3, 4, 5]; - &x[3..2]; + let _ = &x[3..2]; } #[test] diff --git a/library/std/src/f32.rs b/library/std/src/f32.rs index f51b2c2462166..c16d27fa1f58c 100644 --- a/library/std/src/f32.rs +++ b/library/std/src/f32.rs @@ -503,7 +503,7 @@ impl f32 { unsafe { cmath::fdimf(self, other) } } - /// Returns the cubic root of a number. + /// Returns the cube root of a number. /// /// # Examples /// diff --git a/library/std/src/f64.rs b/library/std/src/f64.rs index 8c41e4486865c..4c95df5ffe04a 100644 --- a/library/std/src/f64.rs +++ b/library/std/src/f64.rs @@ -505,7 +505,7 @@ impl f64 { unsafe { cmath::fdim(self, other) } } - /// Returns the cubic root of a number. + /// Returns the cube root of a number. /// /// # Examples /// diff --git a/library/std/src/io/stdio.rs b/library/std/src/io/stdio.rs index d1f9049c8fabb..1e72c9e0611ea 100644 --- a/library/std/src/io/stdio.rs +++ b/library/std/src/io/stdio.rs @@ -497,7 +497,7 @@ pub struct Stdout { /// A locked reference to the [`Stdout`] handle. /// /// This handle implements the [`Write`] trait, and is constructed via -/// the [`Stdout::lock`] method. +/// the [`Stdout::lock`] method. See its documentation for more. /// /// ### Note: Windows Portability Consideration /// When operating in a console, the Windows implementation of this stream does not support @@ -711,7 +711,7 @@ pub struct Stderr { /// A locked reference to the [`Stderr`] handle. /// /// This handle implements the [`Write`] trait and is constructed via -/// the [`Stderr::lock`] method. +/// the [`Stderr::lock`] method. See its documentation for more. /// /// ### Note: Windows Portability Consideration /// When operating in a console, the Windows implementation of this stream does not support diff --git a/library/std/src/sync/rwlock.rs b/library/std/src/sync/rwlock.rs index d967779ce361d..0298f59228cbe 100644 --- a/library/std/src/sync/rwlock.rs +++ b/library/std/src/sync/rwlock.rs @@ -23,7 +23,9 @@ use crate::sys_common::rwlock as sys; /// /// The priority policy of the lock is dependent on the underlying operating /// system's implementation, and this type does not guarantee that any -/// particular policy will be used. +/// particular policy will be used. In particular, a writer which is waiting to +/// acquire the lock in `write` might or might not block concurrent calls to +/// `read`. /// /// The type parameter `T` represents the data that this lock protects. It is /// required that `T` satisfies [`Send`] to be shared across threads and diff --git a/library/std/src/sys_common/wtf8/tests.rs b/library/std/src/sys_common/wtf8/tests.rs index 385e01f92fa14..01e2841e93450 100644 --- a/library/std/src/sys_common/wtf8/tests.rs +++ b/library/std/src/sys_common/wtf8/tests.rs @@ -301,7 +301,7 @@ fn wtf8_slice() { #[test] #[should_panic] fn wtf8_slice_not_code_point_boundary() { - &Wtf8::from_str("aé 💩")[2..4]; + let _ = &Wtf8::from_str("aé 💩")[2..4]; } #[test] @@ -312,18 +312,18 @@ fn wtf8_slice_from() { #[test] #[should_panic] fn wtf8_slice_from_not_code_point_boundary() { - &Wtf8::from_str("aé 💩")[2..]; + let _ = &Wtf8::from_str("aé 💩")[2..]; } #[test] fn wtf8_slice_to() { - assert_eq!(&Wtf8::from_str("aé 💩")[..4].bytes, b"a\xC3\xA9 "); + let _ = assert_eq!(&Wtf8::from_str("aé 💩")[..4].bytes, b"a\xC3\xA9 "); } #[test] #[should_panic] fn wtf8_slice_to_not_code_point_boundary() { - &Wtf8::from_str("aé 💩")[5..]; + let _ = &Wtf8::from_str("aé 💩")[5..]; } #[test] diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs index 7d5e3d05b11fa..859e38dc34647 100644 --- a/src/bootstrap/compile.rs +++ b/src/bootstrap/compile.rs @@ -189,6 +189,12 @@ fn copy_self_contained_objects( DependencyType::TargetSelfContained, ); } + for &obj in &["crtbegin.o", "crtbeginS.o", "crtend.o", "crtendS.o"] { + let src = compiler_file(builder, builder.cc(target), target, obj); + let target = libdir_self_contained.join(obj); + builder.copy(&src, &target); + target_deps.push((target, DependencyType::TargetSelfContained)); + } } else if target.ends_with("-wasi") { let srcdir = builder.wasi_root(target).unwrap().join("lib/wasm32-wasi"); for &obj in &["crt1.o", "crt1-reactor.o"] { diff --git a/src/librustdoc/html/layout.rs b/src/librustdoc/html/layout.rs index e5a686bd07d07..73c106f5ae032 100644 --- a/src/librustdoc/html/layout.rs +++ b/src/librustdoc/html/layout.rs @@ -75,7 +75,7 @@ crate fn render( \ {before_content}\ \ diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs index 6d9e3d0b9eab0..c047f8729adc1 100644 --- a/src/librustdoc/passes/collect_intra_doc_links.rs +++ b/src/librustdoc/passes/collect_intra_doc_links.rs @@ -838,6 +838,14 @@ impl<'a, 'tcx> DocFolder for LinkCollector<'a, 'tcx> { debug!("looking for the `Self` type"); let self_id = if item.is_fake() { None + // Checking if the item is a field in an enum variant + } else if (matches!(self.cx.tcx.def_kind(item.def_id), DefKind::Field) + && matches!( + self.cx.tcx.def_kind(self.cx.tcx.parent(item.def_id).unwrap()), + DefKind::Variant + )) + { + self.cx.tcx.parent(item.def_id).and_then(|item_id| self.cx.tcx.parent(item_id)) } else if matches!( self.cx.tcx.def_kind(item.def_id), DefKind::AssocConst diff --git a/src/test/rustdoc/intra-doc/issue-82209.rs b/src/test/rustdoc/intra-doc/issue-82209.rs new file mode 100644 index 0000000000000..76618cdce4cd2 --- /dev/null +++ b/src/test/rustdoc/intra-doc/issue-82209.rs @@ -0,0 +1,11 @@ +#![crate_name = "foo"] +#![deny(broken_intra_doc_links)] +pub enum Foo { + Bar { + abc: i32, + /// [Self::Bar::abc] + xyz: i32, + }, +} + +// @has foo/enum.Foo.html '//a/@href' '../foo/enum.Foo.html#variant.Bar.field.abc' diff --git a/src/test/ui/array-slice-vec/slice-panic-1.rs b/src/test/ui/array-slice-vec/slice-panic-1.rs index 8b27d055e2be3..4134c62377835 100644 --- a/src/test/ui/array-slice-vec/slice-panic-1.rs +++ b/src/test/ui/array-slice-vec/slice-panic-1.rs @@ -17,7 +17,7 @@ impl Drop for Foo { fn foo() { let x: &[_] = &[Foo, Foo]; - &x[3..4]; + let _ = &x[3..4]; } fn main() { diff --git a/src/test/ui/array-slice-vec/slice-panic-2.rs b/src/test/ui/array-slice-vec/slice-panic-2.rs index 2ee564cadb344..2f7178fb3e132 100644 --- a/src/test/ui/array-slice-vec/slice-panic-2.rs +++ b/src/test/ui/array-slice-vec/slice-panic-2.rs @@ -21,7 +21,7 @@ fn bar() -> usize { fn foo() { let x: &[_] = &[Foo, Foo]; - &x[3..bar()]; + let _ = &x[3..bar()]; } fn main() { diff --git a/src/test/ui/array-slice-vec/slice.rs b/src/test/ui/array-slice-vec/slice.rs index 14e1ddf52eb7b..a514e20277365 100644 --- a/src/test/ui/array-slice-vec/slice.rs +++ b/src/test/ui/array-slice-vec/slice.rs @@ -67,14 +67,14 @@ impl IndexMut for Foo { fn main() { let mut x = Foo; - &x[..]; - &x[Foo..]; - &x[..Foo]; - &x[Foo..Foo]; - &mut x[..]; - &mut x[Foo..]; - &mut x[..Foo]; - &mut x[Foo..Foo]; + let _ = &x[..]; + let _ = &x[Foo..]; + let _ = &x[..Foo]; + let _ = &x[Foo..Foo]; + let _ = &mut x[..]; + let _ = &mut x[Foo..]; + let _ = &mut x[..Foo]; + let _ = &mut x[Foo..Foo]; unsafe { assert_eq!(COUNT, 8); } diff --git a/src/test/ui/const-generics/issues/issue-61432.rs b/src/test/ui/const-generics/issues/issue-61432.rs index 0e228126d7789..604e580895861 100644 --- a/src/test/ui/const-generics/issues/issue-61432.rs +++ b/src/test/ui/const-generics/issues/issue-61432.rs @@ -8,7 +8,7 @@ fn promote() { // let n = N; // &n; - &N; + let _ = &N; } fn main() { diff --git a/src/test/ui/dynamically-sized-types/dst-index.rs b/src/test/ui/dynamically-sized-types/dst-index.rs index 980d99a6d6c11..8aa65bbfdc9e7 100644 --- a/src/test/ui/dynamically-sized-types/dst-index.rs +++ b/src/test/ui/dynamically-sized-types/dst-index.rs @@ -29,6 +29,6 @@ impl Index for T { fn main() { assert_eq!(&S[0], "hello"); - &T[0]; + let _ = &T[0]; // let x = &x as &Debug; } diff --git a/src/test/ui/generator/too-live-local-in-immovable-gen.rs b/src/test/ui/generator/too-live-local-in-immovable-gen.rs index 7f118c88e5e6e..e0b856db7a55d 100644 --- a/src/test/ui/generator/too-live-local-in-immovable-gen.rs +++ b/src/test/ui/generator/too-live-local-in-immovable-gen.rs @@ -15,7 +15,7 @@ fn main() { yield (); 4i32 }; - &a; + let _ = &a; }; } } diff --git a/src/test/ui/generator/too-live-local-in-immovable-gen.stderr b/src/test/ui/generator/too-live-local-in-immovable-gen.stderr index 88dacff7b559b..72a2bd4ebc55c 100644 --- a/src/test/ui/generator/too-live-local-in-immovable-gen.stderr +++ b/src/test/ui/generator/too-live-local-in-immovable-gen.stderr @@ -6,7 +6,7 @@ LL | | // Tests that the generator transformation finds out that `a` LL | | // during the yield expression. Type checking will also compute liveness LL | | // and it should also find out that `a` is not live. ... | -LL | | &a; +LL | | let _ = &a; LL | | }; | |__________^ | diff --git a/src/test/ui/generator/yield-in-initializer.rs b/src/test/ui/generator/yield-in-initializer.rs index 2f8754c95715f..0cab36e5f2880 100644 --- a/src/test/ui/generator/yield-in-initializer.rs +++ b/src/test/ui/generator/yield-in-initializer.rs @@ -11,7 +11,7 @@ fn main() { yield; true }; - &opt; + let _ = &opt; } }; } diff --git a/src/test/ui/issues/issue-43205.rs b/src/test/ui/issues/issue-43205.rs index 894a61f3eff0e..f47d5a347bb11 100644 --- a/src/test/ui/issues/issue-43205.rs +++ b/src/test/ui/issues/issue-43205.rs @@ -1,5 +1,5 @@ // run-pass fn main() { - &&[()][0]; + let _ = &&[()][0]; println!("{:?}", &[(),()][1]); } diff --git a/src/test/ui/issues/issue-5280.rs b/src/test/ui/issues/issue-5280.rs index 3c97dad6b148b..fc966836f3f3c 100644 --- a/src/test/ui/issues/issue-5280.rs +++ b/src/test/ui/issues/issue-5280.rs @@ -9,7 +9,7 @@ trait FontTableTagConversions { impl FontTableTagConversions for FontTableTag { fn tag_to_string(self) { - &self; + let _ = &self; } } diff --git a/src/test/ui/issues/issue-54696.rs b/src/test/ui/issues/issue-54696.rs index d8408ed85491f..15355d30db6a5 100644 --- a/src/test/ui/issues/issue-54696.rs +++ b/src/test/ui/issues/issue-54696.rs @@ -2,7 +2,7 @@ fn main() { // We shouldn't promote this - &(main as fn() == main as fn()); + let _ = &(main as fn() == main as fn()); // Also check nested case - &(&(main as fn()) == &(main as fn())); + let _ = &(&(main as fn()) == &(main as fn())); } diff --git a/src/test/ui/lint/unused-borrows.rs b/src/test/ui/lint/unused-borrows.rs new file mode 100644 index 0000000000000..d29365c11373a --- /dev/null +++ b/src/test/ui/lint/unused-borrows.rs @@ -0,0 +1,33 @@ +#![deny(unused_must_use)] + +fn foo(_: i32) -> bool { todo!() } + +fn bar() -> &'static i32 { + &42; + //~^ unused + + &mut foo(42); + //~^ unused + + &&42; + //~^ unused + + &&mut 42; + //~^ unused + + &mut &42; + //~^ unused + + let _result = foo(4) + && foo(2); // Misplaced semi-colon (perhaps due to reordering of lines) + && foo(42); + //~^ unused + + let _ = &42; // ok + + &42 // ok +} + +fn main() { + let _ = bar(); +} diff --git a/src/test/ui/lint/unused-borrows.stderr b/src/test/ui/lint/unused-borrows.stderr new file mode 100644 index 0000000000000..f1b4beeb10470 --- /dev/null +++ b/src/test/ui/lint/unused-borrows.stderr @@ -0,0 +1,44 @@ +error: unused borrow that must be used + --> $DIR/unused-borrows.rs:6:5 + | +LL | &42; + | ^^^ + | +note: the lint level is defined here + --> $DIR/unused-borrows.rs:1:9 + | +LL | #![deny(unused_must_use)] + | ^^^^^^^^^^^^^^^ + +error: unused borrow that must be used + --> $DIR/unused-borrows.rs:9:5 + | +LL | &mut foo(42); + | ^^^^^^^^^^^^ + +error: unused borrow that must be used + --> $DIR/unused-borrows.rs:12:5 + | +LL | &&42; + | ^^^^ + +error: unused borrow that must be used + --> $DIR/unused-borrows.rs:15:5 + | +LL | &&mut 42; + | ^^^^^^^^ + +error: unused borrow that must be used + --> $DIR/unused-borrows.rs:18:5 + | +LL | &mut &42; + | ^^^^^^^^ + +error: unused borrow that must be used + --> $DIR/unused-borrows.rs:23:9 + | +LL | && foo(42); + | ^^^^^^^^^^ + +error: aborting due to 6 previous errors + diff --git a/src/test/ui/parser/issue-66473.stderr b/src/test/ui/parser/issue-66473.stderr index b370b125cfefd..8a16d7f955129 100644 Binary files a/src/test/ui/parser/issue-66473.stderr and b/src/test/ui/parser/issue-66473.stderr differ diff --git a/src/test/ui/parser/issue-68629.stderr b/src/test/ui/parser/issue-68629.stderr index a7885ecec5647..19c9ef30f9049 100644 Binary files a/src/test/ui/parser/issue-68629.stderr and b/src/test/ui/parser/issue-68629.stderr differ diff --git a/src/test/ui/parser/issue-68730.stderr b/src/test/ui/parser/issue-68730.stderr index 9f8833e17fe25..8602abacabd32 100644 Binary files a/src/test/ui/parser/issue-68730.stderr and b/src/test/ui/parser/issue-68730.stderr differ diff --git a/src/test/ui/parser/utf16-be-without-bom.rs b/src/test/ui/parser/utf16-be-without-bom.rs new file mode 100644 index 0000000000000..22aa19717873a Binary files /dev/null and b/src/test/ui/parser/utf16-be-without-bom.rs differ diff --git a/src/test/ui/parser/utf16-be-without-bom.stderr b/src/test/ui/parser/utf16-be-without-bom.stderr new file mode 100644 index 0000000000000..768d2c5316417 Binary files /dev/null and b/src/test/ui/parser/utf16-be-without-bom.stderr differ diff --git a/src/test/ui/parser/utf16-le-without-bom.rs b/src/test/ui/parser/utf16-le-without-bom.rs new file mode 100644 index 0000000000000..3c1049929e115 Binary files /dev/null and b/src/test/ui/parser/utf16-le-without-bom.rs differ diff --git a/src/test/ui/parser/utf16-le-without-bom.stderr b/src/test/ui/parser/utf16-le-without-bom.stderr new file mode 100644 index 0000000000000..4f4b91e39ed87 Binary files /dev/null and b/src/test/ui/parser/utf16-le-without-bom.stderr differ diff --git a/src/tools/tidy/src/deps.rs b/src/tools/tidy/src/deps.rs index f8e0bcc357d91..651b478e79467 100644 --- a/src/tools/tidy/src/deps.rs +++ b/src/tools/tidy/src/deps.rs @@ -132,6 +132,7 @@ const PERMITTED_DEPENDENCIES: &[&str] = &[ "parking_lot", "parking_lot_core", "pathdiff", + "perf-event-open-sys", "pkg-config", "polonius-engine", "ppv-lite86",