From 83930ecdea7eee3191316770071cc6e5019a8e3e Mon Sep 17 00:00:00 2001 From: Chayim Refael Friedman Date: Mon, 15 May 2023 21:08:45 +0300 Subject: [PATCH 01/13] Give better error when collecting into `&[T]` --- .../src/traits/error_reporting/on_unimplemented.rs | 8 ++++++++ library/core/src/iter/traits/collect.rs | 10 ++++++++++ tests/ui/iterators/collect-into-slice.rs | 6 ++++++ tests/ui/iterators/collect-into-slice.stderr | 12 +++++++++++- 4 files changed, 35 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/on_unimplemented.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/on_unimplemented.rs index 88525e1b720af..10bd027b6848a 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/on_unimplemented.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/on_unimplemented.rs @@ -306,6 +306,14 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> { } } } + + // `&[{integral}]` - `FromIterator` needs that. + if let ty::Ref(_, ref_ty, rustc_ast::Mutability::Not) = self_ty.kind() + && let ty::Slice(sty) = ref_ty.kind() + && sty.is_integral() + { + flags.push((sym::_Self, Some("&[{integral}]".to_owned()))); + } }); if let Ok(Some(command)) = OnUnimplementedDirective::of_item(self.tcx, def_id) { diff --git a/library/core/src/iter/traits/collect.rs b/library/core/src/iter/traits/collect.rs index 76b3a32880d1b..0675e56358f9b 100644 --- a/library/core/src/iter/traits/collect.rs +++ b/library/core/src/iter/traits/collect.rs @@ -94,6 +94,16 @@ /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[rustc_on_unimplemented( + on( + _Self = "&[{A}]", + message = "a slice of type `{Self}` cannot be built since we need to store the elements somewhere", + label = "try explicitly collecting into a `Vec<{A}>`", + ), + on( + all(A = "{integer}", any(_Self = "&[{integral}]",)), + message = "a slice of type `{Self}` cannot be built since we need to store the elements somewhere", + label = "try explicitly collecting into a `Vec<{A}>`", + ), on( _Self = "[{A}]", message = "a slice of type `{Self}` cannot be built since `{Self}` has no definite size", diff --git a/tests/ui/iterators/collect-into-slice.rs b/tests/ui/iterators/collect-into-slice.rs index 5a8aacb1a6df0..045d40a6f71ae 100644 --- a/tests/ui/iterators/collect-into-slice.rs +++ b/tests/ui/iterators/collect-into-slice.rs @@ -14,4 +14,10 @@ fn main() { //~| NOTE doesn't have a size known at compile-time //~| NOTE doesn't have a size known at compile-time process_slice(&some_generated_vec); + + let some_generated_vec = (0..10).collect(); + //~^ ERROR a slice of type `&[i32]` cannot be built since we need to store the elements somewhere + //~| NOTE try explicitly collecting into a `Vec<{integer}>` + //~| NOTE required by a bound in `collect` + process_slice(some_generated_vec); } diff --git a/tests/ui/iterators/collect-into-slice.stderr b/tests/ui/iterators/collect-into-slice.stderr index 29fff8c51c63b..07dc561f06a69 100644 --- a/tests/ui/iterators/collect-into-slice.stderr +++ b/tests/ui/iterators/collect-into-slice.stderr @@ -28,6 +28,16 @@ LL | let some_generated_vec = (0..10).collect(); note: required by a bound in `collect` --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL -error: aborting due to 3 previous errors +error[E0277]: a slice of type `&[i32]` cannot be built since we need to store the elements somewhere + --> $DIR/collect-into-slice.rs:18:38 + | +LL | let some_generated_vec = (0..10).collect(); + | ^^^^^^^ try explicitly collecting into a `Vec<{integer}>` + | + = help: the trait `FromIterator<{integer}>` is not implemented for `&[i32]` +note: required by a bound in `collect` + --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL + +error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0277`. From 77481099ca4be8fd8515d5e5bb873f3674cb7a2b Mon Sep 17 00:00:00 2001 From: LegionMammal978 Date: Mon, 15 May 2023 14:31:00 -0400 Subject: [PATCH 02/13] Mark internal functions and traits unsafe --- library/alloc/src/vec/in_place_collect.rs | 9 ++--- library/core/src/fmt/float.rs | 12 ++++--- library/core/src/fmt/mod.rs | 42 +++++++++++++++-------- library/core/src/fmt/num.rs | 15 +++++--- library/std/src/path.rs | 11 +++--- 5 files changed, 57 insertions(+), 32 deletions(-) diff --git a/library/alloc/src/vec/in_place_collect.rs b/library/alloc/src/vec/in_place_collect.rs index 2f1ee8b03533d..5ecd0479971ea 100644 --- a/library/alloc/src/vec/in_place_collect.rs +++ b/library/alloc/src/vec/in_place_collect.rs @@ -178,7 +178,8 @@ where ) }; - let len = SpecInPlaceCollect::collect_in_place(&mut iterator, dst_buf, dst_end); + // SAFETY: `dst_buf` and `dst_end` are the start and end of the buffer. + let len = unsafe { SpecInPlaceCollect::collect_in_place(&mut iterator, dst_buf, dst_end) }; let src = unsafe { iterator.as_inner().as_into_iter() }; // check if SourceIter contract was upheld @@ -239,7 +240,7 @@ trait SpecInPlaceCollect: Iterator { /// `Iterator::__iterator_get_unchecked` calls with a `TrustedRandomAccessNoCoerce` bound /// on `I` which means the caller of this method must take the safety conditions /// of that trait into consideration. - fn collect_in_place(&mut self, dst: *mut T, end: *const T) -> usize; + unsafe fn collect_in_place(&mut self, dst: *mut T, end: *const T) -> usize; } impl SpecInPlaceCollect for I @@ -247,7 +248,7 @@ where I: Iterator, { #[inline] - default fn collect_in_place(&mut self, dst_buf: *mut T, end: *const T) -> usize { + default unsafe fn collect_in_place(&mut self, dst_buf: *mut T, end: *const T) -> usize { // use try-fold since // - it vectorizes better for some iterator adapters // - unlike most internal iteration methods, it only takes a &mut self @@ -265,7 +266,7 @@ where I: Iterator + TrustedRandomAccessNoCoerce, { #[inline] - fn collect_in_place(&mut self, dst_buf: *mut T, end: *const T) -> usize { + unsafe fn collect_in_place(&mut self, dst_buf: *mut T, end: *const T) -> usize { let len = self.size(); let mut drop_guard = InPlaceDrop { inner: dst_buf, dst: dst_buf }; for i in 0..len { diff --git a/library/core/src/fmt/float.rs b/library/core/src/fmt/float.rs index 89d5fac30d357..3bbf5d8770bd2 100644 --- a/library/core/src/fmt/float.rs +++ b/library/core/src/fmt/float.rs @@ -45,7 +45,8 @@ where &mut buf, &mut parts, ); - fmt.pad_formatted_parts(&formatted) + // SAFETY: `to_exact_fixed_str` and `format_exact` produce only ASCII characters. + unsafe { fmt.pad_formatted_parts(&formatted) } } // Don't inline this so callers that call both this and the above won't wind @@ -71,7 +72,8 @@ where &mut buf, &mut parts, ); - fmt.pad_formatted_parts(&formatted) + // SAFETY: `to_shortest_str` and `format_shortest` produce only ASCII characters. + unsafe { fmt.pad_formatted_parts(&formatted) } } fn float_to_decimal_display(fmt: &mut Formatter<'_>, num: &T) -> Result @@ -116,7 +118,8 @@ where &mut buf, &mut parts, ); - fmt.pad_formatted_parts(&formatted) + // SAFETY: `to_exact_exp_str` and `format_exact` produce only ASCII characters. + unsafe { fmt.pad_formatted_parts(&formatted) } } // Don't inline this so callers that call both this and the above won't wind @@ -143,7 +146,8 @@ where &mut buf, &mut parts, ); - fmt.pad_formatted_parts(&formatted) + // SAFETY: `to_shortest_exp_str` and `format_shortest` produce only ASCII characters. + unsafe { fmt.pad_formatted_parts(&formatted) } } // Common code of floating point LowerExp and UpperExp. diff --git a/library/core/src/fmt/mod.rs b/library/core/src/fmt/mod.rs index bac2f31878b0a..1786b309c5bd3 100644 --- a/library/core/src/fmt/mod.rs +++ b/library/core/src/fmt/mod.rs @@ -1415,7 +1415,11 @@ impl<'a> Formatter<'a> { /// Takes the formatted parts and applies the padding. /// Assumes that the caller already has rendered the parts with required precision, /// so that `self.precision` can be ignored. - fn pad_formatted_parts(&mut self, formatted: &numfmt::Formatted<'_>) -> Result { + /// + /// # Safety + /// + /// Any `numfmt::Part::Copy` parts in `formatted` must contain valid UTF-8. + unsafe fn pad_formatted_parts(&mut self, formatted: &numfmt::Formatted<'_>) -> Result { if let Some(mut width) = self.width { // for the sign-aware zero padding, we render the sign first and // behave as if we had no sign from the beginning. @@ -1438,10 +1442,14 @@ impl<'a> Formatter<'a> { let len = formatted.len(); let ret = if width <= len { // no padding - self.write_formatted_parts(&formatted) + // SAFETY: Per the precondition. + unsafe { self.write_formatted_parts(&formatted) } } else { let post_padding = self.padding(width - len, Alignment::Right)?; - self.write_formatted_parts(&formatted)?; + // SAFETY: Per the precondition. + unsafe { + self.write_formatted_parts(&formatted)?; + } post_padding.write(self) }; self.fill = old_fill; @@ -1449,20 +1457,20 @@ impl<'a> Formatter<'a> { ret } else { // this is the common case and we take a shortcut - self.write_formatted_parts(formatted) + // SAFETY: Per the precondition. + unsafe { self.write_formatted_parts(formatted) } } } - fn write_formatted_parts(&mut self, formatted: &numfmt::Formatted<'_>) -> Result { - fn write_bytes(buf: &mut dyn Write, s: &[u8]) -> Result { + /// # Safety + /// + /// Any `numfmt::Part::Copy` parts in `formatted` must contain valid UTF-8. + unsafe fn write_formatted_parts(&mut self, formatted: &numfmt::Formatted<'_>) -> Result { + unsafe fn write_bytes(buf: &mut dyn Write, s: &[u8]) -> Result { // SAFETY: This is used for `numfmt::Part::Num` and `numfmt::Part::Copy`. // It's safe to use for `numfmt::Part::Num` since every char `c` is between - // `b'0'` and `b'9'`, which means `s` is valid UTF-8. - // It's also probably safe in practice to use for `numfmt::Part::Copy(buf)` - // since `buf` should be plain ASCII, but it's possible for someone to pass - // in a bad value for `buf` into `numfmt::to_shortest_str` since it is a - // public function. - // FIXME: Determine whether this could result in UB. + // `b'0'` and `b'9'`, which means `s` is valid UTF-8. It's safe to use for + // `numfmt::Part::Copy` due to this function's precondition. buf.write_str(unsafe { str::from_utf8_unchecked(s) }) } @@ -1489,11 +1497,15 @@ impl<'a> Formatter<'a> { *c = b'0' + (v % 10) as u8; v /= 10; } - write_bytes(self.buf, &s[..len])?; + // SAFETY: Per the precondition. + unsafe { + write_bytes(self.buf, &s[..len])?; + } } - numfmt::Part::Copy(buf) => { + // SAFETY: Per the precondition. + numfmt::Part::Copy(buf) => unsafe { write_bytes(self.buf, buf)?; - } + }, } } Ok(()) diff --git a/library/core/src/fmt/num.rs b/library/core/src/fmt/num.rs index d8365ae9bf920..4f42f73ebbaff 100644 --- a/library/core/src/fmt/num.rs +++ b/library/core/src/fmt/num.rs @@ -52,8 +52,12 @@ impl_int! { i8 i16 i32 i64 i128 isize } impl_uint! { u8 u16 u32 u64 u128 usize } /// A type that represents a specific radix +/// +/// # Safety +/// +/// `digit` must return an ASCII character. #[doc(hidden)] -trait GenericRadix: Sized { +unsafe trait GenericRadix: Sized { /// The number of digits. const BASE: u8; @@ -129,7 +133,7 @@ struct UpperHex; macro_rules! radix { ($T:ident, $base:expr, $prefix:expr, $($x:pat => $conv:expr),+) => { - impl GenericRadix for $T { + unsafe impl GenericRadix for $T { const BASE: u8 = $base; const PREFIX: &'static str = $prefix; fn digit(x: u8) -> u8 { @@ -407,7 +411,7 @@ macro_rules! impl_Exp { let parts = &[ numfmt::Part::Copy(buf_slice), numfmt::Part::Zero(added_precision), - numfmt::Part::Copy(exp_slice) + numfmt::Part::Copy(exp_slice), ]; let sign = if !is_nonnegative { "-" @@ -416,8 +420,9 @@ macro_rules! impl_Exp { } else { "" }; - let formatted = numfmt::Formatted{sign, parts}; - f.pad_formatted_parts(&formatted) + let formatted = numfmt::Formatted { sign, parts }; + // SAFETY: `buf_slice` and `exp_slice` contain only ASCII characters. + unsafe { f.pad_formatted_parts(&formatted) } } $( diff --git a/library/std/src/path.rs b/library/std/src/path.rs index 43203c5824dad..febdeb514634c 100644 --- a/library/std/src/path.rs +++ b/library/std/src/path.rs @@ -733,8 +733,9 @@ impl<'a> Components<'a> { } } - // parse a given byte sequence into the corresponding path component - fn parse_single_component<'b>(&self, comp: &'b [u8]) -> Option> { + // parse a given byte sequence following the OsStr encoding into the + // corresponding path component + unsafe fn parse_single_component<'b>(&self, comp: &'b [u8]) -> Option> { match comp { b"." if self.prefix_verbatim() => Some(Component::CurDir), b"." => None, // . components are normalized away, except at @@ -754,7 +755,8 @@ impl<'a> Components<'a> { None => (0, self.path), Some(i) => (1, &self.path[..i]), }; - (comp.len() + extra, self.parse_single_component(comp)) + // SAFETY: `comp` is a valid substring, since it is split on a separator. + (comp.len() + extra, unsafe { self.parse_single_component(comp) }) } // parse a component from the right, saying how many bytes to consume to @@ -766,7 +768,8 @@ impl<'a> Components<'a> { None => (0, &self.path[start..]), Some(i) => (1, &self.path[start + i + 1..]), }; - (comp.len() + extra, self.parse_single_component(comp)) + // SAFETY: `comp` is a valid substring, since it is split on a separator. + (comp.len() + extra, unsafe { self.parse_single_component(comp) }) } // trim away repeated separators (i.e., empty components) on the left From 5ae51d69a30dd4da863072582842df0678c8c083 Mon Sep 17 00:00:00 2001 From: Maybe Waffle Date: Mon, 21 Nov 2022 13:44:52 +0000 Subject: [PATCH 03/13] `rustc_mir_build`: drive-by-cleanup: remove some local mutable state --- compiler/rustc_mir_build/src/build/scope.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/compiler/rustc_mir_build/src/build/scope.rs b/compiler/rustc_mir_build/src/build/scope.rs index 56c87c402fe2b..bd30973e2e157 100644 --- a/compiler/rustc_mir_build/src/build/scope.rs +++ b/compiler/rustc_mir_build/src/build/scope.rs @@ -671,12 +671,12 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { } else { self.scopes.breakable_scopes[break_index].continue_drops.as_mut().unwrap() }; - let mut drop_idx = ROOT_NODE; - for scope in &self.scopes.scopes[scope_index + 1..] { - for drop in &scope.drops { - drop_idx = drops.add_drop(*drop, drop_idx); - } - } + + let drop_idx = self.scopes.scopes[scope_index + 1..] + .iter() + .flat_map(|scope| &scope.drops) + .fold(ROOT_NODE, |drop_idx, &drop| drops.add_drop(drop, drop_idx)); + drops.add_entry(block, drop_idx); // `build_drop_trees` doesn't have access to our source_info, so we From 03d5f9b783149eb628015e3ba5cac0f651c3a702 Mon Sep 17 00:00:00 2001 From: Maybe Waffle Date: Mon, 21 Nov 2022 14:22:44 +0000 Subject: [PATCH 04/13] `rustc_mir_build`: drive-by-cleaup: replace nested ifs with a `match` --- compiler/rustc_mir_build/src/build/scope.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/compiler/rustc_mir_build/src/build/scope.rs b/compiler/rustc_mir_build/src/build/scope.rs index bd30973e2e157..b01b6fbf22259 100644 --- a/compiler/rustc_mir_build/src/build/scope.rs +++ b/compiler/rustc_mir_build/src/build/scope.rs @@ -644,24 +644,27 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { } }; - if let Some(destination) = destination { - if let Some(value) = value { + match (destination, value) { + (Some(destination), Some(value)) => { debug!("stmt_expr Break val block_context.push(SubExpr)"); self.block_context.push(BlockFrame::SubExpr); unpack!(block = self.expr_into_dest(destination, block, value)); self.block_context.pop(); - } else { + } + (Some(destination), None) => { self.cfg.push_assign_unit(block, source_info, destination, self.tcx) } - } else { - assert!(value.is_none(), "`return` and `break` should have a destination"); - if self.tcx.sess.instrument_coverage() { + (None, Some(_)) => { + panic!("`return`, `become` and `break` with value and must have a destination") + } + (None, None) if self.tcx.sess.instrument_coverage() => { // Unlike `break` and `return`, which push an `Assign` statement to MIR, from which // a Coverage code region can be generated, `continue` needs no `Assign`; but // without one, the `InstrumentCoverage` MIR pass cannot generate a code region for // `continue`. Coverage will be missing unless we add a dummy `Assign` to MIR. self.add_dummy_assignment(span, block, source_info); } + (None, None) => {} } let region_scope = self.scopes.breakable_scopes[break_index].region_scope; From f542778533f2f92c13822ec951c237d46d7a28ef Mon Sep 17 00:00:00 2001 From: Maybe Waffle Date: Tue, 9 May 2023 07:46:16 +0000 Subject: [PATCH 05/13] Drive-by cleanup: `debug::term_type` => `TerminatorKind::name` --- compiler/rustc_middle/src/mir/syntax.rs | 23 ++++++++++++++++ .../rustc_mir_transform/src/coverage/debug.rs | 27 +++---------------- .../rustc_mir_transform/src/coverage/spans.rs | 3 +-- .../rustc_mir_transform/src/coverage/tests.rs | 11 ++++---- 4 files changed, 32 insertions(+), 32 deletions(-) diff --git a/compiler/rustc_middle/src/mir/syntax.rs b/compiler/rustc_middle/src/mir/syntax.rs index 33b7fe0c2dc55..21faf1958e911 100644 --- a/compiler/rustc_middle/src/mir/syntax.rs +++ b/compiler/rustc_middle/src/mir/syntax.rs @@ -749,6 +749,29 @@ pub enum TerminatorKind<'tcx> { }, } +impl TerminatorKind<'_> { + /// Returns a simple string representation of a `TerminatorKind` variant, independent of any + /// values it might hold (e.g. `TerminatorKind::Call` always returns `"Call"`). + pub const fn name(&self) -> &'static str { + match self { + TerminatorKind::Goto { .. } => "Goto", + TerminatorKind::SwitchInt { .. } => "SwitchInt", + TerminatorKind::Resume => "Resume", + TerminatorKind::Terminate => "Terminate", + TerminatorKind::Return => "Return", + TerminatorKind::Unreachable => "Unreachable", + TerminatorKind::Drop { .. } => "Drop", + TerminatorKind::Call { .. } => "Call", + TerminatorKind::Assert { .. } => "Assert", + TerminatorKind::Yield { .. } => "Yield", + TerminatorKind::GeneratorDrop => "GeneratorDrop", + TerminatorKind::FalseEdge { .. } => "FalseEdge", + TerminatorKind::FalseUnwind { .. } => "FalseUnwind", + TerminatorKind::InlineAsm { .. } => "InlineAsm", + } + } +} + /// Action to be taken when a stack unwind happens. #[derive(Copy, Clone, Debug, PartialEq, Eq, TyEncodable, TyDecodable, Hash, HashStable)] #[derive(TypeFoldable, TypeVisitable)] diff --git a/compiler/rustc_mir_transform/src/coverage/debug.rs b/compiler/rustc_mir_transform/src/coverage/debug.rs index e554c47064680..35e4c24dc462b 100644 --- a/compiler/rustc_mir_transform/src/coverage/debug.rs +++ b/compiler/rustc_mir_transform/src/coverage/debug.rs @@ -118,7 +118,7 @@ use rustc_middle::mir::spanview::{self, SpanViewable}; use rustc_data_structures::fx::FxHashMap; use rustc_middle::mir::coverage::*; -use rustc_middle::mir::{self, BasicBlock, TerminatorKind}; +use rustc_middle::mir::{self, BasicBlock}; use rustc_middle::ty::TyCtxt; use rustc_span::Span; @@ -796,7 +796,7 @@ fn bcb_to_string_sections<'tcx>( } let non_term_blocks = bcb_data.basic_blocks[0..len - 1] .iter() - .map(|&bb| format!("{:?}: {}", bb, term_type(&mir_body[bb].terminator().kind))) + .map(|&bb| format!("{:?}: {}", bb, mir_body[bb].terminator().kind.name())) .collect::>(); if non_term_blocks.len() > 0 { sections.push(non_term_blocks.join("\n")); @@ -804,28 +804,7 @@ fn bcb_to_string_sections<'tcx>( sections.push(format!( "{:?}: {}", bcb_data.basic_blocks.last().unwrap(), - term_type(&bcb_data.terminator(mir_body).kind) + bcb_data.terminator(mir_body).kind.name(), )); sections } - -/// Returns a simple string representation of a `TerminatorKind` variant, independent of any -/// values it might hold. -pub(super) fn term_type(kind: &TerminatorKind<'_>) -> &'static str { - match kind { - TerminatorKind::Goto { .. } => "Goto", - TerminatorKind::SwitchInt { .. } => "SwitchInt", - TerminatorKind::Resume => "Resume", - TerminatorKind::Terminate => "Terminate", - TerminatorKind::Return => "Return", - TerminatorKind::Unreachable => "Unreachable", - TerminatorKind::Drop { .. } => "Drop", - TerminatorKind::Call { .. } => "Call", - TerminatorKind::Assert { .. } => "Assert", - TerminatorKind::Yield { .. } => "Yield", - TerminatorKind::GeneratorDrop => "GeneratorDrop", - TerminatorKind::FalseEdge { .. } => "FalseEdge", - TerminatorKind::FalseUnwind { .. } => "FalseUnwind", - TerminatorKind::InlineAsm { .. } => "InlineAsm", - } -} diff --git a/compiler/rustc_mir_transform/src/coverage/spans.rs b/compiler/rustc_mir_transform/src/coverage/spans.rs index 287ae2170875f..14937912cc599 100644 --- a/compiler/rustc_mir_transform/src/coverage/spans.rs +++ b/compiler/rustc_mir_transform/src/coverage/spans.rs @@ -1,4 +1,3 @@ -use super::debug::term_type; use super::graph::{BasicCoverageBlock, BasicCoverageBlockData, CoverageGraph, START_BCB}; use itertools::Itertools; @@ -40,7 +39,7 @@ impl CoverageStatement { "{}: @{}.{}: {:?}", source_range_no_file(tcx, span), bb.index(), - term_type(&term.kind), + term.kind.name(), term.kind ) } diff --git a/compiler/rustc_mir_transform/src/coverage/tests.rs b/compiler/rustc_mir_transform/src/coverage/tests.rs index 83a335197b343..90b58933df7c0 100644 --- a/compiler/rustc_mir_transform/src/coverage/tests.rs +++ b/compiler/rustc_mir_transform/src/coverage/tests.rs @@ -25,7 +25,6 @@ //! to: `rustc_span::create_default_session_globals_then(|| { test_here(); })`. use super::counters; -use super::debug; use super::graph; use super::spans; @@ -188,12 +187,12 @@ fn debug_basic_blocks(mir_body: &Body<'_>) -> String { | TerminatorKind::Goto { target } | TerminatorKind::InlineAsm { destination: Some(target), .. } | TerminatorKind::Yield { resume: target, .. } => { - format!("{}{:?}:{} -> {:?}", sp, bb, debug::term_type(kind), target) + format!("{}{:?}:{} -> {:?}", sp, bb, kind.name(), target) } TerminatorKind::SwitchInt { targets, .. } => { - format!("{}{:?}:{} -> {:?}", sp, bb, debug::term_type(kind), targets) + format!("{}{:?}:{} -> {:?}", sp, bb, kind.name(), targets) } - _ => format!("{}{:?}:{}", sp, bb, debug::term_type(kind)), + _ => format!("{}{:?}:{}", sp, bb, kind.name()), } }) .collect::>() @@ -215,7 +214,7 @@ fn print_mir_graphviz(name: &str, mir_body: &Body<'_>) { " {:?} [label=\"{:?}: {}\"];\n{}", bb, bb, - debug::term_type(&data.terminator().kind), + data.terminator().kind.name(), mir_body .basic_blocks .successors(bb) @@ -244,7 +243,7 @@ fn print_coverage_graphviz( " {:?} [label=\"{:?}: {}\"];\n{}", bcb, bcb, - debug::term_type(&bcb_data.terminator(mir_body).kind), + bcb_data.terminator(mir_body).kind.name(), basic_coverage_blocks .successors(bcb) .map(|successor| { format!(" {:?} -> {:?};", bcb, successor) }) From 140cdcbc9d50713143f8d1f2403d9044eb0a528f Mon Sep 17 00:00:00 2001 From: Maybe Waffle Date: Tue, 9 May 2023 12:42:39 +0000 Subject: [PATCH 06/13] Drive-by-cleanup: Don't emit `thir::ExprKind::NeverToAny` for `! -> !` --- compiler/rustc_mir_build/src/thir/cx/expr.rs | 1 + src/tools/miri/tests/fail/never_say_never.rs | 6 ++--- .../miri/tests/fail/never_say_never.stderr | 4 ++-- ...smute.unreachable_box.ConstProp.32bit.diff | 14 +++++------- ...smute.unreachable_box.ConstProp.64bit.diff | 14 +++++------- ...te.unreachable_direct.ConstProp.32bit.diff | 17 ++++++-------- ...te.unreachable_direct.ConstProp.64bit.diff | 17 ++++++-------- ...smute.unreachable_mut.ConstProp.32bit.diff | 22 ++++++++----------- ...smute.unreachable_mut.ConstProp.64bit.diff | 22 ++++++++----------- ...smute.unreachable_ref.ConstProp.32bit.diff | 14 +++++------- ...smute.unreachable_ref.ConstProp.64bit.diff | 14 +++++------- tests/mir-opt/issue_72181_1.f.built.after.mir | 14 ------------ ...te_to_box_uninhabited.LowerIntrinsics.diff | 14 +++++------- ...te_to_mut_uninhabited.LowerIntrinsics.diff | 14 +++++------- ...te_to_ref_uninhabited.LowerIntrinsics.diff | 14 +++++------- ...ntrinsics.unreachable.LowerIntrinsics.diff | 11 +++++----- 16 files changed, 77 insertions(+), 135 deletions(-) diff --git a/compiler/rustc_mir_build/src/thir/cx/expr.rs b/compiler/rustc_mir_build/src/thir/cx/expr.rs index f46eb5a0ce18d..c8648224ac1e8 100644 --- a/compiler/rustc_mir_build/src/thir/cx/expr.rs +++ b/compiler/rustc_mir_build/src/thir/cx/expr.rs @@ -130,6 +130,7 @@ impl<'tcx> Cx<'tcx> { ExprKind::Pointer { cast: PointerCast::Unsize, source: self.thir.exprs.push(expr) } } Adjust::Pointer(cast) => ExprKind::Pointer { cast, source: self.thir.exprs.push(expr) }, + Adjust::NeverToAny if adjustment.target.is_never() => return expr, Adjust::NeverToAny => ExprKind::NeverToAny { source: self.thir.exprs.push(expr) }, Adjust::Deref(None) => { adjust_span(&mut expr); diff --git a/src/tools/miri/tests/fail/never_say_never.rs b/src/tools/miri/tests/fail/never_say_never.rs index f6d3dc790bf00..fd082e367a83a 100644 --- a/src/tools/miri/tests/fail/never_say_never.rs +++ b/src/tools/miri/tests/fail/never_say_never.rs @@ -6,10 +6,8 @@ fn main() { let y = &5; - let x: ! = unsafe { - *(y as *const _ as *const !) //~ ERROR: entering unreachable code - }; - f(x) + let x: ! = unsafe { *(y as *const _ as *const !) }; + f(x) //~ ERROR: entering unreachable code } fn f(x: !) -> ! { diff --git a/src/tools/miri/tests/fail/never_say_never.stderr b/src/tools/miri/tests/fail/never_say_never.stderr index a2a63b8baf594..9d3a8df525a49 100644 --- a/src/tools/miri/tests/fail/never_say_never.stderr +++ b/src/tools/miri/tests/fail/never_say_never.stderr @@ -1,8 +1,8 @@ error: Undefined Behavior: entering unreachable code --> $DIR/never_say_never.rs:LL:CC | -LL | *(y as *const _ as *const !) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ entering unreachable code +LL | f(x) + | ^^^^ entering unreachable code | = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information diff --git a/tests/mir-opt/const_prop/transmute.unreachable_box.ConstProp.32bit.diff b/tests/mir-opt/const_prop/transmute.unreachable_box.ConstProp.32bit.diff index bc41b5d08131e..5258d75bdf786 100644 --- a/tests/mir-opt/const_prop/transmute.unreachable_box.ConstProp.32bit.diff +++ b/tests/mir-opt/const_prop/transmute.unreachable_box.ConstProp.32bit.diff @@ -3,24 +3,20 @@ fn unreachable_box() -> ! { let mut _0: !; // return place in scope 0 at $DIR/transmute.rs:+0:36: +0:37 - let mut _1: !; // in scope 0 at $DIR/transmute.rs:+0:38: +3:2 - let _2: std::boxed::Box; // in scope 0 at $DIR/transmute.rs:+1:9: +1:10 - let mut _3: !; // in scope 0 at $DIR/transmute.rs:+2:5: +2:16 + let _1: std::boxed::Box; // in scope 0 at $DIR/transmute.rs:+1:9: +1:10 scope 1 { - debug x => _2; // in scope 1 at $DIR/transmute.rs:+1:9: +1:10 + debug x => _1; // in scope 1 at $DIR/transmute.rs:+1:9: +1:10 } scope 2 { } bb0: { - StorageLive(_1); // scope 0 at $DIR/transmute.rs:+0:38: +3:2 - StorageLive(_2); // scope 0 at $DIR/transmute.rs:+1:9: +1:10 -- _2 = const 1_usize as std::boxed::Box (Transmute); // scope 2 at $DIR/transmute.rs:+1:34: +1:52 -+ _2 = const Box::(Unique:: {{ pointer: NonNull:: {{ pointer: {0x1 as *const Never} }}, _marker: PhantomData:: }}, std::alloc::Global); // scope 2 at $DIR/transmute.rs:+1:34: +1:52 + StorageLive(_1); // scope 0 at $DIR/transmute.rs:+1:9: +1:10 +- _1 = const 1_usize as std::boxed::Box (Transmute); // scope 2 at $DIR/transmute.rs:+1:34: +1:52 ++ _1 = const Box::(Unique:: {{ pointer: NonNull:: {{ pointer: {0x1 as *const Never} }}, _marker: PhantomData:: }}, std::alloc::Global); // scope 2 at $DIR/transmute.rs:+1:34: +1:52 + // mir::Constant + // + span: no-location + // + literal: Const { ty: Box, val: Value(Scalar(0x00000001)) } - StorageLive(_3); // scope 1 at $DIR/transmute.rs:+2:5: +2:16 unreachable; // scope 1 at $DIR/transmute.rs:+2:11: +2:13 } } diff --git a/tests/mir-opt/const_prop/transmute.unreachable_box.ConstProp.64bit.diff b/tests/mir-opt/const_prop/transmute.unreachable_box.ConstProp.64bit.diff index c4376e6e17afc..7e57e06a5cf8b 100644 --- a/tests/mir-opt/const_prop/transmute.unreachable_box.ConstProp.64bit.diff +++ b/tests/mir-opt/const_prop/transmute.unreachable_box.ConstProp.64bit.diff @@ -3,24 +3,20 @@ fn unreachable_box() -> ! { let mut _0: !; // return place in scope 0 at $DIR/transmute.rs:+0:36: +0:37 - let mut _1: !; // in scope 0 at $DIR/transmute.rs:+0:38: +3:2 - let _2: std::boxed::Box; // in scope 0 at $DIR/transmute.rs:+1:9: +1:10 - let mut _3: !; // in scope 0 at $DIR/transmute.rs:+2:5: +2:16 + let _1: std::boxed::Box; // in scope 0 at $DIR/transmute.rs:+1:9: +1:10 scope 1 { - debug x => _2; // in scope 1 at $DIR/transmute.rs:+1:9: +1:10 + debug x => _1; // in scope 1 at $DIR/transmute.rs:+1:9: +1:10 } scope 2 { } bb0: { - StorageLive(_1); // scope 0 at $DIR/transmute.rs:+0:38: +3:2 - StorageLive(_2); // scope 0 at $DIR/transmute.rs:+1:9: +1:10 -- _2 = const 1_usize as std::boxed::Box (Transmute); // scope 2 at $DIR/transmute.rs:+1:34: +1:52 -+ _2 = const Box::(Unique:: {{ pointer: NonNull:: {{ pointer: {0x1 as *const Never} }}, _marker: PhantomData:: }}, std::alloc::Global); // scope 2 at $DIR/transmute.rs:+1:34: +1:52 + StorageLive(_1); // scope 0 at $DIR/transmute.rs:+1:9: +1:10 +- _1 = const 1_usize as std::boxed::Box (Transmute); // scope 2 at $DIR/transmute.rs:+1:34: +1:52 ++ _1 = const Box::(Unique:: {{ pointer: NonNull:: {{ pointer: {0x1 as *const Never} }}, _marker: PhantomData:: }}, std::alloc::Global); // scope 2 at $DIR/transmute.rs:+1:34: +1:52 + // mir::Constant + // + span: no-location + // + literal: Const { ty: Box, val: Value(Scalar(0x0000000000000001)) } - StorageLive(_3); // scope 1 at $DIR/transmute.rs:+2:5: +2:16 unreachable; // scope 1 at $DIR/transmute.rs:+2:11: +2:13 } } diff --git a/tests/mir-opt/const_prop/transmute.unreachable_direct.ConstProp.32bit.diff b/tests/mir-opt/const_prop/transmute.unreachable_direct.ConstProp.32bit.diff index 81b7b36899309..032681f230ba6 100644 --- a/tests/mir-opt/const_prop/transmute.unreachable_direct.ConstProp.32bit.diff +++ b/tests/mir-opt/const_prop/transmute.unreachable_direct.ConstProp.32bit.diff @@ -3,22 +3,19 @@ fn unreachable_direct() -> ! { let mut _0: !; // return place in scope 0 at $DIR/transmute.rs:+0:39: +0:40 - let mut _1: !; // in scope 0 at $DIR/transmute.rs:+0:41: +3:2 - let _2: Never; // in scope 0 at $DIR/transmute.rs:+1:9: +1:10 - let mut _3: (); // in scope 0 at $DIR/transmute.rs:+1:39: +1:41 - let mut _4: !; // in scope 0 at $DIR/transmute.rs:+2:5: +2:15 + let _1: Never; // in scope 0 at $DIR/transmute.rs:+1:9: +1:10 + let mut _2: (); // in scope 0 at $DIR/transmute.rs:+1:39: +1:41 scope 1 { - debug x => _2; // in scope 1 at $DIR/transmute.rs:+1:9: +1:10 + debug x => _1; // in scope 1 at $DIR/transmute.rs:+1:9: +1:10 } scope 2 { } bb0: { - StorageLive(_1); // scope 0 at $DIR/transmute.rs:+0:41: +3:2 - StorageLive(_2); // scope 0 at $DIR/transmute.rs:+1:9: +1:10 - StorageLive(_3); // scope 2 at $DIR/transmute.rs:+1:39: +1:41 - _3 = (); // scope 2 at $DIR/transmute.rs:+1:39: +1:41 - _2 = move _3 as Never (Transmute); // scope 2 at $DIR/transmute.rs:+1:29: +1:42 + StorageLive(_1); // scope 0 at $DIR/transmute.rs:+1:9: +1:10 + StorageLive(_2); // scope 2 at $DIR/transmute.rs:+1:39: +1:41 + _2 = (); // scope 2 at $DIR/transmute.rs:+1:39: +1:41 + _1 = move _2 as Never (Transmute); // scope 2 at $DIR/transmute.rs:+1:29: +1:42 unreachable; // scope 2 at $DIR/transmute.rs:+1:29: +1:42 } } diff --git a/tests/mir-opt/const_prop/transmute.unreachable_direct.ConstProp.64bit.diff b/tests/mir-opt/const_prop/transmute.unreachable_direct.ConstProp.64bit.diff index 81b7b36899309..032681f230ba6 100644 --- a/tests/mir-opt/const_prop/transmute.unreachable_direct.ConstProp.64bit.diff +++ b/tests/mir-opt/const_prop/transmute.unreachable_direct.ConstProp.64bit.diff @@ -3,22 +3,19 @@ fn unreachable_direct() -> ! { let mut _0: !; // return place in scope 0 at $DIR/transmute.rs:+0:39: +0:40 - let mut _1: !; // in scope 0 at $DIR/transmute.rs:+0:41: +3:2 - let _2: Never; // in scope 0 at $DIR/transmute.rs:+1:9: +1:10 - let mut _3: (); // in scope 0 at $DIR/transmute.rs:+1:39: +1:41 - let mut _4: !; // in scope 0 at $DIR/transmute.rs:+2:5: +2:15 + let _1: Never; // in scope 0 at $DIR/transmute.rs:+1:9: +1:10 + let mut _2: (); // in scope 0 at $DIR/transmute.rs:+1:39: +1:41 scope 1 { - debug x => _2; // in scope 1 at $DIR/transmute.rs:+1:9: +1:10 + debug x => _1; // in scope 1 at $DIR/transmute.rs:+1:9: +1:10 } scope 2 { } bb0: { - StorageLive(_1); // scope 0 at $DIR/transmute.rs:+0:41: +3:2 - StorageLive(_2); // scope 0 at $DIR/transmute.rs:+1:9: +1:10 - StorageLive(_3); // scope 2 at $DIR/transmute.rs:+1:39: +1:41 - _3 = (); // scope 2 at $DIR/transmute.rs:+1:39: +1:41 - _2 = move _3 as Never (Transmute); // scope 2 at $DIR/transmute.rs:+1:29: +1:42 + StorageLive(_1); // scope 0 at $DIR/transmute.rs:+1:9: +1:10 + StorageLive(_2); // scope 2 at $DIR/transmute.rs:+1:39: +1:41 + _2 = (); // scope 2 at $DIR/transmute.rs:+1:39: +1:41 + _1 = move _2 as Never (Transmute); // scope 2 at $DIR/transmute.rs:+1:29: +1:42 unreachable; // scope 2 at $DIR/transmute.rs:+1:29: +1:42 } } diff --git a/tests/mir-opt/const_prop/transmute.unreachable_mut.ConstProp.32bit.diff b/tests/mir-opt/const_prop/transmute.unreachable_mut.ConstProp.32bit.diff index 47f023cd93dd0..ec8a62bd62cd6 100644 --- a/tests/mir-opt/const_prop/transmute.unreachable_mut.ConstProp.32bit.diff +++ b/tests/mir-opt/const_prop/transmute.unreachable_mut.ConstProp.32bit.diff @@ -3,28 +3,24 @@ fn unreachable_mut() -> ! { let mut _0: !; // return place in scope 0 at $DIR/transmute.rs:+0:36: +0:37 - let mut _1: !; // in scope 0 at $DIR/transmute.rs:+0:38: +3:2 - let _2: &mut Never; // in scope 0 at $DIR/transmute.rs:+1:9: +1:10 - let mut _3: &mut Never; // in scope 0 at $DIR/transmute.rs:+1:34: +1:52 - let mut _4: !; // in scope 0 at $DIR/transmute.rs:+2:5: +2:16 + let _1: &mut Never; // in scope 0 at $DIR/transmute.rs:+1:9: +1:10 + let mut _2: &mut Never; // in scope 0 at $DIR/transmute.rs:+1:34: +1:52 scope 1 { - debug x => _2; // in scope 1 at $DIR/transmute.rs:+1:9: +1:10 + debug x => _1; // in scope 1 at $DIR/transmute.rs:+1:9: +1:10 } scope 2 { } bb0: { - StorageLive(_1); // scope 0 at $DIR/transmute.rs:+0:38: +3:2 - StorageLive(_2); // scope 0 at $DIR/transmute.rs:+1:9: +1:10 - StorageLive(_3); // scope 0 at $DIR/transmute.rs:+1:34: +1:52 -- _3 = const 1_usize as &mut Never (Transmute); // scope 2 at $DIR/transmute.rs:+1:34: +1:52 -+ _3 = const {0x1 as &mut Never}; // scope 2 at $DIR/transmute.rs:+1:34: +1:52 + StorageLive(_1); // scope 0 at $DIR/transmute.rs:+1:9: +1:10 + StorageLive(_2); // scope 0 at $DIR/transmute.rs:+1:34: +1:52 +- _2 = const 1_usize as &mut Never (Transmute); // scope 2 at $DIR/transmute.rs:+1:34: +1:52 ++ _2 = const {0x1 as &mut Never}; // scope 2 at $DIR/transmute.rs:+1:34: +1:52 + // mir::Constant + // + span: no-location + // + literal: Const { ty: &mut Never, val: Value(Scalar(0x00000001)) } - _2 = &mut (*_3); // scope 0 at $DIR/transmute.rs:+1:34: +1:52 - StorageDead(_3); // scope 0 at $DIR/transmute.rs:+1:54: +1:55 - StorageLive(_4); // scope 1 at $DIR/transmute.rs:+2:5: +2:16 + _1 = &mut (*_2); // scope 0 at $DIR/transmute.rs:+1:34: +1:52 + StorageDead(_2); // scope 0 at $DIR/transmute.rs:+1:54: +1:55 unreachable; // scope 1 at $DIR/transmute.rs:+2:11: +2:13 } } diff --git a/tests/mir-opt/const_prop/transmute.unreachable_mut.ConstProp.64bit.diff b/tests/mir-opt/const_prop/transmute.unreachable_mut.ConstProp.64bit.diff index 62300d2e313b3..288da6e56c53c 100644 --- a/tests/mir-opt/const_prop/transmute.unreachable_mut.ConstProp.64bit.diff +++ b/tests/mir-opt/const_prop/transmute.unreachable_mut.ConstProp.64bit.diff @@ -3,28 +3,24 @@ fn unreachable_mut() -> ! { let mut _0: !; // return place in scope 0 at $DIR/transmute.rs:+0:36: +0:37 - let mut _1: !; // in scope 0 at $DIR/transmute.rs:+0:38: +3:2 - let _2: &mut Never; // in scope 0 at $DIR/transmute.rs:+1:9: +1:10 - let mut _3: &mut Never; // in scope 0 at $DIR/transmute.rs:+1:34: +1:52 - let mut _4: !; // in scope 0 at $DIR/transmute.rs:+2:5: +2:16 + let _1: &mut Never; // in scope 0 at $DIR/transmute.rs:+1:9: +1:10 + let mut _2: &mut Never; // in scope 0 at $DIR/transmute.rs:+1:34: +1:52 scope 1 { - debug x => _2; // in scope 1 at $DIR/transmute.rs:+1:9: +1:10 + debug x => _1; // in scope 1 at $DIR/transmute.rs:+1:9: +1:10 } scope 2 { } bb0: { - StorageLive(_1); // scope 0 at $DIR/transmute.rs:+0:38: +3:2 - StorageLive(_2); // scope 0 at $DIR/transmute.rs:+1:9: +1:10 - StorageLive(_3); // scope 0 at $DIR/transmute.rs:+1:34: +1:52 -- _3 = const 1_usize as &mut Never (Transmute); // scope 2 at $DIR/transmute.rs:+1:34: +1:52 -+ _3 = const {0x1 as &mut Never}; // scope 2 at $DIR/transmute.rs:+1:34: +1:52 + StorageLive(_1); // scope 0 at $DIR/transmute.rs:+1:9: +1:10 + StorageLive(_2); // scope 0 at $DIR/transmute.rs:+1:34: +1:52 +- _2 = const 1_usize as &mut Never (Transmute); // scope 2 at $DIR/transmute.rs:+1:34: +1:52 ++ _2 = const {0x1 as &mut Never}; // scope 2 at $DIR/transmute.rs:+1:34: +1:52 + // mir::Constant + // + span: no-location + // + literal: Const { ty: &mut Never, val: Value(Scalar(0x0000000000000001)) } - _2 = &mut (*_3); // scope 0 at $DIR/transmute.rs:+1:34: +1:52 - StorageDead(_3); // scope 0 at $DIR/transmute.rs:+1:54: +1:55 - StorageLive(_4); // scope 1 at $DIR/transmute.rs:+2:5: +2:16 + _1 = &mut (*_2); // scope 0 at $DIR/transmute.rs:+1:34: +1:52 + StorageDead(_2); // scope 0 at $DIR/transmute.rs:+1:54: +1:55 unreachable; // scope 1 at $DIR/transmute.rs:+2:11: +2:13 } } diff --git a/tests/mir-opt/const_prop/transmute.unreachable_ref.ConstProp.32bit.diff b/tests/mir-opt/const_prop/transmute.unreachable_ref.ConstProp.32bit.diff index 8578f898a7eee..dcca0fca619b0 100644 --- a/tests/mir-opt/const_prop/transmute.unreachable_ref.ConstProp.32bit.diff +++ b/tests/mir-opt/const_prop/transmute.unreachable_ref.ConstProp.32bit.diff @@ -3,24 +3,20 @@ fn unreachable_ref() -> ! { let mut _0: !; // return place in scope 0 at $DIR/transmute.rs:+0:36: +0:37 - let mut _1: !; // in scope 0 at $DIR/transmute.rs:+0:38: +3:2 - let _2: &Never; // in scope 0 at $DIR/transmute.rs:+1:9: +1:10 - let mut _3: !; // in scope 0 at $DIR/transmute.rs:+2:5: +2:16 + let _1: &Never; // in scope 0 at $DIR/transmute.rs:+1:9: +1:10 scope 1 { - debug x => _2; // in scope 1 at $DIR/transmute.rs:+1:9: +1:10 + debug x => _1; // in scope 1 at $DIR/transmute.rs:+1:9: +1:10 } scope 2 { } bb0: { - StorageLive(_1); // scope 0 at $DIR/transmute.rs:+0:38: +3:2 - StorageLive(_2); // scope 0 at $DIR/transmute.rs:+1:9: +1:10 -- _2 = const 1_usize as &Never (Transmute); // scope 2 at $DIR/transmute.rs:+1:30: +1:48 -+ _2 = const {0x1 as &Never}; // scope 2 at $DIR/transmute.rs:+1:30: +1:48 + StorageLive(_1); // scope 0 at $DIR/transmute.rs:+1:9: +1:10 +- _1 = const 1_usize as &Never (Transmute); // scope 2 at $DIR/transmute.rs:+1:30: +1:48 ++ _1 = const {0x1 as &Never}; // scope 2 at $DIR/transmute.rs:+1:30: +1:48 + // mir::Constant + // + span: no-location + // + literal: Const { ty: &Never, val: Value(Scalar(0x00000001)) } - StorageLive(_3); // scope 1 at $DIR/transmute.rs:+2:5: +2:16 unreachable; // scope 1 at $DIR/transmute.rs:+2:11: +2:13 } } diff --git a/tests/mir-opt/const_prop/transmute.unreachable_ref.ConstProp.64bit.diff b/tests/mir-opt/const_prop/transmute.unreachable_ref.ConstProp.64bit.diff index 8b11cea93658d..3a0b967e66f1a 100644 --- a/tests/mir-opt/const_prop/transmute.unreachable_ref.ConstProp.64bit.diff +++ b/tests/mir-opt/const_prop/transmute.unreachable_ref.ConstProp.64bit.diff @@ -3,24 +3,20 @@ fn unreachable_ref() -> ! { let mut _0: !; // return place in scope 0 at $DIR/transmute.rs:+0:36: +0:37 - let mut _1: !; // in scope 0 at $DIR/transmute.rs:+0:38: +3:2 - let _2: &Never; // in scope 0 at $DIR/transmute.rs:+1:9: +1:10 - let mut _3: !; // in scope 0 at $DIR/transmute.rs:+2:5: +2:16 + let _1: &Never; // in scope 0 at $DIR/transmute.rs:+1:9: +1:10 scope 1 { - debug x => _2; // in scope 1 at $DIR/transmute.rs:+1:9: +1:10 + debug x => _1; // in scope 1 at $DIR/transmute.rs:+1:9: +1:10 } scope 2 { } bb0: { - StorageLive(_1); // scope 0 at $DIR/transmute.rs:+0:38: +3:2 - StorageLive(_2); // scope 0 at $DIR/transmute.rs:+1:9: +1:10 -- _2 = const 1_usize as &Never (Transmute); // scope 2 at $DIR/transmute.rs:+1:30: +1:48 -+ _2 = const {0x1 as &Never}; // scope 2 at $DIR/transmute.rs:+1:30: +1:48 + StorageLive(_1); // scope 0 at $DIR/transmute.rs:+1:9: +1:10 +- _1 = const 1_usize as &Never (Transmute); // scope 2 at $DIR/transmute.rs:+1:30: +1:48 ++ _1 = const {0x1 as &Never}; // scope 2 at $DIR/transmute.rs:+1:30: +1:48 + // mir::Constant + // + span: no-location + // + literal: Const { ty: &Never, val: Value(Scalar(0x0000000000000001)) } - StorageLive(_3); // scope 1 at $DIR/transmute.rs:+2:5: +2:16 unreachable; // scope 1 at $DIR/transmute.rs:+2:11: +2:13 } } diff --git a/tests/mir-opt/issue_72181_1.f.built.after.mir b/tests/mir-opt/issue_72181_1.f.built.after.mir index 4086da5201134..25f472251137d 100644 --- a/tests/mir-opt/issue_72181_1.f.built.after.mir +++ b/tests/mir-opt/issue_72181_1.f.built.after.mir @@ -3,27 +3,13 @@ fn f(_1: Void) -> ! { debug v => _1; // in scope 0 at $DIR/issue_72181_1.rs:+0:6: +0:7 let mut _0: !; // return place in scope 0 at $DIR/issue_72181_1.rs:+0:18: +0:19 - let mut _2: !; // in scope 0 at $DIR/issue_72181_1.rs:+0:20: +2:2 - let mut _3: !; // in scope 0 at $DIR/issue_72181_1.rs:+1:5: +1:15 bb0: { - StorageLive(_2); // scope 0 at $DIR/issue_72181_1.rs:+0:20: +2:2 - StorageLive(_3); // scope 0 at $DIR/issue_72181_1.rs:+1:5: +1:15 FakeRead(ForMatchedPlace(None), _1); // scope 0 at $DIR/issue_72181_1.rs:+1:11: +1:12 unreachable; // scope 0 at $DIR/issue_72181_1.rs:+1:11: +1:12 } bb1: { - unreachable; // scope 0 at $DIR/issue_72181_1.rs:+1:5: +1:15 - } - - bb2: { - StorageDead(_3); // scope 0 at $DIR/issue_72181_1.rs:+1:14: +1:15 - unreachable; // scope 0 at $DIR/issue_72181_1.rs:+0:20: +2:2 - } - - bb3: { - StorageDead(_2); // scope 0 at $DIR/issue_72181_1.rs:+2:1: +2:2 return; // scope 0 at $DIR/issue_72181_1.rs:+2:2: +2:2 } } diff --git a/tests/mir-opt/lower_intrinsics.transmute_to_box_uninhabited.LowerIntrinsics.diff b/tests/mir-opt/lower_intrinsics.transmute_to_box_uninhabited.LowerIntrinsics.diff index 8735a7500603d..aa5d9619d10a9 100644 --- a/tests/mir-opt/lower_intrinsics.transmute_to_box_uninhabited.LowerIntrinsics.diff +++ b/tests/mir-opt/lower_intrinsics.transmute_to_box_uninhabited.LowerIntrinsics.diff @@ -3,26 +3,22 @@ fn transmute_to_box_uninhabited() -> ! { let mut _0: !; // return place in scope 0 at $DIR/lower_intrinsics.rs:+0:49: +0:50 - let mut _1: !; // in scope 0 at $DIR/lower_intrinsics.rs:+0:51: +3:2 - let _2: std::boxed::Box; // in scope 0 at $DIR/lower_intrinsics.rs:+1:9: +1:10 - let mut _3: !; // in scope 0 at $DIR/lower_intrinsics.rs:+2:5: +2:16 + let _1: std::boxed::Box; // in scope 0 at $DIR/lower_intrinsics.rs:+1:9: +1:10 scope 1 { - debug x => _2; // in scope 1 at $DIR/lower_intrinsics.rs:+1:9: +1:10 + debug x => _1; // in scope 1 at $DIR/lower_intrinsics.rs:+1:9: +1:10 } bb0: { - StorageLive(_1); // scope 0 at $DIR/lower_intrinsics.rs:+0:51: +3:2 - StorageLive(_2); // scope 0 at $DIR/lower_intrinsics.rs:+1:9: +1:10 -- _2 = transmute::>(const 1_usize) -> [return: bb1, unwind unreachable]; // scope 0 at $DIR/lower_intrinsics.rs:+1:25: +1:52 + StorageLive(_1); // scope 0 at $DIR/lower_intrinsics.rs:+1:9: +1:10 +- _1 = transmute::>(const 1_usize) -> [return: bb1, unwind unreachable]; // scope 0 at $DIR/lower_intrinsics.rs:+1:25: +1:52 - // mir::Constant - // + span: $DIR/lower_intrinsics.rs:70:25: 70:44 - // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(usize) -> Box {transmute::>}, val: Value() } -+ _2 = const 1_usize as std::boxed::Box (Transmute); // scope 0 at $DIR/lower_intrinsics.rs:+1:25: +1:52 ++ _1 = const 1_usize as std::boxed::Box (Transmute); // scope 0 at $DIR/lower_intrinsics.rs:+1:25: +1:52 + goto -> bb1; // scope 0 at $DIR/lower_intrinsics.rs:+1:25: +1:52 } bb1: { - StorageLive(_3); // scope 1 at $DIR/lower_intrinsics.rs:+2:5: +2:16 unreachable; // scope 1 at $DIR/lower_intrinsics.rs:+2:11: +2:13 } } diff --git a/tests/mir-opt/lower_intrinsics.transmute_to_mut_uninhabited.LowerIntrinsics.diff b/tests/mir-opt/lower_intrinsics.transmute_to_mut_uninhabited.LowerIntrinsics.diff index a772132770c36..5fafd45fe8526 100644 --- a/tests/mir-opt/lower_intrinsics.transmute_to_mut_uninhabited.LowerIntrinsics.diff +++ b/tests/mir-opt/lower_intrinsics.transmute_to_mut_uninhabited.LowerIntrinsics.diff @@ -3,26 +3,22 @@ fn transmute_to_mut_uninhabited() -> ! { let mut _0: !; // return place in scope 0 at $DIR/lower_intrinsics.rs:+0:49: +0:50 - let mut _1: !; // in scope 0 at $DIR/lower_intrinsics.rs:+0:51: +3:2 - let _2: &mut Never; // in scope 0 at $DIR/lower_intrinsics.rs:+1:9: +1:10 - let mut _3: !; // in scope 0 at $DIR/lower_intrinsics.rs:+2:5: +2:16 + let _1: &mut Never; // in scope 0 at $DIR/lower_intrinsics.rs:+1:9: +1:10 scope 1 { - debug x => _2; // in scope 1 at $DIR/lower_intrinsics.rs:+1:9: +1:10 + debug x => _1; // in scope 1 at $DIR/lower_intrinsics.rs:+1:9: +1:10 } bb0: { - StorageLive(_1); // scope 0 at $DIR/lower_intrinsics.rs:+0:51: +3:2 - StorageLive(_2); // scope 0 at $DIR/lower_intrinsics.rs:+1:9: +1:10 -- _2 = transmute::(const 1_usize) -> [return: bb1, unwind unreachable]; // scope 0 at $DIR/lower_intrinsics.rs:+1:25: +1:52 + StorageLive(_1); // scope 0 at $DIR/lower_intrinsics.rs:+1:9: +1:10 +- _1 = transmute::(const 1_usize) -> [return: bb1, unwind unreachable]; // scope 0 at $DIR/lower_intrinsics.rs:+1:25: +1:52 - // mir::Constant - // + span: $DIR/lower_intrinsics.rs:64:25: 64:44 - // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(usize) -> &mut Never {transmute::}, val: Value() } -+ _2 = const 1_usize as &mut Never (Transmute); // scope 0 at $DIR/lower_intrinsics.rs:+1:25: +1:52 ++ _1 = const 1_usize as &mut Never (Transmute); // scope 0 at $DIR/lower_intrinsics.rs:+1:25: +1:52 + goto -> bb1; // scope 0 at $DIR/lower_intrinsics.rs:+1:25: +1:52 } bb1: { - StorageLive(_3); // scope 1 at $DIR/lower_intrinsics.rs:+2:5: +2:16 unreachable; // scope 1 at $DIR/lower_intrinsics.rs:+2:11: +2:13 } } diff --git a/tests/mir-opt/lower_intrinsics.transmute_to_ref_uninhabited.LowerIntrinsics.diff b/tests/mir-opt/lower_intrinsics.transmute_to_ref_uninhabited.LowerIntrinsics.diff index c4d53d4e8c748..08dead1321194 100644 --- a/tests/mir-opt/lower_intrinsics.transmute_to_ref_uninhabited.LowerIntrinsics.diff +++ b/tests/mir-opt/lower_intrinsics.transmute_to_ref_uninhabited.LowerIntrinsics.diff @@ -3,26 +3,22 @@ fn transmute_to_ref_uninhabited() -> ! { let mut _0: !; // return place in scope 0 at $DIR/lower_intrinsics.rs:+0:49: +0:50 - let mut _1: !; // in scope 0 at $DIR/lower_intrinsics.rs:+0:51: +3:2 - let _2: &Never; // in scope 0 at $DIR/lower_intrinsics.rs:+1:9: +1:10 - let mut _3: !; // in scope 0 at $DIR/lower_intrinsics.rs:+2:5: +2:16 + let _1: &Never; // in scope 0 at $DIR/lower_intrinsics.rs:+1:9: +1:10 scope 1 { - debug x => _2; // in scope 1 at $DIR/lower_intrinsics.rs:+1:9: +1:10 + debug x => _1; // in scope 1 at $DIR/lower_intrinsics.rs:+1:9: +1:10 } bb0: { - StorageLive(_1); // scope 0 at $DIR/lower_intrinsics.rs:+0:51: +3:2 - StorageLive(_2); // scope 0 at $DIR/lower_intrinsics.rs:+1:9: +1:10 -- _2 = transmute::(const 1_usize) -> [return: bb1, unwind unreachable]; // scope 0 at $DIR/lower_intrinsics.rs:+1:21: +1:48 + StorageLive(_1); // scope 0 at $DIR/lower_intrinsics.rs:+1:9: +1:10 +- _1 = transmute::(const 1_usize) -> [return: bb1, unwind unreachable]; // scope 0 at $DIR/lower_intrinsics.rs:+1:21: +1:48 - // mir::Constant - // + span: $DIR/lower_intrinsics.rs:58:21: 58:40 - // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(usize) -> &Never {transmute::}, val: Value() } -+ _2 = const 1_usize as &Never (Transmute); // scope 0 at $DIR/lower_intrinsics.rs:+1:21: +1:48 ++ _1 = const 1_usize as &Never (Transmute); // scope 0 at $DIR/lower_intrinsics.rs:+1:21: +1:48 + goto -> bb1; // scope 0 at $DIR/lower_intrinsics.rs:+1:21: +1:48 } bb1: { - StorageLive(_3); // scope 1 at $DIR/lower_intrinsics.rs:+2:5: +2:16 unreachable; // scope 1 at $DIR/lower_intrinsics.rs:+2:11: +2:13 } } diff --git a/tests/mir-opt/lower_intrinsics.unreachable.LowerIntrinsics.diff b/tests/mir-opt/lower_intrinsics.unreachable.LowerIntrinsics.diff index c0cc698c48188..28e45909c3372 100644 --- a/tests/mir-opt/lower_intrinsics.unreachable.LowerIntrinsics.diff +++ b/tests/mir-opt/lower_intrinsics.unreachable.LowerIntrinsics.diff @@ -3,16 +3,15 @@ fn unreachable() -> ! { let mut _0: !; // return place in scope 0 at $DIR/lower_intrinsics.rs:+0:25: +0:26 - let mut _1: !; // in scope 0 at $DIR/lower_intrinsics.rs:+0:27: +2:2 - let _2: (); // in scope 0 at $DIR/lower_intrinsics.rs:+1:14: +1:45 - let mut _3: !; // in scope 0 at $DIR/lower_intrinsics.rs:+1:14: +1:45 + let _1: (); // in scope 0 at $DIR/lower_intrinsics.rs:+1:14: +1:45 + let mut _2: !; // in scope 0 at $DIR/lower_intrinsics.rs:+1:14: +1:45 scope 1 { } bb0: { - StorageLive(_2); // scope 0 at $DIR/lower_intrinsics.rs:+1:5: +1:47 - StorageLive(_3); // scope 1 at $DIR/lower_intrinsics.rs:+1:14: +1:45 -- _3 = std::intrinsics::unreachable() -> unwind unreachable; // scope 1 at $DIR/lower_intrinsics.rs:+1:14: +1:45 + StorageLive(_1); // scope 0 at $DIR/lower_intrinsics.rs:+1:5: +1:47 + StorageLive(_2); // scope 1 at $DIR/lower_intrinsics.rs:+1:14: +1:45 +- _2 = std::intrinsics::unreachable() -> unwind unreachable; // scope 1 at $DIR/lower_intrinsics.rs:+1:14: +1:45 - // mir::Constant - // + span: $DIR/lower_intrinsics.rs:31:14: 31:43 - // + literal: Const { ty: unsafe extern "rust-intrinsic" fn() -> ! {std::intrinsics::unreachable}, val: Value() } From 1c7ab18c08109753b795bff83dd838ac8e4cdb70 Mon Sep 17 00:00:00 2001 From: Urgau Date: Fri, 19 May 2023 11:14:55 +0200 Subject: [PATCH 07/13] Rename `drop_copy` lint to `dropping_copy_types` --- compiler/rustc_lint/messages.ftl | 2 +- .../rustc_lint/src/drop_forget_useless.rs | 8 +++--- compiler/rustc_lint/src/lints.rs | 2 +- library/core/src/mem/mod.rs | 2 +- .../clippy_lints/src/drop_forget_ref.rs | 2 +- .../clippy/clippy_lints/src/renamed_lints.rs | 2 +- .../tests/ui/multiple_unsafe_ops_per_block.rs | 2 +- src/tools/clippy/tests/ui/rename.fixed | 4 +-- src/tools/clippy/tests/ui/rename.rs | 2 +- src/tools/clippy/tests/ui/rename.stderr | 4 +-- src/tools/miri/tests/fail/uninit_buffer.rs | 2 +- .../fail/uninit_buffer_with_provenance.rs | 2 +- .../zst-field-retagging-terminates.rs | 2 +- .../ui/associated-inherent-types/inference.rs | 2 +- .../borrowck-field-sensitivity-rpass.rs | 2 +- .../borrowck/borrowck-use-mut-borrow-rpass.rs | 2 +- .../migrations/issue-78720.rs | 2 +- tests/ui/crate-leading-sep.rs | 2 +- tests/ui/drop/repeat-drop.rs | 2 +- tests/ui/generator/drop-env.rs | 2 +- tests/ui/generator/issue-57017.rs | 2 +- tests/ui/generator/non-static-is-unpin.rs | 2 +- tests/ui/generator/resume-arg-size.rs | 2 +- .../stdlib-prelude-from-opaque-late.rs | 2 +- .../{drop_copy.rs => dropping_copy_types.rs} | 2 +- ...copy.stderr => dropping_copy_types.stderr} | 26 +++++++++---------- tests/ui/liveness/liveness-unused.rs | 2 +- .../ui/macros/parse-complex-macro-invoc-op.rs | 2 +- tests/ui/never_type/never-assign-dead-code.rs | 2 +- tests/ui/nll/relate_tys/hr-fn-aba-as-aaa.rs | 2 +- .../or-patterns-default-binding-modes.rs | 2 +- .../borrowck-pat-at-and-box-pass.rs | 2 +- .../borrowck-pat-by-copy-bindings-in-at.rs | 2 +- tests/ui/print_type_sizes/async.rs | 2 +- .../generator_discr_placement.rs | 2 +- ...type-param-outlives-reempty-issue-74429.rs | 2 +- .../dbg-macro-expected-behavior.rs | 2 +- tests/ui/rust-2018/remove-extern-crate.fixed | 2 +- tests/ui/rust-2018/remove-extern-crate.rs | 2 +- tests/ui/statics/issue-91050-1.rs | 2 +- tests/ui/traits/copy-guessing.rs | 2 +- tests/ui/traits/impl-evaluation-order.rs | 2 +- .../trivial-bounds-inconsistent-copy.rs | 2 +- 43 files changed, 60 insertions(+), 60 deletions(-) rename tests/ui/lint/{drop_copy.rs => dropping_copy_types.rs} (98%) rename tests/ui/lint/{drop_copy.stderr => dropping_copy_types.stderr} (85%) diff --git a/compiler/rustc_lint/messages.ftl b/compiler/rustc_lint/messages.ftl index a5639404fafd4..169c1fbe2acaf 100644 --- a/compiler/rustc_lint/messages.ftl +++ b/compiler/rustc_lint/messages.ftl @@ -525,7 +525,7 @@ lint_drop_ref = calls to `std::mem::drop` with a reference instead of an owned v .label = argument has type `{$arg_ty}` .note = use `let _ = ...` to ignore the expression or result -lint_drop_copy = calls to `std::mem::drop` with a value that implements `Copy` does nothing +lint_dropping_copy_types = calls to `std::mem::drop` with a value that implements `Copy` does nothing .label = argument has type `{$arg_ty}` .note = use `let _ = ...` to ignore the expression or result diff --git a/compiler/rustc_lint/src/drop_forget_useless.rs b/compiler/rustc_lint/src/drop_forget_useless.rs index 259abc2af1129..e61adc61e5ecf 100644 --- a/compiler/rustc_lint/src/drop_forget_useless.rs +++ b/compiler/rustc_lint/src/drop_forget_useless.rs @@ -58,7 +58,7 @@ declare_lint! { } declare_lint! { - /// The `drop_copy` lint checks for calls to `std::mem::drop` with a value + /// The `dropping_copy_types` lint checks for calls to `std::mem::drop` with a value /// that derives the Copy trait. /// /// ### Example @@ -76,7 +76,7 @@ declare_lint! { /// Calling `std::mem::drop` [does nothing for types that /// implement Copy](https://doc.rust-lang.org/std/mem/fn.drop.html), since the /// value will be copied and moved into the function on invocation. - pub DROP_COPY, + pub DROPPING_COPY_TYPES, Warn, "calls to `std::mem::drop` with a value that implements Copy" } @@ -109,7 +109,7 @@ declare_lint! { "calls to `std::mem::forget` with a value that implements Copy" } -declare_lint_pass!(DropForgetUseless => [DROP_REF, FORGET_REF, DROP_COPY, FORGET_COPY]); +declare_lint_pass!(DropForgetUseless => [DROP_REF, FORGET_REF, DROPPING_COPY_TYPES, FORGET_COPY]); impl<'tcx> LateLintPass<'tcx> for DropForgetUseless { fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) { @@ -129,7 +129,7 @@ impl<'tcx> LateLintPass<'tcx> for DropForgetUseless { cx.emit_spanned_lint(FORGET_REF, expr.span, ForgetRefDiag { arg_ty, label: arg.span }); }, sym::mem_drop if is_copy && !drop_is_single_call_in_arm => { - cx.emit_spanned_lint(DROP_COPY, expr.span, DropCopyDiag { arg_ty, label: arg.span }); + cx.emit_spanned_lint(DROPPING_COPY_TYPES, expr.span, DropCopyDiag { arg_ty, label: arg.span }); } sym::mem_forget if is_copy => { cx.emit_spanned_lint(FORGET_COPY, expr.span, ForgetCopyDiag { arg_ty, label: arg.span }); diff --git a/compiler/rustc_lint/src/lints.rs b/compiler/rustc_lint/src/lints.rs index 8e48806b50447..278c0bc32e955 100644 --- a/compiler/rustc_lint/src/lints.rs +++ b/compiler/rustc_lint/src/lints.rs @@ -673,7 +673,7 @@ pub struct DropRefDiag<'a> { } #[derive(LintDiagnostic)] -#[diag(lint_drop_copy)] +#[diag(lint_dropping_copy_types)] #[note] pub struct DropCopyDiag<'a> { pub arg_ty: Ty<'a>, diff --git a/library/core/src/mem/mod.rs b/library/core/src/mem/mod.rs index 289305253ecc1..afbfd6d362dc9 100644 --- a/library/core/src/mem/mod.rs +++ b/library/core/src/mem/mod.rs @@ -968,7 +968,7 @@ pub const fn replace(dest: &mut T, src: T) -> T { /// Integers and other types implementing [`Copy`] are unaffected by `drop`. /// /// ``` -/// # #![cfg_attr(not(bootstrap), allow(drop_copy))] +/// # #![cfg_attr(not(bootstrap), allow(dropping_copy_types))] /// #[derive(Copy, Clone)] /// struct Foo(u8); /// diff --git a/src/tools/clippy/clippy_lints/src/drop_forget_ref.rs b/src/tools/clippy/clippy_lints/src/drop_forget_ref.rs index b2f7d026cc8b2..9a7b39e1544eb 100644 --- a/src/tools/clippy/clippy_lints/src/drop_forget_ref.rs +++ b/src/tools/clippy/clippy_lints/src/drop_forget_ref.rs @@ -98,7 +98,7 @@ impl<'tcx> LateLintPass<'tcx> for DropForgetRef { let is_copy = is_copy(cx, arg_ty); let drop_is_single_call_in_arm = is_single_call_in_arm(cx, arg, expr); let (lint, msg) = match fn_name { - // early return for uplifted lints: drop_ref, drop_copy, forget_ref, forget_copy + // early return for uplifted lints: drop_ref, dropping_copy_types, forget_ref, forget_copy sym::mem_drop if arg_ty.is_ref() && !drop_is_single_call_in_arm => return, sym::mem_forget if arg_ty.is_ref() => return, sym::mem_drop if is_copy && !drop_is_single_call_in_arm => return, diff --git a/src/tools/clippy/clippy_lints/src/renamed_lints.rs b/src/tools/clippy/clippy_lints/src/renamed_lints.rs index a2c3465cde4a3..308e40abf6a25 100644 --- a/src/tools/clippy/clippy_lints/src/renamed_lints.rs +++ b/src/tools/clippy/clippy_lints/src/renamed_lints.rs @@ -33,7 +33,7 @@ pub static RENAMED_LINTS: &[(&str, &str)] = &[ ("clippy::zero_width_space", "clippy::invisible_characters"), ("clippy::clone_double_ref", "suspicious_double_ref_op"), ("clippy::drop_bounds", "drop_bounds"), - ("clippy::drop_copy", "drop_copy"), + ("clippy::drop_copy", "dropping_copy_types"), ("clippy::drop_ref", "drop_ref"), ("clippy::for_loop_over_option", "for_loops_over_fallibles"), ("clippy::for_loop_over_result", "for_loops_over_fallibles"), diff --git a/src/tools/clippy/tests/ui/multiple_unsafe_ops_per_block.rs b/src/tools/clippy/tests/ui/multiple_unsafe_ops_per_block.rs index f28153e56b0fe..4ef6f0ca92f2d 100644 --- a/src/tools/clippy/tests/ui/multiple_unsafe_ops_per_block.rs +++ b/src/tools/clippy/tests/ui/multiple_unsafe_ops_per_block.rs @@ -2,7 +2,7 @@ #![allow(unused)] #![allow(deref_nullptr)] #![allow(clippy::unnecessary_operation)] -#![allow(drop_copy)] +#![allow(dropping_copy_types)] #![warn(clippy::multiple_unsafe_ops_per_block)] extern crate proc_macros; diff --git a/src/tools/clippy/tests/ui/rename.fixed b/src/tools/clippy/tests/ui/rename.fixed index 7c2acf43fe836..8633e422805a6 100644 --- a/src/tools/clippy/tests/ui/rename.fixed +++ b/src/tools/clippy/tests/ui/rename.fixed @@ -30,7 +30,7 @@ #![allow(clippy::invisible_characters)] #![allow(suspicious_double_ref_op)] #![allow(drop_bounds)] -#![allow(drop_copy)] +#![allow(dropping_copy_types)] #![allow(drop_ref)] #![allow(for_loops_over_fallibles)] #![allow(forget_copy)] @@ -77,7 +77,7 @@ #![warn(clippy::invisible_characters)] #![warn(suspicious_double_ref_op)] #![warn(drop_bounds)] -#![warn(drop_copy)] +#![warn(dropping_copy_types)] #![warn(drop_ref)] #![warn(for_loops_over_fallibles)] #![warn(for_loops_over_fallibles)] diff --git a/src/tools/clippy/tests/ui/rename.rs b/src/tools/clippy/tests/ui/rename.rs index 8d334b0d0501a..07b33b4da95b3 100644 --- a/src/tools/clippy/tests/ui/rename.rs +++ b/src/tools/clippy/tests/ui/rename.rs @@ -30,7 +30,7 @@ #![allow(clippy::invisible_characters)] #![allow(suspicious_double_ref_op)] #![allow(drop_bounds)] -#![allow(drop_copy)] +#![allow(dropping_copy_types)] #![allow(drop_ref)] #![allow(for_loops_over_fallibles)] #![allow(forget_copy)] diff --git a/src/tools/clippy/tests/ui/rename.stderr b/src/tools/clippy/tests/ui/rename.stderr index fbf8d3d7e4e8b..20e7d96b7209b 100644 --- a/src/tools/clippy/tests/ui/rename.stderr +++ b/src/tools/clippy/tests/ui/rename.stderr @@ -186,11 +186,11 @@ error: lint `clippy::drop_bounds` has been renamed to `drop_bounds` LL | #![warn(clippy::drop_bounds)] | ^^^^^^^^^^^^^^^^^^^ help: use the new name: `drop_bounds` -error: lint `clippy::drop_copy` has been renamed to `drop_copy` +error: lint `clippy::drop_copy` has been renamed to `dropping_copy_types` --> $DIR/rename.rs:80:9 | LL | #![warn(clippy::drop_copy)] - | ^^^^^^^^^^^^^^^^^ help: use the new name: `drop_copy` + | ^^^^^^^^^^^^^^^^^ help: use the new name: `dropping_copy_types` error: lint `clippy::drop_ref` has been renamed to `drop_ref` --> $DIR/rename.rs:81:9 diff --git a/src/tools/miri/tests/fail/uninit_buffer.rs b/src/tools/miri/tests/fail/uninit_buffer.rs index 8a33005837528..d622b2fa7d812 100644 --- a/src/tools/miri/tests/fail/uninit_buffer.rs +++ b/src/tools/miri/tests/fail/uninit_buffer.rs @@ -1,6 +1,6 @@ //@error-in-other-file: memory is uninitialized at [0x4..0x10] -#![allow(drop_copy)] +#![allow(dropping_copy_types)] use std::alloc::{alloc, dealloc, Layout}; use std::slice::from_raw_parts; diff --git a/src/tools/miri/tests/fail/uninit_buffer_with_provenance.rs b/src/tools/miri/tests/fail/uninit_buffer_with_provenance.rs index 443f481c0874a..ca825901372c5 100644 --- a/src/tools/miri/tests/fail/uninit_buffer_with_provenance.rs +++ b/src/tools/miri/tests/fail/uninit_buffer_with_provenance.rs @@ -1,7 +1,7 @@ //@error-in-other-file: memory is uninitialized at [0x4..0x8] //@normalize-stderr-test: "a[0-9]+" -> "ALLOC" #![feature(strict_provenance)] -#![allow(drop_copy)] +#![allow(dropping_copy_types)] // Test printing allocations that contain single-byte provenance. diff --git a/src/tools/miri/tests/pass/stacked-borrows/zst-field-retagging-terminates.rs b/src/tools/miri/tests/pass/stacked-borrows/zst-field-retagging-terminates.rs index 9f743f0b56656..6e13a9ea8369b 100644 --- a/src/tools/miri/tests/pass/stacked-borrows/zst-field-retagging-terminates.rs +++ b/src/tools/miri/tests/pass/stacked-borrows/zst-field-retagging-terminates.rs @@ -1,7 +1,7 @@ //@compile-flags: -Zmiri-retag-fields // Checks that the test does not run forever (which relies on a fast path). -#![allow(drop_copy)] +#![allow(dropping_copy_types)] fn main() { let array = [(); usize::MAX]; diff --git a/tests/ui/associated-inherent-types/inference.rs b/tests/ui/associated-inherent-types/inference.rs index 7d6d26003f60e..ebd8e1d55945f 100644 --- a/tests/ui/associated-inherent-types/inference.rs +++ b/tests/ui/associated-inherent-types/inference.rs @@ -3,7 +3,7 @@ #![feature(inherent_associated_types)] #![allow(incomplete_features)] -#![allow(drop_copy)] +#![allow(dropping_copy_types)] use std::convert::identity; diff --git a/tests/ui/borrowck/borrowck-field-sensitivity-rpass.rs b/tests/ui/borrowck/borrowck-field-sensitivity-rpass.rs index a88b323e0bf1e..78e965cc4bc7b 100644 --- a/tests/ui/borrowck/borrowck-field-sensitivity-rpass.rs +++ b/tests/ui/borrowck/borrowck-field-sensitivity-rpass.rs @@ -1,7 +1,7 @@ // run-pass #![allow(unused_mut)] #![allow(unused_variables)] -#![allow(drop_copy)] +#![allow(dropping_copy_types)] // pretty-expanded FIXME #23616 struct A { a: isize, b: Box } diff --git a/tests/ui/borrowck/borrowck-use-mut-borrow-rpass.rs b/tests/ui/borrowck/borrowck-use-mut-borrow-rpass.rs index 40c6bfeeb434b..9acb1ec5e43a6 100644 --- a/tests/ui/borrowck/borrowck-use-mut-borrow-rpass.rs +++ b/tests/ui/borrowck/borrowck-use-mut-borrow-rpass.rs @@ -1,7 +1,7 @@ // run-pass // pretty-expanded FIXME #23616 -#![allow(drop_copy)] +#![allow(dropping_copy_types)] struct A { a: isize, b: Box } diff --git a/tests/ui/closures/2229_closure_analysis/migrations/issue-78720.rs b/tests/ui/closures/2229_closure_analysis/migrations/issue-78720.rs index bc7295a0826f1..5e4c19ff38b20 100644 --- a/tests/ui/closures/2229_closure_analysis/migrations/issue-78720.rs +++ b/tests/ui/closures/2229_closure_analysis/migrations/issue-78720.rs @@ -1,7 +1,7 @@ // run-pass #![warn(rust_2021_incompatible_closure_captures)] -#![allow(drop_ref, drop_copy)] +#![allow(drop_ref, dropping_copy_types)] fn main() { if let a = "" { diff --git a/tests/ui/crate-leading-sep.rs b/tests/ui/crate-leading-sep.rs index 8d1d0b4fcdf02..fce97d9ba2370 100644 --- a/tests/ui/crate-leading-sep.rs +++ b/tests/ui/crate-leading-sep.rs @@ -1,7 +1,7 @@ // run-pass // pretty-expanded FIXME #23616 -#![allow(drop_copy)] +#![allow(dropping_copy_types)] fn main() { use ::std::mem; diff --git a/tests/ui/drop/repeat-drop.rs b/tests/ui/drop/repeat-drop.rs index 659d35db6575a..a52900311ea65 100644 --- a/tests/ui/drop/repeat-drop.rs +++ b/tests/ui/drop/repeat-drop.rs @@ -1,7 +1,7 @@ // run-pass // needs-unwind -#![allow(drop_ref, drop_copy)] +#![allow(drop_ref, dropping_copy_types)] static mut CHECK: usize = 0; diff --git a/tests/ui/generator/drop-env.rs b/tests/ui/generator/drop-env.rs index cb46953dac3c8..137a407931a17 100644 --- a/tests/ui/generator/drop-env.rs +++ b/tests/ui/generator/drop-env.rs @@ -4,7 +4,7 @@ //[nomiropt]compile-flags: -Z mir-opt-level=0 #![feature(generators, generator_trait)] -#![allow(drop_copy)] +#![allow(dropping_copy_types)] use std::ops::Generator; use std::pin::Pin; diff --git a/tests/ui/generator/issue-57017.rs b/tests/ui/generator/issue-57017.rs index 918d233bf4ee6..aac6e591e688c 100644 --- a/tests/ui/generator/issue-57017.rs +++ b/tests/ui/generator/issue-57017.rs @@ -5,7 +5,7 @@ // [drop_tracking_mir] build-pass #![feature(generators, negative_impls)] -#![allow(drop_ref, drop_copy)] +#![allow(drop_ref, dropping_copy_types)] macro_rules! type_combinations { ( diff --git a/tests/ui/generator/non-static-is-unpin.rs b/tests/ui/generator/non-static-is-unpin.rs index adba800e25aeb..a5dde3912cc00 100644 --- a/tests/ui/generator/non-static-is-unpin.rs +++ b/tests/ui/generator/non-static-is-unpin.rs @@ -3,7 +3,7 @@ // run-pass #![feature(generators, generator_trait)] -#![allow(drop_copy)] +#![allow(dropping_copy_types)] use std::marker::{PhantomPinned, Unpin}; diff --git a/tests/ui/generator/resume-arg-size.rs b/tests/ui/generator/resume-arg-size.rs index 19618f8d0aa55..195166f975b63 100644 --- a/tests/ui/generator/resume-arg-size.rs +++ b/tests/ui/generator/resume-arg-size.rs @@ -1,5 +1,5 @@ #![feature(generators)] -#![allow(drop_copy)] +#![allow(dropping_copy_types)] // run-pass diff --git a/tests/ui/hygiene/stdlib-prelude-from-opaque-late.rs b/tests/ui/hygiene/stdlib-prelude-from-opaque-late.rs index 214267372bf87..721bb7281c0ff 100644 --- a/tests/ui/hygiene/stdlib-prelude-from-opaque-late.rs +++ b/tests/ui/hygiene/stdlib-prelude-from-opaque-late.rs @@ -1,7 +1,7 @@ // check-pass #![feature(decl_macro)] -#![allow(drop_copy)] +#![allow(dropping_copy_types)] macro mac() { mod m { diff --git a/tests/ui/lint/drop_copy.rs b/tests/ui/lint/dropping_copy_types.rs similarity index 98% rename from tests/ui/lint/drop_copy.rs rename to tests/ui/lint/dropping_copy_types.rs index 0adcd34505f0b..2937320e5d833 100644 --- a/tests/ui/lint/drop_copy.rs +++ b/tests/ui/lint/dropping_copy_types.rs @@ -1,6 +1,6 @@ // check-pass -#![warn(drop_copy)] +#![warn(dropping_copy_types)] use std::mem::drop; use std::vec::Vec; diff --git a/tests/ui/lint/drop_copy.stderr b/tests/ui/lint/dropping_copy_types.stderr similarity index 85% rename from tests/ui/lint/drop_copy.stderr rename to tests/ui/lint/dropping_copy_types.stderr index db8e89ad295b9..dc5c6211e7112 100644 --- a/tests/ui/lint/drop_copy.stderr +++ b/tests/ui/lint/dropping_copy_types.stderr @@ -1,5 +1,5 @@ warning: calls to `std::mem::drop` with a value that implements `Copy` does nothing - --> $DIR/drop_copy.rs:34:5 + --> $DIR/dropping_copy_types.rs:34:5 | LL | drop(s1); | ^^^^^--^ @@ -8,13 +8,13 @@ LL | drop(s1); | = note: use `let _ = ...` to ignore the expression or result note: the lint level is defined here - --> $DIR/drop_copy.rs:3:9 + --> $DIR/dropping_copy_types.rs:3:9 | -LL | #![warn(drop_copy)] - | ^^^^^^^^^ +LL | #![warn(dropping_copy_types)] + | ^^^^^^^^^^^^^^^^^^^ warning: calls to `std::mem::drop` with a value that implements `Copy` does nothing - --> $DIR/drop_copy.rs:35:5 + --> $DIR/dropping_copy_types.rs:35:5 | LL | drop(s2); | ^^^^^--^ @@ -24,7 +24,7 @@ LL | drop(s2); = note: use `let _ = ...` to ignore the expression or result warning: calls to `std::mem::drop` with a reference instead of an owned value does nothing - --> $DIR/drop_copy.rs:36:5 + --> $DIR/dropping_copy_types.rs:36:5 | LL | drop(s3); | ^^^^^--^ @@ -35,7 +35,7 @@ LL | drop(s3); = note: `#[warn(drop_ref)]` on by default warning: calls to `std::mem::drop` with a value that implements `Copy` does nothing - --> $DIR/drop_copy.rs:37:5 + --> $DIR/dropping_copy_types.rs:37:5 | LL | drop(s4); | ^^^^^--^ @@ -45,7 +45,7 @@ LL | drop(s4); = note: use `let _ = ...` to ignore the expression or result warning: calls to `std::mem::drop` with a reference instead of an owned value does nothing - --> $DIR/drop_copy.rs:38:5 + --> $DIR/dropping_copy_types.rs:38:5 | LL | drop(s5); | ^^^^^--^ @@ -55,7 +55,7 @@ LL | drop(s5); = note: use `let _ = ...` to ignore the expression or result warning: calls to `std::mem::drop` with a reference instead of an owned value does nothing - --> $DIR/drop_copy.rs:50:5 + --> $DIR/dropping_copy_types.rs:50:5 | LL | drop(a2); | ^^^^^--^ @@ -65,7 +65,7 @@ LL | drop(a2); = note: use `let _ = ...` to ignore the expression or result warning: calls to `std::mem::drop` with a reference instead of an owned value does nothing - --> $DIR/drop_copy.rs:52:5 + --> $DIR/dropping_copy_types.rs:52:5 | LL | drop(a4); | ^^^^^--^ @@ -75,7 +75,7 @@ LL | drop(a4); = note: use `let _ = ...` to ignore the expression or result warning: calls to `std::mem::drop` with a value that implements `Copy` does nothing - --> $DIR/drop_copy.rs:71:13 + --> $DIR/dropping_copy_types.rs:71:13 | LL | drop(println_and(13)); | ^^^^^---------------^ @@ -85,7 +85,7 @@ LL | drop(println_and(13)); = note: use `let _ = ...` to ignore the expression or result warning: calls to `std::mem::drop` with a value that implements `Copy` does nothing - --> $DIR/drop_copy.rs:74:14 + --> $DIR/dropping_copy_types.rs:74:14 | LL | 3 if drop(println_and(14)) == () => (), | ^^^^^---------------^ @@ -95,7 +95,7 @@ LL | 3 if drop(println_and(14)) == () => (), = note: use `let _ = ...` to ignore the expression or result warning: calls to `std::mem::drop` with a value that implements `Copy` does nothing - --> $DIR/drop_copy.rs:76:14 + --> $DIR/dropping_copy_types.rs:76:14 | LL | 4 => drop(2), | ^^^^^-^ diff --git a/tests/ui/liveness/liveness-unused.rs b/tests/ui/liveness/liveness-unused.rs index 8ef6ab1b6ff45..ba635e6638c8c 100644 --- a/tests/ui/liveness/liveness-unused.rs +++ b/tests/ui/liveness/liveness-unused.rs @@ -1,7 +1,7 @@ #![warn(unused)] #![deny(unused_variables)] #![deny(unused_assignments)] -#![allow(dead_code, non_camel_case_types, trivial_numeric_casts, drop_copy)] +#![allow(dead_code, non_camel_case_types, trivial_numeric_casts, dropping_copy_types)] use std::ops::AddAssign; diff --git a/tests/ui/macros/parse-complex-macro-invoc-op.rs b/tests/ui/macros/parse-complex-macro-invoc-op.rs index c50dfdf0116a2..10810388d2033 100644 --- a/tests/ui/macros/parse-complex-macro-invoc-op.rs +++ b/tests/ui/macros/parse-complex-macro-invoc-op.rs @@ -4,7 +4,7 @@ #![allow(unused_assignments)] #![allow(unused_variables)] #![allow(stable_features)] -#![allow(drop_copy)] +#![allow(dropping_copy_types)] // Test parsing binary operators after macro invocations. diff --git a/tests/ui/never_type/never-assign-dead-code.rs b/tests/ui/never_type/never-assign-dead-code.rs index e95a992d7804c..39df7de5a7fbb 100644 --- a/tests/ui/never_type/never-assign-dead-code.rs +++ b/tests/ui/never_type/never-assign-dead-code.rs @@ -3,7 +3,7 @@ // check-pass #![feature(never_type)] -#![allow(drop_copy)] +#![allow(dropping_copy_types)] #![warn(unused)] fn main() { diff --git a/tests/ui/nll/relate_tys/hr-fn-aba-as-aaa.rs b/tests/ui/nll/relate_tys/hr-fn-aba-as-aaa.rs index 73ceaeeb87572..2e9eff59386de 100644 --- a/tests/ui/nll/relate_tys/hr-fn-aba-as-aaa.rs +++ b/tests/ui/nll/relate_tys/hr-fn-aba-as-aaa.rs @@ -5,7 +5,7 @@ // check-pass // compile-flags:-Zno-leak-check -#![allow(drop_copy)] +#![allow(dropping_copy_types)] fn make_it() -> for<'a, 'b> fn(&'a u32, &'b u32) -> &'a u32 { panic!() diff --git a/tests/ui/or-patterns/or-patterns-default-binding-modes.rs b/tests/ui/or-patterns/or-patterns-default-binding-modes.rs index c138d99d30328..398cc0a0ee6e2 100644 --- a/tests/ui/or-patterns/or-patterns-default-binding-modes.rs +++ b/tests/ui/or-patterns/or-patterns-default-binding-modes.rs @@ -3,7 +3,7 @@ // check-pass #![allow(irrefutable_let_patterns)] -#![allow(drop_copy)] +#![allow(dropping_copy_types)] #![allow(drop_ref)] fn main() { diff --git a/tests/ui/pattern/bindings-after-at/borrowck-pat-at-and-box-pass.rs b/tests/ui/pattern/bindings-after-at/borrowck-pat-at-and-box-pass.rs index 965204bf240e3..6184a58b88696 100644 --- a/tests/ui/pattern/bindings-after-at/borrowck-pat-at-and-box-pass.rs +++ b/tests/ui/pattern/bindings-after-at/borrowck-pat-at-and-box-pass.rs @@ -3,7 +3,7 @@ // Test `@` patterns combined with `box` patterns. #![allow(drop_ref)] -#![allow(drop_copy)] +#![allow(dropping_copy_types)] #![feature(box_patterns)] diff --git a/tests/ui/pattern/bindings-after-at/borrowck-pat-by-copy-bindings-in-at.rs b/tests/ui/pattern/bindings-after-at/borrowck-pat-by-copy-bindings-in-at.rs index 3eb5d2cbf5466..1df51c0edd911 100644 --- a/tests/ui/pattern/bindings-after-at/borrowck-pat-by-copy-bindings-in-at.rs +++ b/tests/ui/pattern/bindings-after-at/borrowck-pat-by-copy-bindings-in-at.rs @@ -2,7 +2,7 @@ // Test `Copy` bindings in the rhs of `@` patterns. -#![allow(drop_copy)] +#![allow(dropping_copy_types)] #[derive(Copy, Clone)] struct C; diff --git a/tests/ui/print_type_sizes/async.rs b/tests/ui/print_type_sizes/async.rs index c73268dc46a72..f38a6e674da99 100644 --- a/tests/ui/print_type_sizes/async.rs +++ b/tests/ui/print_type_sizes/async.rs @@ -3,7 +3,7 @@ // build-pass // ignore-pass -#![allow(drop_copy)] +#![allow(dropping_copy_types)] async fn wait() {} diff --git a/tests/ui/print_type_sizes/generator_discr_placement.rs b/tests/ui/print_type_sizes/generator_discr_placement.rs index a77a03f0a8ae4..6adc14f9b99e1 100644 --- a/tests/ui/print_type_sizes/generator_discr_placement.rs +++ b/tests/ui/print_type_sizes/generator_discr_placement.rs @@ -6,7 +6,7 @@ // Avoid emitting panic handlers, like the rest of these tests... #![feature(generators)] -#![allow(drop_copy)] +#![allow(dropping_copy_types)] pub fn foo() { let a = || { diff --git a/tests/ui/regions/type-param-outlives-reempty-issue-74429.rs b/tests/ui/regions/type-param-outlives-reempty-issue-74429.rs index af2bb09805ac6..0c1e931444162 100644 --- a/tests/ui/regions/type-param-outlives-reempty-issue-74429.rs +++ b/tests/ui/regions/type-param-outlives-reempty-issue-74429.rs @@ -3,7 +3,7 @@ // check-pass -#![allow(drop_copy)] +#![allow(dropping_copy_types)] use std::marker::PhantomData; diff --git a/tests/ui/rfc-2361-dbg-macro/dbg-macro-expected-behavior.rs b/tests/ui/rfc-2361-dbg-macro/dbg-macro-expected-behavior.rs index 4c1562790d5f4..542be3942b7ee 100644 --- a/tests/ui/rfc-2361-dbg-macro/dbg-macro-expected-behavior.rs +++ b/tests/ui/rfc-2361-dbg-macro/dbg-macro-expected-behavior.rs @@ -4,7 +4,7 @@ // Tests ensuring that `dbg!(expr)` has the expected run-time behavior. // as well as some compile time properties we expect. -#![allow(drop_copy)] +#![allow(dropping_copy_types)] #[derive(Copy, Clone, Debug)] struct Unit; diff --git a/tests/ui/rust-2018/remove-extern-crate.fixed b/tests/ui/rust-2018/remove-extern-crate.fixed index 4ed4d610025fa..209b91af1ddfb 100644 --- a/tests/ui/rust-2018/remove-extern-crate.fixed +++ b/tests/ui/rust-2018/remove-extern-crate.fixed @@ -5,7 +5,7 @@ // compile-flags:--extern remove_extern_crate #![warn(rust_2018_idioms)] -#![allow(drop_copy)] +#![allow(dropping_copy_types)] //~ WARNING unused extern crate // Shouldn't suggest changing to `use`, as `another_name` diff --git a/tests/ui/rust-2018/remove-extern-crate.rs b/tests/ui/rust-2018/remove-extern-crate.rs index 5dafdb2b7b774..ef3c2db696af2 100644 --- a/tests/ui/rust-2018/remove-extern-crate.rs +++ b/tests/ui/rust-2018/remove-extern-crate.rs @@ -5,7 +5,7 @@ // compile-flags:--extern remove_extern_crate #![warn(rust_2018_idioms)] -#![allow(drop_copy)] +#![allow(dropping_copy_types)] extern crate core; //~ WARNING unused extern crate // Shouldn't suggest changing to `use`, as `another_name` diff --git a/tests/ui/statics/issue-91050-1.rs b/tests/ui/statics/issue-91050-1.rs index f59bcf0b80339..c6268dba567f7 100644 --- a/tests/ui/statics/issue-91050-1.rs +++ b/tests/ui/statics/issue-91050-1.rs @@ -12,7 +12,7 @@ // // In regular builds, the bad cast was UB, like "Invalid LLVMRustVisibility value!" -#![allow(drop_copy)] +#![allow(dropping_copy_types)] pub mod before { #[no_mangle] diff --git a/tests/ui/traits/copy-guessing.rs b/tests/ui/traits/copy-guessing.rs index c1ed4c28a0300..af25010e3bd28 100644 --- a/tests/ui/traits/copy-guessing.rs +++ b/tests/ui/traits/copy-guessing.rs @@ -1,5 +1,5 @@ #![allow(dead_code)] -#![allow(drop_copy)] +#![allow(dropping_copy_types)] // "guessing" in trait selection can affect `copy_or_move`. Check that this // is correctly handled. I am not sure what is the "correct" behaviour, diff --git a/tests/ui/traits/impl-evaluation-order.rs b/tests/ui/traits/impl-evaluation-order.rs index 256ce992eefc4..2ce0b6b0df8f0 100644 --- a/tests/ui/traits/impl-evaluation-order.rs +++ b/tests/ui/traits/impl-evaluation-order.rs @@ -6,7 +6,7 @@ // check-pass -#![allow(drop_copy)] +#![allow(dropping_copy_types)] trait A { type B; diff --git a/tests/ui/trivial-bounds/trivial-bounds-inconsistent-copy.rs b/tests/ui/trivial-bounds/trivial-bounds-inconsistent-copy.rs index 6ed7667115a0d..7b7f4a4efdb85 100644 --- a/tests/ui/trivial-bounds/trivial-bounds-inconsistent-copy.rs +++ b/tests/ui/trivial-bounds/trivial-bounds-inconsistent-copy.rs @@ -2,7 +2,7 @@ // Check tautalogically false `Copy` bounds #![feature(trivial_bounds)] -#![allow(drop_ref, drop_copy)] +#![allow(drop_ref, dropping_copy_types)] fn copy_string(t: String) -> String where String: Copy { //~ WARNING trivial_bounds is_copy(&t); From 85a18289431d245437d80b3006ec499c23e62400 Mon Sep 17 00:00:00 2001 From: Urgau Date: Fri, 19 May 2023 11:19:31 +0200 Subject: [PATCH 08/13] Rename `forget_copy` lint to `forgetting_copy_types` --- compiler/rustc_lint/messages.ftl | 2 +- .../rustc_lint/src/drop_forget_useless.rs | 8 +++---- compiler/rustc_lint/src/lints.rs | 2 +- .../clippy_lints/src/drop_forget_ref.rs | 2 +- .../clippy/clippy_lints/src/renamed_lints.rs | 2 +- src/tools/clippy/tests/ui/mem_forget.rs | 2 +- src/tools/clippy/tests/ui/rename.fixed | 4 ++-- src/tools/clippy/tests/ui/rename.rs | 2 +- src/tools/clippy/tests/ui/rename.stderr | 4 ++-- tests/ui/consts/const_forget.rs | 2 +- tests/ui/consts/issue-104155.rs | 2 +- ...orget_copy.rs => forgetting_copy_types.rs} | 2 +- ...py.stderr => forgetting_copy_types.stderr} | 22 +++++++++---------- 13 files changed, 28 insertions(+), 28 deletions(-) rename tests/ui/lint/{forget_copy.rs => forgetting_copy_types.rs} (97%) rename tests/ui/lint/{forget_copy.stderr => forgetting_copy_types.stderr} (83%) diff --git a/compiler/rustc_lint/messages.ftl b/compiler/rustc_lint/messages.ftl index 169c1fbe2acaf..f60d48e102499 100644 --- a/compiler/rustc_lint/messages.ftl +++ b/compiler/rustc_lint/messages.ftl @@ -533,6 +533,6 @@ lint_forget_ref = calls to `std::mem::forget` with a reference instead of an own .label = argument has type `{$arg_ty}` .note = use `let _ = ...` to ignore the expression or result -lint_forget_copy = calls to `std::mem::forget` with a value that implements `Copy` does nothing +lint_forgetting_copy_types = calls to `std::mem::forget` with a value that implements `Copy` does nothing .label = argument has type `{$arg_ty}` .note = use `let _ = ...` to ignore the expression or result diff --git a/compiler/rustc_lint/src/drop_forget_useless.rs b/compiler/rustc_lint/src/drop_forget_useless.rs index e61adc61e5ecf..8f3f4914ddea9 100644 --- a/compiler/rustc_lint/src/drop_forget_useless.rs +++ b/compiler/rustc_lint/src/drop_forget_useless.rs @@ -82,7 +82,7 @@ declare_lint! { } declare_lint! { - /// The `forget_copy` lint checks for calls to `std::mem::forget` with a value + /// The `forgetting_copy_types` lint checks for calls to `std::mem::forget` with a value /// that derives the Copy trait. /// /// ### Example @@ -104,12 +104,12 @@ declare_lint! { /// An alternative, but also valid, explanation is that Copy types do not /// implement the Drop trait, which means they have no destructors. Without a /// destructor, there is nothing for `std::mem::forget` to ignore. - pub FORGET_COPY, + pub FORGETTING_COPY_TYPES, Warn, "calls to `std::mem::forget` with a value that implements Copy" } -declare_lint_pass!(DropForgetUseless => [DROP_REF, FORGET_REF, DROPPING_COPY_TYPES, FORGET_COPY]); +declare_lint_pass!(DropForgetUseless => [DROP_REF, FORGET_REF, DROPPING_COPY_TYPES, FORGETTING_COPY_TYPES]); impl<'tcx> LateLintPass<'tcx> for DropForgetUseless { fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) { @@ -132,7 +132,7 @@ impl<'tcx> LateLintPass<'tcx> for DropForgetUseless { cx.emit_spanned_lint(DROPPING_COPY_TYPES, expr.span, DropCopyDiag { arg_ty, label: arg.span }); } sym::mem_forget if is_copy => { - cx.emit_spanned_lint(FORGET_COPY, expr.span, ForgetCopyDiag { arg_ty, label: arg.span }); + cx.emit_spanned_lint(FORGETTING_COPY_TYPES, expr.span, ForgetCopyDiag { arg_ty, label: arg.span }); } _ => return, }; diff --git a/compiler/rustc_lint/src/lints.rs b/compiler/rustc_lint/src/lints.rs index 278c0bc32e955..16c81273ef230 100644 --- a/compiler/rustc_lint/src/lints.rs +++ b/compiler/rustc_lint/src/lints.rs @@ -691,7 +691,7 @@ pub struct ForgetRefDiag<'a> { } #[derive(LintDiagnostic)] -#[diag(lint_forget_copy)] +#[diag(lint_forgetting_copy_types)] #[note] pub struct ForgetCopyDiag<'a> { pub arg_ty: Ty<'a>, diff --git a/src/tools/clippy/clippy_lints/src/drop_forget_ref.rs b/src/tools/clippy/clippy_lints/src/drop_forget_ref.rs index 9a7b39e1544eb..db1b8494890ec 100644 --- a/src/tools/clippy/clippy_lints/src/drop_forget_ref.rs +++ b/src/tools/clippy/clippy_lints/src/drop_forget_ref.rs @@ -98,7 +98,7 @@ impl<'tcx> LateLintPass<'tcx> for DropForgetRef { let is_copy = is_copy(cx, arg_ty); let drop_is_single_call_in_arm = is_single_call_in_arm(cx, arg, expr); let (lint, msg) = match fn_name { - // early return for uplifted lints: drop_ref, dropping_copy_types, forget_ref, forget_copy + // early return for uplifted lints: drop_ref, dropping_copy_types, forget_ref, forgetting_copy_types sym::mem_drop if arg_ty.is_ref() && !drop_is_single_call_in_arm => return, sym::mem_forget if arg_ty.is_ref() => return, sym::mem_drop if is_copy && !drop_is_single_call_in_arm => return, diff --git a/src/tools/clippy/clippy_lints/src/renamed_lints.rs b/src/tools/clippy/clippy_lints/src/renamed_lints.rs index 308e40abf6a25..a81dbb9b25992 100644 --- a/src/tools/clippy/clippy_lints/src/renamed_lints.rs +++ b/src/tools/clippy/clippy_lints/src/renamed_lints.rs @@ -38,7 +38,7 @@ pub static RENAMED_LINTS: &[(&str, &str)] = &[ ("clippy::for_loop_over_option", "for_loops_over_fallibles"), ("clippy::for_loop_over_result", "for_loops_over_fallibles"), ("clippy::for_loops_over_fallibles", "for_loops_over_fallibles"), - ("clippy::forget_copy", "forget_copy"), + ("clippy::forget_copy", "forgetting_copy_types"), ("clippy::forget_ref", "forget_ref"), ("clippy::into_iter_on_array", "array_into_iter"), ("clippy::invalid_atomic_ordering", "invalid_atomic_ordering"), diff --git a/src/tools/clippy/tests/ui/mem_forget.rs b/src/tools/clippy/tests/ui/mem_forget.rs index 5137448a6d4ba..edb9d87d032ec 100644 --- a/src/tools/clippy/tests/ui/mem_forget.rs +++ b/src/tools/clippy/tests/ui/mem_forget.rs @@ -5,7 +5,7 @@ use std::mem as memstuff; use std::mem::forget as forgetSomething; #[warn(clippy::mem_forget)] -#[allow(forget_copy)] +#[allow(forgetting_copy_types)] fn main() { let five: i32 = 5; forgetSomething(five); diff --git a/src/tools/clippy/tests/ui/rename.fixed b/src/tools/clippy/tests/ui/rename.fixed index 8633e422805a6..8df63fd9b2335 100644 --- a/src/tools/clippy/tests/ui/rename.fixed +++ b/src/tools/clippy/tests/ui/rename.fixed @@ -33,7 +33,7 @@ #![allow(dropping_copy_types)] #![allow(drop_ref)] #![allow(for_loops_over_fallibles)] -#![allow(forget_copy)] +#![allow(forgetting_copy_types)] #![allow(forget_ref)] #![allow(array_into_iter)] #![allow(invalid_atomic_ordering)] @@ -82,7 +82,7 @@ #![warn(for_loops_over_fallibles)] #![warn(for_loops_over_fallibles)] #![warn(for_loops_over_fallibles)] -#![warn(forget_copy)] +#![warn(forgetting_copy_types)] #![warn(forget_ref)] #![warn(array_into_iter)] #![warn(invalid_atomic_ordering)] diff --git a/src/tools/clippy/tests/ui/rename.rs b/src/tools/clippy/tests/ui/rename.rs index 07b33b4da95b3..7206e19f1e021 100644 --- a/src/tools/clippy/tests/ui/rename.rs +++ b/src/tools/clippy/tests/ui/rename.rs @@ -33,7 +33,7 @@ #![allow(dropping_copy_types)] #![allow(drop_ref)] #![allow(for_loops_over_fallibles)] -#![allow(forget_copy)] +#![allow(forgetting_copy_types)] #![allow(forget_ref)] #![allow(array_into_iter)] #![allow(invalid_atomic_ordering)] diff --git a/src/tools/clippy/tests/ui/rename.stderr b/src/tools/clippy/tests/ui/rename.stderr index 20e7d96b7209b..c2a7c0dd7eb13 100644 --- a/src/tools/clippy/tests/ui/rename.stderr +++ b/src/tools/clippy/tests/ui/rename.stderr @@ -216,11 +216,11 @@ error: lint `clippy::for_loops_over_fallibles` has been renamed to `for_loops_ov LL | #![warn(clippy::for_loops_over_fallibles)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `for_loops_over_fallibles` -error: lint `clippy::forget_copy` has been renamed to `forget_copy` +error: lint `clippy::forget_copy` has been renamed to `forgetting_copy_types` --> $DIR/rename.rs:85:9 | LL | #![warn(clippy::forget_copy)] - | ^^^^^^^^^^^^^^^^^^^ help: use the new name: `forget_copy` + | ^^^^^^^^^^^^^^^^^^^ help: use the new name: `forgetting_copy_types` error: lint `clippy::forget_ref` has been renamed to `forget_ref` --> $DIR/rename.rs:86:9 diff --git a/tests/ui/consts/const_forget.rs b/tests/ui/consts/const_forget.rs index acdd6a54cf4ec..f06149f2cb994 100644 --- a/tests/ui/consts/const_forget.rs +++ b/tests/ui/consts/const_forget.rs @@ -1,6 +1,6 @@ // check-pass -#![allow(forget_copy)] +#![allow(forgetting_copy_types)] use std::mem::forget; diff --git a/tests/ui/consts/issue-104155.rs b/tests/ui/consts/issue-104155.rs index b3821f467b617..7b375dc056675 100644 --- a/tests/ui/consts/issue-104155.rs +++ b/tests/ui/consts/issue-104155.rs @@ -1,6 +1,6 @@ // check-pass -#![allow(forget_copy)] +#![allow(forgetting_copy_types)] const _: () = core::mem::forget(Box::::default); const _: () = core::mem::forget(|| Box::::default()); diff --git a/tests/ui/lint/forget_copy.rs b/tests/ui/lint/forgetting_copy_types.rs similarity index 97% rename from tests/ui/lint/forget_copy.rs rename to tests/ui/lint/forgetting_copy_types.rs index a6b17b76971f2..224c7bcd5f63e 100644 --- a/tests/ui/lint/forget_copy.rs +++ b/tests/ui/lint/forgetting_copy_types.rs @@ -1,6 +1,6 @@ // check-pass -#![warn(forget_copy)] +#![warn(forgetting_copy_types)] use std::mem::forget; use std::vec::Vec; diff --git a/tests/ui/lint/forget_copy.stderr b/tests/ui/lint/forgetting_copy_types.stderr similarity index 83% rename from tests/ui/lint/forget_copy.stderr rename to tests/ui/lint/forgetting_copy_types.stderr index 37bc8a8854ee7..cf4e1845f5681 100644 --- a/tests/ui/lint/forget_copy.stderr +++ b/tests/ui/lint/forgetting_copy_types.stderr @@ -1,5 +1,5 @@ warning: calls to `std::mem::forget` with a value that implements `Copy` does nothing - --> $DIR/forget_copy.rs:34:5 + --> $DIR/forgetting_copy_types.rs:34:5 | LL | forget(s1); | ^^^^^^^--^ @@ -8,13 +8,13 @@ LL | forget(s1); | = note: use `let _ = ...` to ignore the expression or result note: the lint level is defined here - --> $DIR/forget_copy.rs:3:9 + --> $DIR/forgetting_copy_types.rs:3:9 | -LL | #![warn(forget_copy)] - | ^^^^^^^^^^^ +LL | #![warn(forgetting_copy_types)] + | ^^^^^^^^^^^^^^^^^^^^^ warning: calls to `std::mem::forget` with a value that implements `Copy` does nothing - --> $DIR/forget_copy.rs:35:5 + --> $DIR/forgetting_copy_types.rs:35:5 | LL | forget(s2); | ^^^^^^^--^ @@ -24,7 +24,7 @@ LL | forget(s2); = note: use `let _ = ...` to ignore the expression or result warning: calls to `std::mem::forget` with a reference instead of an owned value does nothing - --> $DIR/forget_copy.rs:36:5 + --> $DIR/forgetting_copy_types.rs:36:5 | LL | forget(s3); | ^^^^^^^--^ @@ -35,7 +35,7 @@ LL | forget(s3); = note: `#[warn(forget_ref)]` on by default warning: calls to `std::mem::forget` with a value that implements `Copy` does nothing - --> $DIR/forget_copy.rs:37:5 + --> $DIR/forgetting_copy_types.rs:37:5 | LL | forget(s4); | ^^^^^^^--^ @@ -45,7 +45,7 @@ LL | forget(s4); = note: use `let _ = ...` to ignore the expression or result warning: calls to `std::mem::forget` with a reference instead of an owned value does nothing - --> $DIR/forget_copy.rs:38:5 + --> $DIR/forgetting_copy_types.rs:38:5 | LL | forget(s5); | ^^^^^^^--^ @@ -55,7 +55,7 @@ LL | forget(s5); = note: use `let _ = ...` to ignore the expression or result warning: calls to `std::mem::forget` with a reference instead of an owned value does nothing - --> $DIR/forget_copy.rs:50:5 + --> $DIR/forgetting_copy_types.rs:50:5 | LL | forget(a2); | ^^^^^^^--^ @@ -65,7 +65,7 @@ LL | forget(a2); = note: use `let _ = ...` to ignore the expression or result warning: calls to `std::mem::forget` with a reference instead of an owned value does nothing - --> $DIR/forget_copy.rs:52:5 + --> $DIR/forgetting_copy_types.rs:52:5 | LL | forget(a3); | ^^^^^^^--^ @@ -75,7 +75,7 @@ LL | forget(a3); = note: use `let _ = ...` to ignore the expression or result warning: calls to `std::mem::forget` with a reference instead of an owned value does nothing - --> $DIR/forget_copy.rs:53:5 + --> $DIR/forgetting_copy_types.rs:53:5 | LL | forget(a4); | ^^^^^^^--^ From c93d9c1794eb8d57fd2f108547192c3aeb92b505 Mon Sep 17 00:00:00 2001 From: Urgau Date: Fri, 19 May 2023 11:25:35 +0200 Subject: [PATCH 09/13] Rename `drop_ref` lint to `dropping_references` --- compiler/rustc_lint/messages.ftl | 2 +- .../rustc_lint/src/drop_forget_useless.rs | 8 ++--- compiler/rustc_lint/src/lints.rs | 4 +-- .../clippy_lints/src/drop_forget_ref.rs | 2 +- .../clippy/clippy_lints/src/renamed_lints.rs | 2 +- src/tools/clippy/tests/ui/rename.fixed | 4 +-- src/tools/clippy/tests/ui/rename.rs | 2 +- src/tools/clippy/tests/ui/rename.stderr | 4 +-- .../fail/stacked_borrows/illegal_write2.rs | 2 +- .../borrowck-closures-slice-patterns-ok.rs | 2 +- .../migrations/issue-78720.rs | 2 +- .../optimization/edge_case_run_pass.rs | 2 +- .../run_pass/drop_then_use_fake_reads.rs | 2 +- tests/ui/drop/repeat-drop.rs | 2 +- .../explicit-call-to-supertrait-dtor.fixed | 2 +- .../explicit-call-to-supertrait-dtor.rs | 2 +- tests/ui/generator/issue-57017.rs | 2 +- tests/ui/illegal-ufcs-drop.fixed | 2 +- tests/ui/illegal-ufcs-drop.rs | 2 +- tests/ui/lint/dropping_copy_types.stderr | 2 +- .../{drop_ref.rs => dropping_references.rs} | 2 +- ..._ref.stderr => dropping_references.stderr} | 30 +++++++++---------- tests/ui/nll/ty-outlives/projection-body.rs | 2 +- .../or-patterns-default-binding-modes.rs | 2 +- .../borrowck-pat-at-and-box-pass.rs | 2 +- .../borrowck-move-ref-pattern-pass.rs | 2 +- ...move-ref-patterns-closure-captures-pass.rs | 2 +- .../borrowck-exhaustive.rs | 2 +- .../new-solver/auto-with-drop_tracking_mir.rs | 2 +- .../trivial-bounds-inconsistent-copy.rs | 2 +- 30 files changed, 50 insertions(+), 50 deletions(-) rename tests/ui/lint/{drop_ref.rs => dropping_references.rs} (99%) rename tests/ui/lint/{drop_ref.stderr => dropping_references.stderr} (86%) diff --git a/compiler/rustc_lint/messages.ftl b/compiler/rustc_lint/messages.ftl index f60d48e102499..b0ccbe4b1f1fd 100644 --- a/compiler/rustc_lint/messages.ftl +++ b/compiler/rustc_lint/messages.ftl @@ -521,7 +521,7 @@ lint_opaque_hidden_inferred_bound = opaque type `{$ty}` does not satisfy its ass lint_opaque_hidden_inferred_bound_sugg = add this bound -lint_drop_ref = calls to `std::mem::drop` with a reference instead of an owned value does nothing +lint_dropping_references = calls to `std::mem::drop` with a reference instead of an owned value does nothing .label = argument has type `{$arg_ty}` .note = use `let _ = ...` to ignore the expression or result diff --git a/compiler/rustc_lint/src/drop_forget_useless.rs b/compiler/rustc_lint/src/drop_forget_useless.rs index 8f3f4914ddea9..b1199096d7c82 100644 --- a/compiler/rustc_lint/src/drop_forget_useless.rs +++ b/compiler/rustc_lint/src/drop_forget_useless.rs @@ -7,7 +7,7 @@ use crate::{ }; declare_lint! { - /// The `drop_ref` lint checks for calls to `std::mem::drop` with a reference + /// The `dropping_references` lint checks for calls to `std::mem::drop` with a reference /// instead of an owned value. /// /// ### Example @@ -29,7 +29,7 @@ declare_lint! { /// reference itself, which is a no-op. It will not call the `drop` method (from /// the `Drop` trait implementation) on the underlying referenced value, which /// is likely what was intended. - pub DROP_REF, + pub DROPPING_REFERENCES, Warn, "calls to `std::mem::drop` with a reference instead of an owned value" } @@ -109,7 +109,7 @@ declare_lint! { "calls to `std::mem::forget` with a value that implements Copy" } -declare_lint_pass!(DropForgetUseless => [DROP_REF, FORGET_REF, DROPPING_COPY_TYPES, FORGETTING_COPY_TYPES]); +declare_lint_pass!(DropForgetUseless => [DROPPING_REFERENCES, FORGET_REF, DROPPING_COPY_TYPES, FORGETTING_COPY_TYPES]); impl<'tcx> LateLintPass<'tcx> for DropForgetUseless { fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) { @@ -123,7 +123,7 @@ impl<'tcx> LateLintPass<'tcx> for DropForgetUseless { let drop_is_single_call_in_arm = is_single_call_in_arm(cx, arg, expr); match fn_name { sym::mem_drop if arg_ty.is_ref() && !drop_is_single_call_in_arm => { - cx.emit_spanned_lint(DROP_REF, expr.span, DropRefDiag { arg_ty, label: arg.span }); + cx.emit_spanned_lint(DROPPING_REFERENCES, expr.span, DropRefDiag { arg_ty, label: arg.span }); }, sym::mem_forget if arg_ty.is_ref() => { cx.emit_spanned_lint(FORGET_REF, expr.span, ForgetRefDiag { arg_ty, label: arg.span }); diff --git a/compiler/rustc_lint/src/lints.rs b/compiler/rustc_lint/src/lints.rs index 16c81273ef230..aebfa6f3078cf 100644 --- a/compiler/rustc_lint/src/lints.rs +++ b/compiler/rustc_lint/src/lints.rs @@ -662,9 +662,9 @@ pub struct ForLoopsOverFalliblesSuggestion<'a> { pub end_span: Span, } -// drop_ref.rs +// drop_forget_useless.rs #[derive(LintDiagnostic)] -#[diag(lint_drop_ref)] +#[diag(lint_dropping_references)] #[note] pub struct DropRefDiag<'a> { pub arg_ty: Ty<'a>, diff --git a/src/tools/clippy/clippy_lints/src/drop_forget_ref.rs b/src/tools/clippy/clippy_lints/src/drop_forget_ref.rs index db1b8494890ec..00211d65094ee 100644 --- a/src/tools/clippy/clippy_lints/src/drop_forget_ref.rs +++ b/src/tools/clippy/clippy_lints/src/drop_forget_ref.rs @@ -98,7 +98,7 @@ impl<'tcx> LateLintPass<'tcx> for DropForgetRef { let is_copy = is_copy(cx, arg_ty); let drop_is_single_call_in_arm = is_single_call_in_arm(cx, arg, expr); let (lint, msg) = match fn_name { - // early return for uplifted lints: drop_ref, dropping_copy_types, forget_ref, forgetting_copy_types + // early return for uplifted lints: dropping_references, dropping_copy_types, forget_ref, forgetting_copy_types sym::mem_drop if arg_ty.is_ref() && !drop_is_single_call_in_arm => return, sym::mem_forget if arg_ty.is_ref() => return, sym::mem_drop if is_copy && !drop_is_single_call_in_arm => return, diff --git a/src/tools/clippy/clippy_lints/src/renamed_lints.rs b/src/tools/clippy/clippy_lints/src/renamed_lints.rs index a81dbb9b25992..4d1a462d110ca 100644 --- a/src/tools/clippy/clippy_lints/src/renamed_lints.rs +++ b/src/tools/clippy/clippy_lints/src/renamed_lints.rs @@ -34,7 +34,7 @@ pub static RENAMED_LINTS: &[(&str, &str)] = &[ ("clippy::clone_double_ref", "suspicious_double_ref_op"), ("clippy::drop_bounds", "drop_bounds"), ("clippy::drop_copy", "dropping_copy_types"), - ("clippy::drop_ref", "drop_ref"), + ("clippy::drop_ref", "dropping_references"), ("clippy::for_loop_over_option", "for_loops_over_fallibles"), ("clippy::for_loop_over_result", "for_loops_over_fallibles"), ("clippy::for_loops_over_fallibles", "for_loops_over_fallibles"), diff --git a/src/tools/clippy/tests/ui/rename.fixed b/src/tools/clippy/tests/ui/rename.fixed index 8df63fd9b2335..a4fb4fbffdfc8 100644 --- a/src/tools/clippy/tests/ui/rename.fixed +++ b/src/tools/clippy/tests/ui/rename.fixed @@ -31,7 +31,7 @@ #![allow(suspicious_double_ref_op)] #![allow(drop_bounds)] #![allow(dropping_copy_types)] -#![allow(drop_ref)] +#![allow(dropping_references)] #![allow(for_loops_over_fallibles)] #![allow(forgetting_copy_types)] #![allow(forget_ref)] @@ -78,7 +78,7 @@ #![warn(suspicious_double_ref_op)] #![warn(drop_bounds)] #![warn(dropping_copy_types)] -#![warn(drop_ref)] +#![warn(dropping_references)] #![warn(for_loops_over_fallibles)] #![warn(for_loops_over_fallibles)] #![warn(for_loops_over_fallibles)] diff --git a/src/tools/clippy/tests/ui/rename.rs b/src/tools/clippy/tests/ui/rename.rs index 7206e19f1e021..bb833c9534688 100644 --- a/src/tools/clippy/tests/ui/rename.rs +++ b/src/tools/clippy/tests/ui/rename.rs @@ -31,7 +31,7 @@ #![allow(suspicious_double_ref_op)] #![allow(drop_bounds)] #![allow(dropping_copy_types)] -#![allow(drop_ref)] +#![allow(dropping_references)] #![allow(for_loops_over_fallibles)] #![allow(forgetting_copy_types)] #![allow(forget_ref)] diff --git a/src/tools/clippy/tests/ui/rename.stderr b/src/tools/clippy/tests/ui/rename.stderr index c2a7c0dd7eb13..8bbd046bbf31b 100644 --- a/src/tools/clippy/tests/ui/rename.stderr +++ b/src/tools/clippy/tests/ui/rename.stderr @@ -192,11 +192,11 @@ error: lint `clippy::drop_copy` has been renamed to `dropping_copy_types` LL | #![warn(clippy::drop_copy)] | ^^^^^^^^^^^^^^^^^ help: use the new name: `dropping_copy_types` -error: lint `clippy::drop_ref` has been renamed to `drop_ref` +error: lint `clippy::drop_ref` has been renamed to `dropping_references` --> $DIR/rename.rs:81:9 | LL | #![warn(clippy::drop_ref)] - | ^^^^^^^^^^^^^^^^ help: use the new name: `drop_ref` + | ^^^^^^^^^^^^^^^^ help: use the new name: `dropping_references` error: lint `clippy::for_loop_over_option` has been renamed to `for_loops_over_fallibles` --> $DIR/rename.rs:82:9 diff --git a/src/tools/miri/tests/fail/stacked_borrows/illegal_write2.rs b/src/tools/miri/tests/fail/stacked_borrows/illegal_write2.rs index bf4204c61fd72..a5a1930ed65bb 100644 --- a/src/tools/miri/tests/fail/stacked_borrows/illegal_write2.rs +++ b/src/tools/miri/tests/fail/stacked_borrows/illegal_write2.rs @@ -1,4 +1,4 @@ -#![allow(drop_ref)] +#![allow(dropping_references)] fn main() { let target = &mut 42; diff --git a/tests/ui/borrowck/borrowck-closures-slice-patterns-ok.rs b/tests/ui/borrowck/borrowck-closures-slice-patterns-ok.rs index 9163c8ed6fb2c..60128c9419d11 100644 --- a/tests/ui/borrowck/borrowck-closures-slice-patterns-ok.rs +++ b/tests/ui/borrowck/borrowck-closures-slice-patterns-ok.rs @@ -1,7 +1,7 @@ // Check that closure captures for slice patterns are inferred correctly #![allow(unused_variables)] -#![allow(drop_ref)] +#![allow(dropping_references)] // run-pass diff --git a/tests/ui/closures/2229_closure_analysis/migrations/issue-78720.rs b/tests/ui/closures/2229_closure_analysis/migrations/issue-78720.rs index 5e4c19ff38b20..98f8d5d473380 100644 --- a/tests/ui/closures/2229_closure_analysis/migrations/issue-78720.rs +++ b/tests/ui/closures/2229_closure_analysis/migrations/issue-78720.rs @@ -1,7 +1,7 @@ // run-pass #![warn(rust_2021_incompatible_closure_captures)] -#![allow(drop_ref, dropping_copy_types)] +#![allow(dropping_references, dropping_copy_types)] fn main() { if let a = "" { diff --git a/tests/ui/closures/2229_closure_analysis/optimization/edge_case_run_pass.rs b/tests/ui/closures/2229_closure_analysis/optimization/edge_case_run_pass.rs index 0f15f664e757e..5496d0e5fc7e3 100644 --- a/tests/ui/closures/2229_closure_analysis/optimization/edge_case_run_pass.rs +++ b/tests/ui/closures/2229_closure_analysis/optimization/edge_case_run_pass.rs @@ -3,7 +3,7 @@ #![allow(unused)] #![allow(dead_code)] -#![allow(drop_ref)] +#![allow(dropping_references)] struct Int(i32); struct B<'a>(&'a i32); diff --git a/tests/ui/closures/2229_closure_analysis/run_pass/drop_then_use_fake_reads.rs b/tests/ui/closures/2229_closure_analysis/run_pass/drop_then_use_fake_reads.rs index a097424a02172..b5e97ec1c1b8d 100644 --- a/tests/ui/closures/2229_closure_analysis/run_pass/drop_then_use_fake_reads.rs +++ b/tests/ui/closures/2229_closure_analysis/run_pass/drop_then_use_fake_reads.rs @@ -2,7 +2,7 @@ // check-pass #![feature(rustc_attrs)] -#![allow(drop_ref)] +#![allow(dropping_references)] fn main() { let mut x = 1; diff --git a/tests/ui/drop/repeat-drop.rs b/tests/ui/drop/repeat-drop.rs index a52900311ea65..0afb4bb11bc89 100644 --- a/tests/ui/drop/repeat-drop.rs +++ b/tests/ui/drop/repeat-drop.rs @@ -1,7 +1,7 @@ // run-pass // needs-unwind -#![allow(drop_ref, dropping_copy_types)] +#![allow(dropping_references, dropping_copy_types)] static mut CHECK: usize = 0; diff --git a/tests/ui/explicit/explicit-call-to-supertrait-dtor.fixed b/tests/ui/explicit/explicit-call-to-supertrait-dtor.fixed index 0bc4feed329d3..bb093a4af4a3e 100644 --- a/tests/ui/explicit/explicit-call-to-supertrait-dtor.fixed +++ b/tests/ui/explicit/explicit-call-to-supertrait-dtor.fixed @@ -1,6 +1,6 @@ // run-rustfix -#![allow(drop_ref)] +#![allow(dropping_references)] struct Foo { x: isize diff --git a/tests/ui/explicit/explicit-call-to-supertrait-dtor.rs b/tests/ui/explicit/explicit-call-to-supertrait-dtor.rs index 26ae6698d669d..1a9f89c054f39 100644 --- a/tests/ui/explicit/explicit-call-to-supertrait-dtor.rs +++ b/tests/ui/explicit/explicit-call-to-supertrait-dtor.rs @@ -1,6 +1,6 @@ // run-rustfix -#![allow(drop_ref)] +#![allow(dropping_references)] struct Foo { x: isize diff --git a/tests/ui/generator/issue-57017.rs b/tests/ui/generator/issue-57017.rs index aac6e591e688c..381897c77a5c3 100644 --- a/tests/ui/generator/issue-57017.rs +++ b/tests/ui/generator/issue-57017.rs @@ -5,7 +5,7 @@ // [drop_tracking_mir] build-pass #![feature(generators, negative_impls)] -#![allow(drop_ref, dropping_copy_types)] +#![allow(dropping_references, dropping_copy_types)] macro_rules! type_combinations { ( diff --git a/tests/ui/illegal-ufcs-drop.fixed b/tests/ui/illegal-ufcs-drop.fixed index 8783682dec47d..c088c82791b4d 100644 --- a/tests/ui/illegal-ufcs-drop.fixed +++ b/tests/ui/illegal-ufcs-drop.fixed @@ -1,6 +1,6 @@ // run-rustfix -#![allow(drop_ref)] +#![allow(dropping_references)] struct Foo; diff --git a/tests/ui/illegal-ufcs-drop.rs b/tests/ui/illegal-ufcs-drop.rs index 29774306ec6f5..1389b11218865 100644 --- a/tests/ui/illegal-ufcs-drop.rs +++ b/tests/ui/illegal-ufcs-drop.rs @@ -1,6 +1,6 @@ // run-rustfix -#![allow(drop_ref)] +#![allow(dropping_references)] struct Foo; diff --git a/tests/ui/lint/dropping_copy_types.stderr b/tests/ui/lint/dropping_copy_types.stderr index dc5c6211e7112..b6291aa5ed634 100644 --- a/tests/ui/lint/dropping_copy_types.stderr +++ b/tests/ui/lint/dropping_copy_types.stderr @@ -32,7 +32,7 @@ LL | drop(s3); | argument has type `&SomeStruct` | = note: use `let _ = ...` to ignore the expression or result - = note: `#[warn(drop_ref)]` on by default + = note: `#[warn(dropping_references)]` on by default warning: calls to `std::mem::drop` with a value that implements `Copy` does nothing --> $DIR/dropping_copy_types.rs:37:5 diff --git a/tests/ui/lint/drop_ref.rs b/tests/ui/lint/dropping_references.rs similarity index 99% rename from tests/ui/lint/drop_ref.rs rename to tests/ui/lint/dropping_references.rs index db4f7569f6fa3..0d5d484f4517f 100644 --- a/tests/ui/lint/drop_ref.rs +++ b/tests/ui/lint/dropping_references.rs @@ -1,6 +1,6 @@ // check-pass -#![warn(drop_ref)] +#![warn(dropping_references)] struct SomeStruct; diff --git a/tests/ui/lint/drop_ref.stderr b/tests/ui/lint/dropping_references.stderr similarity index 86% rename from tests/ui/lint/drop_ref.stderr rename to tests/ui/lint/dropping_references.stderr index 04c988fe99da4..7e25a46216ecf 100644 --- a/tests/ui/lint/drop_ref.stderr +++ b/tests/ui/lint/dropping_references.stderr @@ -1,5 +1,5 @@ warning: calls to `std::mem::drop` with a reference instead of an owned value does nothing - --> $DIR/drop_ref.rs:8:5 + --> $DIR/dropping_references.rs:8:5 | LL | drop(&SomeStruct); | ^^^^^-----------^ @@ -8,13 +8,13 @@ LL | drop(&SomeStruct); | = note: use `let _ = ...` to ignore the expression or result note: the lint level is defined here - --> $DIR/drop_ref.rs:3:9 + --> $DIR/dropping_references.rs:3:9 | -LL | #![warn(drop_ref)] - | ^^^^^^^^ +LL | #![warn(dropping_references)] + | ^^^^^^^^^^^^^^^^^^^ warning: calls to `std::mem::drop` with a reference instead of an owned value does nothing - --> $DIR/drop_ref.rs:11:5 + --> $DIR/dropping_references.rs:11:5 | LL | drop(&owned1); | ^^^^^-------^ @@ -24,7 +24,7 @@ LL | drop(&owned1); = note: use `let _ = ...` to ignore the expression or result warning: calls to `std::mem::drop` with a reference instead of an owned value does nothing - --> $DIR/drop_ref.rs:12:5 + --> $DIR/dropping_references.rs:12:5 | LL | drop(&&owned1); | ^^^^^--------^ @@ -34,7 +34,7 @@ LL | drop(&&owned1); = note: use `let _ = ...` to ignore the expression or result warning: calls to `std::mem::drop` with a reference instead of an owned value does nothing - --> $DIR/drop_ref.rs:13:5 + --> $DIR/dropping_references.rs:13:5 | LL | drop(&mut owned1); | ^^^^^-----------^ @@ -44,7 +44,7 @@ LL | drop(&mut owned1); = note: use `let _ = ...` to ignore the expression or result warning: calls to `std::mem::drop` with a reference instead of an owned value does nothing - --> $DIR/drop_ref.rs:17:5 + --> $DIR/dropping_references.rs:17:5 | LL | drop(reference1); | ^^^^^----------^ @@ -54,7 +54,7 @@ LL | drop(reference1); = note: use `let _ = ...` to ignore the expression or result warning: calls to `std::mem::drop` with a reference instead of an owned value does nothing - --> $DIR/drop_ref.rs:20:5 + --> $DIR/dropping_references.rs:20:5 | LL | drop(reference2); | ^^^^^----------^ @@ -64,7 +64,7 @@ LL | drop(reference2); = note: use `let _ = ...` to ignore the expression or result warning: calls to `std::mem::drop` with a reference instead of an owned value does nothing - --> $DIR/drop_ref.rs:23:5 + --> $DIR/dropping_references.rs:23:5 | LL | drop(reference3); | ^^^^^----------^ @@ -74,7 +74,7 @@ LL | drop(reference3); = note: use `let _ = ...` to ignore the expression or result warning: calls to `std::mem::drop` with a reference instead of an owned value does nothing - --> $DIR/drop_ref.rs:28:5 + --> $DIR/dropping_references.rs:28:5 | LL | drop(&val); | ^^^^^----^ @@ -84,7 +84,7 @@ LL | drop(&val); = note: use `let _ = ...` to ignore the expression or result warning: calls to `std::mem::drop` with a reference instead of an owned value does nothing - --> $DIR/drop_ref.rs:36:5 + --> $DIR/dropping_references.rs:36:5 | LL | std::mem::drop(&SomeStruct); | ^^^^^^^^^^^^^^^-----------^ @@ -94,7 +94,7 @@ LL | std::mem::drop(&SomeStruct); = note: use `let _ = ...` to ignore the expression or result warning: calls to `std::mem::drop` with a reference instead of an owned value does nothing - --> $DIR/drop_ref.rs:91:13 + --> $DIR/dropping_references.rs:91:13 | LL | drop(println_and(&13)); | ^^^^^----------------^ @@ -104,7 +104,7 @@ LL | drop(println_and(&13)); = note: use `let _ = ...` to ignore the expression or result warning: calls to `std::mem::drop` with a reference instead of an owned value does nothing - --> $DIR/drop_ref.rs:94:14 + --> $DIR/dropping_references.rs:94:14 | LL | 3 if drop(println_and(&14)) == () => (), | ^^^^^----------------^ @@ -114,7 +114,7 @@ LL | 3 if drop(println_and(&14)) == () => (), = note: use `let _ = ...` to ignore the expression or result warning: calls to `std::mem::drop` with a reference instead of an owned value does nothing - --> $DIR/drop_ref.rs:96:14 + --> $DIR/dropping_references.rs:96:14 | LL | 4 => drop(&2), | ^^^^^--^ diff --git a/tests/ui/nll/ty-outlives/projection-body.rs b/tests/ui/nll/ty-outlives/projection-body.rs index bff9058a507b1..722d6747102fc 100644 --- a/tests/ui/nll/ty-outlives/projection-body.rs +++ b/tests/ui/nll/ty-outlives/projection-body.rs @@ -3,7 +3,7 @@ // // check-pass -#![allow(drop_ref)] +#![allow(dropping_references)] trait MyTrait<'a> { type Output; diff --git a/tests/ui/or-patterns/or-patterns-default-binding-modes.rs b/tests/ui/or-patterns/or-patterns-default-binding-modes.rs index 398cc0a0ee6e2..df6aab0e6a885 100644 --- a/tests/ui/or-patterns/or-patterns-default-binding-modes.rs +++ b/tests/ui/or-patterns/or-patterns-default-binding-modes.rs @@ -4,7 +4,7 @@ #![allow(irrefutable_let_patterns)] #![allow(dropping_copy_types)] -#![allow(drop_ref)] +#![allow(dropping_references)] fn main() { // A regression test for a mistake we made at one point: diff --git a/tests/ui/pattern/bindings-after-at/borrowck-pat-at-and-box-pass.rs b/tests/ui/pattern/bindings-after-at/borrowck-pat-at-and-box-pass.rs index 6184a58b88696..43b53b7cf1f17 100644 --- a/tests/ui/pattern/bindings-after-at/borrowck-pat-at-and-box-pass.rs +++ b/tests/ui/pattern/bindings-after-at/borrowck-pat-at-and-box-pass.rs @@ -2,7 +2,7 @@ // Test `@` patterns combined with `box` patterns. -#![allow(drop_ref)] +#![allow(dropping_references)] #![allow(dropping_copy_types)] #![feature(box_patterns)] diff --git a/tests/ui/pattern/move-ref-patterns/borrowck-move-ref-pattern-pass.rs b/tests/ui/pattern/move-ref-patterns/borrowck-move-ref-pattern-pass.rs index 0550238549ef3..204cd3e665762 100644 --- a/tests/ui/pattern/move-ref-patterns/borrowck-move-ref-pattern-pass.rs +++ b/tests/ui/pattern/move-ref-patterns/borrowck-move-ref-pattern-pass.rs @@ -1,6 +1,6 @@ // check-pass -#![allow(drop_ref)] +#![allow(dropping_references)] fn main() {} diff --git a/tests/ui/pattern/move-ref-patterns/move-ref-patterns-closure-captures-pass.rs b/tests/ui/pattern/move-ref-patterns/move-ref-patterns-closure-captures-pass.rs index 788975d960aa9..4de1f653db03a 100644 --- a/tests/ui/pattern/move-ref-patterns/move-ref-patterns-closure-captures-pass.rs +++ b/tests/ui/pattern/move-ref-patterns/move-ref-patterns-closure-captures-pass.rs @@ -1,6 +1,6 @@ // check-pass -#![allow(drop_ref)] +#![allow(dropping_references)] fn main() { struct U; diff --git a/tests/ui/rfc-2008-non-exhaustive/borrowck-exhaustive.rs b/tests/ui/rfc-2008-non-exhaustive/borrowck-exhaustive.rs index 8f45b989f1363..b9ff24c7624dc 100644 --- a/tests/ui/rfc-2008-non-exhaustive/borrowck-exhaustive.rs +++ b/tests/ui/rfc-2008-non-exhaustive/borrowck-exhaustive.rs @@ -3,7 +3,7 @@ // check-pass -#![allow(drop_ref)] +#![allow(dropping_references)] // aux-build:monovariants.rs extern crate monovariants; diff --git a/tests/ui/traits/new-solver/auto-with-drop_tracking_mir.rs b/tests/ui/traits/new-solver/auto-with-drop_tracking_mir.rs index f115e1433182c..e311a4af2f4ea 100644 --- a/tests/ui/traits/new-solver/auto-with-drop_tracking_mir.rs +++ b/tests/ui/traits/new-solver/auto-with-drop_tracking_mir.rs @@ -14,7 +14,7 @@ async fn foo() { #[cfg(fail)] let x = &NotSync; bar().await; - #[allow(drop_ref)] + #[allow(dropping_references)] drop(x); } diff --git a/tests/ui/trivial-bounds/trivial-bounds-inconsistent-copy.rs b/tests/ui/trivial-bounds/trivial-bounds-inconsistent-copy.rs index 7b7f4a4efdb85..f98c3164d7eb5 100644 --- a/tests/ui/trivial-bounds/trivial-bounds-inconsistent-copy.rs +++ b/tests/ui/trivial-bounds/trivial-bounds-inconsistent-copy.rs @@ -2,7 +2,7 @@ // Check tautalogically false `Copy` bounds #![feature(trivial_bounds)] -#![allow(drop_ref, dropping_copy_types)] +#![allow(dropping_references, dropping_copy_types)] fn copy_string(t: String) -> String where String: Copy { //~ WARNING trivial_bounds is_copy(&t); From 6b08a745a4d59e9bf51d2d591c569c9e758bd02a Mon Sep 17 00:00:00 2001 From: Urgau Date: Fri, 19 May 2023 11:30:11 +0200 Subject: [PATCH 10/13] Rename `forget_ref` lint to `forgetting_references` --- compiler/rustc_lint/messages.ftl | 2 +- .../rustc_lint/src/drop_forget_useless.rs | 8 +++---- compiler/rustc_lint/src/lints.rs | 2 +- .../clippy_lints/src/drop_forget_ref.rs | 2 +- .../clippy/clippy_lints/src/renamed_lints.rs | 2 +- src/tools/clippy/tests/ui/rename.fixed | 4 ++-- src/tools/clippy/tests/ui/rename.rs | 2 +- src/tools/clippy/tests/ui/rename.stderr | 4 ++-- tests/ui/lint/forgetting_copy_types.stderr | 2 +- ...forget_ref.rs => forgetting_references.rs} | 2 +- ...ef.stderr => forgetting_references.stderr} | 24 +++++++++---------- 11 files changed, 27 insertions(+), 27 deletions(-) rename tests/ui/lint/{forget_ref.rs => forgetting_references.rs} (97%) rename tests/ui/lint/{forget_ref.stderr => forgetting_references.stderr} (84%) diff --git a/compiler/rustc_lint/messages.ftl b/compiler/rustc_lint/messages.ftl index b0ccbe4b1f1fd..e1658d3ff82b7 100644 --- a/compiler/rustc_lint/messages.ftl +++ b/compiler/rustc_lint/messages.ftl @@ -529,7 +529,7 @@ lint_dropping_copy_types = calls to `std::mem::drop` with a value that implement .label = argument has type `{$arg_ty}` .note = use `let _ = ...` to ignore the expression or result -lint_forget_ref = calls to `std::mem::forget` with a reference instead of an owned value does nothing +lint_forgetting_references = calls to `std::mem::forget` with a reference instead of an owned value does nothing .label = argument has type `{$arg_ty}` .note = use `let _ = ...` to ignore the expression or result diff --git a/compiler/rustc_lint/src/drop_forget_useless.rs b/compiler/rustc_lint/src/drop_forget_useless.rs index b1199096d7c82..ed2b384805e05 100644 --- a/compiler/rustc_lint/src/drop_forget_useless.rs +++ b/compiler/rustc_lint/src/drop_forget_useless.rs @@ -35,7 +35,7 @@ declare_lint! { } declare_lint! { - /// The `forget_ref` lint checks for calls to `std::mem::forget` with a reference + /// The `forgetting_references` lint checks for calls to `std::mem::forget` with a reference /// instead of an owned value. /// /// ### Example @@ -52,7 +52,7 @@ declare_lint! { /// Calling `forget` on a reference will only forget the /// reference itself, which is a no-op. It will not forget the underlying /// referenced value, which is likely what was intended. - pub FORGET_REF, + pub FORGETTING_REFERENCES, Warn, "calls to `std::mem::forget` with a reference instead of an owned value" } @@ -109,7 +109,7 @@ declare_lint! { "calls to `std::mem::forget` with a value that implements Copy" } -declare_lint_pass!(DropForgetUseless => [DROPPING_REFERENCES, FORGET_REF, DROPPING_COPY_TYPES, FORGETTING_COPY_TYPES]); +declare_lint_pass!(DropForgetUseless => [DROPPING_REFERENCES, FORGETTING_REFERENCES, DROPPING_COPY_TYPES, FORGETTING_COPY_TYPES]); impl<'tcx> LateLintPass<'tcx> for DropForgetUseless { fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) { @@ -126,7 +126,7 @@ impl<'tcx> LateLintPass<'tcx> for DropForgetUseless { cx.emit_spanned_lint(DROPPING_REFERENCES, expr.span, DropRefDiag { arg_ty, label: arg.span }); }, sym::mem_forget if arg_ty.is_ref() => { - cx.emit_spanned_lint(FORGET_REF, expr.span, ForgetRefDiag { arg_ty, label: arg.span }); + cx.emit_spanned_lint(FORGETTING_REFERENCES, expr.span, ForgetRefDiag { arg_ty, label: arg.span }); }, sym::mem_drop if is_copy && !drop_is_single_call_in_arm => { cx.emit_spanned_lint(DROPPING_COPY_TYPES, expr.span, DropCopyDiag { arg_ty, label: arg.span }); diff --git a/compiler/rustc_lint/src/lints.rs b/compiler/rustc_lint/src/lints.rs index aebfa6f3078cf..de1c2be287576 100644 --- a/compiler/rustc_lint/src/lints.rs +++ b/compiler/rustc_lint/src/lints.rs @@ -682,7 +682,7 @@ pub struct DropCopyDiag<'a> { } #[derive(LintDiagnostic)] -#[diag(lint_forget_ref)] +#[diag(lint_forgetting_references)] #[note] pub struct ForgetRefDiag<'a> { pub arg_ty: Ty<'a>, diff --git a/src/tools/clippy/clippy_lints/src/drop_forget_ref.rs b/src/tools/clippy/clippy_lints/src/drop_forget_ref.rs index 00211d65094ee..9c60edb179415 100644 --- a/src/tools/clippy/clippy_lints/src/drop_forget_ref.rs +++ b/src/tools/clippy/clippy_lints/src/drop_forget_ref.rs @@ -98,7 +98,7 @@ impl<'tcx> LateLintPass<'tcx> for DropForgetRef { let is_copy = is_copy(cx, arg_ty); let drop_is_single_call_in_arm = is_single_call_in_arm(cx, arg, expr); let (lint, msg) = match fn_name { - // early return for uplifted lints: dropping_references, dropping_copy_types, forget_ref, forgetting_copy_types + // early return for uplifted lints: dropping_references, dropping_copy_types, forgetting_references, forgetting_copy_types sym::mem_drop if arg_ty.is_ref() && !drop_is_single_call_in_arm => return, sym::mem_forget if arg_ty.is_ref() => return, sym::mem_drop if is_copy && !drop_is_single_call_in_arm => return, diff --git a/src/tools/clippy/clippy_lints/src/renamed_lints.rs b/src/tools/clippy/clippy_lints/src/renamed_lints.rs index 4d1a462d110ca..b0db56bb417ea 100644 --- a/src/tools/clippy/clippy_lints/src/renamed_lints.rs +++ b/src/tools/clippy/clippy_lints/src/renamed_lints.rs @@ -39,7 +39,7 @@ pub static RENAMED_LINTS: &[(&str, &str)] = &[ ("clippy::for_loop_over_result", "for_loops_over_fallibles"), ("clippy::for_loops_over_fallibles", "for_loops_over_fallibles"), ("clippy::forget_copy", "forgetting_copy_types"), - ("clippy::forget_ref", "forget_ref"), + ("clippy::forget_ref", "forgetting_references"), ("clippy::into_iter_on_array", "array_into_iter"), ("clippy::invalid_atomic_ordering", "invalid_atomic_ordering"), ("clippy::invalid_ref", "invalid_value"), diff --git a/src/tools/clippy/tests/ui/rename.fixed b/src/tools/clippy/tests/ui/rename.fixed index a4fb4fbffdfc8..dfe45dec8a745 100644 --- a/src/tools/clippy/tests/ui/rename.fixed +++ b/src/tools/clippy/tests/ui/rename.fixed @@ -34,7 +34,7 @@ #![allow(dropping_references)] #![allow(for_loops_over_fallibles)] #![allow(forgetting_copy_types)] -#![allow(forget_ref)] +#![allow(forgetting_references)] #![allow(array_into_iter)] #![allow(invalid_atomic_ordering)] #![allow(invalid_value)] @@ -83,7 +83,7 @@ #![warn(for_loops_over_fallibles)] #![warn(for_loops_over_fallibles)] #![warn(forgetting_copy_types)] -#![warn(forget_ref)] +#![warn(forgetting_references)] #![warn(array_into_iter)] #![warn(invalid_atomic_ordering)] #![warn(invalid_value)] diff --git a/src/tools/clippy/tests/ui/rename.rs b/src/tools/clippy/tests/ui/rename.rs index bb833c9534688..ce8eca5a3081c 100644 --- a/src/tools/clippy/tests/ui/rename.rs +++ b/src/tools/clippy/tests/ui/rename.rs @@ -34,7 +34,7 @@ #![allow(dropping_references)] #![allow(for_loops_over_fallibles)] #![allow(forgetting_copy_types)] -#![allow(forget_ref)] +#![allow(forgetting_references)] #![allow(array_into_iter)] #![allow(invalid_atomic_ordering)] #![allow(invalid_value)] diff --git a/src/tools/clippy/tests/ui/rename.stderr b/src/tools/clippy/tests/ui/rename.stderr index 8bbd046bbf31b..3fca60aa2ebd3 100644 --- a/src/tools/clippy/tests/ui/rename.stderr +++ b/src/tools/clippy/tests/ui/rename.stderr @@ -222,11 +222,11 @@ error: lint `clippy::forget_copy` has been renamed to `forgetting_copy_types` LL | #![warn(clippy::forget_copy)] | ^^^^^^^^^^^^^^^^^^^ help: use the new name: `forgetting_copy_types` -error: lint `clippy::forget_ref` has been renamed to `forget_ref` +error: lint `clippy::forget_ref` has been renamed to `forgetting_references` --> $DIR/rename.rs:86:9 | LL | #![warn(clippy::forget_ref)] - | ^^^^^^^^^^^^^^^^^^ help: use the new name: `forget_ref` + | ^^^^^^^^^^^^^^^^^^ help: use the new name: `forgetting_references` error: lint `clippy::into_iter_on_array` has been renamed to `array_into_iter` --> $DIR/rename.rs:87:9 diff --git a/tests/ui/lint/forgetting_copy_types.stderr b/tests/ui/lint/forgetting_copy_types.stderr index cf4e1845f5681..36d1ef5c53e93 100644 --- a/tests/ui/lint/forgetting_copy_types.stderr +++ b/tests/ui/lint/forgetting_copy_types.stderr @@ -32,7 +32,7 @@ LL | forget(s3); | argument has type `&SomeStruct` | = note: use `let _ = ...` to ignore the expression or result - = note: `#[warn(forget_ref)]` on by default + = note: `#[warn(forgetting_references)]` on by default warning: calls to `std::mem::forget` with a value that implements `Copy` does nothing --> $DIR/forgetting_copy_types.rs:37:5 diff --git a/tests/ui/lint/forget_ref.rs b/tests/ui/lint/forgetting_references.rs similarity index 97% rename from tests/ui/lint/forget_ref.rs rename to tests/ui/lint/forgetting_references.rs index 13f6d4be3d153..bd51e98003159 100644 --- a/tests/ui/lint/forget_ref.rs +++ b/tests/ui/lint/forgetting_references.rs @@ -1,6 +1,6 @@ // check-pass -#![warn(forget_ref)] +#![warn(forgetting_references)] use std::mem::forget; diff --git a/tests/ui/lint/forget_ref.stderr b/tests/ui/lint/forgetting_references.stderr similarity index 84% rename from tests/ui/lint/forget_ref.stderr rename to tests/ui/lint/forgetting_references.stderr index 63fc779198007..5624b690789f8 100644 --- a/tests/ui/lint/forget_ref.stderr +++ b/tests/ui/lint/forgetting_references.stderr @@ -1,5 +1,5 @@ warning: calls to `std::mem::forget` with a reference instead of an owned value does nothing - --> $DIR/forget_ref.rs:10:5 + --> $DIR/forgetting_references.rs:10:5 | LL | forget(&SomeStruct); | ^^^^^^^-----------^ @@ -8,13 +8,13 @@ LL | forget(&SomeStruct); | = note: use `let _ = ...` to ignore the expression or result note: the lint level is defined here - --> $DIR/forget_ref.rs:3:9 + --> $DIR/forgetting_references.rs:3:9 | -LL | #![warn(forget_ref)] - | ^^^^^^^^^^ +LL | #![warn(forgetting_references)] + | ^^^^^^^^^^^^^^^^^^^^^ warning: calls to `std::mem::forget` with a reference instead of an owned value does nothing - --> $DIR/forget_ref.rs:13:5 + --> $DIR/forgetting_references.rs:13:5 | LL | forget(&owned); | ^^^^^^^------^ @@ -24,7 +24,7 @@ LL | forget(&owned); = note: use `let _ = ...` to ignore the expression or result warning: calls to `std::mem::forget` with a reference instead of an owned value does nothing - --> $DIR/forget_ref.rs:14:5 + --> $DIR/forgetting_references.rs:14:5 | LL | forget(&&owned); | ^^^^^^^-------^ @@ -34,7 +34,7 @@ LL | forget(&&owned); = note: use `let _ = ...` to ignore the expression or result warning: calls to `std::mem::forget` with a reference instead of an owned value does nothing - --> $DIR/forget_ref.rs:15:5 + --> $DIR/forgetting_references.rs:15:5 | LL | forget(&mut owned); | ^^^^^^^----------^ @@ -44,7 +44,7 @@ LL | forget(&mut owned); = note: use `let _ = ...` to ignore the expression or result warning: calls to `std::mem::forget` with a reference instead of an owned value does nothing - --> $DIR/forget_ref.rs:19:5 + --> $DIR/forgetting_references.rs:19:5 | LL | forget(&*reference1); | ^^^^^^^------------^ @@ -54,7 +54,7 @@ LL | forget(&*reference1); = note: use `let _ = ...` to ignore the expression or result warning: calls to `std::mem::forget` with a reference instead of an owned value does nothing - --> $DIR/forget_ref.rs:22:5 + --> $DIR/forgetting_references.rs:22:5 | LL | forget(reference2); | ^^^^^^^----------^ @@ -64,7 +64,7 @@ LL | forget(reference2); = note: use `let _ = ...` to ignore the expression or result warning: calls to `std::mem::forget` with a reference instead of an owned value does nothing - --> $DIR/forget_ref.rs:25:5 + --> $DIR/forgetting_references.rs:25:5 | LL | forget(reference3); | ^^^^^^^----------^ @@ -74,7 +74,7 @@ LL | forget(reference3); = note: use `let _ = ...` to ignore the expression or result warning: calls to `std::mem::forget` with a reference instead of an owned value does nothing - --> $DIR/forget_ref.rs:30:5 + --> $DIR/forgetting_references.rs:30:5 | LL | forget(&val); | ^^^^^^^----^ @@ -84,7 +84,7 @@ LL | forget(&val); = note: use `let _ = ...` to ignore the expression or result warning: calls to `std::mem::forget` with a reference instead of an owned value does nothing - --> $DIR/forget_ref.rs:38:5 + --> $DIR/forgetting_references.rs:38:5 | LL | std::mem::forget(&SomeStruct); | ^^^^^^^^^^^^^^^^^-----------^ From 8294131ceb420f0355b50beb240df3f7a8ef0df2 Mon Sep 17 00:00:00 2001 From: lcnr Date: Mon, 22 May 2023 16:42:34 +0200 Subject: [PATCH 11/13] move lcnr to only review types stuff --- triagebot.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/triagebot.toml b/triagebot.toml index 046d732bd4257..d7cd3ea1275c5 100644 --- a/triagebot.toml +++ b/triagebot.toml @@ -482,7 +482,6 @@ compiler-team = [ "@petrochenkov", "@davidtwco", "@oli-obk", - "@lcnr", "@wesleywiser", ] compiler-team-contributors = [ @@ -593,6 +592,7 @@ style-team = [ "/compiler/rustc_llvm" = ["@cuviper"] "/compiler/rustc_middle/src/mir" = ["compiler", "mir"] "/compiler/rustc_middle/src/traits" = ["compiler", "types"] +"/compiler/rustc_middle/src/ty" = ["compiler", "types"] "/compiler/rustc_const_eval/src/interpret" = ["compiler", "mir"] "/compiler/rustc_const_eval/src/transform" = ["compiler", "mir-opt"] "/compiler/rustc_mir_build/src/build" = ["compiler", "mir"] From 56b8b1c3537ab3311b350a407442bffe7f0ace26 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 22 May 2023 17:33:42 +0200 Subject: [PATCH 12/13] Update browser-ui-test to 0.16.4 --- .../docker/host-x86_64/x86_64-gnu-tools/browser-ui-test.version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ci/docker/host-x86_64/x86_64-gnu-tools/browser-ui-test.version b/src/ci/docker/host-x86_64/x86_64-gnu-tools/browser-ui-test.version index 6b4966ddeb408..806935b827ff5 100644 --- a/src/ci/docker/host-x86_64/x86_64-gnu-tools/browser-ui-test.version +++ b/src/ci/docker/host-x86_64/x86_64-gnu-tools/browser-ui-test.version @@ -1 +1 @@ -0.16.3 \ No newline at end of file +0.16.4 \ No newline at end of file From 194960bae9b3e4b1ca2a6825b42e7110fd204b87 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 22 May 2023 17:34:48 +0200 Subject: [PATCH 13/13] Migrate GUI colors test to original CSS color format --- tests/rustdoc-gui/scrape-examples-color.goml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/rustdoc-gui/scrape-examples-color.goml b/tests/rustdoc-gui/scrape-examples-color.goml index 8ddb06fccfca6..b6991b912b583 100644 --- a/tests/rustdoc-gui/scrape-examples-color.goml +++ b/tests/rustdoc-gui/scrape-examples-color.goml @@ -81,16 +81,16 @@ define-function: ( call-function: ("check-background", { "theme": "ayu", - "background_color_start": "rgb(15, 20, 25)", + "background_color_start": "rgba(15, 20, 25, 1)", "background_color_end": "rgba(15, 20, 25, 0)", }) call-function: ("check-background", { "theme": "dark", - "background_color_start": "rgb(53, 53, 53)", + "background_color_start": "rgba(53, 53, 53, 1)", "background_color_end": "rgba(53, 53, 53, 0)", }) call-function: ("check-background", { "theme": "light", - "background_color_start": "rgb(255, 255, 255)", + "background_color_start": "rgba(255, 255, 255, 1)", "background_color_end": "rgba(255, 255, 255, 0)", })