Auto merge of #111848 - Dylan-DPC:rollup-7jqydzg, r=Dylan-DPC

Rollup of 6 pull requests

Successful merges:

 - #111501 (MIR drive-by cleanups)
 - #111609 (Mark internal functions and traits unsafe to reflect preconditions)
 - #111612 (Give better error when collecting into `&[T]`)
 - #111756 (Rename `{drop,forget}_{copy,ref}` lints to more consistent naming)
 - #111843 (move lcnr to only review types stuff)
 - #111844 (Migrate GUI colors test to original CSS color format)

r? `@ghost`
`@rustbot` modify labels: rollup
This commit is contained in:
bors 2023-05-22 20:33:51 +00:00
commit 8b4b20836b
98 changed files with 376 additions and 372 deletions

View File

@ -521,18 +521,18 @@ 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
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
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
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

View File

@ -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,13 +29,13 @@ 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"
}
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,13 +52,13 @@ 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"
}
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,13 +76,13 @@ 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"
}
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, DROP_COPY, FORGET_COPY]);
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>) {
@ -123,16 +123,16 @@ 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 });
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(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 });
cx.emit_spanned_lint(FORGETTING_COPY_TYPES, expr.span, ForgetCopyDiag { arg_ty, label: arg.span });
}
_ => return,
};

View File

@ -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>,
@ -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>,
@ -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>,
@ -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>,

View File

@ -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)]

View File

@ -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;
@ -671,12 +674,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

View File

@ -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);

View File

@ -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::<Vec<_>>();
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",
}
}

View File

@ -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
)
}

View File

@ -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::<Vec<_>>()
@ -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) })

View File

@ -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) {

View File

@ -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<T, I>: Iterator<Item = T> {
/// `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<T, I> SpecInPlaceCollect<T, I> for I
@ -247,7 +248,7 @@ where
I: Iterator<Item = T>,
{
#[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<Item = T> + 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 {

View File

@ -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<T>(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.

View File

@ -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(())

View File

@ -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) }
}
$(

View File

@ -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",

View File

@ -968,7 +968,7 @@ pub const fn replace<T>(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);
///

View File

@ -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<Component<'b>> {
// 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<Component<'b>> {
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

View File

@ -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: 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,

View File

@ -33,13 +33,13 @@ 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_ref", "drop_ref"),
("clippy::drop_copy", "dropping_copy_types"),
("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"),
("clippy::forget_copy", "forget_copy"),
("clippy::forget_ref", "forget_ref"),
("clippy::forget_copy", "forgetting_copy_types"),
("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"),

View File

@ -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);

View File

@ -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;

View File

@ -30,11 +30,11 @@
#![allow(clippy::invisible_characters)]
#![allow(suspicious_double_ref_op)]
#![allow(drop_bounds)]
#![allow(drop_copy)]
#![allow(drop_ref)]
#![allow(dropping_copy_types)]
#![allow(dropping_references)]
#![allow(for_loops_over_fallibles)]
#![allow(forget_copy)]
#![allow(forget_ref)]
#![allow(forgetting_copy_types)]
#![allow(forgetting_references)]
#![allow(array_into_iter)]
#![allow(invalid_atomic_ordering)]
#![allow(invalid_value)]
@ -77,13 +77,13 @@
#![warn(clippy::invisible_characters)]
#![warn(suspicious_double_ref_op)]
#![warn(drop_bounds)]
#![warn(drop_copy)]
#![warn(drop_ref)]
#![warn(dropping_copy_types)]
#![warn(dropping_references)]
#![warn(for_loops_over_fallibles)]
#![warn(for_loops_over_fallibles)]
#![warn(for_loops_over_fallibles)]
#![warn(forget_copy)]
#![warn(forget_ref)]
#![warn(forgetting_copy_types)]
#![warn(forgetting_references)]
#![warn(array_into_iter)]
#![warn(invalid_atomic_ordering)]
#![warn(invalid_value)]

View File

@ -30,11 +30,11 @@
#![allow(clippy::invisible_characters)]
#![allow(suspicious_double_ref_op)]
#![allow(drop_bounds)]
#![allow(drop_copy)]
#![allow(drop_ref)]
#![allow(dropping_copy_types)]
#![allow(dropping_references)]
#![allow(for_loops_over_fallibles)]
#![allow(forget_copy)]
#![allow(forget_ref)]
#![allow(forgetting_copy_types)]
#![allow(forgetting_references)]
#![allow(array_into_iter)]
#![allow(invalid_atomic_ordering)]
#![allow(invalid_value)]

View File

@ -186,17 +186,17 @@ 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`
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
@ -216,17 +216,17 @@ 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`
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

View File

@ -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: !) -> ! {

View File

@ -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

View File

@ -1,4 +1,4 @@
#![allow(drop_ref)]
#![allow(dropping_references)]
fn main() {
let target = &mut 42;

View File

@ -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;

View File

@ -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.

View File

@ -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];

View File

@ -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<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: std::boxed::Box<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 std::boxed::Box<Never> (Transmute); // scope 2 at $DIR/transmute.rs:+1:34: +1:52
+ _2 = const Box::<Never>(Unique::<Never> {{ pointer: NonNull::<Never> {{ pointer: {0x1 as *const Never} }}, _marker: PhantomData::<Never> }}, 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<Never> (Transmute); // scope 2 at $DIR/transmute.rs:+1:34: +1:52
+ _1 = const Box::<Never>(Unique::<Never> {{ pointer: NonNull::<Never> {{ pointer: {0x1 as *const Never} }}, _marker: PhantomData::<Never> }}, std::alloc::Global); // scope 2 at $DIR/transmute.rs:+1:34: +1:52
+ // mir::Constant
+ // + span: no-location
+ // + literal: Const { ty: Box<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
}
}

