use let chains in mir, resolve, target
This commit is contained in:
@@ -104,10 +104,10 @@ impl<'tcx> Visitor<'tcx> for ReachableContext<'tcx> {
|
||||
|
||||
fn visit_inline_asm(&mut self, asm: &'tcx hir::InlineAsm<'tcx>, id: hir::HirId) {
|
||||
for (op, _) in asm.operands {
|
||||
if let hir::InlineAsmOperand::SymStatic { def_id, .. } = op {
|
||||
if let Some(def_id) = def_id.as_local() {
|
||||
self.reachable_symbols.insert(def_id);
|
||||
}
|
||||
if let hir::InlineAsmOperand::SymStatic { def_id, .. } = op
|
||||
&& let Some(def_id) = def_id.as_local()
|
||||
{
|
||||
self.reachable_symbols.insert(def_id);
|
||||
}
|
||||
}
|
||||
intravisit::walk_inline_asm(self, asm, id);
|
||||
|
||||
@@ -929,10 +929,10 @@ struct CheckTraitImplStable<'tcx> {
|
||||
|
||||
impl<'tcx> Visitor<'tcx> for CheckTraitImplStable<'tcx> {
|
||||
fn visit_path(&mut self, path: &hir::Path<'tcx>, _id: hir::HirId) {
|
||||
if let Some(def_id) = path.res.opt_def_id() {
|
||||
if let Some(stab) = self.tcx.lookup_stability(def_id) {
|
||||
self.fully_stable &= stab.level.is_stable();
|
||||
}
|
||||
if let Some(def_id) = path.res.opt_def_id()
|
||||
&& let Some(stab) = self.tcx.lookup_stability(def_id)
|
||||
{
|
||||
self.fully_stable &= stab.level.is_stable();
|
||||
}
|
||||
intravisit::walk_path(self, path)
|
||||
}
|
||||
@@ -1055,10 +1055,10 @@ pub fn check_unused_or_stable_features(tcx: TyCtxt<'_>) {
|
||||
// implications from this crate.
|
||||
remaining_implications.remove(&feature);
|
||||
|
||||
if let FeatureStability::Unstable { old_name: Some(alias) } = stability {
|
||||
if let Some(span) = remaining_lib_features.swap_remove(&alias) {
|
||||
tcx.dcx().emit_err(errors::RenamedFeature { span, feature, alias });
|
||||
}
|
||||
if let FeatureStability::Unstable { old_name: Some(alias) } = stability
|
||||
&& let Some(span) = remaining_lib_features.swap_remove(&alias)
|
||||
{
|
||||
tcx.dcx().emit_err(errors::RenamedFeature { span, feature, alias });
|
||||
}
|
||||
|
||||
if remaining_lib_features.is_empty() && remaining_implications.is_empty() {
|
||||
|
||||
@@ -75,19 +75,19 @@ impl<'tcx> Visitor<'tcx> for CaptureCollector<'_, 'tcx> {
|
||||
}
|
||||
|
||||
fn visit_expr(&mut self, expr: &'tcx hir::Expr<'tcx>) {
|
||||
if let hir::ExprKind::Closure(closure) = expr.kind {
|
||||
if let Some(upvars) = self.tcx.upvars_mentioned(closure.def_id) {
|
||||
// Every capture of a closure expression is a local in scope,
|
||||
// that is moved/copied/borrowed into the closure value, and
|
||||
// for this analysis they are like any other access to a local.
|
||||
//
|
||||
// E.g. in `|b| |c| (a, b, c)`, the upvars of the inner closure
|
||||
// are `a` and `b`, and while `a` is not directly used in the
|
||||
// outer closure, it needs to be an upvar there too, so that
|
||||
// the inner closure can take it (from the outer closure's env).
|
||||
for (&var_id, upvar) in upvars {
|
||||
self.visit_local_use(var_id, upvar.span);
|
||||
}
|
||||
if let hir::ExprKind::Closure(closure) = expr.kind
|
||||
&& let Some(upvars) = self.tcx.upvars_mentioned(closure.def_id)
|
||||
{
|
||||
// Every capture of a closure expression is a local in scope,
|
||||
// that is moved/copied/borrowed into the closure value, and
|
||||
// for this analysis they are like any other access to a local.
|
||||
//
|
||||
// E.g. in `|b| |c| (a, b, c)`, the upvars of the inner closure
|
||||
// are `a` and `b`, and while `a` is not directly used in the
|
||||
// outer closure, it needs to be an upvar there too, so that
|
||||
// the inner closure can take it (from the outer closure's env).
|
||||
for (&var_id, upvar) in upvars {
|
||||
self.visit_local_use(var_id, upvar.span);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user