Auto merge of #118297 - shepmaster:warn-dead-tuple-fields, r=WaffleLapkin
Merge `unused_tuple_struct_fields` into `dead_code` This implicitly upgrades the lint from `allow` to `warn` and places it into the `unused` lint group. [Discussion on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Moving.20.60unused_tuple_struct_fields.60.20from.20allow.20to.20warn)
This commit is contained in:
commit
5113ed28ea
@ -328,6 +328,7 @@ fn register_builtins(store: &mut LintStore) {
|
||||
store.register_renamed("disjoint_capture_migration", "rust_2021_incompatible_closure_captures");
|
||||
store.register_renamed("or_patterns_back_compat", "rust_2021_incompatible_or_patterns");
|
||||
store.register_renamed("non_fmt_panic", "non_fmt_panics");
|
||||
store.register_renamed("unused_tuple_struct_fields", "dead_code");
|
||||
|
||||
// These were moved to tool lints, but rustc still sees them when compiling normally, before
|
||||
// tool lints are registered, so `check_tool_name_for_backwards_compat` doesn't work. Use
|
||||
|
@ -125,7 +125,6 @@ declare_lint_pass! {
|
||||
UNUSED_MACROS,
|
||||
UNUSED_MUT,
|
||||
UNUSED_QUALIFICATIONS,
|
||||
UNUSED_TUPLE_STRUCT_FIELDS,
|
||||
UNUSED_UNSAFE,
|
||||
UNUSED_VARIABLES,
|
||||
USELESS_DEPRECATED,
|
||||
@ -697,8 +696,13 @@ declare_lint! {
|
||||
/// Dead code may signal a mistake or unfinished code. To silence the
|
||||
/// warning for individual items, prefix the name with an underscore such
|
||||
/// as `_foo`. If it was intended to expose the item outside of the crate,
|
||||
/// consider adding a visibility modifier like `pub`. Otherwise consider
|
||||
/// removing the unused code.
|
||||
/// consider adding a visibility modifier like `pub`.
|
||||
///
|
||||
/// To preserve the numbering of tuple structs with unused fields,
|
||||
/// change the unused fields to have unit type or use
|
||||
/// `PhantomData`.
|
||||
///
|
||||
/// Otherwise consider removing the unused code.
|
||||
pub DEAD_CODE,
|
||||
Warn,
|
||||
"detect unused, unexported items"
|
||||
@ -732,32 +736,6 @@ declare_lint! {
|
||||
"detects attributes that were not used by the compiler"
|
||||
}
|
||||
|
||||
declare_lint! {
|
||||
/// The `unused_tuple_struct_fields` lint detects fields of tuple structs
|
||||
/// that are never read.
|
||||
///
|
||||
/// ### Example
|
||||
///
|
||||
/// ```rust
|
||||
/// #[warn(unused_tuple_struct_fields)]
|
||||
/// struct S(i32, i32, i32);
|
||||
/// let s = S(1, 2, 3);
|
||||
/// let _ = (s.0, s.2);
|
||||
/// ```
|
||||
///
|
||||
/// {{produces}}
|
||||
///
|
||||
/// ### Explanation
|
||||
///
|
||||
/// Tuple struct fields that are never read anywhere may indicate a
|
||||
/// mistake or unfinished code. To silence this warning, consider
|
||||
/// removing the unused field(s) or, to preserve the numbering of the
|
||||
/// remaining fields, change the unused field(s) to have unit type.
|
||||
pub UNUSED_TUPLE_STRUCT_FIELDS,
|
||||
Allow,
|
||||
"detects tuple struct fields that are never read"
|
||||
}
|
||||
|
||||
declare_lint! {
|
||||
/// The `unreachable_code` lint detects unreachable code paths.
|
||||
///
|
||||
|
@ -15,8 +15,8 @@ use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
|
||||
use rustc_middle::middle::privacy::Level;
|
||||
use rustc_middle::query::Providers;
|
||||
use rustc_middle::ty::{self, TyCtxt};
|
||||
use rustc_session::lint::builtin::{DEAD_CODE, UNUSED_TUPLE_STRUCT_FIELDS};
|
||||
use rustc_session::lint::{self, Lint, LintId};
|
||||
use rustc_session::lint;
|
||||
use rustc_session::lint::builtin::DEAD_CODE;
|
||||
use rustc_span::symbol::{sym, Symbol};
|
||||
use rustc_target::abi::FieldIdx;
|
||||
use std::mem;
|
||||
@ -766,6 +766,12 @@ enum ShouldWarnAboutField {
|
||||
No,
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
|
||||
enum ReportOn {
|
||||
TupleField,
|
||||
NamedField,
|
||||
}
|
||||
|
||||
impl<'tcx> DeadVisitor<'tcx> {
|
||||
fn should_warn_about_field(&mut self, field: &ty::FieldDef) -> ShouldWarnAboutField {
|
||||
if self.live_symbols.contains(&field.did.expect_local()) {
|
||||
@ -787,9 +793,9 @@ impl<'tcx> DeadVisitor<'tcx> {
|
||||
ShouldWarnAboutField::Yes
|
||||
}
|
||||
|
||||
fn def_lint_level(&self, lint: &'static Lint, id: LocalDefId) -> lint::Level {
|
||||
fn def_lint_level(&self, id: LocalDefId) -> lint::Level {
|
||||
let hir_id = self.tcx.local_def_id_to_hir_id(id);
|
||||
self.tcx.lint_level_at_node(lint, hir_id).0
|
||||
self.tcx.lint_level_at_node(DEAD_CODE, hir_id).0
|
||||
}
|
||||
|
||||
// # Panics
|
||||
@ -803,7 +809,7 @@ impl<'tcx> DeadVisitor<'tcx> {
|
||||
dead_codes: &[&DeadItem],
|
||||
participle: &str,
|
||||
parent_item: Option<LocalDefId>,
|
||||
lint: &'static Lint,
|
||||
report_on: ReportOn,
|
||||
) {
|
||||
let Some(&first_item) = dead_codes.first() else {
|
||||
return;
|
||||
@ -864,8 +870,8 @@ impl<'tcx> DeadVisitor<'tcx> {
|
||||
None
|
||||
};
|
||||
|
||||
let diag = if LintId::of(lint) == LintId::of(UNUSED_TUPLE_STRUCT_FIELDS) {
|
||||
MultipleDeadCodes::UnusedTupleStructFields {
|
||||
let diag = match report_on {
|
||||
ReportOn::TupleField => MultipleDeadCodes::UnusedTupleStructFields {
|
||||
multiple,
|
||||
num,
|
||||
descr,
|
||||
@ -874,9 +880,9 @@ impl<'tcx> DeadVisitor<'tcx> {
|
||||
change_fields_suggestion: ChangeFieldsToBeOfUnitType { num, spans: spans.clone() },
|
||||
parent_info,
|
||||
ignored_derived_impls,
|
||||
}
|
||||
} else {
|
||||
MultipleDeadCodes::DeadCodes {
|
||||
},
|
||||
|
||||
ReportOn::NamedField => MultipleDeadCodes::DeadCodes {
|
||||
multiple,
|
||||
num,
|
||||
descr,
|
||||
@ -884,11 +890,11 @@ impl<'tcx> DeadVisitor<'tcx> {
|
||||
name_list,
|
||||
parent_info,
|
||||
ignored_derived_impls,
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
let hir_id = tcx.local_def_id_to_hir_id(first_item.def_id);
|
||||
self.tcx.emit_spanned_lint(lint, hir_id, MultiSpan::from_spans(spans), diag);
|
||||
self.tcx.emit_spanned_lint(DEAD_CODE, hir_id, MultiSpan::from_spans(spans), diag);
|
||||
}
|
||||
|
||||
fn warn_multiple(
|
||||
@ -896,7 +902,7 @@ impl<'tcx> DeadVisitor<'tcx> {
|
||||
def_id: LocalDefId,
|
||||
participle: &str,
|
||||
dead_codes: Vec<DeadItem>,
|
||||
lint: &'static Lint,
|
||||
report_on: ReportOn,
|
||||
) {
|
||||
let mut dead_codes = dead_codes
|
||||
.iter()
|
||||
@ -907,7 +913,7 @@ impl<'tcx> DeadVisitor<'tcx> {
|
||||
}
|
||||
dead_codes.sort_by_key(|v| v.level);
|
||||
for group in dead_codes[..].group_by(|a, b| a.level == b.level) {
|
||||
self.lint_at_single_level(&group, participle, Some(def_id), lint);
|
||||
self.lint_at_single_level(&group, participle, Some(def_id), report_on);
|
||||
}
|
||||
}
|
||||
|
||||
@ -915,9 +921,9 @@ impl<'tcx> DeadVisitor<'tcx> {
|
||||
let item = DeadItem {
|
||||
def_id: id,
|
||||
name: self.tcx.item_name(id.to_def_id()),
|
||||
level: self.def_lint_level(DEAD_CODE, id),
|
||||
level: self.def_lint_level(id),
|
||||
};
|
||||
self.lint_at_single_level(&[&item], participle, None, DEAD_CODE);
|
||||
self.lint_at_single_level(&[&item], participle, None, ReportOn::NamedField);
|
||||
}
|
||||
|
||||
fn check_definition(&mut self, def_id: LocalDefId) {
|
||||
@ -964,12 +970,12 @@ fn check_mod_deathness(tcx: TyCtxt<'_>, module: LocalModDefId) {
|
||||
let def_id = item.id.owner_id.def_id;
|
||||
if !visitor.is_live_code(def_id) {
|
||||
let name = tcx.item_name(def_id.to_def_id());
|
||||
let level = visitor.def_lint_level(DEAD_CODE, def_id);
|
||||
let level = visitor.def_lint_level(def_id);
|
||||
|
||||
dead_items.push(DeadItem { def_id, name, level })
|
||||
}
|
||||
}
|
||||
visitor.warn_multiple(item.owner_id.def_id, "used", dead_items, DEAD_CODE);
|
||||
visitor.warn_multiple(item.owner_id.def_id, "used", dead_items, ReportOn::NamedField);
|
||||
}
|
||||
|
||||
if !live_symbols.contains(&item.owner_id.def_id) {
|
||||
@ -991,7 +997,7 @@ fn check_mod_deathness(tcx: TyCtxt<'_>, module: LocalModDefId) {
|
||||
let def_id = variant.def_id.expect_local();
|
||||
if !live_symbols.contains(&def_id) {
|
||||
// Record to group diagnostics.
|
||||
let level = visitor.def_lint_level(DEAD_CODE, def_id);
|
||||
let level = visitor.def_lint_level(def_id);
|
||||
dead_variants.push(DeadItem { def_id, name: variant.name, level });
|
||||
continue;
|
||||
}
|
||||
@ -999,24 +1005,30 @@ fn check_mod_deathness(tcx: TyCtxt<'_>, module: LocalModDefId) {
|
||||
let is_positional = variant.fields.raw.first().map_or(false, |field| {
|
||||
field.name.as_str().starts_with(|c: char| c.is_ascii_digit())
|
||||
});
|
||||
let lint = if is_positional { UNUSED_TUPLE_STRUCT_FIELDS } else { DEAD_CODE };
|
||||
let report_on =
|
||||
if is_positional { ReportOn::TupleField } else { ReportOn::NamedField };
|
||||
let dead_fields = variant
|
||||
.fields
|
||||
.iter()
|
||||
.filter_map(|field| {
|
||||
let def_id = field.did.expect_local();
|
||||
if let ShouldWarnAboutField::Yes = visitor.should_warn_about_field(field) {
|
||||
let level = visitor.def_lint_level(lint, def_id);
|
||||
let level = visitor.def_lint_level(def_id);
|
||||
Some(DeadItem { def_id, name: field.name, level })
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
visitor.warn_multiple(def_id, "read", dead_fields, lint);
|
||||
visitor.warn_multiple(def_id, "read", dead_fields, report_on);
|
||||
}
|
||||
|
||||
visitor.warn_multiple(item.owner_id.def_id, "constructed", dead_variants, DEAD_CODE);
|
||||
visitor.warn_multiple(
|
||||
item.owner_id.def_id,
|
||||
"constructed",
|
||||
dead_variants,
|
||||
ReportOn::NamedField,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,7 @@
|
||||
//! Creating a recursive data structure:
|
||||
//!
|
||||
//! ```
|
||||
//! ##[allow(dead_code)]
|
||||
//! #[derive(Debug)]
|
||||
//! enum List<T> {
|
||||
//! Cons(T, Box<List<T>>),
|
||||
|
@ -171,7 +171,7 @@ struct WithHeader<H>(NonNull<u8>, PhantomData<H>);
|
||||
/// An opaque representation of `WithHeader<H>` to avoid the
|
||||
/// projection invariance of `<T as Pointee>::Metadata`.
|
||||
#[repr(transparent)]
|
||||
#[allow(unused_tuple_struct_fields)] // Field only used through `WithHeader` type above.
|
||||
#[allow(dead_code)] // Field only used through `WithHeader` type above.
|
||||
struct WithOpaqueHeader(NonNull<u8>);
|
||||
|
||||
impl WithOpaqueHeader {
|
||||
|
@ -524,7 +524,7 @@ fn test_extend_ref() {
|
||||
#[test]
|
||||
fn test_recovery() {
|
||||
#[derive(Debug)]
|
||||
struct Foo(&'static str, i32);
|
||||
struct Foo(&'static str, #[allow(dead_code)] i32);
|
||||
|
||||
impl PartialEq for Foo {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
|
@ -1085,7 +1085,7 @@ fn test_clone_from() {
|
||||
fn test_vec_deque_truncate_drop() {
|
||||
static mut DROPS: u32 = 0;
|
||||
#[derive(Clone)]
|
||||
struct Elem(i32);
|
||||
struct Elem(#[allow(dead_code)] i32);
|
||||
impl Drop for Elem {
|
||||
fn drop(&mut self) {
|
||||
unsafe {
|
||||
|
@ -1,7 +1,7 @@
|
||||
fn require_sync<T: Sync>(_: T) {}
|
||||
fn require_send_sync<T: Send + Sync>(_: T) {}
|
||||
|
||||
struct NotSend(*const ());
|
||||
struct NotSend(#[allow(dead_code)] *const ());
|
||||
unsafe impl Sync for NotSend {}
|
||||
|
||||
#[test]
|
||||
|
@ -547,7 +547,7 @@ fn test_cmp() {
|
||||
#[test]
|
||||
fn test_vec_truncate_drop() {
|
||||
static mut DROPS: u32 = 0;
|
||||
struct Elem(i32);
|
||||
struct Elem(#[allow(dead_code)] i32);
|
||||
impl Drop for Elem {
|
||||
fn drop(&mut self) {
|
||||
unsafe {
|
||||
@ -1089,7 +1089,7 @@ fn test_into_iter_advance_by() {
|
||||
|
||||
#[test]
|
||||
fn test_into_iter_drop_allocator() {
|
||||
struct ReferenceCountedAllocator<'a>(DropCounter<'a>);
|
||||
struct ReferenceCountedAllocator<'a>(#[allow(dead_code)] DropCounter<'a>);
|
||||
|
||||
unsafe impl Allocator for ReferenceCountedAllocator<'_> {
|
||||
fn allocate(&self, layout: Layout) -> Result<NonNull<[u8]>, core::alloc::AllocError> {
|
||||
@ -2407,7 +2407,7 @@ fn test_vec_dedup_multiple_ident() {
|
||||
#[test]
|
||||
fn test_vec_dedup_partialeq() {
|
||||
#[derive(Debug)]
|
||||
struct Foo(i32, i32);
|
||||
struct Foo(i32, #[allow(dead_code)] i32);
|
||||
|
||||
impl PartialEq for Foo {
|
||||
fn eq(&self, other: &Foo) -> bool {
|
||||
|
@ -91,7 +91,7 @@ fn binary_search_l3_worst_case(b: &mut Bencher) {
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
struct Rgb(u8, u8, u8);
|
||||
struct Rgb(#[allow(dead_code)] u8, #[allow(dead_code)] u8, #[allow(dead_code)] u8);
|
||||
|
||||
impl Rgb {
|
||||
fn gen(i: usize) -> Self {
|
||||
@ -154,7 +154,7 @@ swap_with_slice!(swap_with_slice_5x_usize_3000, 3000, |i| [i; 5]);
|
||||
#[bench]
|
||||
fn fill_byte_sized(b: &mut Bencher) {
|
||||
#[derive(Copy, Clone)]
|
||||
struct NewType(u8);
|
||||
struct NewType(#[allow(dead_code)] u8);
|
||||
|
||||
let mut ary = [NewType(0); 1024];
|
||||
|
||||
|
@ -122,7 +122,7 @@ fn any_unsized() {
|
||||
fn distinct_type_names() {
|
||||
// https://github.com/rust-lang/rust/issues/84666
|
||||
|
||||
struct Velocity(f32, f32);
|
||||
struct Velocity(#[allow(dead_code)] f32, #[allow(dead_code)] f32);
|
||||
|
||||
fn type_name_of_val<T>(_: T) -> &'static str {
|
||||
type_name::<T>()
|
||||
|
@ -262,7 +262,7 @@ fn array_default_impl_avoids_leaks_on_panic() {
|
||||
use core::sync::atomic::{AtomicUsize, Ordering::Relaxed};
|
||||
static COUNTER: AtomicUsize = AtomicUsize::new(0);
|
||||
#[derive(Debug)]
|
||||
struct Bomb(usize);
|
||||
struct Bomb(#[allow(dead_code)] usize);
|
||||
|
||||
impl Default for Bomb {
|
||||
fn default() -> Bomb {
|
||||
|
@ -188,7 +188,7 @@ fn ptr_bitops() {
|
||||
#[cfg(any(not(target_arch = "arm"), target_os = "linux"))] // Missing intrinsic in compiler-builtins
|
||||
fn ptr_bitops_tagging() {
|
||||
#[repr(align(16))]
|
||||
struct Tagme(u128);
|
||||
struct Tagme(#[allow(dead_code)] u128);
|
||||
|
||||
let tagme = Tagme(1000);
|
||||
let ptr = &tagme as *const Tagme as *mut Tagme;
|
||||
|
@ -4,7 +4,7 @@ use core::intrinsics::assume;
|
||||
#[test]
|
||||
fn test_typeid_sized_types() {
|
||||
struct X;
|
||||
struct Y(u32);
|
||||
struct Y(#[allow(dead_code)] u32);
|
||||
|
||||
assert_eq!(TypeId::of::<X>(), TypeId::of::<X>());
|
||||
assert_eq!(TypeId::of::<Y>(), TypeId::of::<Y>());
|
||||
@ -14,8 +14,8 @@ fn test_typeid_sized_types() {
|
||||
#[test]
|
||||
fn test_typeid_unsized_types() {
|
||||
trait Z {}
|
||||
struct X(str);
|
||||
struct Y(dyn Z + 'static);
|
||||
struct X(#[allow(dead_code)] str);
|
||||
struct Y(#[allow(dead_code)] dyn Z + 'static);
|
||||
|
||||
assert_eq!(TypeId::of::<X>(), TypeId::of::<X>());
|
||||
assert_eq!(TypeId::of::<Y>(), TypeId::of::<Y>());
|
||||
|
@ -451,34 +451,34 @@ fn align_offset_various_strides() {
|
||||
for ptr in 1usize..4 * align {
|
||||
unsafe {
|
||||
#[repr(packed)]
|
||||
struct A3(u16, u8);
|
||||
struct A3(#[allow(dead_code)] u16, #[allow(dead_code)] u8);
|
||||
x |= test_stride::<A3>(ptr::invalid::<A3>(ptr), align);
|
||||
|
||||
struct A4(u32);
|
||||
struct A4(#[allow(dead_code)] u32);
|
||||
x |= test_stride::<A4>(ptr::invalid::<A4>(ptr), align);
|
||||
|
||||
#[repr(packed)]
|
||||
struct A5(u32, u8);
|
||||
struct A5(#[allow(dead_code)] u32, #[allow(dead_code)] u8);
|
||||
x |= test_stride::<A5>(ptr::invalid::<A5>(ptr), align);
|
||||
|
||||
#[repr(packed)]
|
||||
struct A6(u32, u16);
|
||||
struct A6(#[allow(dead_code)] u32, #[allow(dead_code)] u16);
|
||||
x |= test_stride::<A6>(ptr::invalid::<A6>(ptr), align);
|
||||
|
||||
#[repr(packed)]
|
||||
struct A7(u32, u16, u8);
|
||||
struct A7(#[allow(dead_code)] u32, #[allow(dead_code)] u16, #[allow(dead_code)] u8);
|
||||
x |= test_stride::<A7>(ptr::invalid::<A7>(ptr), align);
|
||||
|
||||
#[repr(packed)]
|
||||
struct A8(u32, u32);
|
||||
struct A8(#[allow(dead_code)] u32, #[allow(dead_code)] u32);
|
||||
x |= test_stride::<A8>(ptr::invalid::<A8>(ptr), align);
|
||||
|
||||
#[repr(packed)]
|
||||
struct A9(u32, u32, u8);
|
||||
struct A9(#[allow(dead_code)] u32, #[allow(dead_code)] u32, #[allow(dead_code)] u8);
|
||||
x |= test_stride::<A9>(ptr::invalid::<A9>(ptr), align);
|
||||
|
||||
#[repr(packed)]
|
||||
struct A10(u32, u32, u16);
|
||||
struct A10(#[allow(dead_code)] u32, #[allow(dead_code)] u32, #[allow(dead_code)] u16);
|
||||
x |= test_stride::<A10>(ptr::invalid::<A10>(ptr), align);
|
||||
|
||||
x |= test_stride::<u32>(ptr::invalid::<u32>(ptr), align);
|
||||
@ -517,34 +517,34 @@ fn align_offset_various_strides_const() {
|
||||
while ptr < 4 * align {
|
||||
unsafe {
|
||||
#[repr(packed)]
|
||||
struct A3(u16, u8);
|
||||
struct A3(#[allow(dead_code)] u16, #[allow(dead_code)] u8);
|
||||
test_stride::<A3>(ptr::invalid::<A3>(ptr), ptr, align);
|
||||
|
||||
struct A4(u32);
|
||||
struct A4(#[allow(dead_code)] u32);
|
||||
test_stride::<A4>(ptr::invalid::<A4>(ptr), ptr, align);
|
||||
|
||||
#[repr(packed)]
|
||||
struct A5(u32, u8);
|
||||
struct A5(#[allow(dead_code)] u32, #[allow(dead_code)] u8);
|
||||
test_stride::<A5>(ptr::invalid::<A5>(ptr), ptr, align);
|
||||
|
||||
#[repr(packed)]
|
||||
struct A6(u32, u16);
|
||||
struct A6(#[allow(dead_code)] u32, #[allow(dead_code)] u16);
|
||||
test_stride::<A6>(ptr::invalid::<A6>(ptr), ptr, align);
|
||||
|
||||
#[repr(packed)]
|
||||
struct A7(u32, u16, u8);
|
||||
struct A7(#[allow(dead_code)] u32, #[allow(dead_code)] u16, #[allow(dead_code)] u8);
|
||||
test_stride::<A7>(ptr::invalid::<A7>(ptr), ptr, align);
|
||||
|
||||
#[repr(packed)]
|
||||
struct A8(u32, u32);
|
||||
struct A8(#[allow(dead_code)] u32, #[allow(dead_code)] u32);
|
||||
test_stride::<A8>(ptr::invalid::<A8>(ptr), ptr, align);
|
||||
|
||||
#[repr(packed)]
|
||||
struct A9(u32, u32, u8);
|
||||
struct A9(#[allow(dead_code)] u32, #[allow(dead_code)] u32, #[allow(dead_code)] u8);
|
||||
test_stride::<A9>(ptr::invalid::<A9>(ptr), ptr, align);
|
||||
|
||||
#[repr(packed)]
|
||||
struct A10(u32, u32, u16);
|
||||
struct A10(#[allow(dead_code)] u32, #[allow(dead_code)] u32, #[allow(dead_code)] u16);
|
||||
test_stride::<A10>(ptr::invalid::<A10>(ptr), ptr, align);
|
||||
|
||||
test_stride::<u32>(ptr::invalid::<u32>(ptr), ptr, align);
|
||||
@ -672,7 +672,7 @@ fn align_offset_issue_103361() {
|
||||
const SIZE: usize = 1 << 30;
|
||||
#[cfg(target_pointer_width = "16")]
|
||||
const SIZE: usize = 1 << 13;
|
||||
struct HugeSize([u8; SIZE - 1]);
|
||||
struct HugeSize(#[allow(dead_code)] [u8; SIZE - 1]);
|
||||
let _ = ptr::invalid::<HugeSize>(SIZE).align_offset(SIZE);
|
||||
}
|
||||
|
||||
@ -684,7 +684,7 @@ fn align_offset_issue_103361_const() {
|
||||
const SIZE: usize = 1 << 30;
|
||||
#[cfg(target_pointer_width = "16")]
|
||||
const SIZE: usize = 1 << 13;
|
||||
struct HugeSize([u8; SIZE - 1]);
|
||||
struct HugeSize(#[allow(dead_code)] [u8; SIZE - 1]);
|
||||
|
||||
const {
|
||||
assert!(ptr::invalid::<HugeSize>(SIZE - 1).align_offset(SIZE) == SIZE - 1);
|
||||
@ -834,7 +834,7 @@ fn ptr_metadata_bounds() {
|
||||
fn dyn_metadata() {
|
||||
#[derive(Debug)]
|
||||
#[repr(align(32))]
|
||||
struct Something([u8; 47]);
|
||||
struct Something(#[allow(dead_code)] [u8; 47]);
|
||||
|
||||
let value = Something([0; 47]);
|
||||
let trait_object: &dyn Debug = &value;
|
||||
|
@ -2109,9 +2109,9 @@ fn test_align_to_zst() {
|
||||
#[test]
|
||||
fn test_align_to_non_trivial() {
|
||||
#[repr(align(8))]
|
||||
struct U64(u64, u64);
|
||||
struct U64(#[allow(dead_code)] u64, #[allow(dead_code)] u64);
|
||||
#[repr(align(8))]
|
||||
struct U64U64U32(u64, u64, u32);
|
||||
struct U64U64U32(#[allow(dead_code)] u64, #[allow(dead_code)] u64, #[allow(dead_code)] u32);
|
||||
let data = [
|
||||
U64(1, 2),
|
||||
U64(3, 4),
|
||||
@ -2196,7 +2196,7 @@ fn test_slice_partition_dedup_multiple_ident() {
|
||||
#[test]
|
||||
fn test_slice_partition_dedup_partialeq() {
|
||||
#[derive(Debug)]
|
||||
struct Foo(i32, i32);
|
||||
struct Foo(i32, #[allow(dead_code)] i32);
|
||||
|
||||
impl PartialEq for Foo {
|
||||
fn eq(&self, other: &Foo) -> bool {
|
||||
|
@ -352,7 +352,7 @@ fn test_replace() {
|
||||
use crate::hash;
|
||||
|
||||
#[derive(Debug)]
|
||||
struct Foo(&'static str, i32);
|
||||
struct Foo(&'static str, #[allow(dead_code)] i32);
|
||||
|
||||
impl PartialEq for Foo {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
|
@ -22,7 +22,7 @@ pub(super) enum Op<'a> {
|
||||
|
||||
// rm `.cloned()`
|
||||
// e.g. `map` `for_each` `all` `any`
|
||||
NeedlessMove(&'a str, &'a Expr<'a>),
|
||||
NeedlessMove(&'a Expr<'a>),
|
||||
|
||||
// later `.cloned()`
|
||||
// and add `&` to the parameter of closure parameter
|
||||
@ -59,7 +59,7 @@ pub(super) fn check<'tcx>(
|
||||
return;
|
||||
}
|
||||
|
||||
if let Op::NeedlessMove(_, expr) = op {
|
||||
if let Op::NeedlessMove(expr) = op {
|
||||
let rustc_hir::ExprKind::Closure(closure) = expr.kind else {
|
||||
return;
|
||||
};
|
||||
@ -104,7 +104,7 @@ pub(super) fn check<'tcx>(
|
||||
}
|
||||
|
||||
let (lint, msg, trailing_clone) = match op {
|
||||
Op::RmCloned | Op::NeedlessMove(_, _) => (REDUNDANT_CLONE, "unneeded cloning of iterator items", ""),
|
||||
Op::RmCloned | Op::NeedlessMove(_) => (REDUNDANT_CLONE, "unneeded cloning of iterator items", ""),
|
||||
Op::LaterCloned | Op::FixClosure(_, _) => (
|
||||
ITER_OVEREAGER_CLONED,
|
||||
"unnecessarily eager cloning of iterator items",
|
||||
@ -133,7 +133,7 @@ pub(super) fn check<'tcx>(
|
||||
diag.span_suggestion(replace_span, "try", snip, Applicability::MachineApplicable);
|
||||
}
|
||||
},
|
||||
Op::NeedlessMove(_, _) => {
|
||||
Op::NeedlessMove(_) => {
|
||||
let method_span = expr.span.with_lo(cloned_call.span.hi());
|
||||
if let Some(snip) = snippet_opt(cx, method_span) {
|
||||
let replace_span = expr.span.with_lo(cloned_recv.span.hi());
|
||||
|
@ -4186,7 +4186,7 @@ impl Methods {
|
||||
expr,
|
||||
recv,
|
||||
recv2,
|
||||
iter_overeager_cloned::Op::NeedlessMove(name, arg),
|
||||
iter_overeager_cloned::Op::NeedlessMove(arg),
|
||||
false,
|
||||
);
|
||||
}
|
||||
@ -4204,7 +4204,7 @@ impl Methods {
|
||||
expr,
|
||||
recv,
|
||||
recv2,
|
||||
iter_overeager_cloned::Op::NeedlessMove(name, arg),
|
||||
iter_overeager_cloned::Op::NeedlessMove(arg),
|
||||
false,
|
||||
),
|
||||
Some(("chars", recv, _, _, _))
|
||||
@ -4379,7 +4379,7 @@ impl Methods {
|
||||
expr,
|
||||
recv,
|
||||
recv2,
|
||||
iter_overeager_cloned::Op::NeedlessMove(name, arg),
|
||||
iter_overeager_cloned::Op::NeedlessMove(arg),
|
||||
false,
|
||||
),
|
||||
_ => {},
|
||||
@ -4433,7 +4433,7 @@ impl Methods {
|
||||
expr,
|
||||
recv,
|
||||
recv2,
|
||||
iter_overeager_cloned::Op::NeedlessMove(name, m_arg),
|
||||
iter_overeager_cloned::Op::NeedlessMove(m_arg),
|
||||
false,
|
||||
),
|
||||
_ => {},
|
||||
|
@ -80,7 +80,6 @@ enum IfBlockType<'hir> {
|
||||
Ty<'hir>,
|
||||
Symbol,
|
||||
&'hir Expr<'hir>,
|
||||
Option<&'hir Expr<'hir>>,
|
||||
),
|
||||
/// An `if let Xxx(a) = b { c } else { d }` expression.
|
||||
///
|
||||
@ -143,7 +142,7 @@ fn check_let_some_else_return_none(cx: &LateContext<'_>, stmt: &Stmt<'_>) {
|
||||
|
||||
fn is_early_return(smbl: Symbol, cx: &LateContext<'_>, if_block: &IfBlockType<'_>) -> bool {
|
||||
match *if_block {
|
||||
IfBlockType::IfIs(caller, caller_ty, call_sym, if_then, _) => {
|
||||
IfBlockType::IfIs(caller, caller_ty, call_sym, if_then) => {
|
||||
// If the block could be identified as `if x.is_none()/is_err()`,
|
||||
// we then only need to check the if_then return to see if it is none/err.
|
||||
is_type_diagnostic_item(cx, caller_ty, smbl)
|
||||
@ -235,7 +234,7 @@ impl QuestionMark {
|
||||
&& !is_else_clause(cx.tcx, expr)
|
||||
&& let ExprKind::MethodCall(segment, caller, ..) = &cond.kind
|
||||
&& let caller_ty = cx.typeck_results().expr_ty(caller)
|
||||
&& let if_block = IfBlockType::IfIs(caller, caller_ty, segment.ident.name, then, r#else)
|
||||
&& let if_block = IfBlockType::IfIs(caller, caller_ty, segment.ident.name, then)
|
||||
&& (is_early_return(sym::Option, cx, &if_block) || is_early_return(sym::Result, cx, &if_block))
|
||||
{
|
||||
let mut applicability = Applicability::MachineApplicable;
|
||||
|
@ -26,18 +26,18 @@ pub(super) fn check<'tcx>(
|
||||
|
||||
// `Repr(C)` <-> unordered type.
|
||||
// If the first field of the `Repr(C)` type matches then the transmute is ok
|
||||
(ReducedTy::OrderedFields(_, Some(from_sub_ty)), ReducedTy::UnorderedFields(to_sub_ty))
|
||||
| (ReducedTy::UnorderedFields(from_sub_ty), ReducedTy::OrderedFields(_, Some(to_sub_ty))) => {
|
||||
(ReducedTy::OrderedFields(Some(from_sub_ty)), ReducedTy::UnorderedFields(to_sub_ty))
|
||||
| (ReducedTy::UnorderedFields(from_sub_ty), ReducedTy::OrderedFields(Some(to_sub_ty))) => {
|
||||
from_ty = from_sub_ty;
|
||||
to_ty = to_sub_ty;
|
||||
continue;
|
||||
},
|
||||
(ReducedTy::OrderedFields(_, Some(from_sub_ty)), ReducedTy::Other(to_sub_ty)) if reduced_tys.to_fat_ptr => {
|
||||
(ReducedTy::OrderedFields(Some(from_sub_ty)), ReducedTy::Other(to_sub_ty)) if reduced_tys.to_fat_ptr => {
|
||||
from_ty = from_sub_ty;
|
||||
to_ty = to_sub_ty;
|
||||
continue;
|
||||
},
|
||||
(ReducedTy::Other(from_sub_ty), ReducedTy::OrderedFields(_, Some(to_sub_ty)))
|
||||
(ReducedTy::Other(from_sub_ty), ReducedTy::OrderedFields(Some(to_sub_ty)))
|
||||
if reduced_tys.from_fat_ptr =>
|
||||
{
|
||||
from_ty = from_sub_ty;
|
||||
@ -235,8 +235,8 @@ enum ReducedTy<'tcx> {
|
||||
TypeErasure { raw_ptr_only: bool },
|
||||
/// The type is a struct containing either zero non-zero sized fields, or multiple non-zero
|
||||
/// sized fields with a defined order.
|
||||
/// The second value is the first non-zero sized type.
|
||||
OrderedFields(Ty<'tcx>, Option<Ty<'tcx>>),
|
||||
/// The value is the first non-zero sized type.
|
||||
OrderedFields(Option<Ty<'tcx>>),
|
||||
/// The type is a struct containing multiple non-zero sized fields with no defined order.
|
||||
UnorderedFields(Ty<'tcx>),
|
||||
/// Any other type.
|
||||
@ -259,7 +259,7 @@ fn reduce_ty<'tcx>(cx: &LateContext<'tcx>, mut ty: Ty<'tcx>) -> ReducedTy<'tcx>
|
||||
ty::Tuple(args) => {
|
||||
let mut iter = args.iter();
|
||||
let Some(sized_ty) = iter.find(|&ty| !is_zero_sized_ty(cx, ty)) else {
|
||||
return ReducedTy::OrderedFields(ty, None);
|
||||
return ReducedTy::OrderedFields(None);
|
||||
};
|
||||
if iter.all(|ty| is_zero_sized_ty(cx, ty)) {
|
||||
ty = sized_ty;
|
||||
@ -281,7 +281,7 @@ fn reduce_ty<'tcx>(cx: &LateContext<'tcx>, mut ty: Ty<'tcx>) -> ReducedTy<'tcx>
|
||||
continue;
|
||||
}
|
||||
if def.repr().inhibit_struct_field_reordering_opt() {
|
||||
ReducedTy::OrderedFields(ty, Some(sized_ty))
|
||||
ReducedTy::OrderedFields(Some(sized_ty))
|
||||
} else {
|
||||
ReducedTy::UnorderedFields(ty)
|
||||
}
|
||||
|
@ -2,7 +2,6 @@
|
||||
// As the most common case is the `http` crate, it replicates `http::HeaderName`'s structure.
|
||||
|
||||
#![allow(clippy::declare_interior_mutable_const)]
|
||||
#![allow(unused_tuple_struct_fields)]
|
||||
|
||||
use std::sync::atomic::AtomicUsize;
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
#![warn(clippy::useless_format)]
|
||||
#![allow(
|
||||
unused_tuple_struct_fields,
|
||||
clippy::print_literal,
|
||||
clippy::redundant_clone,
|
||||
clippy::to_string_in_format_args,
|
||||
|
@ -1,6 +1,5 @@
|
||||
#![warn(clippy::useless_format)]
|
||||
#![allow(
|
||||
unused_tuple_struct_fields,
|
||||
clippy::print_literal,
|
||||
clippy::redundant_clone,
|
||||
clippy::to_string_in_format_args,
|
||||
|
@ -1,5 +1,5 @@
|
||||
error: useless use of `format!`
|
||||
--> $DIR/format.rs:20:5
|
||||
--> $DIR/format.rs:19:5
|
||||
|
|
||||
LL | format!("foo");
|
||||
| ^^^^^^^^^^^^^^ help: consider using `.to_string()`: `"foo".to_string()`
|
||||
@ -8,19 +8,19 @@ LL | format!("foo");
|
||||
= help: to override `-D warnings` add `#[allow(clippy::useless_format)]`
|
||||
|
||||
error: useless use of `format!`
|
||||
--> $DIR/format.rs:21:5
|
||||
--> $DIR/format.rs:20:5
|
||||
|
|
||||
LL | format!("{{}}");
|
||||
| ^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `"{}".to_string()`
|
||||
|
||||
error: useless use of `format!`
|
||||
--> $DIR/format.rs:22:5
|
||||
--> $DIR/format.rs:21:5
|
||||
|
|
||||
LL | format!("{{}} abc {{}}");
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `"{} abc {}".to_string()`
|
||||
|
||||
error: useless use of `format!`
|
||||
--> $DIR/format.rs:23:5
|
||||
--> $DIR/format.rs:22:5
|
||||
|
|
||||
LL | / format!(
|
||||
LL | | r##"foo {{}}
|
||||
@ -35,67 +35,67 @@ LL ~ " bar"##.to_string();
|
||||
|
|
||||
|
||||
error: useless use of `format!`
|
||||
--> $DIR/format.rs:28:13
|
||||
--> $DIR/format.rs:27:13
|
||||
|
|
||||
LL | let _ = format!("");
|
||||
| ^^^^^^^^^^^ help: consider using `String::new()`: `String::new()`
|
||||
|
||||
error: useless use of `format!`
|
||||
--> $DIR/format.rs:30:5
|
||||
--> $DIR/format.rs:29:5
|
||||
|
|
||||
LL | format!("{}", "foo");
|
||||
| ^^^^^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `"foo".to_string()`
|
||||
|
||||
error: useless use of `format!`
|
||||
--> $DIR/format.rs:38:5
|
||||
--> $DIR/format.rs:37:5
|
||||
|
|
||||
LL | format!("{}", arg);
|
||||
| ^^^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `arg.to_string()`
|
||||
|
||||
error: useless use of `format!`
|
||||
--> $DIR/format.rs:68:5
|
||||
--> $DIR/format.rs:67:5
|
||||
|
|
||||
LL | format!("{}", 42.to_string());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `42.to_string()`
|
||||
|
||||
error: useless use of `format!`
|
||||
--> $DIR/format.rs:70:5
|
||||
--> $DIR/format.rs:69:5
|
||||
|
|
||||
LL | format!("{}", x.display().to_string());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `x.display().to_string()`
|
||||
|
||||
error: useless use of `format!`
|
||||
--> $DIR/format.rs:74:18
|
||||
--> $DIR/format.rs:73:18
|
||||
|
|
||||
LL | let _ = Some(format!("{}", a + "bar"));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `a + "bar"`
|
||||
|
||||
error: useless use of `format!`
|
||||
--> $DIR/format.rs:78:22
|
||||
--> $DIR/format.rs:77:22
|
||||
|
|
||||
LL | let _s: String = format!("{}", &*v.join("\n"));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `(&*v.join("\n")).to_string()`
|
||||
|
||||
error: useless use of `format!`
|
||||
--> $DIR/format.rs:84:13
|
||||
--> $DIR/format.rs:83:13
|
||||
|
|
||||
LL | let _ = format!("{x}");
|
||||
| ^^^^^^^^^^^^^^ help: consider using `.to_string()`: `x.to_string()`
|
||||
|
||||
error: useless use of `format!`
|
||||
--> $DIR/format.rs:86:13
|
||||
--> $DIR/format.rs:85:13
|
||||
|
|
||||
LL | let _ = format!("{y}", y = x);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `x.to_string()`
|
||||
|
||||
error: useless use of `format!`
|
||||
--> $DIR/format.rs:90:13
|
||||
--> $DIR/format.rs:89:13
|
||||
|
|
||||
LL | let _ = format!("{abc}");
|
||||
| ^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `abc.to_string()`
|
||||
|
||||
error: useless use of `format!`
|
||||
--> $DIR/format.rs:92:13
|
||||
--> $DIR/format.rs:91:13
|
||||
|
|
||||
LL | let _ = format!("{xx}");
|
||||
| ^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `xx.to_string()`
|
||||
|
@ -1,5 +1,5 @@
|
||||
#![warn(clippy::from_iter_instead_of_collect)]
|
||||
#![allow(unused_imports, unused_tuple_struct_fields)]
|
||||
#![allow(unused_imports)]
|
||||
#![allow(clippy::useless_vec)]
|
||||
|
||||
use std::collections::{BTreeMap, BTreeSet, HashMap, VecDeque};
|
||||
|
@ -1,5 +1,5 @@
|
||||
#![warn(clippy::from_iter_instead_of_collect)]
|
||||
#![allow(unused_imports, unused_tuple_struct_fields)]
|
||||
#![allow(unused_imports)]
|
||||
#![allow(clippy::useless_vec)]
|
||||
|
||||
use std::collections::{BTreeMap, BTreeSet, HashMap, VecDeque};
|
||||
|
@ -1,7 +1,6 @@
|
||||
#![feature(never_type)]
|
||||
#![allow(
|
||||
unused_mut,
|
||||
unused_tuple_struct_fields,
|
||||
clippy::redundant_allocation,
|
||||
clippy::needless_pass_by_ref_mut
|
||||
)]
|
||||
|
@ -1,7 +1,6 @@
|
||||
#![feature(never_type)]
|
||||
#![allow(
|
||||
unused_mut,
|
||||
unused_tuple_struct_fields,
|
||||
clippy::redundant_allocation,
|
||||
clippy::needless_pass_by_ref_mut
|
||||
)]
|
||||
|
@ -1,5 +1,5 @@
|
||||
error: this function could have a `#[must_use]` attribute
|
||||
--> $DIR/must_use_candidates.rs:16:1
|
||||
--> $DIR/must_use_candidates.rs:15:1
|
||||
|
|
||||
LL | pub fn pure(i: u8) -> u8 {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: add the attribute: `#[must_use] pub fn pure(i: u8) -> u8`
|
||||
@ -8,25 +8,25 @@ LL | pub fn pure(i: u8) -> u8 {
|
||||
= help: to override `-D warnings` add `#[allow(clippy::must_use_candidate)]`
|
||||
|
||||
error: this method could have a `#[must_use]` attribute
|
||||
--> $DIR/must_use_candidates.rs:21:5
|
||||
--> $DIR/must_use_candidates.rs:20:5
|
||||
|
|
||||
LL | pub fn inherent_pure(&self) -> u8 {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: add the attribute: `#[must_use] pub fn inherent_pure(&self) -> u8`
|
||||
|
||||
error: this function could have a `#[must_use]` attribute
|
||||
--> $DIR/must_use_candidates.rs:52:1
|
||||
--> $DIR/must_use_candidates.rs:51:1
|
||||
|
|
||||
LL | pub fn with_marker(_d: std::marker::PhantomData<&mut u32>) -> bool {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: add the attribute: `#[must_use] pub fn with_marker(_d: std::marker::PhantomData<&mut u32>) -> bool`
|
||||
|
||||
error: this function could have a `#[must_use]` attribute
|
||||
--> $DIR/must_use_candidates.rs:64:1
|
||||
--> $DIR/must_use_candidates.rs:63:1
|
||||
|
|
||||
LL | pub fn rcd(_x: Rc<u32>) -> bool {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: add the attribute: `#[must_use] pub fn rcd(_x: Rc<u32>) -> bool`
|
||||
|
||||
error: this function could have a `#[must_use]` attribute
|
||||
--> $DIR/must_use_candidates.rs:72:1
|
||||
--> $DIR/must_use_candidates.rs:71:1
|
||||
|
|
||||
LL | pub fn arcd(_x: Arc<u32>) -> bool {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: add the attribute: `#[must_use] pub fn arcd(_x: Arc<u32>) -> bool`
|
||||
|
@ -1,5 +1,4 @@
|
||||
#![warn(clippy::init_numbered_fields)]
|
||||
#![allow(unused_tuple_struct_fields)]
|
||||
|
||||
#[derive(Default)]
|
||||
struct TupleStruct(u32, u32, u8);
|
||||
|
@ -1,5 +1,4 @@
|
||||
#![warn(clippy::init_numbered_fields)]
|
||||
#![allow(unused_tuple_struct_fields)]
|
||||
|
||||
#[derive(Default)]
|
||||
struct TupleStruct(u32, u32, u8);
|
||||
|
@ -1,5 +1,5 @@
|
||||
error: used a field initializer for a tuple struct
|
||||
--> $DIR/numbered_fields.rs:18:13
|
||||
--> $DIR/numbered_fields.rs:17:13
|
||||
|
|
||||
LL | let _ = TupleStruct {
|
||||
| _____________^
|
||||
@ -13,7 +13,7 @@ LL | | };
|
||||
= help: to override `-D warnings` add `#[allow(clippy::init_numbered_fields)]`
|
||||
|
||||
error: used a field initializer for a tuple struct
|
||||
--> $DIR/numbered_fields.rs:25:13
|
||||
--> $DIR/numbered_fields.rs:24:13
|
||||
|
|
||||
LL | let _ = TupleStruct {
|
||||
| _____________^
|
||||
|
@ -1,6 +1,5 @@
|
||||
#![warn(clippy::option_if_let_else)]
|
||||
#![allow(
|
||||
unused_tuple_struct_fields,
|
||||
clippy::ref_option_ref,
|
||||
clippy::equatable_if_let,
|
||||
clippy::let_unit_value,
|
||||
|
@ -1,6 +1,5 @@
|
||||
#![warn(clippy::option_if_let_else)]
|
||||
#![allow(
|
||||
unused_tuple_struct_fields,
|
||||
clippy::ref_option_ref,
|
||||
clippy::equatable_if_let,
|
||||
clippy::let_unit_value,
|
||||
|
@ -1,5 +1,5 @@
|
||||
error: use Option::map_or instead of an if let/else
|
||||
--> $DIR/option_if_let_else.rs:11:5
|
||||
--> $DIR/option_if_let_else.rs:10:5
|
||||
|
|
||||
LL | / if let Some(x) = string {
|
||||
LL | | (true, x)
|
||||
@ -12,19 +12,19 @@ LL | | }
|
||||
= help: to override `-D warnings` add `#[allow(clippy::option_if_let_else)]`
|
||||
|
||||
error: use Option::map_or instead of an if let/else
|
||||
--> $DIR/option_if_let_else.rs:29:13
|
||||
--> $DIR/option_if_let_else.rs:28:13
|
||||
|
|
||||
LL | let _ = if let Some(s) = *string { s.len() } else { 0 };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `string.map_or(0, |s| s.len())`
|
||||
|
||||
error: use Option::map_or instead of an if let/else
|
||||
--> $DIR/option_if_let_else.rs:30:13
|
||||
--> $DIR/option_if_let_else.rs:29:13
|
||||
|
|
||||
LL | let _ = if let Some(s) = &num { s } else { &0 };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `num.as_ref().map_or(&0, |s| s)`
|
||||
|
||||
error: use Option::map_or instead of an if let/else
|
||||
--> $DIR/option_if_let_else.rs:31:13
|
||||
--> $DIR/option_if_let_else.rs:30:13
|
||||
|
|
||||
LL | let _ = if let Some(s) = &mut num {
|
||||
| _____________^
|
||||
@ -44,13 +44,13 @@ LL ~ });
|
||||
|
|
||||
|
||||
error: use Option::map_or instead of an if let/else
|
||||
--> $DIR/option_if_let_else.rs:37:13
|
||||
--> $DIR/option_if_let_else.rs:36:13
|
||||
|
|
||||
LL | let _ = if let Some(ref s) = num { s } else { &0 };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `num.as_ref().map_or(&0, |s| s)`
|
||||
|
||||
error: use Option::map_or instead of an if let/else
|
||||
--> $DIR/option_if_let_else.rs:38:13
|
||||
--> $DIR/option_if_let_else.rs:37:13
|
||||
|
|
||||
LL | let _ = if let Some(mut s) = num {
|
||||
| _____________^
|
||||
@ -70,7 +70,7 @@ LL ~ });
|
||||
|
|
||||
|
||||
error: use Option::map_or instead of an if let/else
|
||||
--> $DIR/option_if_let_else.rs:44:13
|
||||
--> $DIR/option_if_let_else.rs:43:13
|
||||
|
|
||||
LL | let _ = if let Some(ref mut s) = num {
|
||||
| _____________^
|
||||
@ -90,7 +90,7 @@ LL ~ });
|
||||
|
|
||||
|
||||
error: use Option::map_or instead of an if let/else
|
||||
--> $DIR/option_if_let_else.rs:53:5
|
||||
--> $DIR/option_if_let_else.rs:52:5
|
||||
|
|
||||
LL | / if let Some(x) = arg {
|
||||
LL | | let y = x * x;
|
||||
@ -109,7 +109,7 @@ LL + })
|
||||
|
|
||||
|
||||
error: use Option::map_or_else instead of an if let/else
|
||||
--> $DIR/option_if_let_else.rs:66:13
|
||||
--> $DIR/option_if_let_else.rs:65:13
|
||||
|
|
||||
LL | let _ = if let Some(x) = arg {
|
||||
| _____________^
|
||||
@ -121,7 +121,7 @@ LL | | };
|
||||
| |_____^ help: try: `arg.map_or_else(side_effect, |x| x)`
|
||||
|
||||
error: use Option::map_or_else instead of an if let/else
|
||||
--> $DIR/option_if_let_else.rs:75:13
|
||||
--> $DIR/option_if_let_else.rs:74:13
|
||||
|
|
||||
LL | let _ = if let Some(x) = arg {
|
||||
| _____________^
|
||||
@ -144,7 +144,7 @@ LL ~ }, |x| x * x * x * x);
|
||||
|
|
||||
|
||||
error: use Option::map_or_else instead of an if let/else
|
||||
--> $DIR/option_if_let_else.rs:108:13
|
||||
--> $DIR/option_if_let_else.rs:107:13
|
||||
|
|
||||
LL | / if let Some(idx) = s.find('.') {
|
||||
LL | | vec![s[..idx].to_string(), s[idx..].to_string()]
|
||||
@ -154,7 +154,7 @@ LL | | }
|
||||
| |_____________^ help: try: `s.find('.').map_or_else(|| vec![s.to_string()], |idx| vec![s[..idx].to_string(), s[idx..].to_string()])`
|
||||
|
||||
error: use Option::map_or_else instead of an if let/else
|
||||
--> $DIR/option_if_let_else.rs:119:5
|
||||
--> $DIR/option_if_let_else.rs:118:5
|
||||
|
|
||||
LL | / if let Ok(binding) = variable {
|
||||
LL | | println!("Ok {binding}");
|
||||
@ -177,13 +177,13 @@ LL + })
|
||||
|
|
||||
|
||||
error: use Option::map_or instead of an if let/else
|
||||
--> $DIR/option_if_let_else.rs:143:13
|
||||
--> $DIR/option_if_let_else.rs:142:13
|
||||
|
|
||||
LL | let _ = if let Some(x) = optional { x + 2 } else { 5 };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `optional.map_or(5, |x| x + 2)`
|
||||
|
||||
error: use Option::map_or instead of an if let/else
|
||||
--> $DIR/option_if_let_else.rs:153:13
|
||||
--> $DIR/option_if_let_else.rs:152:13
|
||||
|
|
||||
LL | let _ = if let Some(x) = Some(0) {
|
||||
| _____________^
|
||||
@ -205,13 +205,13 @@ LL ~ });
|
||||
|
|
||||
|
||||
error: use Option::map_or instead of an if let/else
|
||||
--> $DIR/option_if_let_else.rs:181:13
|
||||
--> $DIR/option_if_let_else.rs:180:13
|
||||
|
|
||||
LL | let _ = if let Some(x) = Some(0) { s.len() + x } else { s.len() };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Some(0).map_or(s.len(), |x| s.len() + x)`
|
||||
|
||||
error: use Option::map_or instead of an if let/else
|
||||
--> $DIR/option_if_let_else.rs:185:13
|
||||
--> $DIR/option_if_let_else.rs:184:13
|
||||
|
|
||||
LL | let _ = if let Some(x) = Some(0) {
|
||||
| _____________^
|
||||
@ -231,7 +231,7 @@ LL ~ });
|
||||
|
|
||||
|
||||
error: use Option::map_or instead of an if let/else
|
||||
--> $DIR/option_if_let_else.rs:224:13
|
||||
--> $DIR/option_if_let_else.rs:223:13
|
||||
|
|
||||
LL | let _ = match s {
|
||||
| _____________^
|
||||
@ -241,7 +241,7 @@ LL | | };
|
||||
| |_____^ help: try: `s.map_or(1, |string| string.len())`
|
||||
|
||||
error: use Option::map_or instead of an if let/else
|
||||
--> $DIR/option_if_let_else.rs:228:13
|
||||
--> $DIR/option_if_let_else.rs:227:13
|
||||
|
|
||||
LL | let _ = match Some(10) {
|
||||
| _____________^
|
||||
@ -251,7 +251,7 @@ LL | | };
|
||||
| |_____^ help: try: `Some(10).map_or(5, |a| a + 1)`
|
||||
|
||||
error: use Option::map_or instead of an if let/else
|
||||
--> $DIR/option_if_let_else.rs:234:13
|
||||
--> $DIR/option_if_let_else.rs:233:13
|
||||
|
|
||||
LL | let _ = match res {
|
||||
| _____________^
|
||||
@ -261,7 +261,7 @@ LL | | };
|
||||
| |_____^ help: try: `res.map_or(1, |a| a + 1)`
|
||||
|
||||
error: use Option::map_or instead of an if let/else
|
||||
--> $DIR/option_if_let_else.rs:238:13
|
||||
--> $DIR/option_if_let_else.rs:237:13
|
||||
|
|
||||
LL | let _ = match res {
|
||||
| _____________^
|
||||
@ -271,13 +271,13 @@ LL | | };
|
||||
| |_____^ help: try: `res.map_or(1, |a| a + 1)`
|
||||
|
||||
error: use Option::map_or instead of an if let/else
|
||||
--> $DIR/option_if_let_else.rs:242:13
|
||||
--> $DIR/option_if_let_else.rs:241:13
|
||||
|
|
||||
LL | let _ = if let Ok(a) = res { a + 1 } else { 5 };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `res.map_or(5, |a| a + 1)`
|
||||
|
||||
error: use Option::map_or instead of an if let/else
|
||||
--> $DIR/option_if_let_else.rs:259:17
|
||||
--> $DIR/option_if_let_else.rs:258:17
|
||||
|
|
||||
LL | let _ = match initial {
|
||||
| _________________^
|
||||
@ -287,7 +287,7 @@ LL | | };
|
||||
| |_________^ help: try: `initial.as_ref().map_or(42, |value| do_something(value))`
|
||||
|
||||
error: use Option::map_or instead of an if let/else
|
||||
--> $DIR/option_if_let_else.rs:266:17
|
||||
--> $DIR/option_if_let_else.rs:265:17
|
||||
|
|
||||
LL | let _ = match initial {
|
||||
| _________________^
|
||||
@ -297,7 +297,7 @@ LL | | };
|
||||
| |_________^ help: try: `initial.as_mut().map_or(42, |value| do_something2(value))`
|
||||
|
||||
error: use Option::map_or_else instead of an if let/else
|
||||
--> $DIR/option_if_let_else.rs:289:24
|
||||
--> $DIR/option_if_let_else.rs:288:24
|
||||
|
|
||||
LL | let mut _hashmap = if let Some(hm) = &opt {
|
||||
| ________________________^
|
||||
@ -308,7 +308,7 @@ LL | | };
|
||||
| |_____^ help: try: `opt.as_ref().map_or_else(HashMap::new, |hm| hm.clone())`
|
||||
|
||||
error: use Option::map_or_else instead of an if let/else
|
||||
--> $DIR/option_if_let_else.rs:295:19
|
||||
--> $DIR/option_if_let_else.rs:294:19
|
||||
|
|
||||
LL | let mut _hm = if let Some(hm) = &opt { hm.clone() } else { new_map!() };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `opt.as_ref().map_or_else(|| new_map!(), |hm| hm.clone())`
|
||||
|
@ -1,5 +1,4 @@
|
||||
#![warn(clippy::unreadable_literal)]
|
||||
#![allow(unused_tuple_struct_fields)]
|
||||
|
||||
struct Foo(u64);
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
#![warn(clippy::unreadable_literal)]
|
||||
#![allow(unused_tuple_struct_fields)]
|
||||
|
||||
struct Foo(u64);
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
error: long literal lacking separators
|
||||
--> $DIR/unreadable_literal.rs:32:17
|
||||
--> $DIR/unreadable_literal.rs:31:17
|
||||
|
|
||||
LL | let _bad = (0b110110_i64, 0x12345678_usize, 123456_f32, 1.234567_f32);
|
||||
| ^^^^^^^^^^^^ help: consider: `0b11_0110_i64`
|
||||
@ -8,55 +8,55 @@ LL | let _bad = (0b110110_i64, 0x12345678_usize, 123456_f32, 1.234567_f32);
|
||||
= help: to override `-D warnings` add `#[allow(clippy::unreadable_literal)]`
|
||||
|
||||
error: long literal lacking separators
|
||||
--> $DIR/unreadable_literal.rs:32:31
|
||||
--> $DIR/unreadable_literal.rs:31:31
|
||||
|
|
||||
LL | let _bad = (0b110110_i64, 0x12345678_usize, 123456_f32, 1.234567_f32);
|
||||
| ^^^^^^^^^^^^^^^^ help: consider: `0x1234_5678_usize`
|
||||
|
||||
error: long literal lacking separators
|
||||
--> $DIR/unreadable_literal.rs:32:49
|
||||
--> $DIR/unreadable_literal.rs:31:49
|
||||
|
|
||||
LL | let _bad = (0b110110_i64, 0x12345678_usize, 123456_f32, 1.234567_f32);
|
||||
| ^^^^^^^^^^ help: consider: `123_456_f32`
|
||||
|
||||
error: long literal lacking separators
|
||||
--> $DIR/unreadable_literal.rs:32:61
|
||||
--> $DIR/unreadable_literal.rs:31:61
|
||||
|
|
||||
LL | let _bad = (0b110110_i64, 0x12345678_usize, 123456_f32, 1.234567_f32);
|
||||
| ^^^^^^^^^^^^ help: consider: `1.234_567_f32`
|
||||
|
||||
error: long literal lacking separators
|
||||
--> $DIR/unreadable_literal.rs:34:20
|
||||
--> $DIR/unreadable_literal.rs:33:20
|
||||
|
|
||||
LL | let _bad_sci = 1.123456e1;
|
||||
| ^^^^^^^^^^ help: consider: `1.123_456e1`
|
||||
|
||||
error: long literal lacking separators
|
||||
--> $DIR/unreadable_literal.rs:36:18
|
||||
--> $DIR/unreadable_literal.rs:35:18
|
||||
|
|
||||
LL | let _fail1 = 0xabcdef;
|
||||
| ^^^^^^^^ help: consider: `0x00ab_cdef`
|
||||
|
||||
error: long literal lacking separators
|
||||
--> $DIR/unreadable_literal.rs:37:23
|
||||
--> $DIR/unreadable_literal.rs:36:23
|
||||
|
|
||||
LL | let _fail2: u32 = 0xBAFEBAFE;
|
||||
| ^^^^^^^^^^ help: consider: `0xBAFE_BAFE`
|
||||
|
||||
error: long literal lacking separators
|
||||
--> $DIR/unreadable_literal.rs:38:18
|
||||
--> $DIR/unreadable_literal.rs:37:18
|
||||
|
|
||||
LL | let _fail3 = 0xabcdeff;
|
||||
| ^^^^^^^^^ help: consider: `0x0abc_deff`
|
||||
|
||||
error: long literal lacking separators
|
||||
--> $DIR/unreadable_literal.rs:39:24
|
||||
--> $DIR/unreadable_literal.rs:38:24
|
||||
|
|
||||
LL | let _fail4: i128 = 0xabcabcabcabcabcabc;
|
||||
| ^^^^^^^^^^^^^^^^^^^^ help: consider: `0x00ab_cabc_abca_bcab_cabc`
|
||||
|
||||
error: long literal lacking separators
|
||||
--> $DIR/unreadable_literal.rs:40:18
|
||||
--> $DIR/unreadable_literal.rs:39:18
|
||||
|
|
||||
LL | let _fail5 = 1.100300400;
|
||||
| ^^^^^^^^^^^ help: consider: `1.100_300_400`
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
//@[stack]error-in-other-file: which is strongly protected
|
||||
//@[tree]error-in-other-file: /deallocation through .* is forbidden/
|
||||
struct Newtype<'a>(&'a mut i32, i32);
|
||||
struct Newtype<'a>(#[allow(dead_code)] &'a mut i32, #[allow(dead_code)] i32);
|
||||
|
||||
fn dealloc_while_running(_n: Newtype<'_>, dealloc: impl FnOnce()) {
|
||||
dealloc();
|
||||
|
@ -4,7 +4,7 @@
|
||||
//@[stack]error-in-other-file: which is strongly protected
|
||||
//@[tree]error-in-other-file: /deallocation through .* is forbidden/
|
||||
|
||||
struct Newtype<'a>(&'a mut i32);
|
||||
struct Newtype<'a>(#[allow(dead_code)] &'a mut i32);
|
||||
|
||||
fn dealloc_while_running(_n: Newtype<'_>, dealloc: impl FnOnce()) {
|
||||
dealloc();
|
||||
|
@ -6,7 +6,7 @@
|
||||
use std::sync::atomic::{AtomicI64, Ordering};
|
||||
|
||||
#[repr(align(8))]
|
||||
struct AlignedI64(i64);
|
||||
struct AlignedI64(#[allow(dead_code)] i64);
|
||||
|
||||
fn main() {
|
||||
static X: AlignedI64 = AlignedI64(0);
|
||||
|
@ -1,7 +1,7 @@
|
||||
// should find the bug even without retagging
|
||||
//@compile-flags: -Zmiri-disable-stacked-borrows
|
||||
|
||||
struct SliceWithHead(u8, [u8]);
|
||||
struct SliceWithHead(#[allow(dead_code)] u8, #[allow(dead_code)] [u8]);
|
||||
|
||||
fn main() {
|
||||
let buf = [0u32; 1];
|
||||
|
@ -3,7 +3,7 @@
|
||||
// Some targets treat arrays and structs very differently. We would probably catch that on those
|
||||
// targets since we check the `PassMode`; here we ensure that we catch it on *all* targets
|
||||
// (in particular, on x86-64 the pass mode is `Indirect` for both of these).
|
||||
struct S(i32, i32, i32, i32);
|
||||
struct S(#[allow(dead_code)] i32, #[allow(dead_code)] i32, #[allow(dead_code)] i32, #[allow(dead_code)] i32);
|
||||
type A = [i32; 4];
|
||||
|
||||
fn main() {
|
||||
|
@ -1,7 +1,7 @@
|
||||
trait Empty {}
|
||||
|
||||
#[repr(transparent)]
|
||||
pub struct FunnyPointer(dyn Empty);
|
||||
pub struct FunnyPointer(#[allow(dead_code)] dyn Empty);
|
||||
|
||||
#[repr(C)]
|
||||
pub struct Meta {
|
||||
|
@ -1,7 +1,7 @@
|
||||
//@compile-flags: -Cdebug-assertions=no
|
||||
|
||||
#[repr(transparent)]
|
||||
struct HasDrop(u8);
|
||||
struct HasDrop(#[allow(dead_code)] u8);
|
||||
|
||||
impl Drop for HasDrop {
|
||||
fn drop(&mut self) {}
|
||||
|
@ -7,7 +7,7 @@ mod utils;
|
||||
|
||||
#[repr(align(8))]
|
||||
#[derive(Copy, Clone)]
|
||||
struct Align8(u64);
|
||||
struct Align8(#[allow(dead_code)] u64);
|
||||
|
||||
fn main() {
|
||||
let buffer = [0u32; 128]; // get some 4-aligned memory
|
||||
@ -35,7 +35,7 @@ fn main() {
|
||||
if cfg!(read_unaligned_ptr) {
|
||||
#[repr(align(16))]
|
||||
#[derive(Copy, Clone)]
|
||||
struct Align16(u128);
|
||||
struct Align16(#[allow(dead_code)] u128);
|
||||
|
||||
let align16 = if align8.addr() % 16 == 0 { align8 } else { align8.wrapping_add(2) };
|
||||
assert!(align16.addr() % 16 == 0);
|
||||
|
@ -46,7 +46,7 @@ fn test_align_to() {
|
||||
{
|
||||
#[repr(align(8))]
|
||||
#[derive(Copy, Clone)]
|
||||
struct Align8(u64);
|
||||
struct Align8(#[allow(dead_code)] u64);
|
||||
|
||||
let (_l, m, _r) = unsafe { s.align_to::<Align8>() };
|
||||
assert!(m.len() > 0);
|
||||
@ -97,7 +97,7 @@ fn huge_align() {
|
||||
const SIZE: usize = 1 << 30;
|
||||
#[cfg(target_pointer_width = "16")]
|
||||
const SIZE: usize = 1 << 13;
|
||||
struct HugeSize([u8; SIZE - 1]);
|
||||
struct HugeSize(#[allow(dead_code)] [u8; SIZE - 1]);
|
||||
let _ = std::ptr::invalid::<HugeSize>(SIZE).align_offset(SIZE);
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,7 @@ fn test1() {
|
||||
}
|
||||
|
||||
// Make the allocator itself so big that the Box is not even a ScalarPair any more.
|
||||
struct OnceAllocRef<'s, 'a>(&'s OnceAlloc<'a>, u64);
|
||||
struct OnceAllocRef<'s, 'a>(&'s OnceAlloc<'a>, #[allow(dead_code)] u64);
|
||||
|
||||
unsafe impl<'shared, 'a: 'shared> Allocator for OnceAllocRef<'shared, 'a> {
|
||||
fn allocate(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError> {
|
||||
|
@ -46,7 +46,7 @@ fn boxed_pair_to_vec() {
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
struct Foo(u64);
|
||||
struct Foo(#[allow(dead_code)] u64);
|
||||
fn reinterstruct(box_pair: Box<PairFoo>) -> Vec<Foo> {
|
||||
let ref_pair = Box::leak(box_pair) as *mut PairFoo;
|
||||
let ptr_foo = unsafe { std::ptr::addr_of_mut!((*ref_pair).fst) };
|
||||
|
@ -1,6 +1,6 @@
|
||||
// test that ordinary fat pointer operations work.
|
||||
|
||||
struct Wrapper<T: ?Sized>(u32, T);
|
||||
struct Wrapper<T: ?Sized>(#[allow(dead_code)] u32, T);
|
||||
|
||||
struct FatPtrContainer<'a> {
|
||||
ptr: &'a [u8],
|
||||
|
@ -2,7 +2,7 @@
|
||||
use std::mem;
|
||||
|
||||
#[repr(packed(4))]
|
||||
struct Slice([u32]);
|
||||
struct Slice(#[allow(dead_code)] [u32]);
|
||||
|
||||
#[repr(packed(2), C)]
|
||||
struct PackedSized {
|
||||
|
@ -1,6 +1,6 @@
|
||||
#[repr(u8)]
|
||||
enum Foo {
|
||||
Foo(u8),
|
||||
Foo(#[allow(dead_code)] u8),
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
@ -4,7 +4,7 @@
|
||||
use std::mem;
|
||||
|
||||
const SZ: usize = 100;
|
||||
struct P<T: ?Sized>([u8; SZ], T);
|
||||
struct P<T: ?Sized>(#[allow(dead_code)] [u8; SZ], T);
|
||||
|
||||
type Ack<T> = P<P<T>>;
|
||||
|
||||
|
@ -102,7 +102,7 @@ fn test_inner_packed() {
|
||||
struct Inner(u32);
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
struct Outer(u8, Inner);
|
||||
struct Outer(#[allow(dead_code)] u8, Inner);
|
||||
|
||||
let o = Outer(0, Inner(42));
|
||||
let _x = o.1;
|
||||
|
@ -1,6 +1,6 @@
|
||||
//@compile-flags: -Zmiri-retag-fields=none
|
||||
|
||||
struct Newtype<'a>(&'a mut i32);
|
||||
struct Newtype<'a>(#[allow(dead_code)] &'a mut i32);
|
||||
|
||||
fn dealloc_while_running(_n: Newtype<'_>, dealloc: impl FnOnce()) {
|
||||
dealloc();
|
||||
|
@ -1,6 +1,6 @@
|
||||
//@compile-flags: -Zmiri-retag-fields=scalar
|
||||
|
||||
struct Newtype<'a>(&'a mut i32, i32, i32);
|
||||
struct Newtype<'a>(#[allow(dead_code)] &'a mut i32, #[allow(dead_code)] i32, #[allow(dead_code)] i32);
|
||||
|
||||
fn dealloc_while_running(_n: Newtype<'_>, dealloc: impl FnOnce()) {
|
||||
dealloc();
|
||||
|
@ -226,7 +226,7 @@ fn not_unpin_not_protected() {
|
||||
// the self-referential-coroutine situation, it does not seem worth the potential trouble.)
|
||||
use std::marker::PhantomPinned;
|
||||
|
||||
pub struct NotUnpin(i32, PhantomPinned);
|
||||
pub struct NotUnpin(#[allow(dead_code)] i32, PhantomPinned);
|
||||
|
||||
fn inner(x: &mut NotUnpin, f: fn(&mut NotUnpin)) {
|
||||
// `f` may mutate, but it may not deallocate!
|
||||
|
@ -318,7 +318,7 @@ fn not_unpin_not_protected() {
|
||||
// the self-referential-coroutine situation, it does not seem worth the potential trouble.)
|
||||
use std::marker::PhantomPinned;
|
||||
|
||||
pub struct NotUnpin(i32, PhantomPinned);
|
||||
pub struct NotUnpin(#[allow(dead_code)] i32, PhantomPinned);
|
||||
|
||||
fn inner(x: &mut NotUnpin, f: fn(&mut NotUnpin)) {
|
||||
// `f` may mutate, but it may not deallocate!
|
||||
|
@ -10,7 +10,7 @@ impl Drop for Foo {
|
||||
static mut FOO: bool = false;
|
||||
|
||||
enum Bar {
|
||||
A(Box<i32>),
|
||||
A(#[allow(dead_code)] Box<i32>),
|
||||
B(Foo),
|
||||
}
|
||||
|
||||
|
@ -1947,7 +1947,7 @@ fn rewrite_unary_op(
|
||||
}
|
||||
|
||||
pub(crate) enum RhsAssignKind<'ast> {
|
||||
Expr(&'ast ast::ExprKind, Span),
|
||||
Expr(&'ast ast::ExprKind, #[allow(dead_code)] Span),
|
||||
Bounds,
|
||||
Ty,
|
||||
}
|
||||
|
@ -34,9 +34,9 @@ enum EnumNoDrop<T1, T2> {
|
||||
}
|
||||
|
||||
|
||||
struct NonGenericNoDrop(#[allow(unused_tuple_struct_fields)] i32);
|
||||
struct NonGenericNoDrop(#[allow(dead_code)] i32);
|
||||
|
||||
struct NonGenericWithDrop(#[allow(unused_tuple_struct_fields)] i32);
|
||||
struct NonGenericWithDrop(#[allow(dead_code)] i32);
|
||||
//~ MONO_ITEM fn std::ptr::drop_in_place::<NonGenericWithDrop> - shim(Some(NonGenericWithDrop)) @@ generic_drop_glue-cgu.0[Internal]
|
||||
|
||||
impl Drop for NonGenericWithDrop {
|
||||
|
@ -6,9 +6,9 @@
|
||||
#![feature(start)]
|
||||
|
||||
//~ MONO_ITEM fn std::ptr::drop_in_place::<Root> - shim(Some(Root)) @@ transitive_drop_glue-cgu.0[Internal]
|
||||
struct Root(#[allow(unused_tuple_struct_fields)] Intermediate);
|
||||
struct Root(#[allow(dead_code)] Intermediate);
|
||||
//~ MONO_ITEM fn std::ptr::drop_in_place::<Intermediate> - shim(Some(Intermediate)) @@ transitive_drop_glue-cgu.0[Internal]
|
||||
struct Intermediate(#[allow(unused_tuple_struct_fields)] Leaf);
|
||||
struct Intermediate(#[allow(dead_code)] Leaf);
|
||||
//~ MONO_ITEM fn std::ptr::drop_in_place::<Leaf> - shim(Some(Leaf)) @@ transitive_drop_glue-cgu.0[Internal]
|
||||
struct Leaf;
|
||||
|
||||
@ -17,9 +17,9 @@ impl Drop for Leaf {
|
||||
fn drop(&mut self) {}
|
||||
}
|
||||
|
||||
struct RootGen<T>(#[allow(unused_tuple_struct_fields)] IntermediateGen<T>);
|
||||
struct IntermediateGen<T>(#[allow(unused_tuple_struct_fields)] LeafGen<T>);
|
||||
struct LeafGen<T>(#[allow(unused_tuple_struct_fields)] T);
|
||||
struct RootGen<T>(#[allow(dead_code)] IntermediateGen<T>);
|
||||
struct IntermediateGen<T>(#[allow(dead_code)] LeafGen<T>);
|
||||
struct LeafGen<T>(#[allow(dead_code)] T);
|
||||
|
||||
impl<T> Drop for LeafGen<T> {
|
||||
fn drop(&mut self) {}
|
||||
|
@ -40,7 +40,7 @@ impl Trait for u32 {
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
struct Wrapper<T: ?Sized>(#[allow(unused_tuple_struct_fields)] *const T);
|
||||
struct Wrapper<T: ?Sized>(#[allow(dead_code)] *const T);
|
||||
|
||||
impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<Wrapper<U>> for Wrapper<T> {}
|
||||
|
||||
|
@ -74,7 +74,7 @@ fn panic(panic_info: &core::panic::PanicInfo) -> ! {
|
||||
extern "C" fn rust_eh_personality() {}
|
||||
|
||||
#[derive(Default, Debug)]
|
||||
struct Page(#[allow(unused_tuple_struct_fields)] [[u64; 32]; 16]);
|
||||
struct Page(#[allow(dead_code)] [[u64; 32]; 16]);
|
||||
|
||||
#[no_mangle]
|
||||
fn main(_argc: i32, _argv: *const *const u8) -> isize {
|
||||
|
@ -61,7 +61,7 @@ fn panic(panic_info: &core::panic::PanicInfo) -> ! {
|
||||
extern "C" fn rust_eh_personality() {}
|
||||
|
||||
#[derive(Default, Debug)]
|
||||
struct Page(#[allow(unused_tuple_struct_fields)] [[u64; 32]; 16]);
|
||||
struct Page(#[allow(dead_code)] [[u64; 32]; 16]);
|
||||
|
||||
#[no_mangle]
|
||||
fn main(_argc: i32, _argv: *const *const u8) -> isize {
|
||||
|
@ -1,7 +1,7 @@
|
||||
// run-pass
|
||||
|
||||
#[derive(Debug)]
|
||||
struct Foo(#[allow(unused_tuple_struct_fields)] Box<[u8]>);
|
||||
struct Foo(#[allow(dead_code)] Box<[u8]>);
|
||||
|
||||
pub fn main() {
|
||||
println!("{:?}", Foo(Box::new([0, 1, 2])));
|
||||
|
@ -17,7 +17,7 @@ impl Foo for Def {
|
||||
const X: i32 = 97;
|
||||
}
|
||||
|
||||
struct Proxy<T>(#[allow(unused_tuple_struct_fields)] T);
|
||||
struct Proxy<T>(#[allow(dead_code)] T);
|
||||
|
||||
impl<T: Foo> Foo for Proxy<T> {
|
||||
const X: i32 = T::X;
|
||||
|
@ -5,7 +5,7 @@
|
||||
trait Device {
|
||||
type Resources;
|
||||
}
|
||||
#[allow(unused_tuple_struct_fields)]
|
||||
#[allow(dead_code)]
|
||||
struct Foo<D, R>(D, R);
|
||||
|
||||
trait Tr {
|
||||
|
@ -9,7 +9,7 @@ pub trait UnifyKey {
|
||||
fn dummy(&self) { }
|
||||
}
|
||||
|
||||
pub struct Node<K:UnifyKey>(#[allow(unused_tuple_struct_fields)] K, K::Value);
|
||||
pub struct Node<K:UnifyKey>(#[allow(dead_code)] K, K::Value);
|
||||
|
||||
fn foo<K : UnifyKey<Value=Option<V>>,V : Clone>(node: &Node<K>) -> Option<V> {
|
||||
node.1.clone()
|
||||
|
@ -1,5 +1,5 @@
|
||||
// run-pass
|
||||
struct S<T: 'static>(#[allow(unused_tuple_struct_fields)] Option<&'static T>);
|
||||
struct S<T: 'static>(#[allow(dead_code)] Option<&'static T>);
|
||||
|
||||
trait Tr { type Out; }
|
||||
impl<T> Tr for T { type Out = T; }
|
||||
|
@ -3,9 +3,9 @@ pub trait Parser {
|
||||
type Input;
|
||||
}
|
||||
|
||||
pub struct Iter<P: Parser>(#[allow(unused_tuple_struct_fields)] P, P::Input);
|
||||
pub struct Iter<P: Parser>(#[allow(dead_code)] P, P::Input);
|
||||
|
||||
#[allow(unused_tuple_struct_fields)]
|
||||
#[allow(dead_code)]
|
||||
pub struct Map<P, F>(P, F);
|
||||
impl<P, F> Parser for Map<P, F> where F: FnMut(P) {
|
||||
type Input = u8;
|
||||
|
@ -1,4 +1,4 @@
|
||||
struct S<T: 'static>(#[allow(unused_tuple_struct_fields)] Option<&'static T>);
|
||||
struct S<T: 'static>(#[allow(dead_code)] Option<&'static T>);
|
||||
|
||||
trait Tr { type Out; }
|
||||
impl<T> Tr for T { type Out = T; }
|
||||
|
@ -17,7 +17,7 @@ use std::pin::Pin;
|
||||
use std::task::{Context, Poll};
|
||||
|
||||
const BIG_FUT_SIZE: usize = 1024;
|
||||
struct BigFut(#[allow(unused_tuple_struct_fields)] [u8; BIG_FUT_SIZE]);
|
||||
struct BigFut(#[allow(dead_code)] [u8; BIG_FUT_SIZE]);
|
||||
|
||||
impl BigFut {
|
||||
fn new() -> Self {
|
||||
|
@ -17,7 +17,7 @@ use std::pin::Pin;
|
||||
use std::task::{Context, Poll};
|
||||
|
||||
const BIG_FUT_SIZE: usize = 1024;
|
||||
struct Big(#[allow(unused_tuple_struct_fields)] [u8; BIG_FUT_SIZE]);
|
||||
struct Big(#[allow(dead_code)] [u8; BIG_FUT_SIZE]);
|
||||
|
||||
impl Big {
|
||||
fn new() -> Self {
|
||||
|
@ -9,7 +9,7 @@ unsafe auto trait AutoUnsafe {}
|
||||
impl !Auto for bool {}
|
||||
impl !AutoUnsafe for bool {}
|
||||
|
||||
struct AutoBool(#[allow(unused_tuple_struct_fields)] bool);
|
||||
struct AutoBool(#[allow(dead_code)] bool);
|
||||
|
||||
impl Auto for AutoBool {}
|
||||
unsafe impl AutoUnsafe for AutoBool {}
|
||||
|
@ -15,7 +15,7 @@ trait Parser {
|
||||
}
|
||||
}
|
||||
|
||||
struct Token<T>(#[allow(unused_tuple_struct_fields)] T::Item) where T: Iterator;
|
||||
struct Token<T>(#[allow(dead_code)] T::Item) where T: Iterator;
|
||||
|
||||
impl<T> Parser for Token<T> where T: Iterator {
|
||||
type Input = T;
|
||||
@ -25,7 +25,7 @@ impl<T> Parser for Token<T> where T: Iterator {
|
||||
}
|
||||
}
|
||||
|
||||
struct Chain<L, R>(#[allow(unused_tuple_struct_fields)] L, #[allow(unused_tuple_struct_fields)] R);
|
||||
struct Chain<L, R>(#[allow(dead_code)] L, #[allow(dead_code)] R);
|
||||
|
||||
impl<L, R> Parser for Chain<L, R> where L: Parser, R: Parser<Input = L::Input> {
|
||||
type Input = L::Input;
|
||||
|
@ -3,7 +3,7 @@
|
||||
#![allow(non_camel_case_types)]
|
||||
|
||||
|
||||
#[allow(unused_tuple_struct_fields)]
|
||||
#[allow(dead_code)]
|
||||
enum color {
|
||||
rgb(isize, isize, isize),
|
||||
rgba(isize, isize, isize, isize),
|
||||
|
@ -1,7 +1,7 @@
|
||||
// run-pass
|
||||
#![allow(non_camel_case_types)]
|
||||
|
||||
enum blah { a(isize, isize, #[allow(unused_tuple_struct_fields)] usize), b(isize, isize), c, }
|
||||
enum blah { a(isize, isize, #[allow(dead_code)] usize), b(isize, isize), c, }
|
||||
|
||||
fn or_alt(q: blah) -> isize {
|
||||
match q { blah::a(x, y, _) | blah::b(x, y) => { return x + y; } blah::c => { return 0; } }
|
||||
|
@ -3,6 +3,6 @@
|
||||
|
||||
// pretty-expanded FIXME #23616
|
||||
|
||||
enum clam<T> { a(#[allow(unused_tuple_struct_fields)] T), }
|
||||
enum clam<T> { a(#[allow(dead_code)] T), }
|
||||
|
||||
pub fn main() { let c = clam::a(2); match c { clam::a::<isize>(_) => { } } }
|
||||
|
@ -12,7 +12,7 @@ use trait_superkinds_in_metadata::RequiresCopy;
|
||||
use std::marker;
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
struct X<T>(#[allow(unused_tuple_struct_fields)] T);
|
||||
struct X<T>(#[allow(dead_code)] T);
|
||||
|
||||
impl<T:Sync> RequiresShare for X<T> { }
|
||||
|
||||
|
@ -51,10 +51,10 @@ fn test_sync_trait() {
|
||||
}
|
||||
|
||||
/* Test Clone Trait Migration */
|
||||
struct S(Foo);
|
||||
struct S(#[allow(dead_code)] Foo);
|
||||
struct T(i32);
|
||||
|
||||
struct U(S, T);
|
||||
struct U(#[allow(dead_code)] S, T);
|
||||
|
||||
impl Clone for U {
|
||||
fn clone(&self) -> Self {
|
||||
|
@ -51,10 +51,10 @@ fn test_sync_trait() {
|
||||
}
|
||||
|
||||
/* Test Clone Trait Migration */
|
||||
struct S(Foo);
|
||||
struct S(#[allow(dead_code)] Foo);
|
||||
struct T(i32);
|
||||
|
||||
struct U(S, T);
|
||||
struct U(#[allow(dead_code)] S, T);
|
||||
|
||||
impl Clone for U {
|
||||
fn clone(&self) -> Self {
|
||||
|
@ -18,10 +18,10 @@ impl Foo {
|
||||
}
|
||||
}
|
||||
|
||||
struct S(#[allow(unused_tuple_struct_fields)] Foo);
|
||||
struct S(#[allow(dead_code)] Foo);
|
||||
|
||||
#[derive(Clone)]
|
||||
struct T(#[allow(unused_tuple_struct_fields)] i32);
|
||||
struct T(#[allow(dead_code)] i32);
|
||||
|
||||
struct U(S, T);
|
||||
|
||||
|
@ -18,10 +18,10 @@ impl Foo {
|
||||
}
|
||||
}
|
||||
|
||||
struct S(#[allow(unused_tuple_struct_fields)] Foo);
|
||||
struct S(#[allow(dead_code)] Foo);
|
||||
|
||||
#[derive(Clone)]
|
||||
struct T(#[allow(unused_tuple_struct_fields)] i32);
|
||||
struct T(#[allow(dead_code)] i32);
|
||||
|
||||
struct U(S, T);
|
||||
|
||||
|
@ -13,7 +13,7 @@ impl Drop for Foo {
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
struct ConstainsDropField(Foo, #[allow(unused_tuple_struct_fields)] Foo);
|
||||
struct ConstainsDropField(Foo, #[allow(dead_code)] Foo);
|
||||
|
||||
// `t` needs Drop because one of its elements needs drop,
|
||||
// therefore precise capture might affect drop ordering
|
||||
|
@ -13,7 +13,7 @@ impl Drop for Foo {
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
struct ConstainsDropField(Foo, #[allow(unused_tuple_struct_fields)] Foo);
|
||||
struct ConstainsDropField(Foo, #[allow(dead_code)] Foo);
|
||||
|
||||
// `t` needs Drop because one of its elements needs drop,
|
||||
// therefore precise capture might affect drop ordering
|
||||
|
@ -2,7 +2,7 @@
|
||||
#![allow(unused_variables)]
|
||||
#![allow(unused_assignments)]
|
||||
#[derive(Debug)]
|
||||
#[allow(unused_tuple_struct_fields)]
|
||||
#[allow(dead_code)]
|
||||
enum Foo {
|
||||
Bar(u32, u32),
|
||||
Baz(&'static u32, &'static u32)
|
||||
|
@ -20,5 +20,5 @@ impl<T> Test<T> {
|
||||
}
|
||||
|
||||
trait Foo { fn dummy(&self) { }}
|
||||
struct Output(#[allow(unused_tuple_struct_fields)] isize);
|
||||
struct Output(#[allow(dead_code)] isize);
|
||||
impl Foo for Output {}
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
extern crate const_generic_lib;
|
||||
|
||||
struct Container(#[allow(unused_tuple_struct_fields)] const_generic_lib::Alias);
|
||||
struct Container(#[allow(dead_code)] const_generic_lib::Alias);
|
||||
|
||||
fn main() {
|
||||
let res = const_generic_lib::function(const_generic_lib::Struct([14u8, 1u8, 2u8]));
|
||||
|
@ -16,7 +16,7 @@ impl BlockCipher for BarCipher {
|
||||
const BLOCK_SIZE: usize = 32;
|
||||
}
|
||||
|
||||
pub struct Block<C>(#[allow(unused_tuple_struct_fields)] C);
|
||||
pub struct Block<C>(#[allow(dead_code)] C);
|
||||
|
||||
pub fn test<C: BlockCipher, const M: usize>()
|
||||
where
|
||||
|
@ -9,7 +9,7 @@ trait Foo {
|
||||
const ASSOC: usize = 1;
|
||||
}
|
||||
|
||||
#[allow(unused_tuple_struct_fields)]
|
||||
#[allow(dead_code)]
|
||||
struct Iced<T: Foo>(T, [(); T::ASSOC])
|
||||
where
|
||||
[(); T::ASSOC]: ;
|
||||
|
@ -9,7 +9,7 @@ trait Foo {
|
||||
const ASSOC: usize = 1;
|
||||
}
|
||||
|
||||
#[allow(unused_tuple_struct_fields)]
|
||||
#[allow(dead_code)]
|
||||
struct Iced<T: Foo>(T, [(); T::ASSOC])
|
||||
where
|
||||
[(); T::ASSOC]: ;
|
||||
|
@ -6,7 +6,7 @@ trait Nat {
|
||||
}
|
||||
|
||||
struct Zero;
|
||||
struct Succ<N>(#[allow(unused_tuple_struct_fields)] N);
|
||||
struct Succ<N>(#[allow(dead_code)] N);
|
||||
|
||||
impl Nat for Zero {
|
||||
const VALUE: usize = 0;
|
||||
|
@ -2,10 +2,10 @@
|
||||
|
||||
use std::mem;
|
||||
|
||||
#[allow(unused_tuple_struct_fields)]
|
||||
#[allow(dead_code)]
|
||||
struct Trivial(u8, f32);
|
||||
|
||||
#[allow(unused_tuple_struct_fields)]
|
||||
#[allow(dead_code)]
|
||||
struct NonTrivial(u8, String);
|
||||
|
||||
const CONST_U8: bool = mem::needs_drop::<u8>();
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
use std::{mem, ptr};
|
||||
|
||||
struct Foo(#[allow(unused_tuple_struct_fields)] u32);
|
||||
struct Foo(#[allow(dead_code)] u32);
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
struct Bar {
|
||||
|
@ -1,7 +1,7 @@
|
||||
// run-pass
|
||||
// Eventually this will be rejected (when the future-compat lints are turned into hard errors), and
|
||||
// then this test can be removed. But meanwhile we should ensure that this works and does not ICE.
|
||||
struct NoDerive(i32);
|
||||
struct NoDerive(#[allow(dead_code)] i32);
|
||||
|
||||
#[derive(PartialEq)]
|
||||
struct WrapEmbedded(*const NoDerive);
|
||||
|
@ -15,7 +15,7 @@
|
||||
#![warn(indirect_structural_match)]
|
||||
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
struct NoDerive(#[allow(unused_tuple_struct_fields)] u32);
|
||||
struct NoDerive(#[allow(dead_code)] u32);
|
||||
|
||||
// This impl makes `NoDerive` irreflexive.
|
||||
impl PartialEq for NoDerive { fn eq(&self, _: &Self) -> bool { false } }
|
||||
|
@ -1,7 +1,7 @@
|
||||
// run-pass
|
||||
|
||||
const HASH_LEN: usize = 20;
|
||||
struct Hash(#[allow(unused_tuple_struct_fields)] [u8; HASH_LEN]);
|
||||
struct Hash(#[allow(dead_code)] [u8; HASH_LEN]);
|
||||
fn init_hash(_: &mut [u8; HASH_LEN]) {}
|
||||
|
||||
fn foo<'a>() -> &'a () {
|
||||
|
@ -4,7 +4,7 @@ use std::sync::atomic::*;
|
||||
|
||||
static FLAG: AtomicBool = AtomicBool::new(false);
|
||||
|
||||
struct NoisyDrop(&'static str);
|
||||
struct NoisyDrop(#[allow(dead_code)] &'static str);
|
||||
impl Drop for NoisyDrop {
|
||||
fn drop(&mut self) {
|
||||
FLAG.store(true, Ordering::SeqCst);
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user