View File

@ -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<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: std::boxed::Box<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 std::boxed::Box<Never> (Transmute); // scope 2 at $DIR/transmute.rs:+1:34: +1:52
+ _2 = const Box::<Never>(Unique::<Never> {{ pointer: NonNull::<Never> {{ pointer: {0x1 as *const Never} }}, _marker: PhantomData::<Never> }}, 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<Never> (Transmute); // scope 2 at $DIR/transmute.rs:+1:34: +1:52
+ _1 = const Box::<Never>(Unique::<Never> {{ pointer: NonNull::<Never> {{ pointer: {0x1 as *const Never} }}, _marker: PhantomData::<Never> }}, std::alloc::Global); // scope 2 at $DIR/transmute.rs:+1:34: +1:52
+ // mir::Constant
+ // + span: no-location
+ // + literal: Const { ty: Box<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
}
}

View File

@ -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
}
}

View File

@ -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
}
}

View File

@ -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
}
}

View File

@ -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
}
}

View File

@ -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
}
}

View File

@ -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
}
}

View File

@ -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
}
}

View File

@ -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<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: std::boxed::Box<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::<usize, Box<Never>>(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::<usize, Box<Never>>(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<Never> {transmute::<usize, Box<Never>>}, val: Value(<ZST>) }
+ _2 = const 1_usize as std::boxed::Box<Never> (Transmute); // scope 0 at $DIR/lower_intrinsics.rs:+1:25: +1:52
+ _1 = const 1_usize as std::boxed::Box<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
}
}

View File

@ -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::<usize, &mut Never>(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::<usize, &mut Never>(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::<usize, &mut Never>}, val: Value(<ZST>) }
+ _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
}
}

View File

@ -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::<usize, &Never>(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::<usize, &Never>(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::<usize, &Never>}, val: Value(<ZST>) }
+ _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
}
}

View File

@ -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(<ZST>) }

View File

@ -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)",
})

View File

@ -3,7 +3,7 @@
#![feature(inherent_associated_types)]
#![allow(incomplete_features)]
#![allow(drop_copy)]
#![allow(dropping_copy_types)]
use std::convert::identity;

View File

@ -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

View File

@ -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<isize> }

View File

@ -1,7 +1,7 @@
// run-pass
// pretty-expanded FIXME #23616
#![allow(drop_copy)]
#![allow(dropping_copy_types)]
struct A { a: isize, b: Box<isize> }

View File

