Diagnose liveness on MIR.
This commit is contained in:
parent
96b70fc3a1
commit
ca0379d6cd
88 changed files with 2592 additions and 2761 deletions
|
|
@ -1095,6 +1095,7 @@ fn run_required_analyses(tcx: TyCtxt<'_>) {
|
|||
tcx.ensure_ok().check_transmutes(def_id);
|
||||
}
|
||||
tcx.ensure_ok().has_ffi_unwind_calls(def_id);
|
||||
tcx.ensure_ok().check_liveness(def_id);
|
||||
|
||||
// If we need to codegen, ensure that we emit all errors from
|
||||
// `mir_drops_elaborated_and_const_checked` now, to avoid discovering
|
||||
|
|
|
|||
|
|
@ -894,7 +894,7 @@ pub enum BindingForm<'tcx> {
|
|||
/// Binding for a `self`/`&self`/`&mut self` binding where the type is implicit.
|
||||
ImplicitSelf(ImplicitSelfKind),
|
||||
/// Reference used in a guard expression to ensure immutability.
|
||||
RefForGuard,
|
||||
RefForGuard(Local),
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, TyEncodable, TyDecodable, HashStable)]
|
||||
|
|
@ -917,7 +917,7 @@ mod binding_form_impl {
|
|||
match self {
|
||||
Var(binding) => binding.hash_stable(hcx, hasher),
|
||||
ImplicitSelf(kind) => kind.hash_stable(hcx, hasher),
|
||||
RefForGuard => (),
|
||||
RefForGuard(local) => local.hash_stable(hcx, hasher),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1129,7 +1129,7 @@ impl<'tcx> LocalDecl<'tcx> {
|
|||
/// expression that is used to access said variable for the guard of the
|
||||
/// match arm.
|
||||
pub fn is_ref_for_guard(&self) -> bool {
|
||||
matches!(self.local_info(), LocalInfo::User(BindingForm::RefForGuard))
|
||||
matches!(self.local_info(), LocalInfo::User(BindingForm::RefForGuard(_)))
|
||||
}
|
||||
|
||||
/// Returns `Some` if this is a reference to a static item that is used to
|
||||
|
|
|
|||
|
|
@ -259,7 +259,7 @@ impl<'tcx> PlaceTy<'tcx> {
|
|||
impl<V, T> ProjectionElem<V, T> {
|
||||
/// Returns `true` if the target of this projection may refer to a different region of memory
|
||||
/// than the base.
|
||||
fn is_indirect(&self) -> bool {
|
||||
pub fn is_indirect(&self) -> bool {
|
||||
match self {
|
||||
Self::Deref => true,
|
||||
|
||||
|
|
|
|||
|
|
@ -1195,8 +1195,10 @@ rustc_queries! {
|
|||
desc { |tcx| "checking privacy in {}", describe_as_module(key.to_local_def_id(), tcx) }
|
||||
}
|
||||
|
||||
query check_liveness(key: LocalDefId) {
|
||||
desc { |tcx| "checking liveness of variables in `{}`", tcx.def_path_str(key) }
|
||||
query check_liveness(key: LocalDefId) -> &'tcx rustc_index::bit_set::DenseBitSet<abi::FieldIdx> {
|
||||
arena_cache
|
||||
desc { |tcx| "checking liveness of variables in `{}`", tcx.def_path_str(key.to_def_id()) }
|
||||
cache_on_disk_if(tcx) { tcx.is_typeck_child(key.to_def_id()) }
|
||||
}
|
||||
|
||||
/// Return the live symbols in the crate for dead code check.
|
||||
|
|
|
|||
|
|
@ -327,6 +327,11 @@ pub fn place_to_string_for_capture<'tcx>(tcx: TyCtxt<'tcx>, place: &HirPlace<'tc
|
|||
)
|
||||
}
|
||||
},
|
||||
HirProjectionKind::UnwrapUnsafeBinder => {
|
||||
curr_string = format!("unwrap_binder!({curr_string})");
|
||||
}
|
||||
// Just change the type to the hidden type, so we can actually project.
|
||||
HirProjectionKind::OpaqueCast => {}
|
||||
proj => bug!("{:?} unexpected because it isn't captured", proj),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2864,7 +2864,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
user_ty: None,
|
||||
source_info,
|
||||
local_info: ClearCrossCrate::Set(Box::new(LocalInfo::User(
|
||||
BindingForm::RefForGuard,
|
||||
BindingForm::RefForGuard(for_arm_body),
|
||||
))),
|
||||
});
|
||||
if self.should_emit_debug_info_for_binding(name, var_id) {
|
||||
|
|
|
|||
|
|
@ -69,11 +69,6 @@ pub fn build_mir<'tcx>(tcx: TyCtxt<'tcx>, def: LocalDefId) -> Body<'tcx> {
|
|||
}
|
||||
};
|
||||
|
||||
// Checking liveness after building the THIR ensures there were no typeck errors.
|
||||
//
|
||||
// maybe move the check to a MIR pass?
|
||||
tcx.ensure_ok().check_liveness(def);
|
||||
|
||||
// Don't steal here, instead steal in unsafeck. This is so that
|
||||
// pattern inline constants can be evaluated as part of building the
|
||||
// THIR of the parent function without a cycle.
|
||||
|
|
|
|||
|
|
@ -34,12 +34,16 @@ mir_transform_force_inline_attr =
|
|||
mir_transform_force_inline_justification =
|
||||
`{$callee}` is required to be inlined to: {$sym}
|
||||
|
||||
mir_transform_maybe_string_interpolation = you might have meant to use string interpolation in this string literal
|
||||
|
||||
mir_transform_must_not_suspend = {$pre}`{$def_path}`{$post} held across a suspend point, but should not be
|
||||
.label = the value is held across this suspend point
|
||||
.note = {$reason}
|
||||
.help = consider using a block (`{"{ ... }"}`) to shrink the value's scope, ending before the suspend point
|
||||
mir_transform_operation_will_panic = this operation will panic at runtime
|
||||
|
||||
mir_transform_string_interpolation_only_works = string interpolation only works in `format!` invocations
|
||||
|
||||
mir_transform_tail_expr_drop_order = relative drop order changing in Rust 2024
|
||||
.temporaries = in Rust 2024, this temporary value will be dropped first
|
||||
.observers = in Rust 2024, this local variable or temporary value will be dropped second
|
||||
|
|
@ -77,3 +81,26 @@ mir_transform_unconditional_recursion = function cannot return without recursing
|
|||
mir_transform_unconditional_recursion_call_site_label = recursive call site
|
||||
|
||||
mir_transform_unknown_pass_name = MIR pass `{$name}` is unknown and will be ignored
|
||||
|
||||
mir_transform_unused_assign = value assigned to `{$name}` is never read
|
||||
.help = maybe it is overwritten before being read?
|
||||
|
||||
mir_transform_unused_assign_passed = value passed to `{$name}` is never read
|
||||
.help = maybe it is overwritten before being read?
|
||||
|
||||
mir_transform_unused_assign_suggestion =
|
||||
you might have meant to mutate the pointed at value being passed in, instead of changing the reference in the local binding
|
||||
|
||||
mir_transform_unused_capture_maybe_capture_ref = value captured by `{$name}` is never read
|
||||
.help = did you mean to capture by reference instead?
|
||||
|
||||
mir_transform_unused_var_assigned_only = variable `{$name}` is assigned to, but never used
|
||||
.note = consider using `_{$name}` instead
|
||||
|
||||
mir_transform_unused_var_underscore = if this is intentional, prefix it with an underscore
|
||||
|
||||
mir_transform_unused_variable = unused variable: `{$name}`
|
||||
|
||||
mir_transform_unused_variable_args_in_macro = `{$name}` is captured in macro and introduced a unused variable
|
||||
|
||||
mir_transform_unused_variable_try_ignore = try ignoring the field
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use rustc_errors::codes::*;
|
||||
use rustc_errors::{Diag, LintDiagnostic};
|
||||
use rustc_errors::{Applicability, Diag, EmissionGuarantee, LintDiagnostic, Subdiagnostic};
|
||||
use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
|
||||
use rustc_middle::mir::AssertKind;
|
||||
use rustc_middle::query::Key;
|
||||
|
|
@ -158,6 +158,114 @@ pub(crate) struct FnItemRef {
|
|||
pub ident: Ident,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[diag(mir_transform_unused_capture_maybe_capture_ref)]
|
||||
#[help]
|
||||
pub(crate) struct UnusedCaptureMaybeCaptureRef {
|
||||
pub name: Symbol,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[diag(mir_transform_unused_var_assigned_only)]
|
||||
#[note]
|
||||
pub(crate) struct UnusedVarAssignedOnly {
|
||||
pub name: Symbol,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[diag(mir_transform_unused_assign)]
|
||||
pub(crate) struct UnusedAssign {
|
||||
pub name: Symbol,
|
||||
#[subdiagnostic]
|
||||
pub suggestion: Option<UnusedAssignSuggestion>,
|
||||
#[help]
|
||||
pub help: bool,
|
||||
}
|
||||
|
||||
#[derive(Subdiagnostic)]
|
||||
#[multipart_suggestion(mir_transform_unused_assign_suggestion, applicability = "maybe-incorrect")]
|
||||
pub(crate) struct UnusedAssignSuggestion {
|
||||
pub pre: &'static str,
|
||||
#[suggestion_part(code = "{pre}mut ")]
|
||||
pub ty_span: Option<Span>,
|
||||
#[suggestion_part(code = "")]
|
||||
pub ty_ref_span: Span,
|
||||
#[suggestion_part(code = "*")]
|
||||
pub pre_lhs_span: Span,
|
||||
#[suggestion_part(code = "")]
|
||||
pub rhs_borrow_span: Span,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[diag(mir_transform_unused_assign_passed)]
|
||||
#[help]
|
||||
pub(crate) struct UnusedAssignPassed {
|
||||
pub name: Symbol,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[diag(mir_transform_unused_variable)]
|
||||
pub(crate) struct UnusedVariable {
|
||||
pub name: Symbol,
|
||||
#[subdiagnostic]
|
||||
pub string_interp: Vec<UnusedVariableStringInterp>,
|
||||
#[subdiagnostic]
|
||||
pub sugg: UnusedVariableSugg,
|
||||
}
|
||||
|
||||
#[derive(Subdiagnostic)]
|
||||
pub(crate) enum UnusedVariableSugg {
|
||||
#[multipart_suggestion(
|
||||
mir_transform_unused_variable_try_ignore,
|
||||
applicability = "machine-applicable"
|
||||
)]
|
||||
TryIgnore {
|
||||
#[suggestion_part(code = "{name}: _")]
|
||||
shorthands: Vec<Span>,
|
||||
#[suggestion_part(code = "_")]
|
||||
non_shorthands: Vec<Span>,
|
||||
name: Symbol,
|
||||
},
|
||||
|
||||
#[multipart_suggestion(
|
||||
mir_transform_unused_var_underscore,
|
||||
applicability = "machine-applicable"
|
||||
)]
|
||||
TryPrefix {
|
||||
#[suggestion_part(code = "_{name}")]
|
||||
spans: Vec<Span>,
|
||||
name: Symbol,
|
||||
},
|
||||
|
||||
#[help(mir_transform_unused_variable_args_in_macro)]
|
||||
NoSugg {
|
||||
#[primary_span]
|
||||
span: Span,
|
||||
name: Symbol,
|
||||
},
|
||||
}
|
||||
|
||||
pub(crate) struct UnusedVariableStringInterp {
|
||||
pub lit: Span,
|
||||
}
|
||||
|
||||
impl Subdiagnostic for UnusedVariableStringInterp {
|
||||
fn add_to_diag<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
|
||||
diag.span_label(
|
||||
self.lit,
|
||||
crate::fluent_generated::mir_transform_maybe_string_interpolation,
|
||||
);
|
||||
diag.multipart_suggestion(
|
||||
crate::fluent_generated::mir_transform_string_interpolation_only_works,
|
||||
vec![
|
||||
(self.lit.shrink_to_lo(), String::from("format!(")),
|
||||
(self.lit.shrink_to_hi(), String::from(")")),
|
||||
],
|
||||
Applicability::MachineApplicable,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) struct MustNotSupend<'a, 'tcx> {
|
||||
pub tcx: TyCtxt<'tcx>,
|
||||
pub yield_sp: Span,
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ mod errors;
|
|||
mod ffi_unwind_calls;
|
||||
mod lint;
|
||||
mod lint_tail_expr_drop_order;
|
||||
mod liveness;
|
||||
mod patch;
|
||||
mod shim;
|
||||
mod ssa;
|
||||
|
|
@ -215,6 +216,7 @@ pub fn provide(providers: &mut Providers) {
|
|||
mir_for_ctfe,
|
||||
mir_coroutine_witnesses: coroutine::mir_coroutine_witnesses,
|
||||
optimized_mir,
|
||||
check_liveness: liveness::check_liveness,
|
||||
is_mir_available,
|
||||
is_ctfe_mir_available: is_mir_available,
|
||||
mir_callgraph_cyclic: inline::cycle::mir_callgraph_cyclic,
|
||||
|
|
@ -512,6 +514,8 @@ fn mir_drops_elaborated_and_const_checked(tcx: TyCtxt<'_>, def: LocalDefId) -> &
|
|||
}
|
||||
}
|
||||
|
||||
tcx.ensure_done().check_liveness(def);
|
||||
|
||||
let (body, _) = tcx.mir_promoted(def);
|
||||
let mut body = body.steal();
|
||||
|
||||
|
|
|
|||
1328
compiler/rustc_mir_transform/src/liveness.rs
Normal file
1328
compiler/rustc_mir_transform/src/liveness.rs
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -395,8 +395,6 @@ passes_macro_only_attribute =
|
|||
passes_may_dangle =
|
||||
`#[may_dangle]` must be applied to a lifetime or type generic parameter in `Drop` impl
|
||||
|
||||
passes_maybe_string_interpolation = you might have meant to use string interpolation in this string literal
|
||||
|
||||
passes_missing_const_err =
|
||||
attributes `#[rustc_const_unstable]`, `#[rustc_const_stable]` and `#[rustc_const_stable_indirect]` require the function or method to be `const`
|
||||
.help = make the function or method const
|
||||
|
|
@ -568,8 +566,6 @@ passes_should_be_applied_to_trait =
|
|||
attribute should be applied to a trait
|
||||
.label = not a trait
|
||||
|
||||
passes_string_interpolation_only_works = string interpolation only works in `format!` invocations
|
||||
|
||||
passes_trait_impl_const_stability_mismatch = const stability on the impl does not match the const stability on the trait
|
||||
passes_trait_impl_const_stability_mismatch_impl_stable = this impl is (implicitly) stable...
|
||||
passes_trait_impl_const_stability_mismatch_impl_unstable = this impl is unstable...
|
||||
|
|
@ -636,18 +632,6 @@ passes_unused =
|
|||
unused attribute
|
||||
.suggestion = remove this attribute
|
||||
|
||||
passes_unused_assign = value assigned to `{$name}` is never read
|
||||
.help = maybe it is overwritten before being read?
|
||||
|
||||
passes_unused_assign_passed = value passed to `{$name}` is never read
|
||||
.help = maybe it is overwritten before being read?
|
||||
|
||||
passes_unused_assign_suggestion =
|
||||
you might have meant to mutate the pointed at value being passed in, instead of changing the reference in the local binding
|
||||
|
||||
passes_unused_capture_maybe_capture_ref = value captured by `{$name}` is never read
|
||||
.help = did you mean to capture by reference instead?
|
||||
|
||||
passes_unused_default_method_body_const_note =
|
||||
`default_method_body_is_const` has been replaced with `const` on traits
|
||||
|
||||
|
|
@ -671,25 +655,6 @@ passes_unused_multiple =
|
|||
passes_unused_no_lints_note =
|
||||
attribute `{$name}` without any lints has no effect
|
||||
|
||||
passes_unused_var_assigned_only = variable `{$name}` is assigned to, but never used
|
||||
.note = consider using `_{$name}` instead
|
||||
|
||||
passes_unused_var_maybe_capture_ref = unused variable: `{$name}`
|
||||
.help = did you mean to capture by reference instead?
|
||||
|
||||
passes_unused_var_remove_field = unused variable: `{$name}`
|
||||
passes_unused_var_remove_field_suggestion = try removing the field
|
||||
passes_unused_var_typo = you might have meant to pattern match on the similarly named {$kind} `{$item_name}`
|
||||
|
||||
passes_unused_variable_args_in_macro = `{$name}` is captured in macro and introduced a unused variable
|
||||
|
||||
passes_unused_variable_try_ignore = unused variable: `{$name}`
|
||||
.suggestion = try ignoring the field
|
||||
|
||||
passes_unused_variable_try_prefix = unused variable: `{$name}`
|
||||
.label = unused variable
|
||||
.suggestion = if this is intentional, prefix it with an underscore
|
||||
|
||||
passes_useless_assignment =
|
||||
useless assignment of {$is_field_assign ->
|
||||
[true] field
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ use std::path::{Path, PathBuf};
|
|||
use rustc_errors::codes::*;
|
||||
use rustc_errors::{
|
||||
Applicability, Diag, DiagCtxtHandle, DiagSymbolList, Diagnostic, EmissionGuarantee, Level,
|
||||
MultiSpan, Subdiagnostic,
|
||||
MultiSpan,
|
||||
};
|
||||
use rustc_hir::Target;
|
||||
use rustc_hir::attrs::{MirDialect, MirPhase};
|
||||
|
|
@ -1308,61 +1308,6 @@ pub(crate) struct ProcMacroBadSig {
|
|||
pub kind: ProcMacroKind,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[diag(passes_unused_var_maybe_capture_ref)]
|
||||
#[help]
|
||||
pub(crate) struct UnusedVarMaybeCaptureRef {
|
||||
pub name: String,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[diag(passes_unused_capture_maybe_capture_ref)]
|
||||
#[help]
|
||||
pub(crate) struct UnusedCaptureMaybeCaptureRef {
|
||||
pub name: String,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[diag(passes_unused_var_remove_field)]
|
||||
pub(crate) struct UnusedVarRemoveField {
|
||||
pub name: String,
|
||||
#[subdiagnostic]
|
||||
pub sugg: UnusedVarRemoveFieldSugg,
|
||||
}
|
||||
|
||||
#[derive(Subdiagnostic)]
|
||||
#[multipart_suggestion(
|
||||
passes_unused_var_remove_field_suggestion,
|
||||
applicability = "machine-applicable"
|
||||
)]
|
||||
pub(crate) struct UnusedVarRemoveFieldSugg {
|
||||
#[suggestion_part(code = "")]
|
||||
pub spans: Vec<Span>,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[diag(passes_unused_var_assigned_only)]
|
||||
#[note]
|
||||
pub(crate) struct UnusedVarAssignedOnly {
|
||||
pub name: String,
|
||||
#[subdiagnostic]
|
||||
pub typo: Option<PatternTypo>,
|
||||
}
|
||||
|
||||
#[derive(Subdiagnostic)]
|
||||
#[multipart_suggestion(
|
||||
passes_unused_var_typo,
|
||||
style = "verbose",
|
||||
applicability = "maybe-incorrect"
|
||||
)]
|
||||
pub(crate) struct PatternTypo {
|
||||
#[suggestion_part(code = "{code}")]
|
||||
pub span: Span,
|
||||
pub code: String,
|
||||
pub item_name: String,
|
||||
pub kind: String,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[diag(passes_unnecessary_stable_feature)]
|
||||
pub(crate) struct UnnecessaryStableFeature {
|
||||
|
|
@ -1387,102 +1332,6 @@ pub(crate) struct UnnecessaryPartialStableFeature {
|
|||
#[note]
|
||||
pub(crate) struct IneffectiveUnstableImpl;
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[diag(passes_unused_assign)]
|
||||
pub(crate) struct UnusedAssign {
|
||||
pub name: String,
|
||||
#[subdiagnostic]
|
||||
pub suggestion: Option<UnusedAssignSuggestion>,
|
||||
#[help]
|
||||
pub help: bool,
|
||||
}
|
||||
|
||||
#[derive(Subdiagnostic)]
|
||||
#[multipart_suggestion(passes_unused_assign_suggestion, applicability = "maybe-incorrect")]
|
||||
pub(crate) struct UnusedAssignSuggestion {
|
||||
pub pre: &'static str,
|
||||
#[suggestion_part(code = "{pre}mut ")]
|
||||
pub ty_span: Option<Span>,
|
||||
#[suggestion_part(code = "")]
|
||||
pub ty_ref_span: Span,
|
||||
#[suggestion_part(code = "*")]
|
||||
pub ident_span: Span,
|
||||
#[suggestion_part(code = "")]
|
||||
pub expr_ref_span: Span,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[diag(passes_unused_assign_passed)]
|
||||
#[help]
|
||||
pub(crate) struct UnusedAssignPassed {
|
||||
pub name: String,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[diag(passes_unused_variable_try_prefix)]
|
||||
pub(crate) struct UnusedVariableTryPrefix {
|
||||
#[label]
|
||||
pub label: Option<Span>,
|
||||
#[subdiagnostic]
|
||||
pub string_interp: Vec<UnusedVariableStringInterp>,
|
||||
#[subdiagnostic]
|
||||
pub sugg: UnusedVariableSugg,
|
||||
pub name: String,
|
||||
#[subdiagnostic]
|
||||
pub typo: Option<PatternTypo>,
|
||||
}
|
||||
|
||||
#[derive(Subdiagnostic)]
|
||||
pub(crate) enum UnusedVariableSugg {
|
||||
#[multipart_suggestion(passes_suggestion, applicability = "maybe-incorrect")]
|
||||
TryPrefixSugg {
|
||||
#[suggestion_part(code = "_{name}")]
|
||||
spans: Vec<Span>,
|
||||
name: String,
|
||||
},
|
||||
#[help(passes_unused_variable_args_in_macro)]
|
||||
NoSugg {
|
||||
#[primary_span]
|
||||
span: Span,
|
||||
name: String,
|
||||
},
|
||||
}
|
||||
|
||||
pub(crate) struct UnusedVariableStringInterp {
|
||||
pub lit: Span,
|
||||
pub lo: Span,
|
||||
pub hi: Span,
|
||||
}
|
||||
|
||||
impl Subdiagnostic for UnusedVariableStringInterp {
|
||||
fn add_to_diag<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
|
||||
diag.span_label(self.lit, crate::fluent_generated::passes_maybe_string_interpolation);
|
||||
diag.multipart_suggestion(
|
||||
crate::fluent_generated::passes_string_interpolation_only_works,
|
||||
vec![(self.lo, String::from("format!(")), (self.hi, String::from(")"))],
|
||||
Applicability::MachineApplicable,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[diag(passes_unused_variable_try_ignore)]
|
||||
pub(crate) struct UnusedVarTryIgnore {
|
||||
pub name: String,
|
||||
#[subdiagnostic]
|
||||
pub sugg: UnusedVarTryIgnoreSugg,
|
||||
}
|
||||
|
||||
#[derive(Subdiagnostic)]
|
||||
#[multipart_suggestion(passes_suggestion, applicability = "maybe-incorrect")]
|
||||
pub(crate) struct UnusedVarTryIgnoreSugg {
|
||||
#[suggestion_part(code = "{name}: _")]
|
||||
pub shorthands: Vec<Span>,
|
||||
#[suggestion_part(code = "_")]
|
||||
pub non_shorthands: Vec<Span>,
|
||||
pub name: String,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[diag(passes_attr_crate_level)]
|
||||
#[note]
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@ pub mod input_stats;
|
|||
mod lang_items;
|
||||
pub mod layout_test;
|
||||
mod lib_features;
|
||||
mod liveness;
|
||||
mod reachable;
|
||||
pub mod stability;
|
||||
mod upvars;
|
||||
|
|
@ -44,7 +43,6 @@ pub fn provide(providers: &mut Providers) {
|
|||
entry::provide(providers);
|
||||
lang_items::provide(providers);
|
||||
lib_features::provide(providers);
|
||||
liveness::provide(providers);
|
||||
reachable::provide(providers);
|
||||
stability::provide(providers);
|
||||
upvars::provide(providers);
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -1,146 +0,0 @@
|
|||
use std::iter;
|
||||
|
||||
use crate::liveness::{LiveNode, Variable};
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
pub(super) struct RWU {
|
||||
pub(super) reader: bool,
|
||||
pub(super) writer: bool,
|
||||
pub(super) used: bool,
|
||||
}
|
||||
|
||||
/// Conceptually, this is like a `Vec<Vec<RWU>>`. But the number of
|
||||
/// RWU's can get very large, so it uses a more compact representation.
|
||||
pub(super) struct RWUTable {
|
||||
/// Total number of live nodes.
|
||||
live_nodes: usize,
|
||||
/// Total number of variables.
|
||||
vars: usize,
|
||||
|
||||
/// A compressed representation of `RWU`s.
|
||||
///
|
||||
/// Each word represents 2 different `RWU`s packed together. Each packed RWU
|
||||
/// is stored in 4 bits: a reader bit, a writer bit, a used bit and a
|
||||
/// padding bit.
|
||||
///
|
||||
/// The data for each live node is contiguous and starts at a word boundary,
|
||||
/// so there might be an unused space left.
|
||||
words: Vec<u8>,
|
||||
/// Number of words per each live node.
|
||||
live_node_words: usize,
|
||||
}
|
||||
|
||||
impl RWUTable {
|
||||
const RWU_READER: u8 = 0b0001;
|
||||
const RWU_WRITER: u8 = 0b0010;
|
||||
const RWU_USED: u8 = 0b0100;
|
||||
const RWU_MASK: u8 = 0b1111;
|
||||
|
||||
/// Size of packed RWU in bits.
|
||||
const RWU_BITS: usize = 4;
|
||||
/// Size of a word in bits.
|
||||
const WORD_BITS: usize = size_of::<u8>() * 8;
|
||||
/// Number of packed RWUs that fit into a single word.
|
||||
const WORD_RWU_COUNT: usize = Self::WORD_BITS / Self::RWU_BITS;
|
||||
|
||||
pub(super) fn new(live_nodes: usize, vars: usize) -> RWUTable {
|
||||
let live_node_words = vars.div_ceil(Self::WORD_RWU_COUNT);
|
||||
Self { live_nodes, vars, live_node_words, words: vec![0u8; live_node_words * live_nodes] }
|
||||
}
|
||||
|
||||
fn word_and_shift(&self, ln: LiveNode, var: Variable) -> (usize, u32) {
|
||||
assert!(ln.index() < self.live_nodes);
|
||||
assert!(var.index() < self.vars);
|
||||
|
||||
let var = var.index();
|
||||
let word = var / Self::WORD_RWU_COUNT;
|
||||
let shift = Self::RWU_BITS * (var % Self::WORD_RWU_COUNT);
|
||||
(ln.index() * self.live_node_words + word, shift as u32)
|
||||
}
|
||||
|
||||
fn pick2_rows_mut(&mut self, a: LiveNode, b: LiveNode) -> (&mut [u8], &mut [u8]) {
|
||||
assert!(a.index() < self.live_nodes);
|
||||
assert!(b.index() < self.live_nodes);
|
||||
assert!(a != b);
|
||||
|
||||
let a_start = a.index() * self.live_node_words;
|
||||
let b_start = b.index() * self.live_node_words;
|
||||
|
||||
unsafe {
|
||||
let ptr = self.words.as_mut_ptr();
|
||||
(
|
||||
std::slice::from_raw_parts_mut(ptr.add(a_start), self.live_node_words),
|
||||
std::slice::from_raw_parts_mut(ptr.add(b_start), self.live_node_words),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn copy(&mut self, dst: LiveNode, src: LiveNode) {
|
||||
if dst == src {
|
||||
return;
|
||||
}
|
||||
|
||||
let (dst_row, src_row) = self.pick2_rows_mut(dst, src);
|
||||
dst_row.copy_from_slice(src_row);
|
||||
}
|
||||
|
||||
/// Sets `dst` to the union of `dst` and `src`, returns true if `dst` was
|
||||
/// changed.
|
||||
pub(super) fn union(&mut self, dst: LiveNode, src: LiveNode) -> bool {
|
||||
if dst == src {
|
||||
return false;
|
||||
}
|
||||
|
||||
let mut changed = false;
|
||||
let (dst_row, src_row) = self.pick2_rows_mut(dst, src);
|
||||
for (dst_word, src_word) in iter::zip(dst_row, &*src_row) {
|
||||
let old = *dst_word;
|
||||
let new = *dst_word | src_word;
|
||||
*dst_word = new;
|
||||
changed |= old != new;
|
||||
}
|
||||
changed
|
||||
}
|
||||
|
||||
pub(super) fn get_reader(&self, ln: LiveNode, var: Variable) -> bool {
|
||||
let (word, shift) = self.word_and_shift(ln, var);
|
||||
(self.words[word] >> shift) & Self::RWU_READER != 0
|
||||
}
|
||||
|
||||
pub(super) fn get_writer(&self, ln: LiveNode, var: Variable) -> bool {
|
||||
let (word, shift) = self.word_and_shift(ln, var);
|
||||
(self.words[word] >> shift) & Self::RWU_WRITER != 0
|
||||
}
|
||||
|
||||
pub(super) fn get_used(&self, ln: LiveNode, var: Variable) -> bool {
|
||||
let (word, shift) = self.word_and_shift(ln, var);
|
||||
(self.words[word] >> shift) & Self::RWU_USED != 0
|
||||
}
|
||||
|
||||
pub(super) fn get(&self, ln: LiveNode, var: Variable) -> RWU {
|
||||
let (word, shift) = self.word_and_shift(ln, var);
|
||||
let rwu_packed = self.words[word] >> shift;
|
||||
RWU {
|
||||
reader: rwu_packed & Self::RWU_READER != 0,
|
||||
writer: rwu_packed & Self::RWU_WRITER != 0,
|
||||
used: rwu_packed & Self::RWU_USED != 0,
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn set(&mut self, ln: LiveNode, var: Variable, rwu: RWU) {
|
||||
let mut packed = 0;
|
||||
if rwu.reader {
|
||||
packed |= Self::RWU_READER;
|
||||
}
|
||||
if rwu.writer {
|
||||
packed |= Self::RWU_WRITER;
|
||||
}
|
||||
if rwu.used {
|
||||
packed |= Self::RWU_USED;
|
||||
}
|
||||
|
||||
let (word, shift) = self.word_and_shift(ln, var);
|
||||
let word = &mut self.words[word];
|
||||
*word = (*word & !(Self::RWU_MASK << shift)) | (packed << shift)
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
#![warn(clippy::needless_match)]
|
||||
#![allow(clippy::manual_map)]
|
||||
#![allow(dead_code)]
|
||||
|
||||
#![allow(unused)]
|
||||
#[derive(Clone, Copy)]
|
||||
enum Simple {
|
||||
A,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#![warn(clippy::needless_match)]
|
||||
#![allow(clippy::manual_map)]
|
||||
#![allow(dead_code)]
|
||||
|
||||
#![allow(unused)]
|
||||
#[derive(Clone, Copy)]
|
||||
enum Simple {
|
||||
A,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
#![deny(clippy::useless_conversion)]
|
||||
#![allow(clippy::needless_if, clippy::unnecessary_wraps)]
|
||||
#![allow(clippy::needless_if, clippy::unnecessary_wraps, unused)]
|
||||
// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint
|
||||
#![allow(static_mut_refs)]
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
#![deny(clippy::useless_conversion)]
|
||||
#![allow(clippy::needless_if, clippy::unnecessary_wraps)]
|
||||
#![allow(clippy::needless_if, clippy::unnecessary_wraps, unused)]
|
||||
// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint
|
||||
#![allow(static_mut_refs)]
|
||||
|
||||
|
|
|
|||
|
|
@ -69,6 +69,7 @@ fn goto_out_jump() {
|
|||
fn goto_out_jump_noreturn() {
|
||||
unsafe {
|
||||
let mut value = false;
|
||||
//~^ WARN value assigned to `value` is never read
|
||||
let mut out: usize;
|
||||
asm!(
|
||||
"lea {}, [{} + 1]",
|
||||
|
|
|
|||
|
|
@ -18,5 +18,14 @@ note: the lint level is defined here
|
|||
LL | #[warn(unreachable_code)]
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
warning: 1 warning emitted
|
||||
warning: value assigned to `value` is never read
|
||||
--> $DIR/goto.rs:70:25
|
||||
|
|
||||
LL | let mut value = false;
|
||||
| ^^^^^
|
||||
|
|
||||
= help: maybe it is overwritten before being read?
|
||||
= note: `#[warn(unused_assignments)]` on by default
|
||||
|
||||
warning: 2 warnings emitted
|
||||
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
// in <https://github.com/rust-lang/rust/pull/123350>.
|
||||
|
||||
#![allow(unused_mut)]
|
||||
#![allow(unused_assignments)]
|
||||
|
||||
extern crate block_on;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
//@ run-pass
|
||||
|
||||
#[allow(unused)]
|
||||
pub fn main() {
|
||||
struct A {
|
||||
a: isize,
|
||||
|
|
|
|||
|
|
@ -13,13 +13,11 @@ struct Point {
|
|||
|
||||
pub fn f() {
|
||||
let mut a = 1;
|
||||
let mut c = Point{ x:1, y:0 };
|
||||
let mut c = Point { x: 1, y: 0 };
|
||||
|
||||
// Captured by value, but variable is dead on entry.
|
||||
(move || {
|
||||
// This will not trigger a warning for unused variable as
|
||||
// c.x will be treated as a Non-tracked place
|
||||
c.x = 1;
|
||||
c.x = 1; //~ WARN value captured by `c.x` is never read
|
||||
println!("{}", c.x);
|
||||
a = 1; //~ WARN value captured by `a` is never read
|
||||
println!("{}", a);
|
||||
|
|
@ -27,10 +25,10 @@ pub fn f() {
|
|||
|
||||
// Read and written to, but never actually used.
|
||||
(move || {
|
||||
// This will not trigger a warning for unused variable as
|
||||
// c.x will be treated as a Non-tracked place
|
||||
c.x += 1;
|
||||
a += 1; //~ WARN unused variable: `a`
|
||||
c.x += 1; //~ WARN value captured by `c.x` is never read
|
||||
//~| WARN value assigned to `c.x` is never read
|
||||
a += 1; //~ WARN value captured by `a` is never read
|
||||
//~| WARN value assigned to `a` is never read
|
||||
})();
|
||||
|
||||
(move || {
|
||||
|
|
@ -45,10 +43,7 @@ pub fn f() {
|
|||
let b = Box::new(42);
|
||||
(move || {
|
||||
println!("{}", c.x);
|
||||
// Never read because this is FnOnce closure.
|
||||
// This will not trigger a warning for unused variable as
|
||||
// c.x will be treated as a Non-tracked place
|
||||
c.x += 1;
|
||||
c.x += 1; //~ WARN value assigned to `c.x` is never read
|
||||
println!("{}", a);
|
||||
a += 1; //~ WARN value assigned to `a` is never read
|
||||
drop(b);
|
||||
|
|
@ -56,35 +51,32 @@ pub fn f() {
|
|||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
struct MyStruct<'a> {
|
||||
x: Option<& 'a str>,
|
||||
struct MyStruct<'a> {
|
||||
x: Option<&'a str>,
|
||||
y: i32,
|
||||
}
|
||||
|
||||
pub fn nested() {
|
||||
let mut a : Option<& str>;
|
||||
let mut a: Option<&str>;
|
||||
a = None;
|
||||
let mut b : Option<& str>;
|
||||
let mut b: Option<&str>;
|
||||
b = None;
|
||||
let mut d = MyStruct{ x: None, y: 1};
|
||||
let mut e = MyStruct{ x: None, y: 1};
|
||||
let mut d = MyStruct { x: None, y: 1 };
|
||||
let mut e = MyStruct { x: None, y: 1 };
|
||||
(|| {
|
||||
(|| {
|
||||
// This will not trigger a warning for unused variable as
|
||||
// d.x will be treated as a Non-tracked place
|
||||
d.x = Some("d1");
|
||||
d.x = Some("d1"); //~ WARN value assigned to `d.x` is never read
|
||||
d.x = Some("d2");
|
||||
a = Some("d1"); //~ WARN value assigned to `a` is never read
|
||||
a = Some("d2");
|
||||
})();
|
||||
(move || {
|
||||
// This will not trigger a warning for unused variable as
|
||||
//e.x will be treated as a Non-tracked place
|
||||
e.x = Some("e1");
|
||||
e.x = Some("e2");
|
||||
b = Some("e1"); //~ WARN value assigned to `b` is never read
|
||||
//~| WARN unused variable: `b`
|
||||
b = Some("e2"); //~ WARN value assigned to `b` is never read
|
||||
e.x = Some("e1"); //~ WARN value captured by `e.x` is never read
|
||||
//~| WARN value assigned to `e.x` is never read
|
||||
e.x = Some("e2"); //~ WARN value assigned to `e.x` is never read
|
||||
b = Some("e1"); //~ WARN value captured by `b` is never read
|
||||
//~| WARN value assigned to `b` is never read
|
||||
b = Some("e2"); //~ WARN value assigned to `b` is never read
|
||||
})();
|
||||
})();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
warning: value captured by `a` is never read
|
||||
--> $DIR/liveness.rs:24:9
|
||||
warning: value assigned to `c.x` is never read
|
||||
--> $DIR/liveness.rs:46:9
|
||||
|
|
||||
LL | a = 1;
|
||||
| ^
|
||||
LL | c.x += 1;
|
||||
| ^^^^^^^^
|
||||
|
|
||||
= help: did you mean to capture by reference instead?
|
||||
= help: maybe it is overwritten before being read?
|
||||
note: the lint level is defined here
|
||||
--> $DIR/liveness.rs:5:9
|
||||
|
|
||||
|
|
@ -12,54 +12,125 @@ LL | #![warn(unused)]
|
|||
| ^^^^^^
|
||||
= note: `#[warn(unused_assignments)]` implied by `#[warn(unused)]`
|
||||
|
||||
warning: unused variable: `a`
|
||||
--> $DIR/liveness.rs:33:9
|
||||
warning: value assigned to `a` is never read
|
||||
--> $DIR/liveness.rs:48:9
|
||||
|
|
||||
LL | a += 1;
|
||||
| ^^^^^^
|
||||
|
|
||||
= help: maybe it is overwritten before being read?
|
||||
|
||||
warning: value captured by `c.x` is never read
|
||||
--> $DIR/liveness.rs:28:9
|
||||
|
|
||||
LL | c.x += 1;
|
||||
| ^^^
|
||||
|
|
||||
= help: did you mean to capture by reference instead?
|
||||
|
||||
warning: value assigned to `c.x` is never read
|
||||
--> $DIR/liveness.rs:28:9
|
||||
|
|
||||
LL | c.x += 1;
|
||||
| ^^^^^^^^
|
||||
|
|
||||
= help: maybe it is overwritten before being read?
|
||||
|
||||
warning: value captured by `a` is never read
|
||||
--> $DIR/liveness.rs:30:9
|
||||
|
|
||||
LL | a += 1;
|
||||
| ^
|
||||
|
|
||||
= help: did you mean to capture by reference instead?
|
||||
= note: `#[warn(unused_variables)]` implied by `#[warn(unused)]`
|
||||
|
||||
warning: value assigned to `a` is never read
|
||||
--> $DIR/liveness.rs:53:9
|
||||
--> $DIR/liveness.rs:30:9
|
||||
|
|
||||
LL | a += 1;
|
||||
| ^
|
||||
| ^^^^^^
|
||||
|
|
||||
= help: maybe it is overwritten before being read?
|
||||
|
||||
warning: value assigned to `a` is never read
|
||||
warning: value captured by `c.x` is never read
|
||||
--> $DIR/liveness.rs:20:9
|
||||
|
|
||||
LL | c.x = 1;
|
||||
| ^^^
|
||||
|
|
||||
= help: did you mean to capture by reference instead?
|
||||
|
||||
warning: value captured by `a` is never read
|
||||
--> $DIR/liveness.rs:22:9
|
||||
|
|
||||
LL | a = 1;
|
||||
| ^
|
||||
|
|
||||
= help: did you mean to capture by reference instead?
|
||||
|
||||
warning: value captured by `e.x` is never read
|
||||
--> $DIR/liveness.rs:74:13
|
||||
|
|
||||
LL | e.x = Some("e1");
|
||||
| ^^^
|
||||
|
|
||||
= help: did you mean to capture by reference instead?
|
||||
|
||||
warning: value assigned to `e.x` is never read
|
||||
--> $DIR/liveness.rs:74:13
|
||||
|
|
||||
LL | e.x = Some("e1");
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: maybe it is overwritten before being read?
|
||||
|
||||
warning: value assigned to `e.x` is never read
|
||||
--> $DIR/liveness.rs:76:13
|
||||
|
|
||||
LL | e.x = Some("e2");
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: maybe it is overwritten before being read?
|
||||
|
||||
warning: value captured by `b` is never read
|
||||
--> $DIR/liveness.rs:77:13
|
||||
|
|
||||
LL | a = Some("d1");
|
||||
| ^
|
||||
|
|
||||
= help: maybe it is overwritten before being read?
|
||||
|
||||
warning: value assigned to `b` is never read
|
||||
--> $DIR/liveness.rs:85:13
|
||||
|
|
||||
LL | b = Some("e1");
|
||||
| ^
|
||||
|
|
||||
= help: maybe it is overwritten before being read?
|
||||
|
||||
warning: value assigned to `b` is never read
|
||||
--> $DIR/liveness.rs:87:13
|
||||
|
|
||||
LL | b = Some("e2");
|
||||
| ^
|
||||
|
|
||||
= help: maybe it is overwritten before being read?
|
||||
|
||||
warning: unused variable: `b`
|
||||
--> $DIR/liveness.rs:85:13
|
||||
|
|
||||
LL | b = Some("e1");
|
||||
| ^
|
||||
|
|
||||
= help: did you mean to capture by reference instead?
|
||||
|
||||
warning: 7 warnings emitted
|
||||
warning: value assigned to `b` is never read
|
||||
--> $DIR/liveness.rs:77:13
|
||||
|
|
||||
LL | b = Some("e1");
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: maybe it is overwritten before being read?
|
||||
|
||||
warning: value assigned to `b` is never read
|
||||
--> $DIR/liveness.rs:79:13
|
||||
|
|
||||
LL | b = Some("e2");
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: maybe it is overwritten before being read?
|
||||
|
||||
warning: value assigned to `d.x` is never read
|
||||
--> $DIR/liveness.rs:68:13
|
||||
|
|
||||
LL | d.x = Some("d1");
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: maybe it is overwritten before being read?
|
||||
|
||||
warning: value assigned to `a` is never read
|
||||
--> $DIR/liveness.rs:70:13
|
||||
|
|
||||
LL | a = Some("d1");
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: maybe it is overwritten before being read?
|
||||
|
||||
warning: 16 warnings emitted
|
||||
|
||||
|
|
|
|||
|
|
@ -12,14 +12,16 @@ struct MyStruct {
|
|||
|
||||
pub fn unintentional_copy_one() {
|
||||
let mut a = 1;
|
||||
let mut last = MyStruct{ a: 1, b: 1};
|
||||
//~^ WARN unused variable: `a`
|
||||
let mut last = MyStruct { a: 1, b: 1 };
|
||||
//~^ WARN unused variable: `last`
|
||||
let mut f = move |s| {
|
||||
// This will not trigger a warning for unused variable
|
||||
// as last.a will be treated as a Non-tracked place
|
||||
last.a = s;
|
||||
//~^ WARN value captured by `last.a` is never read
|
||||
//~| WARN value assigned to `last.a` is never read
|
||||
a = s;
|
||||
//~^ WARN value assigned to `a` is never read
|
||||
//~| WARN unused variable: `a`
|
||||
//~^ WARN value captured by `a` is never read
|
||||
//~| WARN value assigned to `a` is never read
|
||||
};
|
||||
f(2);
|
||||
f(3);
|
||||
|
|
@ -28,12 +30,16 @@ pub fn unintentional_copy_one() {
|
|||
|
||||
pub fn unintentional_copy_two() {
|
||||
let mut a = 1;
|
||||
let mut sum = MyStruct{ a: 1, b: 0};
|
||||
//~^ WARN unused variable: `a`
|
||||
let mut sum = MyStruct { a: 1, b: 0 };
|
||||
//~^ WARN unused variable: `sum`
|
||||
(1..10).for_each(move |x| {
|
||||
// This will not trigger a warning for unused variable
|
||||
// as sum.b will be treated as a Non-tracked place
|
||||
sum.b += x;
|
||||
a += x; //~ WARN unused variable: `a`
|
||||
//~^ WARN value captured by `sum.b` is never read
|
||||
//~| WARN value assigned to `sum.b` is never read
|
||||
a += x;
|
||||
//~^ WARN value captured by `a` is never read
|
||||
//~| WARN value assigned to `a` is never read
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
warning: value assigned to `a` is never read
|
||||
--> $DIR/liveness_unintentional_copy.rs:20:9
|
||||
warning: value captured by `last.a` is never read
|
||||
--> $DIR/liveness_unintentional_copy.rs:19:9
|
||||
|
|
||||
LL | a = s;
|
||||
| ^
|
||||
LL | last.a = s;
|
||||
| ^^^^^^
|
||||
|
|
||||
= help: maybe it is overwritten before being read?
|
||||
= help: did you mean to capture by reference instead?
|
||||
note: the lint level is defined here
|
||||
--> $DIR/liveness_unintentional_copy.rs:4:9
|
||||
|
|
||||
|
|
@ -12,22 +12,87 @@ LL | #![warn(unused)]
|
|||
| ^^^^^^
|
||||
= note: `#[warn(unused_assignments)]` implied by `#[warn(unused)]`
|
||||
|
||||
warning: unused variable: `a`
|
||||
--> $DIR/liveness_unintentional_copy.rs:20:9
|
||||
warning: value assigned to `last.a` is never read
|
||||
--> $DIR/liveness_unintentional_copy.rs:19:9
|
||||
|
|
||||
LL | last.a = s;
|
||||
| ^^^^^^^^^^
|
||||
|
|
||||
= help: maybe it is overwritten before being read?
|
||||
|
||||
warning: value captured by `a` is never read
|
||||
--> $DIR/liveness_unintentional_copy.rs:22:9
|
||||
|
|
||||
LL | a = s;
|
||||
| ^
|
||||
|
|
||||
= help: did you mean to capture by reference instead?
|
||||
= note: `#[warn(unused_variables)]` implied by `#[warn(unused)]`
|
||||
|
||||
warning: value assigned to `a` is never read
|
||||
--> $DIR/liveness_unintentional_copy.rs:22:9
|
||||
|
|
||||
LL | a = s;
|
||||
| ^^^^^
|
||||
|
|
||||
= help: maybe it is overwritten before being read?
|
||||
|
||||
warning: unused variable: `a`
|
||||
--> $DIR/liveness_unintentional_copy.rs:36:9
|
||||
--> $DIR/liveness_unintentional_copy.rs:14:9
|
||||
|
|
||||
LL | let mut a = 1;
|
||||
| ^^^^^ help: if this is intentional, prefix it with an underscore: `_a`
|
||||
|
|
||||
= note: `#[warn(unused_variables)]` implied by `#[warn(unused)]`
|
||||
|
||||
warning: unused variable: `last`
|
||||
--> $DIR/liveness_unintentional_copy.rs:16:9
|
||||
|
|
||||
LL | let mut last = MyStruct { a: 1, b: 1 };
|
||||
| ^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_last`
|
||||
|
||||
warning: value captured by `sum.b` is never read
|
||||
--> $DIR/liveness_unintentional_copy.rs:37:9
|
||||
|
|
||||
LL | sum.b += x;
|
||||
| ^^^^^
|
||||
|
|
||||
= help: did you mean to capture by reference instead?
|
||||
|
||||
warning: value assigned to `sum.b` is never read
|
||||
--> $DIR/liveness_unintentional_copy.rs:37:9
|
||||
|
|
||||
LL | sum.b += x;
|
||||
| ^^^^^^^^^^
|
||||
|
|
||||
= help: maybe it is overwritten before being read?
|
||||
|
||||
warning: value captured by `a` is never read
|
||||
--> $DIR/liveness_unintentional_copy.rs:40:9
|
||||
|
|
||||
LL | a += x;
|
||||
| ^
|
||||
|
|
||||
= help: did you mean to capture by reference instead?
|
||||
|
||||
warning: 3 warnings emitted
|
||||
warning: value assigned to `a` is never read
|
||||
--> $DIR/liveness_unintentional_copy.rs:40:9
|
||||
|
|
||||
LL | a += x;
|
||||
| ^^^^^^
|
||||
|
|
||||
= help: maybe it is overwritten before being read?
|
||||
|
||||
warning: unused variable: `a`
|
||||
--> $DIR/liveness_unintentional_copy.rs:32:9
|
||||
|
|
||||
LL | let mut a = 1;
|
||||
| ^^^^^ help: if this is intentional, prefix it with an underscore: `_a`
|
||||
|
||||
warning: unused variable: `sum`
|
||||
--> $DIR/liveness_unintentional_copy.rs:34:9
|
||||
|
|
||||
LL | let mut sum = MyStruct { a: 1, b: 0 };
|
||||
| ^^^^^^^ help: if this is intentional, prefix it with an underscore: `_sum`
|
||||
|
||||
warning: 12 warnings emitted
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
warning: unused variable: `g2`
|
||||
--> $DIR/destructure-pattern-closure-within-closure.rs:10:17
|
||||
warning: unused variable: `t2`
|
||||
--> $DIR/destructure-pattern-closure-within-closure.rs:13:21
|
||||
|
|
||||
LL | let (_, g2) = g;
|
||||
| ^^ help: if this is intentional, prefix it with an underscore: `_g2`
|
||||
LL | let (_, t2) = t;
|
||||
| ^^ help: if this is intentional, prefix it with an underscore: `_t2`
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/destructure-pattern-closure-within-closure.rs:3:9
|
||||
|
|
@ -11,11 +11,11 @@ LL | #![warn(unused)]
|
|||
| ^^^^^^
|
||||
= note: `#[warn(unused_variables)]` implied by `#[warn(unused)]`
|
||||
|
||||
warning: unused variable: `t2`
|
||||
--> $DIR/destructure-pattern-closure-within-closure.rs:13:21
|
||||
warning: unused variable: `g2`
|
||||
--> $DIR/destructure-pattern-closure-within-closure.rs:10:17
|
||||
|
|
||||
LL | let (_, t2) = t;
|
||||
| ^^ help: if this is intentional, prefix it with an underscore: `_t2`
|
||||
LL | let (_, g2) = g;
|
||||
| ^^ help: if this is intentional, prefix it with an underscore: `_g2`
|
||||
|
||||
warning: 2 warnings emitted
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,8 @@
|
|||
|
||||
pub fn main() {
|
||||
let mut x = 1;
|
||||
//~^ WARN unused variable: `x`
|
||||
let _thunk = Box::new(move|| { x = 2; });
|
||||
//~^ WARN value assigned to `x` is never read
|
||||
//~| WARN unused variable: `x`
|
||||
//~^ WARN value captured by `x` is never read
|
||||
//~| WARN value assigned to `x` is never read
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,20 +1,27 @@
|
|||
warning: value assigned to `x` is never read
|
||||
--> $DIR/moved-upvar-mut-rebind-11958.rs:10:36
|
||||
|
|
||||
LL | let _thunk = Box::new(move|| { x = 2; });
|
||||
| ^
|
||||
|
|
||||
= help: maybe it is overwritten before being read?
|
||||
= note: `#[warn(unused_assignments)]` (part of `#[warn(unused)]`) on by default
|
||||
|
||||
warning: unused variable: `x`
|
||||
--> $DIR/moved-upvar-mut-rebind-11958.rs:10:36
|
||||
warning: value captured by `x` is never read
|
||||
--> $DIR/moved-upvar-mut-rebind-11958.rs:11:36
|
||||
|
|
||||
LL | let _thunk = Box::new(move|| { x = 2; });
|
||||
| ^
|
||||
|
|
||||
= help: did you mean to capture by reference instead?
|
||||
= note: `#[warn(unused_assignments)]` (part of `#[warn(unused)]`) on by default
|
||||
|
||||
warning: value assigned to `x` is never read
|
||||
--> $DIR/moved-upvar-mut-rebind-11958.rs:11:36
|
||||
|
|
||||
LL | let _thunk = Box::new(move|| { x = 2; });
|
||||
| ^^^^^
|
||||
|
|
||||
= help: maybe it is overwritten before being read?
|
||||
|
||||
warning: unused variable: `x`
|
||||
--> $DIR/moved-upvar-mut-rebind-11958.rs:9:9
|
||||
|
|
||||
LL | let mut x = 1;
|
||||
| ^^^^^ help: if this is intentional, prefix it with an underscore: `_x`
|
||||
|
|
||||
= note: `#[warn(unused_variables)]` (part of `#[warn(unused)]`) on by default
|
||||
|
||||
warning: 2 warnings emitted
|
||||
warning: 3 warnings emitted
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
//@ aux-build:trait_object_lt_defaults_lib.rs
|
||||
//@ run-pass
|
||||
#![allow(dead_code)]
|
||||
#![allow(dead_code, unused)]
|
||||
extern crate trait_object_lt_defaults_lib;
|
||||
|
||||
// Tests that `A<'a, 3, dyn Test>` is short for `A<'a, 3, dyn Test + 'a>`
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ fn assert_drop_order(expected_drops: impl IntoIterator<Item = u32>, f: impl Fn(&
|
|||
assert_eq!(order, correct_order);
|
||||
}
|
||||
|
||||
#[expect(unused_variables, unused_assignments, irrefutable_let_patterns)]
|
||||
#[expect(unused_variables, irrefutable_let_patterns)]
|
||||
fn main() {
|
||||
// When bindings are declared with `let pat;`, they're visited in left-to-right order, using the
|
||||
// order given by the first occurrence of each variable. They're later dropped in reverse.
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
//@ run-pass
|
||||
|
||||
#[allow(dead_code)]
|
||||
#![allow(dead_code, unused_variables, unused_assignments)]
|
||||
|
||||
struct Struct<'s>(&'s str);
|
||||
|
||||
impl<'s> Drop for Struct<'s> {
|
||||
|
|
|
|||
|
|
@ -14,25 +14,6 @@ LL | let object2 = Object;
|
|||
LL ~ *object = object2;
|
||||
|
|
||||
|
||||
error: value assigned to `object` is never read
|
||||
--> $DIR/mut-arg-of-borrowed-type-meant-to-be-arg-of-mut-borrow.rs:14:4
|
||||
|
|
||||
LL | object = &object2;
|
||||
| ^^^^^^
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/mut-arg-of-borrowed-type-meant-to-be-arg-of-mut-borrow.rs:2:9
|
||||
|
|
||||
LL | #![deny(unused_assignments)]
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
help: you might have meant to mutate the pointed at value being passed in, instead of changing the reference in the local binding
|
||||
|
|
||||
LL ~ fn change_object2(object: &mut Object) {
|
||||
LL |
|
||||
LL | let object2 = Object;
|
||||
LL ~ *object = object2;
|
||||
|
|
||||
|
||||
error[E0597]: `object2` does not live long enough
|
||||
--> $DIR/mut-arg-of-borrowed-type-meant-to-be-arg-of-mut-borrow.rs:14:13
|
||||
|
|
||||
|
|
@ -51,17 +32,22 @@ LL | }
|
|||
| - `object2` dropped here while still borrowed
|
||||
|
||||
error: value assigned to `object` is never read
|
||||
--> $DIR/mut-arg-of-borrowed-type-meant-to-be-arg-of-mut-borrow.rs:22:5
|
||||
--> $DIR/mut-arg-of-borrowed-type-meant-to-be-arg-of-mut-borrow.rs:14:4
|
||||
|
|
||||
LL | object = &mut object2;
|
||||
| ^^^^^^
|
||||
LL | object = &object2;
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/mut-arg-of-borrowed-type-meant-to-be-arg-of-mut-borrow.rs:2:9
|
||||
|
|
||||
LL | #![deny(unused_assignments)]
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
help: you might have meant to mutate the pointed at value being passed in, instead of changing the reference in the local binding
|
||||
|
|
||||
LL ~ fn change_object3(object: &mut Object) {
|
||||
LL ~ fn change_object2(object: &mut Object) {
|
||||
LL |
|
||||
LL | let object2 = Object;
|
||||
LL ~ *object = object2;
|
||||
LL | let object2 = Object;
|
||||
LL ~ *object = object2;
|
||||
|
|
||||
|
||||
error[E0596]: cannot borrow `object2` as mutable, as it is not declared as mutable
|
||||
|
|
@ -75,6 +61,20 @@ help: consider changing this to be mutable
|
|||
LL | let mut object2 = Object;
|
||||
| +++
|
||||
|
||||
error: value assigned to `object` is never read
|
||||
--> $DIR/mut-arg-of-borrowed-type-meant-to-be-arg-of-mut-borrow.rs:22:5
|
||||
|
|
||||
LL | object = &mut object2;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
help: you might have meant to mutate the pointed at value being passed in, instead of changing the reference in the local binding
|
||||
|
|
||||
LL ~ fn change_object3(object: &mut Object) {
|
||||
LL |
|
||||
LL | let object2 = Object;
|
||||
LL ~ *object = object2;
|
||||
|
|
||||
|
||||
error: aborting due to 5 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0308, E0596, E0597.
|
||||
|
|
|
|||
|
|
@ -1,4 +1,7 @@
|
|||
//@ run-pass
|
||||
|
||||
#![allow(unused_assignments)]
|
||||
|
||||
struct S {
|
||||
o: Option<String>
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,15 +1,3 @@
|
|||
warning: unused variable: `x`
|
||||
--> $DIR/issue-85071-2.rs:18:9
|
||||
|
|
||||
LL | let x = s.f();
|
||||
| ^ help: if this is intentional, prefix it with an underscore: `_x`
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/issue-85071-2.rs:7:9
|
||||
|
|
||||
LL | #![warn(unused_variables,unreachable_code)]
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
warning: unreachable definition
|
||||
--> $DIR/issue-85071-2.rs:18:9
|
||||
|
|
||||
|
|
@ -29,5 +17,17 @@ note: the lint level is defined here
|
|||
LL | #![warn(unused_variables,unreachable_code)]
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
warning: unused variable: `x`
|
||||
--> $DIR/issue-85071-2.rs:18:9
|
||||
|
|
||||
LL | let x = s.f();
|
||||
| ^ help: if this is intentional, prefix it with an underscore: `_x`
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/issue-85071-2.rs:7:9
|
||||
|
|
||||
LL | #![warn(unused_variables,unreachable_code)]
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
warning: 2 warnings emitted
|
||||
|
||||
|
|
|
|||
|
|
@ -1,15 +1,3 @@
|
|||
warning: unused variable: `x`
|
||||
--> $DIR/issue-85071.rs:15:9
|
||||
|
|
||||
LL | let x = f();
|
||||
| ^ help: if this is intentional, prefix it with an underscore: `_x`
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/issue-85071.rs:9:9
|
||||
|
|
||||
LL | #![warn(unused_variables,unreachable_code)]
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
warning: unreachable definition
|
||||
--> $DIR/issue-85071.rs:15:9
|
||||
|
|
||||
|
|
@ -29,5 +17,17 @@ note: the lint level is defined here
|
|||
LL | #![warn(unused_variables,unreachable_code)]
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
warning: unused variable: `x`
|
||||
--> $DIR/issue-85071.rs:15:9
|
||||
|
|
||||
LL | let x = f();
|
||||
| ^ help: if this is intentional, prefix it with an underscore: `_x`
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/issue-85071.rs:9:9
|
||||
|
|
||||
LL | #![warn(unused_variables,unreachable_code)]
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
warning: 2 warnings emitted
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
{"$message_type":"future_incompat","future_incompat_report":[{"diagnostic":{"$message_type":"diagnostic","message":"unused variable: `x`","code":{"code":"unused_variables","explanation":null},"level":"warning","spans":[{"file_name":"$DIR/future-incompat-json-test.rs","byte_start":340,"byte_end":341,"line_start":9,"line_end":9,"column_start":9,"column_end":10,"is_primary":true,"text":[{"text":" let x = 1;","highlight_start":9,"highlight_end":10}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"if this is intentional, prefix it with an underscore","code":null,"level":"help","spans":[{"file_name":"$DIR/future-incompat-json-test.rs","byte_start":340,"byte_end":341,"line_start":9,"line_end":9,"column_start":9,"column_end":10,"is_primary":true,"text":[{"text":" let x = 1;","highlight_start":9,"highlight_end":10}],"label":null,"suggested_replacement":"_x","suggestion_applicability":"MaybeIncorrect","expansion":null}],"children":[],"rendered":null}],"rendered":"warning: unused variable: `x`
|
||||
{"$message_type":"future_incompat","future_incompat_report":[{"diagnostic":{"$message_type":"diagnostic","message":"unused variable: `x`","code":{"code":"unused_variables","explanation":null},"level":"warning","spans":[{"file_name":"$DIR/future-incompat-json-test.rs","byte_start":340,"byte_end":341,"line_start":9,"line_end":9,"column_start":9,"column_end":10,"is_primary":true,"text":[{"text":" let x = 1;","highlight_start":9,"highlight_end":10}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"if this is intentional, prefix it with an underscore","code":null,"level":"help","spans":[{"file_name":"$DIR/future-incompat-json-test.rs","byte_start":340,"byte_end":341,"line_start":9,"line_end":9,"column_start":9,"column_end":10,"is_primary":true,"text":[{"text":" let x = 1;","highlight_start":9,"highlight_end":10}],"label":null,"suggested_replacement":"_x","suggestion_applicability":"MachineApplicable","expansion":null}],"children":[],"rendered":null}],"rendered":"warning: unused variable: `x`
|
||||
--> $DIR/future-incompat-json-test.rs:9:9
|
||||
|
|
||||
LL | let x = 1;
|
||||
|
|
|
|||
|
|
@ -13,4 +13,5 @@ macro_rules! pat {
|
|||
|
||||
fn main() {
|
||||
let pat!(value) = Value { value: () };
|
||||
//~^ WARN value assigned to `value` is never read
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,11 @@
|
|||
warning: value assigned to `value` is never read
|
||||
--> $DIR/issue-49588-non-shorthand-field-patterns-in-pattern-macro.rs:15:14
|
||||
|
|
||||
LL | let pat!(value) = Value { value: () };
|
||||
| ^^^^^
|
||||
|
|
||||
= help: maybe it is overwritten before being read?
|
||||
= note: `#[warn(unused_assignments)]` (part of `#[warn(unused)]`) on by default
|
||||
|
||||
warning: 1 warning emitted
|
||||
|
||||
|
|
@ -16,7 +16,7 @@ warning: unused variable: `Foo`
|
|||
--> $DIR/lint-uppercase-variables.rs:22:9
|
||||
|
|
||||
LL | Foo => {}
|
||||
| ^^^
|
||||
| ^^^ help: if this is intentional, prefix it with an underscore: `_Foo`
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/lint-uppercase-variables.rs:1:9
|
||||
|
|
@ -24,29 +24,12 @@ note: the lint level is defined here
|
|||
LL | #![warn(unused)]
|
||||
| ^^^^^^
|
||||
= note: `#[warn(unused_variables)]` implied by `#[warn(unused)]`
|
||||
help: if this is intentional, prefix it with an underscore
|
||||
|
|
||||
LL | _Foo => {}
|
||||
| +
|
||||
help: you might have meant to pattern match on the similarly named variant `Foo`
|
||||
|
|
||||
LL | foo::Foo::Foo => {}
|
||||
| ++++++++++
|
||||
|
||||
warning: unused variable: `Foo`
|
||||
--> $DIR/lint-uppercase-variables.rs:28:9
|
||||
|
|
||||
LL | let Foo = foo::Foo::Foo;
|
||||
| ^^^
|
||||
|
|
||||
help: if this is intentional, prefix it with an underscore
|
||||
|
|
||||
LL | let _Foo = foo::Foo::Foo;
|
||||
| +
|
||||
help: you might have meant to pattern match on the similarly named variant `Foo`
|
||||
|
|
||||
LL | let foo::Foo::Foo = foo::Foo::Foo;
|
||||
| ++++++++++
|
||||
| ^^^ help: if this is intentional, prefix it with an underscore: `_Foo`
|
||||
|
||||
error[E0170]: pattern binding `Foo` is named the same as one of the variants of the type `foo::Foo`
|
||||
--> $DIR/lint-uppercase-variables.rs:33:17
|
||||
|
|
|
|||
|
|
@ -2,11 +2,19 @@ warning: unused variable: `x`
|
|||
--> $DIR/expect_lint_from_macro.rs:7:13
|
||||
|
|
||||
LL | let x = 0;
|
||||
| ^ help: if this is intentional, prefix it with an underscore: `_x`
|
||||
| ^
|
||||
...
|
||||
LL | trigger_unused_variables_macro!();
|
||||
| --------------------------------- in this macro invocation
|
||||
|
|
||||
help: `x` is captured in macro and introduced a unused variable
|
||||
--> $DIR/expect_lint_from_macro.rs:7:13
|
||||
|
|
||||
LL | let x = 0;
|
||||
| ^
|
||||
...
|
||||
LL | trigger_unused_variables_macro!();
|
||||
| --------------------------------- in this macro invocation
|
||||
note: the lint level is defined here
|
||||
--> $DIR/expect_lint_from_macro.rs:3:9
|
||||
|
|
||||
|
|
@ -18,11 +26,19 @@ warning: unused variable: `x`
|
|||
--> $DIR/expect_lint_from_macro.rs:7:13
|
||||
|
|
||||
LL | let x = 0;
|
||||
| ^ help: if this is intentional, prefix it with an underscore: `_x`
|
||||
| ^
|
||||
...
|
||||
LL | trigger_unused_variables_macro!();
|
||||
| --------------------------------- in this macro invocation
|
||||
|
|
||||
help: `x` is captured in macro and introduced a unused variable
|
||||
--> $DIR/expect_lint_from_macro.rs:7:13
|
||||
|
|
||||
LL | let x = 0;
|
||||
| ^
|
||||
...
|
||||
LL | trigger_unused_variables_macro!();
|
||||
| --------------------------------- in this macro invocation
|
||||
= note: this warning originates in the macro `trigger_unused_variables_macro` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
warning: 2 warnings emitted
|
||||
|
|
|
|||
|
|
@ -14,12 +14,6 @@ LL | let x = 2;
|
|||
|
|
||||
= note: requested on the command line with `--force-warn unused-variables`
|
||||
|
||||
warning: unused variable: `fox_name`
|
||||
--> $DIR/force_warn_expected_lints_fulfilled.rs:26:9
|
||||
|
|
||||
LL | let fox_name = "Sir Nibbles";
|
||||
| ^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_fox_name`
|
||||
|
||||
warning: variable does not need to be mutable
|
||||
--> $DIR/force_warn_expected_lints_fulfilled.rs:30:9
|
||||
|
|
||||
|
|
@ -30,6 +24,12 @@ LL | let mut what_does_the_fox_say = "*ding* *deng* *dung*";
|
|||
|
|
||||
= note: requested on the command line with `--force-warn unused-mut`
|
||||
|
||||
warning: unused variable: `fox_name`
|
||||
--> $DIR/force_warn_expected_lints_fulfilled.rs:26:9
|
||||
|
|
||||
LL | let fox_name = "Sir Nibbles";
|
||||
| ^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_fox_name`
|
||||
|
||||
warning: unused variable: `this_should_fulfill_the_expectation`
|
||||
--> $DIR/force_warn_expected_lints_fulfilled.rs:41:9
|
||||
|
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#![deny(unused_variables)]
|
||||
macro_rules! make_var {
|
||||
($struct:ident, $var:ident) => {
|
||||
let $var = $struct.$var;
|
||||
let $var = $struct.$var; //~ ERROR unused variable: `var`
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -12,6 +12,6 @@ struct MyStruct {
|
|||
|
||||
fn main() {
|
||||
let s = MyStruct { var: 42 };
|
||||
make_var!(s, var); //~ ERROR unused variable: `var`
|
||||
make_var!(s, var);
|
||||
let a = 1; //~ ERROR unused variable: `a`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,11 @@
|
|||
error: unused variable: `var`
|
||||
--> $DIR/issue-117284-arg-in-macro.rs:15:18
|
||||
--> $DIR/issue-117284-arg-in-macro.rs:4:13
|
||||
|
|
||||
LL | let $var = $struct.$var;
|
||||
| ^^^^
|
||||
...
|
||||
LL | make_var!(s, var);
|
||||
| ^^^
|
||||
| ----------------- in this macro invocation
|
||||
|
|
||||
help: `var` is captured in macro and introduced a unused variable
|
||||
--> $DIR/issue-117284-arg-in-macro.rs:4:13
|
||||
|
|
|
|||
|
|
@ -1,27 +1,45 @@
|
|||
warning: unused variable: `i_think_continually`
|
||||
--> $DIR/issue-47390-unused-variable-in-struct-pattern.rs:26:9
|
||||
warning: variable does not need to be mutable
|
||||
--> $DIR/issue-47390-unused-variable-in-struct-pattern.rs:33:9
|
||||
|
|
||||
LL | let i_think_continually = 2;
|
||||
| ^^^^^^^^^^^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_i_think_continually`
|
||||
LL | let mut mut_unused_var = 1;
|
||||
| ----^^^^^^^^^^^^^^
|
||||
| |
|
||||
| help: remove this `mut`
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/issue-47390-unused-variable-in-struct-pattern.rs:5:9
|
||||
|
|
||||
LL | #![warn(unused)] // UI tests pass `-A unused` (#43896)
|
||||
| ^^^^^^
|
||||
= note: `#[warn(unused_mut)]` implied by `#[warn(unused)]`
|
||||
|
||||
warning: variable does not need to be mutable
|
||||
--> $DIR/issue-47390-unused-variable-in-struct-pattern.rs:37:10
|
||||
|
|
||||
LL | let (mut var, unused_var) = (1, 2);
|
||||
| ----^^^
|
||||
| |
|
||||
| help: remove this `mut`
|
||||
|
||||
warning: unused variable: `i_think_continually`
|
||||
--> $DIR/issue-47390-unused-variable-in-struct-pattern.rs:26:9
|
||||
|
|
||||
LL | let i_think_continually = 2;
|
||||
| ^^^^^^^^^^^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_i_think_continually`
|
||||
|
|
||||
= note: `#[warn(unused_variables)]` implied by `#[warn(unused)]`
|
||||
|
||||
warning: unused variable: `mut_unused_var`
|
||||
--> $DIR/issue-47390-unused-variable-in-struct-pattern.rs:33:13
|
||||
--> $DIR/issue-47390-unused-variable-in-struct-pattern.rs:33:9
|
||||
|
|
||||
LL | let mut mut_unused_var = 1;
|
||||
| ^^^^^^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_mut_unused_var`
|
||||
| ^^^^^^^^^^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_mut_unused_var`
|
||||
|
||||
warning: unused variable: `var`
|
||||
--> $DIR/issue-47390-unused-variable-in-struct-pattern.rs:37:14
|
||||
--> $DIR/issue-47390-unused-variable-in-struct-pattern.rs:37:10
|
||||
|
|
||||
LL | let (mut var, unused_var) = (1, 2);
|
||||
| ^^^ help: if this is intentional, prefix it with an underscore: `_var`
|
||||
| ^^^^^^^ help: if this is intentional, prefix it with an underscore: `_var`
|
||||
|
||||
warning: unused variable: `unused_var`
|
||||
--> $DIR/issue-47390-unused-variable-in-struct-pattern.rs:37:19
|
||||
|
|
@ -36,22 +54,13 @@ LL | if let SoulHistory { corridors_of_light,
|
|||
| ^^^^^^^^^^^^^^^^^^ help: try ignoring the field: `corridors_of_light: _`
|
||||
|
||||
warning: variable `hours_are_suns` is assigned to, but never used
|
||||
--> $DIR/issue-47390-unused-variable-in-struct-pattern.rs:46:30
|
||||
--> $DIR/issue-47390-unused-variable-in-struct-pattern.rs:46:26
|
||||
|
|
||||
LL | mut hours_are_suns,
|
||||
| ^^^^^^^^^^^^^^
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: consider using `_hours_are_suns` instead
|
||||
|
||||
warning: value assigned to `hours_are_suns` is never read
|
||||
--> $DIR/issue-47390-unused-variable-in-struct-pattern.rs:48:9
|
||||
|
|
||||
LL | hours_are_suns = false;
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: maybe it is overwritten before being read?
|
||||
= note: `#[warn(unused_assignments)]` implied by `#[warn(unused)]`
|
||||
|
||||
warning: unused variable: `fire`
|
||||
--> $DIR/issue-47390-unused-variable-in-struct-pattern.rs:52:32
|
||||
|
|
||||
|
|
@ -94,23 +103,14 @@ warning: unused variable: `case`
|
|||
LL | Tuple(Large::Suit { case }, ()) => {}
|
||||
| ^^^^ help: try ignoring the field: `case: _`
|
||||
|
||||
warning: variable does not need to be mutable
|
||||
--> $DIR/issue-47390-unused-variable-in-struct-pattern.rs:33:9
|
||||
warning: value assigned to `hours_are_suns` is never read
|
||||
--> $DIR/issue-47390-unused-variable-in-struct-pattern.rs:48:9
|
||||
|
|
||||
LL | let mut mut_unused_var = 1;
|
||||
| ----^^^^^^^^^^^^^^
|
||||
| |
|
||||
| help: remove this `mut`
|
||||
LL | hours_are_suns = false;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: `#[warn(unused_mut)]` implied by `#[warn(unused)]`
|
||||
|
||||
warning: variable does not need to be mutable
|
||||
--> $DIR/issue-47390-unused-variable-in-struct-pattern.rs:37:10
|
||||
|
|
||||
LL | let (mut var, unused_var) = (1, 2);
|
||||
| ----^^^
|
||||
| |
|
||||
| help: remove this `mut`
|
||||
= help: maybe it is overwritten before being read?
|
||||
= note: `#[warn(unused_assignments)]` implied by `#[warn(unused)]`
|
||||
|
||||
warning: 16 warnings emitted
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,12 @@ LL | #![deny(unused)]
|
|||
| ^^^^^^
|
||||
= note: `#[deny(unused_variables)]` implied by `#[deny(unused)]`
|
||||
|
||||
error: unused variable: `x`
|
||||
--> $DIR/issue-54180-unused-ref-field.rs:29:45
|
||||
|
|
||||
LL | let _: i32 = points.iter().map(|Point { x, y }| y).sum();
|
||||
| ^ help: try ignoring the field: `x: _`
|
||||
|
||||
error: unused variable: `f1`
|
||||
--> $DIR/issue-54180-unused-ref-field.rs:26:13
|
||||
|
|
||||
|
|
@ -23,11 +29,5 @@ error: unused variable: `x`
|
|||
LL | Point { y, ref mut x } => y,
|
||||
| ^^^^^^^^^ help: try ignoring the field: `x: _`
|
||||
|
||||
error: unused variable: `x`
|
||||
--> $DIR/issue-54180-unused-ref-field.rs:29:45
|
||||
|
|
||||
LL | let _: i32 = points.iter().map(|Point { x, y }| y).sum();
|
||||
| ^ help: try ignoring the field: `x: _`
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -10,24 +10,18 @@ note: the lint level is defined here
|
|||
LL | #![deny(unused_variables)]
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
error: unused variable: `a`
|
||||
--> $DIR/lint-unused-variables.rs:21:9
|
||||
|
|
||||
LL | a: i32,
|
||||
| ^ help: if this is intentional, prefix it with an underscore: `_a`
|
||||
|
||||
error: unused variable: `a`
|
||||
--> $DIR/lint-unused-variables.rs:67:9
|
||||
|
|
||||
LL | a: i32,
|
||||
| ^ help: if this is intentional, prefix it with an underscore: `_a`
|
||||
|
||||
error: unused variable: `b`
|
||||
--> $DIR/lint-unused-variables.rs:13:5
|
||||
|
|
||||
LL | b: i32,
|
||||
| ^ help: if this is intentional, prefix it with an underscore: `_b`
|
||||
|
||||
error: unused variable: `a`
|
||||
--> $DIR/lint-unused-variables.rs:21:9
|
||||
|
|
||||
LL | a: i32,
|
||||
| ^ help: if this is intentional, prefix it with an underscore: `_a`
|
||||
|
||||
error: unused variable: `b`
|
||||
--> $DIR/lint-unused-variables.rs:28:9
|
||||
|
|
||||
|
|
@ -70,5 +64,11 @@ error: unused variable: `b`
|
|||
LL | b: i32,
|
||||
| ^ help: if this is intentional, prefix it with an underscore: `_b`
|
||||
|
||||
error: unused variable: `a`
|
||||
--> $DIR/lint-unused-variables.rs:67:9
|
||||
|
|
||||
LL | a: i32,
|
||||
| ^ help: if this is intentional, prefix it with an underscore: `_a`
|
||||
|
||||
error: aborting due to 11 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
warning: value assigned to `src` is never read
|
||||
--> $DIR/liveness-asm.rs:14:32
|
||||
--> $DIR/liveness-asm.rs:14:5
|
||||
|
|
||||
LL | asm!("/*{0}*/", inout(reg) src);
|
||||
| ^^^
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: maybe it is overwritten before being read?
|
||||
note: the lint level is defined here
|
||||
|
|
@ -12,10 +12,10 @@ LL | #![warn(unused_assignments)]
|
|||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
warning: value assigned to `src` is never read
|
||||
--> $DIR/liveness-asm.rs:24:39
|
||||
--> $DIR/liveness-asm.rs:24:5
|
||||
|
|
||||
LL | asm!("/*{0}*/", inout(reg) src => src);
|
||||
| ^^^
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: maybe it is overwritten before being read?
|
||||
|
||||
|
|
|
|||
|
|
@ -4,16 +4,18 @@
|
|||
|
||||
pub static A: i32 = {
|
||||
let mut i = 0;
|
||||
let mut a = 0; //~ WARN variable `a` is assigned to, but never used
|
||||
let mut a = 0;
|
||||
//~^ WARN variable `a` is assigned to, but never used
|
||||
while i < 10 {
|
||||
i += 1;
|
||||
a += 1;
|
||||
//~^ WARN value assigned to `a` is never read
|
||||
}
|
||||
i
|
||||
};
|
||||
|
||||
pub const B: u32 = {
|
||||
let mut b = 1;
|
||||
let mut b = 1; //~ WARN value assigned to `b` is never read
|
||||
b += 1; //~ WARN value assigned to `b` is never read
|
||||
b = 42;
|
||||
b
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
warning: unused variable: `e`
|
||||
--> $DIR/liveness-consts.rs:24:13
|
||||
--> $DIR/liveness-consts.rs:26:13
|
||||
|
|
||||
LL | let e = 1;
|
||||
| ^ help: if this is intentional, prefix it with an underscore: `_e`
|
||||
|
|
@ -12,53 +12,69 @@ LL | #![warn(unused)]
|
|||
= note: `#[warn(unused_variables)]` implied by `#[warn(unused)]`
|
||||
|
||||
warning: unused variable: `s`
|
||||
--> $DIR/liveness-consts.rs:33:24
|
||||
--> $DIR/liveness-consts.rs:35:24
|
||||
|
|
||||
LL | pub fn f(x: [u8; { let s = 17; 100 }]) -> [u8; { let z = 18; 100 }] {
|
||||
| ^ help: if this is intentional, prefix it with an underscore: `_s`
|
||||
|
||||
warning: unused variable: `z`
|
||||
--> $DIR/liveness-consts.rs:33:55
|
||||
--> $DIR/liveness-consts.rs:35:55
|
||||
|
|
||||
LL | pub fn f(x: [u8; { let s = 17; 100 }]) -> [u8; { let z = 18; 100 }] {
|
||||
| ^ help: if this is intentional, prefix it with an underscore: `_z`
|
||||
|
||||
warning: variable `a` is assigned to, but never used
|
||||
--> $DIR/liveness-consts.rs:7:13
|
||||
--> $DIR/liveness-consts.rs:7:9
|
||||
|
|
||||
LL | let mut a = 0;
|
||||
| ^
|
||||
| ^^^^^
|
||||
|
|
||||
= note: consider using `_a` instead
|
||||
|
||||
warning: value assigned to `b` is never read
|
||||
--> $DIR/liveness-consts.rs:17:5
|
||||
warning: value assigned to `a` is never read
|
||||
--> $DIR/liveness-consts.rs:11:9
|
||||
|
|
||||
LL | b += 1;
|
||||
| ^
|
||||
LL | a += 1;
|
||||
| ^^^^^^
|
||||
|
|
||||
= help: maybe it is overwritten before being read?
|
||||
= note: `#[warn(unused_assignments)]` implied by `#[warn(unused)]`
|
||||
|
||||
warning: value assigned to `b` is never read
|
||||
--> $DIR/liveness-consts.rs:18:17
|
||||
|
|
||||
LL | let mut b = 1;
|
||||
| ^
|
||||
|
|
||||
= help: maybe it is overwritten before being read?
|
||||
|
||||
warning: value assigned to `b` is never read
|
||||
--> $DIR/liveness-consts.rs:19:5
|
||||
|
|
||||
LL | b += 1;
|
||||
| ^^^^^^
|
||||
|
|
||||
= help: maybe it is overwritten before being read?
|
||||
|
||||
warning: unused variable: `z`
|
||||
--> $DIR/liveness-consts.rs:60:13
|
||||
--> $DIR/liveness-consts.rs:62:13
|
||||
|
|
||||
LL | let z = 42;
|
||||
| ^ help: if this is intentional, prefix it with an underscore: `_z`
|
||||
|
||||
warning: value assigned to `t` is never read
|
||||
--> $DIR/liveness-consts.rs:42:9
|
||||
--> $DIR/liveness-consts.rs:44:9
|
||||
|
|
||||
LL | t = t + t;
|
||||
| ^
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= help: maybe it is overwritten before being read?
|
||||
|
||||
warning: unused variable: `w`
|
||||
--> $DIR/liveness-consts.rs:49:13
|
||||
--> $DIR/liveness-consts.rs:51:13
|
||||
|
|
||||
LL | let w = 10;
|
||||
| ^ help: if this is intentional, prefix it with an underscore: `_w`
|
||||
|
||||
warning: 8 warnings emitted
|
||||
warning: 10 warnings emitted
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
error: value assigned to `x` is never read
|
||||
--> $DIR/liveness-dead.rs:9:13
|
||||
--> $DIR/liveness-dead.rs:9:24
|
||||
|
|
||||
LL | let mut x: isize = 3;
|
||||
| ^
|
||||
| ^
|
||||
|
|
||||
= help: maybe it is overwritten before being read?
|
||||
note: the lint level is defined here
|
||||
|
|
@ -15,15 +15,15 @@ error: value assigned to `x` is never read
|
|||
--> $DIR/liveness-dead.rs:17:5
|
||||
|
|
||||
LL | x = 4;
|
||||
| ^
|
||||
| ^^^^^
|
||||
|
|
||||
= help: maybe it is overwritten before being read?
|
||||
|
||||
error: value passed to `x` is never read
|
||||
--> $DIR/liveness-dead.rs:20:11
|
||||
--> $DIR/liveness-dead.rs:20:7
|
||||
|
|
||||
LL | fn f4(mut x: i32) {
|
||||
| ^
|
||||
| ^^^^^
|
||||
|
|
||||
= help: maybe it is overwritten before being read?
|
||||
|
||||
|
|
@ -31,7 +31,7 @@ error: value assigned to `x` is never read
|
|||
--> $DIR/liveness-dead.rs:27:5
|
||||
|
|
||||
LL | x = 4;
|
||||
| ^
|
||||
| ^^^^^
|
||||
|
|
||||
= help: maybe it is overwritten before being read?
|
||||
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ fn f3b() {
|
|||
//~^ ERROR variable `z` is assigned to, but never used
|
||||
loop {
|
||||
z += 4;
|
||||
//~^ ERROR value assigned to `z` is never read
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -46,6 +47,7 @@ fn f3b() {
|
|||
fn f3c() {
|
||||
let mut z = 3;
|
||||
loop { z += 4; }
|
||||
//~^ ERROR value assigned to `z` is never read
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
|
|
@ -55,6 +57,16 @@ fn f3d() {
|
|||
x += 4;
|
||||
}
|
||||
|
||||
fn f3e() {
|
||||
let a = 13;
|
||||
let mut z = 3;
|
||||
//~^ ERROR variable `z` is assigned to, but never used
|
||||
loop {
|
||||
z += a;
|
||||
//~^ ERROR value assigned to `z` is never read
|
||||
}
|
||||
}
|
||||
|
||||
fn f4() {
|
||||
match Some(3) {
|
||||
Some(i) => {
|
||||
|
|
@ -68,7 +80,15 @@ enum tri {
|
|||
a(isize), b(isize), c(isize)
|
||||
}
|
||||
|
||||
fn f4b() -> isize {
|
||||
fn f4b() {
|
||||
match tri::a(3) {
|
||||
tri::a(i) | tri::b(i) | tri::c(i) => {
|
||||
//~^ ERROR unused variable: `i`
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn f4c() -> isize {
|
||||
match tri::a(3) {
|
||||
tri::a(i) | tri::b(i) | tri::c(i) => {
|
||||
i
|
||||
|
|
@ -76,6 +96,13 @@ fn f4b() -> isize {
|
|||
}
|
||||
}
|
||||
|
||||
fn f4d() {
|
||||
match tri::a(3) {
|
||||
tri::a(i) | tri::b(i) | tri::c(i) if i == 0 => {}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
fn f5a() {
|
||||
for x in 1..10 { }
|
||||
//~^ ERROR unused variable: `x`
|
||||
|
|
@ -138,10 +165,92 @@ fn f7() {
|
|||
drop(a);
|
||||
}
|
||||
|
||||
fn f8(a: u32) {
|
||||
let _ = a;
|
||||
}
|
||||
|
||||
fn f9() {
|
||||
let mut a = 10;
|
||||
//~^ ERROR variable `a` is assigned to, but never used
|
||||
let b = 13;
|
||||
let c = 13;
|
||||
let d = 13;
|
||||
let e = 13;
|
||||
let f = 13;
|
||||
let g = 13;
|
||||
let h = 13;
|
||||
|
||||
a += b;
|
||||
//~^ ERROR value assigned to `a` is never read
|
||||
a -= c;
|
||||
//~^ ERROR value assigned to `a` is never read
|
||||
a *= d;
|
||||
//~^ ERROR value assigned to `a` is never read
|
||||
a /= e;
|
||||
//~^ ERROR value assigned to `a` is never read
|
||||
a |= f;
|
||||
//~^ ERROR value assigned to `a` is never read
|
||||
a &= g;
|
||||
//~^ ERROR value assigned to `a` is never read
|
||||
a %= h;
|
||||
//~^ ERROR value assigned to `a` is never read
|
||||
}
|
||||
|
||||
fn f9b() {
|
||||
let mut a = 10;
|
||||
let b = 13;
|
||||
let c = 13;
|
||||
let d = 13;
|
||||
let e = 13;
|
||||
let f = 13;
|
||||
let g = 13;
|
||||
let h = 13;
|
||||
|
||||
a += b;
|
||||
a -= c;
|
||||
a *= d;
|
||||
a /= e;
|
||||
a |= f;
|
||||
a &= g;
|
||||
a %= h;
|
||||
|
||||
let _ = a;
|
||||
}
|
||||
|
||||
fn f9c() {
|
||||
let mut a = 10.;
|
||||
//~^ ERROR variable `a` is assigned to, but never used
|
||||
let b = 13.;
|
||||
let c = 13.;
|
||||
let d = 13.;
|
||||
let e = 13.;
|
||||
let f = 13.;
|
||||
|
||||
a += b;
|
||||
//~^ ERROR value assigned to `a` is never read
|
||||
a -= c;
|
||||
//~^ ERROR value assigned to `a` is never read
|
||||
a *= d;
|
||||
//~^ ERROR value assigned to `a` is never read
|
||||
a /= e;
|
||||
//~^ ERROR value assigned to `a` is never read
|
||||
a %= f;
|
||||
//~^ ERROR value assigned to `a` is never read
|
||||
}
|
||||
|
||||
fn f10<T>(mut a: T, b: T) {
|
||||
//~^ ERROR variable `a` is assigned to, but never used
|
||||
a = b;
|
||||
//~^ ERROR value assigned to `a` is never read
|
||||
}
|
||||
|
||||
fn f10b<T>(mut a: Box<T>, b: Box<T>) {
|
||||
a = b;
|
||||
}
|
||||
|
||||
// unused params warnings are not needed for intrinsic functions without bodies
|
||||
#[rustc_intrinsic]
|
||||
unsafe fn simd_shuffle<T, I, U>(a: T, b: T, i: I) -> U;
|
||||
|
||||
|
||||
fn main() {
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
warning: unreachable statement
|
||||
--> $DIR/liveness-unused.rs:93:9
|
||||
--> $DIR/liveness-unused.rs:120:9
|
||||
|
|
||||
LL | continue;
|
||||
| -------- any code following this expression is unreachable
|
||||
|
|
@ -44,10 +44,10 @@ LL | let x = 3;
|
|||
| ^ help: if this is intentional, prefix it with an underscore: `_x`
|
||||
|
||||
error: variable `x` is assigned to, but never used
|
||||
--> $DIR/liveness-unused.rs:31:13
|
||||
--> $DIR/liveness-unused.rs:31:9
|
||||
|
|
||||
LL | let mut x = 3;
|
||||
| ^
|
||||
| ^^^^^
|
||||
|
|
||||
= note: consider using `_x` instead
|
||||
|
||||
|
|
@ -55,7 +55,7 @@ error: value assigned to `x` is never read
|
|||
--> $DIR/liveness-unused.rs:33:5
|
||||
|
|
||||
LL | x += 4;
|
||||
| ^
|
||||
| ^^^^^^
|
||||
|
|
||||
= help: maybe it is overwritten before being read?
|
||||
note: the lint level is defined here
|
||||
|
|
@ -65,39 +65,82 @@ LL | #![deny(unused_assignments)]
|
|||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: variable `z` is assigned to, but never used
|
||||
--> $DIR/liveness-unused.rs:38:13
|
||||
--> $DIR/liveness-unused.rs:38:9
|
||||
|
|
||||
LL | let mut z = 3;
|
||||
| ^
|
||||
| ^^^^^
|
||||
|
|
||||
= note: consider using `_z` instead
|
||||
|
||||
error: value assigned to `z` is never read
|
||||
--> $DIR/liveness-unused.rs:41:9
|
||||
|
|
||||
LL | z += 4;
|
||||
| ^^^^^^
|
||||
|
|
||||
= help: maybe it is overwritten before being read?
|
||||
|
||||
error: value assigned to `z` is never read
|
||||
--> $DIR/liveness-unused.rs:49:12
|
||||
|
|
||||
LL | loop { z += 4; }
|
||||
| ^^^^^^
|
||||
|
|
||||
= help: maybe it is overwritten before being read?
|
||||
|
||||
error: variable `z` is assigned to, but never used
|
||||
--> $DIR/liveness-unused.rs:62:9
|
||||
|
|
||||
LL | let mut z = 3;
|
||||
| ^^^^^
|
||||
|
|
||||
= note: consider using `_z` instead
|
||||
|
||||
error: value assigned to `z` is never read
|
||||
--> $DIR/liveness-unused.rs:65:9
|
||||
|
|
||||
LL | z += a;
|
||||
| ^^^^^^
|
||||
|
|
||||
= help: maybe it is overwritten before being read?
|
||||
|
||||
error: unused variable: `i`
|
||||
--> $DIR/liveness-unused.rs:60:12
|
||||
--> $DIR/liveness-unused.rs:72:12
|
||||
|
|
||||
LL | Some(i) => {
|
||||
| ^ help: if this is intentional, prefix it with an underscore: `_i`
|
||||
|
||||
error: unused variable: `i`
|
||||
--> $DIR/liveness-unused.rs:85:14
|
||||
|
|
||||
LL | tri::a(i) | tri::b(i) | tri::c(i) => {
|
||||
| ^ ^ ^
|
||||
|
|
||||
help: if this is intentional, prefix it with an underscore
|
||||
|
|
||||
LL | tri::a(_i) | tri::b(_i) | tri::c(_i) => {
|
||||
| + + +
|
||||
|
||||
error: unused variable: `x`
|
||||
--> $DIR/liveness-unused.rs:80:9
|
||||
--> $DIR/liveness-unused.rs:107:9
|
||||
|
|
||||
LL | for x in 1..10 { }
|
||||
| ^ help: if this is intentional, prefix it with an underscore: `_x`
|
||||
|
||||
error: unused variable: `x`
|
||||
--> $DIR/liveness-unused.rs:85:10
|
||||
--> $DIR/liveness-unused.rs:112:10
|
||||
|
|
||||
LL | for (x, _) in [1, 2, 3].iter().enumerate() { }
|
||||
| ^ help: if this is intentional, prefix it with an underscore: `_x`
|
||||
|
||||
error: unused variable: `x`
|
||||
--> $DIR/liveness-unused.rs:90:13
|
||||
--> $DIR/liveness-unused.rs:117:13
|
||||
|
|
||||
LL | for (_, x) in [1, 2, 3].iter().enumerate() {
|
||||
| ^ help: if this is intentional, prefix it with an underscore: `_x`
|
||||
|
||||
error: variable `x` is assigned to, but never used
|
||||
--> $DIR/liveness-unused.rs:113:9
|
||||
--> $DIR/liveness-unused.rs:140:9
|
||||
|
|
||||
LL | let x;
|
||||
| ^
|
||||
|
|
@ -105,12 +148,140 @@ LL | let x;
|
|||
= note: consider using `_x` instead
|
||||
|
||||
error: value assigned to `x` is never read
|
||||
--> $DIR/liveness-unused.rs:117:9
|
||||
--> $DIR/liveness-unused.rs:144:9
|
||||
|
|
||||
LL | x = 0;
|
||||
| ^
|
||||
| ^^^^^
|
||||
|
|
||||
= help: maybe it is overwritten before being read?
|
||||
|
||||
error: aborting due to 13 previous errors; 1 warning emitted
|
||||
error: variable `a` is assigned to, but never used
|
||||
--> $DIR/liveness-unused.rs:173:9
|
||||
|
|
||||
LL | let mut a = 10;
|
||||
| ^^^^^
|
||||
|
|
||||
= note: consider using `_a` instead
|
||||
|
||||
error: value assigned to `a` is never read
|
||||
--> $DIR/liveness-unused.rs:183:5
|
||||
|
|
||||
LL | a += b;
|
||||
| ^^^^^^
|
||||
|
|
||||
= help: maybe it is overwritten before being read?
|
||||
|
||||
error: value assigned to `a` is never read
|
||||
--> $DIR/liveness-unused.rs:185:5
|
||||
|
|
||||
LL | a -= c;
|
||||
| ^^^^^^
|
||||
|
|
||||
= help: maybe it is overwritten before being read?
|
||||
|
||||
error: value assigned to `a` is never read
|
||||
--> $DIR/liveness-unused.rs:187:5
|
||||
|
|
||||
LL | a *= d;
|
||||
| ^^^^^^
|
||||
|
|
||||
= help: maybe it is overwritten before being read?
|
||||
|
||||
error: value assigned to `a` is never read
|
||||
--> $DIR/liveness-unused.rs:189:5
|
||||
|
|
||||
LL | a /= e;
|
||||
| ^^^^^^
|
||||
|
|
||||
= help: maybe it is overwritten before being read?
|
||||
|
||||
error: value assigned to `a` is never read
|
||||
--> $DIR/liveness-unused.rs:191:5
|
||||
|
|
||||
LL | a |= f;
|
||||
| ^^^^^^
|
||||
|
|
||||
= help: maybe it is overwritten before being read?
|
||||
|
||||
error: value assigned to `a` is never read
|
||||
--> $DIR/liveness-unused.rs:193:5
|
||||
|
|
||||
LL | a &= g;
|
||||
| ^^^^^^
|
||||
|
|
||||
= help: maybe it is overwritten before being read?
|
||||
|
||||
error: value assigned to `a` is never read
|
||||
--> $DIR/liveness-unused.rs:195:5
|
||||
|
|
||||
LL | a %= h;
|
||||
| ^^^^^^
|
||||
|
|
||||
= help: maybe it is overwritten before being read?
|
||||
|
||||
error: variable `a` is assigned to, but never used
|
||||
--> $DIR/liveness-unused.rs:221:9
|
||||
|
|
||||
LL | let mut a = 10.;
|
||||
| ^^^^^
|
||||
|
|
||||
= note: consider using `_a` instead
|
||||
|
||||
error: value assigned to `a` is never read
|
||||
--> $DIR/liveness-unused.rs:229:5
|
||||
|
|
||||
LL | a += b;
|
||||
| ^^^^^^
|
||||
|
|
||||
= help: maybe it is overwritten before being read?
|
||||
|
||||
error: value assigned to `a` is never read
|
||||
--> $DIR/liveness-unused.rs:231:5
|
||||
|
|
||||
LL | a -= c;
|
||||
| ^^^^^^
|
||||
|
|
||||
= help: maybe it is overwritten before being read?
|
||||
|
||||
error: value assigned to `a` is never read
|
||||
--> $DIR/liveness-unused.rs:233:5
|
||||
|
|
||||
LL | a *= d;
|
||||
| ^^^^^^
|
||||
|
|
||||
= help: maybe it is overwritten before being read?
|
||||
|
||||
error: value assigned to `a` is never read
|
||||
--> $DIR/liveness-unused.rs:235:5
|
||||
|
|
||||
LL | a /= e;
|
||||
| ^^^^^^
|
||||
|
|
||||
= help: maybe it is overwritten before being read?
|
||||
|
||||
error: value assigned to `a` is never read
|
||||
--> $DIR/liveness-unused.rs:237:5
|
||||
|
|
||||
LL | a %= f;
|
||||
| ^^^^^^
|
||||
|
|
||||
= help: maybe it is overwritten before being read?
|
||||
|
||||
error: variable `a` is assigned to, but never used
|
||||
--> $DIR/liveness-unused.rs:241:11
|
||||
|
|
||||
LL | fn f10<T>(mut a: T, b: T) {
|
||||
| ^^^^^
|
||||
|
|
||||
= note: consider using `_a` instead
|
||||
|
||||
error: value assigned to `a` is never read
|
||||
--> $DIR/liveness-unused.rs:243:5
|
||||
|
|
||||
LL | a = b;
|
||||
| ^
|
||||
|
|
||||
= help: maybe it is overwritten before being read?
|
||||
|
||||
error: aborting due to 34 previous errors; 1 warning emitted
|
||||
|
||||
|
|
|
|||
|
|
@ -7,8 +7,8 @@
|
|||
pub fn unintentional_copy_one() {
|
||||
let mut last = None;
|
||||
let mut f = move |s| {
|
||||
last = Some(s); //~ WARN value assigned to `last` is never read
|
||||
//~| WARN unused variable: `last`
|
||||
last = Some(s); //~ WARN value captured by `last` is never read
|
||||
//~| WARN value assigned to `last` is never read
|
||||
};
|
||||
f("a");
|
||||
f("b");
|
||||
|
|
@ -19,7 +19,9 @@ pub fn unintentional_copy_one() {
|
|||
pub fn unintentional_copy_two() {
|
||||
let mut sum = 0;
|
||||
(1..10).for_each(move |x| {
|
||||
sum += x; //~ WARN unused variable: `sum`
|
||||
sum += x;
|
||||
//~^ WARN value captured by `sum` is never read
|
||||
//~| WARN value assigned to `sum` is never read
|
||||
});
|
||||
dbg!(sum);
|
||||
}
|
||||
|
|
@ -39,11 +41,14 @@ pub fn f() {
|
|||
|
||||
// Read and written to, but never actually used.
|
||||
let _ = move || {
|
||||
c += 1; //~ WARN unused variable: `c`
|
||||
c += 1;
|
||||
//~^ WARN value captured by `c` is never read
|
||||
//~| WARN value assigned to `c` is never read
|
||||
};
|
||||
let _ = async move {
|
||||
c += 1; //~ WARN value assigned to `c` is never read
|
||||
//~| WARN unused variable: `c`
|
||||
c += 1;
|
||||
//~^ WARN value captured by `c` is never read
|
||||
//~| WARN value assigned to `c` is never read
|
||||
};
|
||||
|
||||
let _ = move || {
|
||||
|
|
@ -74,8 +79,8 @@ pub fn nested() {
|
|||
d = Some("d2");
|
||||
};
|
||||
let _ = move || {
|
||||
e = Some("e1"); //~ WARN value assigned to `e` is never read
|
||||
//~| WARN unused variable: `e`
|
||||
e = Some("e1"); //~ WARN value captured by `e` is never read
|
||||
//~| WARN value assigned to `e` is never read
|
||||
e = Some("e2"); //~ WARN value assigned to `e` is never read
|
||||
};
|
||||
};
|
||||
|
|
@ -84,7 +89,8 @@ pub fn nested() {
|
|||
pub fn g<T: Default>(mut v: T) {
|
||||
let _ = |r| {
|
||||
if r {
|
||||
v = T::default(); //~ WARN value assigned to `v` is never read
|
||||
v = T::default();
|
||||
//~^ WARN value assigned to `v` is never read
|
||||
} else {
|
||||
drop(v);
|
||||
}
|
||||
|
|
@ -96,8 +102,8 @@ pub fn h<T: Copy + Default + std::fmt::Debug>() {
|
|||
let _ = move |b| {
|
||||
loop {
|
||||
if b {
|
||||
z = T::default(); //~ WARN value assigned to `z` is never read
|
||||
//~| WARN unused variable: `z`
|
||||
z = T::default(); //~ WARN value captured by `z` is never read
|
||||
//~| WARN value assigned to `z` is never read
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
|
@ -123,7 +129,7 @@ pub fn async_coroutine() {
|
|||
|
||||
let _ = async move {
|
||||
state = 4; //~ WARN value assigned to `state` is never read
|
||||
//~| WARN unused variable: `state`
|
||||
//~| WARN value captured by `state` is never read
|
||||
yield_now().await;
|
||||
state = 5; //~ WARN value assigned to `state` is never read
|
||||
};
|
||||
|
|
@ -141,4 +147,21 @@ pub fn coroutine() {
|
|||
};
|
||||
}
|
||||
|
||||
pub fn panics() {
|
||||
use std::panic::{AssertUnwindSafe, catch_unwind, resume_unwind};
|
||||
|
||||
let mut panic = true;
|
||||
|
||||
// `a` can be called again, even if it has panicked at an earlier run.
|
||||
let mut a = || {
|
||||
if panic {
|
||||
panic = false;
|
||||
resume_unwind(Box::new(()))
|
||||
}
|
||||
};
|
||||
|
||||
catch_unwind(AssertUnwindSafe(|| a())).ok();
|
||||
a();
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
warning: value assigned to `last` is never read
|
||||
warning: value captured by `last` is never read
|
||||
--> $DIR/liveness-upvars.rs:10:9
|
||||
|
|
||||
LL | last = Some(s);
|
||||
| ^^^^
|
||||
|
|
||||
= help: maybe it is overwritten before being read?
|
||||
= help: did you mean to capture by reference instead?
|
||||
note: the lint level is defined here
|
||||
--> $DIR/liveness-upvars.rs:4:9
|
||||
|
|
||||
|
|
@ -12,16 +12,15 @@ LL | #![warn(unused)]
|
|||
| ^^^^^^
|
||||
= note: `#[warn(unused_assignments)]` implied by `#[warn(unused)]`
|
||||
|
||||
warning: unused variable: `last`
|
||||
warning: value assigned to `last` is never read
|
||||
--> $DIR/liveness-upvars.rs:10:9
|
||||
|
|
||||
LL | last = Some(s);
|
||||
| ^^^^
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: did you mean to capture by reference instead?
|
||||
= note: `#[warn(unused_variables)]` implied by `#[warn(unused)]`
|
||||
= help: maybe it is overwritten before being read?
|
||||
|
||||
warning: unused variable: `sum`
|
||||
warning: value captured by `sum` is never read
|
||||
--> $DIR/liveness-upvars.rs:22:9
|
||||
|
|
||||
LL | sum += x;
|
||||
|
|
@ -29,8 +28,64 @@ LL | sum += x;
|
|||
|
|
||||
= help: did you mean to capture by reference instead?
|
||||
|
||||
warning: value assigned to `sum` is never read
|
||||
--> $DIR/liveness-upvars.rs:22:9
|
||||
|
|
||||
LL | sum += x;
|
||||
| ^^^^^^^^
|
||||
|
|
||||
= help: maybe it is overwritten before being read?
|
||||
|
||||
warning: value assigned to `c` is never read
|
||||
--> $DIR/liveness-upvars.rs:69:9
|
||||
|
|
||||
LL | c += 1;
|
||||
| ^^^^^^
|
||||
|
|
||||
= help: maybe it is overwritten before being read?
|
||||
|
||||
warning: value assigned to `c` is never read
|
||||
--> $DIR/liveness-upvars.rs:63:9
|
||||
|
|
||||
LL | c += 1;
|
||||
| ^^^^^^
|
||||
|
|
||||
= help: maybe it is overwritten before being read?
|
||||
|
||||
warning: value captured by `c` is never read
|
||||
--> $DIR/liveness-upvars.rs:32:9
|
||||
--> $DIR/liveness-upvars.rs:49:9
|
||||
|
|
||||
LL | c += 1;
|
||||
| ^
|
||||
|
|
||||
= help: did you mean to capture by reference instead?
|
||||
|
||||
warning: value assigned to `c` is never read
|
||||
--> $DIR/liveness-upvars.rs:49:9
|
||||
|
|
||||
LL | c += 1;
|
||||
| ^^^^^^
|
||||
|
|
||||
= help: maybe it is overwritten before being read?
|
||||
|
||||
warning: value captured by `c` is never read
|
||||
--> $DIR/liveness-upvars.rs:44:9
|
||||
|
|
||||
LL | c += 1;
|
||||
| ^
|
||||
|
|
||||
= help: did you mean to capture by reference instead?
|
||||
|
||||
warning: value assigned to `c` is never read
|
||||
--> $DIR/liveness-upvars.rs:44:9
|
||||
|
|
||||
LL | c += 1;
|
||||
| ^^^^^^
|
||||
|
|
||||
= help: maybe it is overwritten before being read?
|
||||
|
||||
warning: value captured by `c` is never read
|
||||
--> $DIR/liveness-upvars.rs:38:9
|
||||
|
|
||||
LL | c = 1;
|
||||
| ^
|
||||
|
|
@ -38,148 +93,108 @@ LL | c = 1;
|
|||
= help: did you mean to capture by reference instead?
|
||||
|
||||
warning: value captured by `c` is never read
|
||||
--> $DIR/liveness-upvars.rs:36:9
|
||||
--> $DIR/liveness-upvars.rs:34:9
|
||||
|
|
||||
LL | c = 1;
|
||||
| ^
|
||||
|
|
||||
= help: did you mean to capture by reference instead?
|
||||
|
||||
warning: unused variable: `c`
|
||||
--> $DIR/liveness-upvars.rs:42:9
|
||||
warning: value captured by `e` is never read
|
||||
--> $DIR/liveness-upvars.rs:82:13
|
||||
|
|
||||
LL | c += 1;
|
||||
| ^
|
||||
LL | e = Some("e1");
|
||||
| ^
|
||||
|
|
||||
= help: did you mean to capture by reference instead?
|
||||
|
||||
warning: value assigned to `c` is never read
|
||||
--> $DIR/liveness-upvars.rs:45:9
|
||||
warning: value assigned to `e` is never read
|
||||
--> $DIR/liveness-upvars.rs:82:13
|
||||
|
|
||||
LL | c += 1;
|
||||
| ^
|
||||
LL | e = Some("e1");
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: maybe it is overwritten before being read?
|
||||
|
||||
warning: unused variable: `c`
|
||||
--> $DIR/liveness-upvars.rs:45:9
|
||||
warning: value assigned to `e` is never read
|
||||
--> $DIR/liveness-upvars.rs:84:13
|
||||
|
|
||||
LL | c += 1;
|
||||
| ^
|
||||
|
|
||||
= help: did you mean to capture by reference instead?
|
||||
|
||||
warning: value assigned to `c` is never read
|
||||
--> $DIR/liveness-upvars.rs:58:9
|
||||
|
|
||||
LL | c += 1;
|
||||
| ^
|
||||
|
|
||||
= help: maybe it is overwritten before being read?
|
||||
|
||||
warning: value assigned to `c` is never read
|
||||
--> $DIR/liveness-upvars.rs:64:9
|
||||
|
|
||||
LL | c += 1;
|
||||
| ^
|
||||
LL | e = Some("e2");
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: maybe it is overwritten before being read?
|
||||
|
||||
warning: value assigned to `d` is never read
|
||||
--> $DIR/liveness-upvars.rs:73:13
|
||||
--> $DIR/liveness-upvars.rs:78:13
|
||||
|
|
||||
LL | d = Some("d1");
|
||||
| ^
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: maybe it is overwritten before being read?
|
||||
|
||||
warning: value assigned to `e` is never read
|
||||
--> $DIR/liveness-upvars.rs:77:13
|
||||
|
|
||||
LL | e = Some("e1");
|
||||
| ^
|
||||
|
|
||||
= help: maybe it is overwritten before being read?
|
||||
|
||||
warning: value assigned to `e` is never read
|
||||
--> $DIR/liveness-upvars.rs:79:13
|
||||
|
|
||||
LL | e = Some("e2");
|
||||
| ^
|
||||
|
|
||||
= help: maybe it is overwritten before being read?
|
||||
|
||||
warning: unused variable: `e`
|
||||
--> $DIR/liveness-upvars.rs:77:13
|
||||
|
|
||||
LL | e = Some("e1");
|
||||
| ^
|
||||
|
|
||||
= help: did you mean to capture by reference instead?
|
||||
|
||||
warning: value assigned to `v` is never read
|
||||
--> $DIR/liveness-upvars.rs:87:13
|
||||
--> $DIR/liveness-upvars.rs:92:13
|
||||
|
|
||||
LL | v = T::default();
|
||||
| ^
|
||||
|
|
||||
= help: maybe it is overwritten before being read?
|
||||
|
||||
warning: value assigned to `z` is never read
|
||||
--> $DIR/liveness-upvars.rs:99:17
|
||||
|
|
||||
LL | z = T::default();
|
||||
| ^
|
||||
|
|
||||
= help: maybe it is overwritten before being read?
|
||||
|
||||
warning: unused variable: `z`
|
||||
--> $DIR/liveness-upvars.rs:99:17
|
||||
warning: value captured by `z` is never read
|
||||
--> $DIR/liveness-upvars.rs:105:17
|
||||
|
|
||||
LL | z = T::default();
|
||||
| ^
|
||||
|
|
||||
= help: did you mean to capture by reference instead?
|
||||
|
||||
warning: value assigned to `state` is never read
|
||||
--> $DIR/liveness-upvars.rs:125:9
|
||||
warning: value assigned to `z` is never read
|
||||
--> $DIR/liveness-upvars.rs:105:17
|
||||
|
|
||||
LL | z = T::default();
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: maybe it is overwritten before being read?
|
||||
|
||||
warning: value captured by `state` is never read
|
||||
--> $DIR/liveness-upvars.rs:131:9
|
||||
|
|
||||
LL | state = 4;
|
||||
| ^^^^^
|
||||
|
|
||||
= help: did you mean to capture by reference instead?
|
||||
|
||||
warning: value assigned to `state` is never read
|
||||
--> $DIR/liveness-upvars.rs:131:9
|
||||
|
|
||||
LL | state = 4;
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= help: maybe it is overwritten before being read?
|
||||
|
||||
warning: value assigned to `state` is never read
|
||||
--> $DIR/liveness-upvars.rs:128:9
|
||||
--> $DIR/liveness-upvars.rs:134:9
|
||||
|
|
||||
LL | state = 5;
|
||||
| ^^^^^
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= help: maybe it is overwritten before being read?
|
||||
|
||||
warning: unused variable: `state`
|
||||
--> $DIR/liveness-upvars.rs:125:9
|
||||
|
|
||||
LL | state = 4;
|
||||
| ^^^^^
|
||||
|
|
||||
= help: did you mean to capture by reference instead?
|
||||
|
||||
warning: value assigned to `s` is never read
|
||||
--> $DIR/liveness-upvars.rs:137:9
|
||||
--> $DIR/liveness-upvars.rs:143:9
|
||||
|
|
||||
LL | s = 1;
|
||||
| ^
|
||||
| ^^^^^
|
||||
|
|
||||
= help: maybe it is overwritten before being read?
|
||||
|
||||
warning: value assigned to `s` is never read
|
||||
--> $DIR/liveness-upvars.rs:139:9
|
||||
--> $DIR/liveness-upvars.rs:145:9
|
||||
|
|
||||
LL | s = yield ();
|
||||
| ^
|
||||
| ^^^^^^^^^^^^
|
||||
|
|
||||
= help: maybe it is overwritten before being read?
|
||||
|
||||
warning: 22 warnings emitted
|
||||
warning: 24 warnings emitted
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
// fields and fn arguments.
|
||||
|
||||
|
||||
#![allow(dead_code)]
|
||||
#![allow(dead_code, unused)]
|
||||
|
||||
trait Test {
|
||||
fn foo(&self) { }
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
// lifetime bound.
|
||||
|
||||
|
||||
#![allow(dead_code)]
|
||||
#![allow(dead_code, unused)]
|
||||
|
||||
use std::fmt::Display;
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
// through the `Box` struct.
|
||||
|
||||
|
||||
#![allow(dead_code)]
|
||||
#![allow(dead_code, unused)]
|
||||
|
||||
trait Test {
|
||||
fn foo(&self) { }
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
// lifetime bound.
|
||||
|
||||
|
||||
#![allow(dead_code)]
|
||||
#![allow(dead_code, unused)]
|
||||
|
||||
trait Test {
|
||||
fn foo(&self) { }
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
// through the `MyBox` struct.
|
||||
|
||||
|
||||
#![allow(dead_code)]
|
||||
#![allow(dead_code, unused)]
|
||||
|
||||
trait Test {
|
||||
fn foo(&self) { }
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
// lifetime bound.
|
||||
|
||||
|
||||
#![allow(dead_code)]
|
||||
#![allow(dead_code, unused)]
|
||||
|
||||
use std::fmt::Display;
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
// valid.
|
||||
|
||||
|
||||
#![allow(dead_code)]
|
||||
#![allow(dead_code, unused)]
|
||||
|
||||
trait Test {
|
||||
fn foo(&self) { }
|
||||
|
|
|
|||
|
|
@ -97,157 +97,71 @@ LL - (Foo, _) | (Ban, Foo) => {}
|
|||
LL + (Foo, _) | (Bat, Foo) => {}
|
||||
|
|
||||
|
||||
error: variable `Ban` is assigned to, but never used
|
||||
error: unused variable: `Ban`
|
||||
--> $DIR/binding-typo-2.rs:14:23
|
||||
|
|
||||
LL | (Foo, Bar) | (Ban, Foo) => {}
|
||||
| ^^^
|
||||
| ^^^ help: if this is intentional, prefix it with an underscore: `_Ban`
|
||||
|
|
||||
= note: consider using `_Ban` instead
|
||||
note: the lint level is defined here
|
||||
--> $DIR/binding-typo-2.rs:2:9
|
||||
|
|
||||
LL | #![deny(unused_variables)]
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
help: you might have meant to pattern match on the similarly named variant `Bar`
|
||||
|
|
||||
LL - (Foo, Bar) | (Ban, Foo) => {}
|
||||
LL + (Foo, Bar) | (Lol::Bar, Foo) => {}
|
||||
|
|
||||
|
||||
error: variable `Ban` is assigned to, but never used
|
||||
error: unused variable: `Ban`
|
||||
--> $DIR/binding-typo-2.rs:25:21
|
||||
|
|
||||
LL | (Foo, _) | (Ban, Foo) => {}
|
||||
| ^^^
|
||||
|
|
||||
= note: consider using `_Ban` instead
|
||||
help: you might have meant to pattern match on the similarly named variant `Bar`
|
||||
|
|
||||
LL - (Foo, _) | (Ban, Foo) => {}
|
||||
LL + (Foo, _) | (Lol::Bar, Foo) => {}
|
||||
|
|
||||
| ^^^ help: if this is intentional, prefix it with an underscore: `_Ban`
|
||||
|
||||
error: unused variable: `Non`
|
||||
--> $DIR/binding-typo-2.rs:37:9
|
||||
|
|
||||
LL | Non => {}
|
||||
| ^^^
|
||||
|
|
||||
help: if this is intentional, prefix it with an underscore
|
||||
|
|
||||
LL | _Non => {}
|
||||
| +
|
||||
help: you might have meant to pattern match on the similarly named variant `None`
|
||||
|
|
||||
LL - Non => {}
|
||||
LL + std::prelude::v1::None => {}
|
||||
|
|
||||
| ^^^ help: if this is intentional, prefix it with an underscore: `_Non`
|
||||
|
||||
error: unused variable: `Non`
|
||||
--> $DIR/binding-typo-2.rs:44:9
|
||||
|
|
||||
LL | Non | None => {}
|
||||
| ^^^
|
||||
|
|
||||
help: if this is intentional, prefix it with an underscore
|
||||
|
|
||||
LL | _Non | None => {}
|
||||
| +
|
||||
help: you might have meant to pattern match on the similarly named variant `None`
|
||||
|
|
||||
LL - Non | None => {}
|
||||
LL + std::prelude::v1::None | None => {}
|
||||
|
|
||||
| ^^^ help: if this is intentional, prefix it with an underscore: `_Non`
|
||||
|
||||
error: unused variable: `Non`
|
||||
--> $DIR/binding-typo-2.rs:54:9
|
||||
|
|
||||
LL | Non | Some(_) => {}
|
||||
| ^^^
|
||||
|
|
||||
help: if this is intentional, prefix it with an underscore
|
||||
|
|
||||
LL | _Non | Some(_) => {}
|
||||
| +
|
||||
help: you might have meant to pattern match on the similarly named variant `None`
|
||||
|
|
||||
LL - Non | Some(_) => {}
|
||||
LL + std::prelude::v1::None | Some(_) => {}
|
||||
|
|
||||
| ^^^ help: if this is intentional, prefix it with an underscore: `_Non`
|
||||
|
||||
error: variable `Ban` is assigned to, but never used
|
||||
error: unused variable: `Ban`
|
||||
--> $DIR/binding-typo-2.rs:69:21
|
||||
|
|
||||
LL | (Foo, _) | (Ban, Foo) => {}
|
||||
| ^^^
|
||||
|
|
||||
= note: consider using `_Ban` instead
|
||||
help: you might have meant to pattern match on the similarly named variant `Bar`
|
||||
|
|
||||
LL - (Foo, _) | (Ban, Foo) => {}
|
||||
LL + (Foo, _) | (Lol::Bar, Foo) => {}
|
||||
|
|
||||
| ^^^ help: if this is intentional, prefix it with an underscore: `_Ban`
|
||||
|
||||
error: variable `Ban` is assigned to, but never used
|
||||
error: unused variable: `Ban`
|
||||
--> $DIR/binding-typo-2.rs:86:21
|
||||
|
|
||||
LL | (Foo, _) | (Ban, Foo) => {}
|
||||
| ^^^
|
||||
|
|
||||
= note: consider using `_Ban` instead
|
||||
help: you might have meant to pattern match on the similarly named variant `Bar`
|
||||
|
|
||||
LL - (Foo, _) | (Ban, Foo) => {}
|
||||
LL + (Foo, _) | (Lol::Bar, Foo) => {}
|
||||
|
|
||||
| ^^^ help: if this is intentional, prefix it with an underscore: `_Ban`
|
||||
|
||||
error: unused variable: `Ban`
|
||||
--> $DIR/binding-typo-2.rs:98:10
|
||||
|
|
||||
LL | (Ban, _) => {}
|
||||
| ^^^
|
||||
|
|
||||
help: if this is intentional, prefix it with an underscore
|
||||
|
|
||||
LL | (_Ban, _) => {}
|
||||
| +
|
||||
help: you might have meant to pattern match on the similarly named variant `Bar`
|
||||
|
|
||||
LL - (Ban, _) => {}
|
||||
LL + (Lol::Bar, _) => {}
|
||||
|
|
||||
| ^^^ help: if this is intentional, prefix it with an underscore: `_Ban`
|
||||
|
||||
error: unused variable: `Ban`
|
||||
--> $DIR/binding-typo-2.rs:104:9
|
||||
|
|
||||
LL | Ban => {}
|
||||
| ^^^
|
||||
|
|
||||
help: if this is intentional, prefix it with an underscore
|
||||
|
|
||||
LL | _Ban => {}
|
||||
| +
|
||||
help: you might have meant to pattern match on the similarly named struct `Bay`
|
||||
|
|
||||
LL - Ban => {}
|
||||
LL + Bay => {}
|
||||
|
|
||||
| ^^^ help: if this is intentional, prefix it with an underscore: `_Ban`
|
||||
|
||||
error: unused variable: `Batery`
|
||||
--> $DIR/binding-typo-2.rs:110:9
|
||||
|
|
||||
LL | Batery => {}
|
||||
| ^^^^^^
|
||||
|
|
||||
help: if this is intentional, prefix it with an underscore
|
||||
|
|
||||
LL | _Batery => {}
|
||||
| +
|
||||
help: you might have meant to pattern match on the similarly named constant `Battery`
|
||||
|
|
||||
LL | Battery => {}
|
||||
| +
|
||||
| ^^^^^^ help: if this is intentional, prefix it with an underscore: `_Batery`
|
||||
|
||||
error: aborting due to 16 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
//@ run-pass
|
||||
#![feature(coroutines, stmt_expr_attributes)]
|
||||
#![feature(coroutine_trait)]
|
||||
#![allow(unused_assignments, unused_variables)]
|
||||
|
||||
use std::cell::Cell;
|
||||
use std::mem;
|
||||
use std::ops::Coroutine;
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
//@ run-rustfix
|
||||
|
||||
#![allow(unused_variables)]
|
||||
#![allow(unused_assignments)]
|
||||
|
||||
fn main() {
|
||||
let s: Option<u8> = None;
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
//@ run-rustfix
|
||||
|
||||
#![allow(unused_variables)]
|
||||
#![allow(unused_assignments)]
|
||||
|
||||
fn main() {
|
||||
let s: Option<u8> = None;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: pattern on wrong side of `@`
|
||||
--> $DIR/intersection-patterns-1.rs:17:9
|
||||
--> $DIR/intersection-patterns-1.rs:18:9
|
||||
|
|
||||
LL | Some(x) @ y => {}
|
||||
| -------^^^-
|
||||
|
|
@ -14,7 +14,7 @@ LL + y @ Some(x) => {}
|
|||
|
|
||||
|
||||
error: pattern on wrong side of `@`
|
||||
--> $DIR/intersection-patterns-1.rs:27:9
|
||||
--> $DIR/intersection-patterns-1.rs:28:9
|
||||
|
|
||||
LL | 1 ..= 5 @ e => {}
|
||||
| -------^^^-
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
//@ run-pass
|
||||
#![allow(unused)]
|
||||
#![warn(unused_assignments)]
|
||||
|
||||
// Test copy
|
||||
|
||||
|
|
@ -34,10 +35,12 @@ pub fn main() {
|
|||
let mut x@B {b, ..} = B {a: 10, b: C {c: 20}};
|
||||
assert_eq!(x.a, 10);
|
||||
x.b.c = 30;
|
||||
//~^ WARN value assigned to `x` is never read
|
||||
assert_eq!(b.c, 20);
|
||||
let mut y@D {d, ..} = D {a: 10, d: C {c: 20}};
|
||||
assert_eq!(y.a, 10);
|
||||
y.d.c = 30;
|
||||
//~^ WARN value assigned to `y` is never read
|
||||
assert_eq!(d.c, 20);
|
||||
|
||||
match (E::E { a: 10, e: C { c: 20 } }) {
|
||||
|
|
@ -50,7 +53,9 @@ pub fn main() {
|
|||
}
|
||||
match (E::E { a: 10, e: C { c: 20 } }) {
|
||||
mut x @ E::E{ a, e: C { mut c } } => {
|
||||
//~^ WARN value assigned to `a` is never read
|
||||
x = E::NotE;
|
||||
//~^ WARN value assigned to `x` is never read
|
||||
c += 30;
|
||||
assert_eq!(c, 50);
|
||||
}
|
||||
|
|
|
|||
39
tests/ui/pattern/bindings-after-at/bind-by-copy.stderr
Normal file
39
tests/ui/pattern/bindings-after-at/bind-by-copy.stderr
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
warning: value assigned to `x` is never read
|
||||
--> $DIR/bind-by-copy.rs:37:5
|
||||
|
|
||||
LL | x.b.c = 30;
|
||||
| ^^^^^^^^^^
|
||||
|
|
||||
= help: maybe it is overwritten before being read?
|
||||
note: the lint level is defined here
|
||||
--> $DIR/bind-by-copy.rs:3:9
|
||||
|
|
||||
LL | #![warn(unused_assignments)]
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
warning: value assigned to `y` is never read
|
||||
--> $DIR/bind-by-copy.rs:42:5
|
||||
|
|
||||
LL | y.d.c = 30;
|
||||
| ^^^^^^^^^^
|
||||
|
|
||||
= help: maybe it is overwritten before being read?
|
||||
|
||||
warning: value assigned to `x` is never read
|
||||
--> $DIR/bind-by-copy.rs:57:13
|
||||
|
|
||||
LL | x = E::NotE;
|
||||
| ^^^^^^^^^^^
|
||||
|
|
||||
= help: maybe it is overwritten before being read?
|
||||
|
||||
warning: value assigned to `a` is never read
|
||||
--> $DIR/bind-by-copy.rs:55:23
|
||||
|
|
||||
LL | mut x @ E::E{ a, e: C { mut c } } => {
|
||||
| ^
|
||||
|
|
||||
= help: maybe it is overwritten before being read?
|
||||
|
||||
warning: 4 warnings emitted
|
||||
|
||||
|
|
@ -4,6 +4,7 @@ fn main() {
|
|||
return ();
|
||||
|
||||
let x = ();
|
||||
//~^ WARN unused variable: `x`
|
||||
x
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,10 @@
|
|||
warning: unused variable: `x`
|
||||
--> $DIR/early-return-with-unreachable-code-24353.rs:6:9
|
||||
|
|
||||
LL | let x = ();
|
||||
| ^ help: if this is intentional, prefix it with an underscore: `_x`
|
||||
|
|
||||
= note: `#[warn(unused_variables)]` (part of `#[warn(unused)]`) on by default
|
||||
|
||||
warning: 1 warning emitted
|
||||
|
||||
|
|
@ -58,6 +58,7 @@ fn match_with_or() {
|
|||
fn nested_mixed() {
|
||||
match (&Some(5), &Some(6)) {
|
||||
(Some(a), &Some(mut b)) => {
|
||||
//~^ WARN value assigned to `b` is never read
|
||||
// Here, the `a` will be `&i32`, because in the first half of the tuple
|
||||
// we hit a non-reference pattern and shift into `ref` mode.
|
||||
//
|
||||
|
|
|
|||
11
tests/ui/rfcs/rfc-2005-default-binding-mode/general.stderr
Normal file
11
tests/ui/rfcs/rfc-2005-default-binding-mode/general.stderr
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
warning: value assigned to `b` is never read
|
||||
--> $DIR/general.rs:60:25
|
||||
|
|
||||
LL | (Some(a), &Some(mut b)) => {
|
||||
| ^^^^^
|
||||
|
|
||||
= help: maybe it is overwritten before being read?
|
||||
= note: `#[warn(unused_assignments)]` (part of `#[warn(unused)]`) on by default
|
||||
|
||||
warning: 1 warning emitted
|
||||
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
warning: value assigned to `small` is never read
|
||||
--> $DIR/std-panic-locations.rs:47:31
|
||||
|
|
||||
LL | assert_panicked(move || { small[1] += 1; });
|
||||
| ^^^^^^^^^^^^^
|
||||
|
|
||||
= help: maybe it is overwritten before being read?
|
||||
= note: `#[warn(unused_assignments)]` (part of `#[warn(unused)]`) on by default
|
||||
|
||||
warning: 1 warning emitted
|
||||
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
warning: value assigned to `small` is never read
|
||||
--> $DIR/std-panic-locations.rs:47:31
|
||||
|
|
||||
LL | assert_panicked(move || { small[1] += 1; });
|
||||
| ^^^^^^^^^^^^^
|
||||
|
|
||||
= help: maybe it is overwritten before being read?
|
||||
= note: `#[warn(unused_assignments)]` (part of `#[warn(unused)]`) on by default
|
||||
|
||||
warning: 1 warning emitted
|
||||
|
||||
|
|
@ -45,6 +45,7 @@ fn main() {
|
|||
assert_panicked(move || { small[1]; });
|
||||
assert_panicked(move || { small.index_mut(1); });
|
||||
assert_panicked(move || { small[1] += 1; });
|
||||
//~^ WARN value assigned to `small` is never read
|
||||
|
||||
let sorted: BTreeMap<bool, bool> = Default::default();
|
||||
assert_panicked(|| { sorted.index(&false); });
|
||||
|
|
|
|||
|
|
@ -10,18 +10,6 @@ note: the lint level is defined here
|
|||
LL | #![deny(unused_variables)]
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
error: unused variable: `a`
|
||||
--> $DIR/param-attrs-cfg.rs:40:27
|
||||
|
|
||||
LL | #[cfg(something)] a: i32,
|
||||
| ^ help: if this is intentional, prefix it with an underscore: `_a`
|
||||
|
||||
error: unused variable: `a`
|
||||
--> $DIR/param-attrs-cfg.rs:106:27
|
||||
|
|
||||
LL | #[cfg(something)] a: i32,
|
||||
| ^ help: if this is intentional, prefix it with an underscore: `_a`
|
||||
|
||||
error: unused variable: `b`
|
||||
--> $DIR/param-attrs-cfg.rs:29:23
|
||||
|
|
||||
|
|
@ -34,6 +22,12 @@ error: unused variable: `c`
|
|||
LL | #[cfg_attr(nothing, cfg(nothing))] c: i32,
|
||||
| ^ help: if this is intentional, prefix it with an underscore: `_c`
|
||||
|
||||
error: unused variable: `a`
|
||||
--> $DIR/param-attrs-cfg.rs:40:27
|
||||
|
|
||||
LL | #[cfg(something)] a: i32,
|
||||
| ^ help: if this is intentional, prefix it with an underscore: `_a`
|
||||
|
||||
error: unused variable: `b`
|
||||
--> $DIR/param-attrs-cfg.rs:47:27
|
||||
|
|
||||
|
|
@ -118,5 +112,11 @@ error: unused variable: `c`
|
|||
LL | #[cfg_attr(nothing, cfg(nothing))] c: i32,
|
||||
| ^ help: if this is intentional, prefix it with an underscore: `_c`
|
||||
|
||||
error: unused variable: `a`
|
||||
--> $DIR/param-attrs-cfg.rs:106:27
|
||||
|
|
||||
LL | #[cfg(something)] a: i32,
|
||||
| ^ help: if this is intentional, prefix it with an underscore: `_a`
|
||||
|
||||
error: aborting due to 19 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ struct Foo {
|
|||
|
||||
fn use_foo(x: Foo) -> i32 {
|
||||
let Foo { foo, bar, .. } = x; //~ WARNING unused variable: `bar`
|
||||
//~| help: try removing the field
|
||||
//~| help: try ignoring the field
|
||||
return foo;
|
||||
}
|
||||
|
||||
|
|
@ -24,7 +24,7 @@ fn use_match(x: Foo) {
|
|||
|
||||
match x {
|
||||
Foo { foo, .. } => { //~ WARNING unused variable
|
||||
//~| help: try removing the field
|
||||
//~| help: try ignoring the field
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,9 +2,7 @@ warning: unused variable: `bar`
|
|||
--> $DIR/try-removing-the-field.rs:12:20
|
||||
|
|
||||
LL | let Foo { foo, bar, .. } = x;
|
||||
| ^^^-
|
||||
| |
|
||||
| help: try removing the field
|
||||
| ^^^ help: try ignoring the field: `bar: _`
|
||||
|
|
||||
= note: `#[warn(unused_variables)]` (part of `#[warn(unused)]`) on by default
|
||||
|
||||
|
|
@ -18,9 +16,7 @@ warning: unused variable: `foo`
|
|||
--> $DIR/try-removing-the-field.rs:26:15
|
||||
|
|
||||
LL | Foo { foo, .. } => {
|
||||
| ^^^-
|
||||
| |
|
||||
| help: try removing the field
|
||||
| ^^^ help: try ignoring the field: `foo: _`
|
||||
|
||||
warning: 3 warnings emitted
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
error: unused variable: `x`
|
||||
--> $DIR/unused-closure-argument.rs:12:23
|
||||
--> $DIR/unused-closure-argument.rs:17:15
|
||||
|
|
||||
LL | .map(|Point { x, y }| y)
|
||||
| ^ help: try ignoring the field: `x: _`
|
||||
LL | .map(|x| 4)
|
||||
| ^ help: if this is intentional, prefix it with an underscore: `_x`
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/unused-closure-argument.rs:1:9
|
||||
|
|
@ -11,10 +11,10 @@ LL | #![deny(unused_variables)]
|
|||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
error: unused variable: `x`
|
||||
--> $DIR/unused-closure-argument.rs:17:15
|
||||
--> $DIR/unused-closure-argument.rs:12:23
|
||||
|
|
||||
LL | .map(|x| 4)
|
||||
| ^ help: if this is intentional, prefix it with an underscore: `_x`
|
||||
LL | .map(|Point { x, y }| y)
|
||||
| ^ help: try ignoring the field: `x: _`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ error: unused variable: `xyza`
|
|||
--> $DIR/issue-100584.rs:2:8
|
||||
|
|
||||
LL | fn foo(xyza: &str) {
|
||||
| ^^^^ unused variable
|
||||
| ^^^^
|
||||
LL |
|
||||
LL | let _ = "{xyza}";
|
||||
| -------- you might have meant to use string interpolation in this string literal
|
||||
|
|
@ -26,7 +26,7 @@ error: unused variable: `xyza`
|
|||
--> $DIR/issue-100584.rs:7:9
|
||||
|
|
||||
LL | fn foo3(xyza: &str) {
|
||||
| ^^^^ unused variable
|
||||
| ^^^^
|
||||
LL |
|
||||
LL | let _ = "aaa{xyza}bbb";
|
||||
| -------------- you might have meant to use string interpolation in this string literal
|
||||
|
|
|
|||
|
|
@ -1,9 +1,8 @@
|
|||
//@ run-pass
|
||||
|
||||
#![allow(dead_code)]
|
||||
#![allow(unused_variables)]
|
||||
// Type ascription doesn't lead to unsoundness
|
||||
#![allow(dead_code, unused_variables, unused_assignments)]
|
||||
|
||||
// Type ascription doesn't lead to unsoundness
|
||||
#![feature(type_ascription)]
|
||||
|
||||
use std::mem;
|
||||
|
|
|
|||
|
|
@ -21,8 +21,9 @@ fn main() {
|
|||
|
||||
call(move || {
|
||||
// this mutates a moved copy, and hence doesn't affect original
|
||||
counter += 1; //~ WARN value assigned to `counter` is never read
|
||||
//~| WARN unused variable: `counter`
|
||||
counter += 1;
|
||||
//~^ WARN value captured by `counter` is never read
|
||||
//~| WARN value assigned to `counter` is never read
|
||||
});
|
||||
assert_eq!(counter, 88);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,20 @@
|
|||
warning: value captured by `counter` is never read
|
||||
--> $DIR/unboxed-closures-counter-not-moved.rs:24:9
|
||||
|
|
||||
LL | counter += 1;
|
||||
| ^^^^^^^
|
||||
|
|
||||
= help: did you mean to capture by reference instead?
|
||||
= note: `#[warn(unused_assignments)]` (part of `#[warn(unused)]`) on by default
|
||||
|
||||
warning: value assigned to `counter` is never read
|
||||
--> $DIR/unboxed-closures-counter-not-moved.rs:24:9
|
||||
|
|
||||
LL | counter += 1;
|
||||
| ^^^^^^^^^^^^
|
||||
|
|
||||
= help: maybe it is overwritten before being read?
|
||||
|
||||
warning: unused variable: `item`
|
||||
--> $DIR/unboxed-closures-counter-not-moved.rs:15:13
|
||||
|
|
||||
|
|
@ -6,22 +23,5 @@ LL | for item in y {
|
|||
|
|
||||
= note: `#[warn(unused_variables)]` (part of `#[warn(unused)]`) on by default
|
||||
|
||||
warning: value assigned to `counter` is never read
|
||||
--> $DIR/unboxed-closures-counter-not-moved.rs:24:9
|
||||
|
|
||||
LL | counter += 1;
|
||||
| ^^^^^^^
|
||||
|
|
||||
= help: maybe it is overwritten before being read?
|
||||
= note: `#[warn(unused_assignments)]` (part of `#[warn(unused)]`) on by default
|
||||
|
||||
warning: unused variable: `counter`
|
||||
--> $DIR/unboxed-closures-counter-not-moved.rs:24:9
|
||||
|
|
||||
LL | counter += 1;
|
||||
| ^^^^^^^
|
||||
|
|
||||
= help: did you mean to capture by reference instead?
|
||||
|
||||
warning: 3 warnings emitted
|
||||
|
||||
|
|
|
|||
|
|
@ -13,11 +13,17 @@ fn set(x: &mut usize) { *x = 42; }
|
|||
fn main() {
|
||||
{
|
||||
let mut x = 0_usize;
|
||||
move || x += 1; //~ WARN unused variable: `x`
|
||||
//~^ WARN unused variable: `x`
|
||||
move || x += 1;
|
||||
//~^ WARN value captured by `x` is never read
|
||||
//~| WARN value assigned to `x` is never read
|
||||
}
|
||||
{
|
||||
let mut x = 0_usize;
|
||||
move || x += 1; //~ WARN unused variable: `x`
|
||||
//~^ WARN unused variable: `x`
|
||||
move || x += 1;
|
||||
//~^ WARN value captured by `x` is never read
|
||||
//~| WARN value assigned to `x` is never read
|
||||
}
|
||||
{
|
||||
let mut x = 0_usize;
|
||||
|
|
|
|||
|
|
@ -1,19 +1,49 @@
|
|||
warning: unused variable: `x`
|
||||
--> $DIR/unboxed-closures-move-mutable.rs:16:17
|
||||
warning: value captured by `x` is never read
|
||||
--> $DIR/unboxed-closures-move-mutable.rs:24:17
|
||||
|
|
||||
LL | move || x += 1;
|
||||
| ^
|
||||
|
|
||||
= help: did you mean to capture by reference instead?
|
||||
= note: `#[warn(unused_assignments)]` (part of `#[warn(unused)]`) on by default
|
||||
|
||||
warning: value assigned to `x` is never read
|
||||
--> $DIR/unboxed-closures-move-mutable.rs:24:17
|
||||
|
|
||||
LL | move || x += 1;
|
||||
| ^^^^^^
|
||||
|
|
||||
= help: maybe it is overwritten before being read?
|
||||
|
||||
warning: value captured by `x` is never read
|
||||
--> $DIR/unboxed-closures-move-mutable.rs:17:17
|
||||
|
|
||||
LL | move || x += 1;
|
||||
| ^
|
||||
|
|
||||
= help: did you mean to capture by reference instead?
|
||||
|
||||
warning: value assigned to `x` is never read
|
||||
--> $DIR/unboxed-closures-move-mutable.rs:17:17
|
||||
|
|
||||
LL | move || x += 1;
|
||||
| ^^^^^^
|
||||
|
|
||||
= help: maybe it is overwritten before being read?
|
||||
|
||||
warning: unused variable: `x`
|
||||
--> $DIR/unboxed-closures-move-mutable.rs:15:13
|
||||
|
|
||||
LL | let mut x = 0_usize;
|
||||
| ^^^^^ help: if this is intentional, prefix it with an underscore: `_x`
|
||||
|
|
||||
= note: `#[warn(unused_variables)]` (part of `#[warn(unused)]`) on by default
|
||||
|
||||
warning: unused variable: `x`
|
||||
--> $DIR/unboxed-closures-move-mutable.rs:20:17
|
||||
--> $DIR/unboxed-closures-move-mutable.rs:22:13
|
||||
|
|
||||
LL | move || x += 1;
|
||||
| ^
|
||||
|
|
||||
= help: did you mean to capture by reference instead?
|
||||
LL | let mut x = 0_usize;
|
||||
| ^^^^^ help: if this is intentional, prefix it with an underscore: `_x`
|
||||
|
||||
warning: 2 warnings emitted
|
||||
warning: 6 warnings emitted
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue