]> git.lizzy.rs Git - rust.git/commitdiff
Rollup merge of #105515 - estebank:issue-104141, r=oli-obk
authorMatthias Krüger <matthias.krueger@famsik.de>
Tue, 27 Dec 2022 07:57:45 +0000 (08:57 +0100)
committerGitHub <noreply@github.com>
Tue, 27 Dec 2022 07:57:45 +0000 (08:57 +0100)
Account for macros in const generics

Fix #104141.

1  2 
compiler/rustc_lint/src/unused.rs

index 3b8df61a0eab771a704f9ed9006bbd1807b612fa,4699f7487e6a7e435d4699e4c5662e625c485671..a7a5234049fe63db04d6789e5a509238dd4346ae
@@@ -96,7 -96,7 +96,7 @@@ impl<'tcx> LateLintPass<'tcx> for Unuse
  
          if let hir::ExprKind::Match(await_expr, _arms, hir::MatchSource::AwaitDesugar) = expr.kind
              && let ty = cx.typeck_results().expr_ty(&await_expr)
 -            && let ty::Opaque(future_def_id, _) = ty.kind()
 +            && let ty::Alias(ty::Opaque, ty::AliasTy { def_id: future_def_id, .. }) = ty.kind()
              && cx.tcx.ty_is_opaque_future(ty)
              // FIXME: This also includes non-async fns that return `impl Future`.
              && let async_fn_def_id = cx.tcx.parent(*future_def_id)
                          .map(|inner| MustUsePath::Boxed(Box::new(inner)))
                  }
                  ty::Adt(def, _) => is_def_must_use(cx, def.did(), span),
 -                ty::Opaque(def, _) => {
 +                ty::Alias(ty::Opaque, ty::AliasTy { def_id: def, .. }) => {
                      elaborate_predicates_with_span(
                          cx.tcx,
                          cx.tcx.explicit_item_bounds(def).iter().cloned(),
@@@ -617,10 -617,7 +617,10 @@@ trait UnusedDelimLint 
          lhs_needs_parens
              || (followed_by_block
                  && match &inner.kind {
 -                    ExprKind::Ret(_) | ExprKind::Break(..) | ExprKind::Yield(..) => true,
 +                    ExprKind::Ret(_)
 +                    | ExprKind::Break(..)
 +                    | ExprKind::Yield(..)
 +                    | ExprKind::Yeet(..) => true,
                      ExprKind::Range(_lhs, Some(rhs), _limits) => {
                          matches!(rhs.kind, ExprKind::Block(..))
                      }
@@@ -949,7 -946,6 +949,7 @@@ impl UnusedParens 
  }
  
  impl EarlyLintPass for UnusedParens {
 +    #[inline]
      fn check_expr(&mut self, cx: &EarlyContext<'_>, e: &ast::Expr) {
          match e.kind {
              ExprKind::Let(ref pat, _, _) | ExprKind::ForLoop(ref pat, ..) => {
@@@ -1142,6 -1138,7 +1142,7 @@@ impl UnusedDelimLint for UnusedBraces 
                              && !cx.sess().source_map().is_multiline(value.span)
                              && value.attrs.is_empty()
                              && !value.span.from_expansion()
+                             && !inner.span.from_expansion()
                          {
                              self.emit_unused_delims_expr(cx, value, ctx, left_pos, right_pos)
                          }
@@@ -1168,7 -1165,6 +1169,7 @@@ impl EarlyLintPass for UnusedBraces 
          <Self as UnusedDelimLint>::check_stmt(self, cx, s)
      }
  
 +    #[inline]
      fn check_expr(&mut self, cx: &EarlyContext<'_>, e: &ast::Expr) {
          <Self as UnusedDelimLint>::check_expr(self, cx, e);
  
@@@ -1279,7 -1275,7 +1280,7 @@@ impl UnusedImportBraces 
      fn check_use_tree(&self, cx: &EarlyContext<'_>, use_tree: &ast::UseTree, item: &ast::Item) {
          if let ast::UseTreeKind::Nested(ref items) = use_tree.kind {
              // Recursively check nested UseTrees
 -            for &(ref tree, _) in items {
 +            for (tree, _) in items {
                  self.check_use_tree(cx, tree, item);
              }