@ -1,7 +1,7 @@
// run-pass
#![warn(rust_2021_incompatible_closure_captures)]
#![allow(drop_ref, drop_copy)]
#![allow(dropping_references, dropping_copy_types)]
fn main() {
if let a = "" {

View File

@ -3,7 +3,7 @@
#![allow(unused)]
#![allow(dead_code)]
#![allow(drop_ref)]
#![allow(dropping_references)]
struct Int(i32);
struct B<'a>(&'a i32);

View File

@ -2,7 +2,7 @@
// check-pass
#![feature(rustc_attrs)]
#![allow(drop_ref)]
#![allow(dropping_references)]
fn main() {
let mut x = 1;

View File

@ -1,6 +1,6 @@
// check-pass
#![allow(forget_copy)]
#![allow(forgetting_copy_types)]
use std::mem::forget;

View File

@ -1,6 +1,6 @@
// check-pass
#![allow(forget_copy)]
#![allow(forgetting_copy_types)]
const _: () = core::mem::forget(Box::<u32>::default);
const _: () = core::mem::forget(|| Box::<u32>::default());

View File

@ -1,7 +1,7 @@
// run-pass
// pretty-expanded FIXME #23616
#![allow(drop_copy)]
#![allow(dropping_copy_types)]
fn main() {
use ::std::mem;

View File

@ -1,7 +1,7 @@
// run-pass
// needs-unwind
#![allow(drop_ref, drop_copy)]
#![allow(dropping_references, dropping_copy_types)]
static mut CHECK: usize = 0;

View File

@ -1,6 +1,6 @@
// run-rustfix
#![allow(drop_ref)]
#![allow(dropping_references)]
struct Foo {
x: isize

View File

@ -1,6 +1,6 @@
// run-rustfix
#![allow(drop_ref)]
#![allow(dropping_references)]
struct Foo {
x: isize

View File

@ -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;

View File

@ -5,7 +5,7 @@
// [drop_tracking_mir] build-pass
#![feature(generators, negative_impls)]
#![allow(drop_ref, drop_copy)]
#![allow(dropping_references, dropping_copy_types)]
macro_rules! type_combinations {
(

View File

@ -3,7 +3,7 @@
// run-pass
#![feature(generators, generator_trait)]
#![allow(drop_copy)]
#![allow(dropping_copy_types)]
use std::marker::{PhantomPinned, Unpin};

View File

@ -1,5 +1,5 @@
#![feature(generators)]
#![allow(drop_copy)]
#![allow(dropping_copy_types)]
// run-pass

View File

@ -1,7 +1,7 @@
// check-pass
#![feature(decl_macro)]
#![allow(drop_copy)]
#![allow(dropping_copy_types)]
macro mac() {
mod m {

View File

@ -1,6 +1,6 @@
// run-rustfix
#![allow(drop_ref)]
#![allow(dropping_references)]
struct Foo;

View File

@ -1,6 +1,6 @@
// run-rustfix
#![allow(drop_ref)]
#![allow(dropping_references)]
struct Foo;

View File

@ -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);
}

View File

@ -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`.

View File

@ -1,6 +1,6 @@
// check-pass
#![warn(drop_copy)]
#![warn(dropping_copy_types)]
use std::mem::drop;
use std::vec::Vec;

View File

@ -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);
| ^^^^^--^
@ -32,10 +32,10 @@ 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/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),
| ^^^^^-^

View File

@ -1,6 +1,6 @@
// check-pass
#![warn(drop_ref)]
#![warn(dropping_references)]
struct SomeStruct;

View File

@ -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),
| ^^^^^--^

View File

@ -1,6 +1,6 @@
// check-pass
#![warn(forget_copy)]
#![warn(forgetting_copy_types)]
use std::mem::forget;
use std::vec::Vec;

View File

@ -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);
| ^^^^^^^--^
@ -32,10 +32,10 @@ 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/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);
| ^^^^^^^--^

View File

@ -1,6 +1,6 @@
// check-pass
#![warn(forget_ref)]
#![warn(forgetting_references)]
use std::mem::forget;

View File

@ -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);
| ^^^^^^^^^^^^^^^^^-----------^

View File

@ -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;

View File

@ -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.

View File

@ -3,7 +3,7 @@
// check-pass
#![feature(never_type)]
#![allow(drop_copy)]
#![allow(dropping_copy_types)]
#![warn(unused)]
fn main() {

View File

@ -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!()

View File

@ -3,7 +3,7 @@
//
// check-pass
#![allow(drop_ref)]
#![allow(dropping_references)]
trait MyTrait<'a> {
type Output;

View File

@ -3,8 +3,8 @@
// check-pass
#![allow(irrefutable_let_patterns)]
#![allow(drop_copy)]
#![allow(drop_ref)]
#![allow(dropping_copy_types)]
#![allow(dropping_references)]
fn main() {
// A regression test for a mistake we made at one point:

View File

@ -2,8 +2,8 @@
// Test `@` patterns combined with `box` patterns.
#![allow(drop_ref)]
#![allow(drop_copy)]
#![allow(dropping_references)]
#![allow(dropping_copy_types)]
#![feature(box_patterns)]

View File

@ -2,7 +2,7 @@
// Test `Copy` bindings in the rhs of `@` patterns.
#![allow(drop_copy)]
#![allow(dropping_copy_types)]
#[derive(Copy, Clone)]
struct C;

View File

@ -1,6 +1,6 @@
// check-pass
#![allow(drop_ref)]
#![allow(dropping_references)]
fn main() {}

View File

@ -1,6 +1,6 @@
// check-pass
#![allow(drop_ref)]
#![allow(dropping_references)]
fn main() {
struct U;

View File

@ -3,7 +3,7 @@
// build-pass
// ignore-pass
#![allow(drop_copy)]
#![allow(dropping_copy_types)]
async fn wait() {}

View File

@ -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 = || {

View File

@ -3,7 +3,7 @@
// check-pass
#![allow(drop_copy)]
#![allow(dropping_copy_types)]
use std::marker::PhantomData;

View File

@ -3,7 +3,7 @@
// check-pass
#![allow(drop_ref)]
#![allow(dropping_references)]
// aux-build:monovariants.rs
extern crate monovariants;

View File

@ -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;

View File

@ -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`

View File

@ -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`

View File

@ -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]

View File

@ -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,

View File

@ -6,7 +6,7 @@
// check-pass
#![allow(drop_copy)]
#![allow(dropping_copy_types)]
trait A {
type B;

View File

@ -14,7 +14,7 @@ async fn foo() {
#[cfg(fail)]
let x = &NotSync;
bar().await;
#[allow(drop_ref)]
#[allow(dropping_references)]
drop(x);
}

View File

@ -2,7 +2,7 @@
// Check tautalogically false `Copy` bounds
#![feature(trivial_bounds)]
#![allow(drop_ref, drop_copy)]
#![allow(dropping_references, dropping_copy_types)]
fn copy_string(t: String) -> String where String: Copy { //~ WARNING trivial_bounds
is_copy(&t);

View File

@ -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"]