Skip to content

Commit cde58f7

Browse files
authored
Rollup merge of rust-lang#83916 - Amanieu:asm_anonconst, r=petrochenkov
Use AnonConst for asm! constants This replaces the old system which used explicit promotion. See rust-lang#83169 for more background. The syntax for `const` operands is still the same as before: `const <expr>`. Fixes rust-lang#83169 Because the implementation is heavily based on inline consts, we suffer from the same issues: - We lose the ability to use expressions derived from generics. See the deleted tests in `src/test/ui/asm/const.rs`. - We are hitting the same ICEs as inline consts, for example rust-lang#78174. It is unlikely that we will be able to stabilize this before inline consts are stabilized.
2 parents 44e3ccb + 879bfec commit cde58f7

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

clippy_lints/src/loops/never_loop.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -142,12 +142,12 @@ fn never_loop_expr(expr: &Expr<'_>, main_loop_id: HirId) -> NeverLoopResult {
142142
.map(|(o, _)| match o {
143143
InlineAsmOperand::In { expr, .. }
144144
| InlineAsmOperand::InOut { expr, .. }
145-
| InlineAsmOperand::Const { expr }
146145
| InlineAsmOperand::Sym { expr } => never_loop_expr(expr, main_loop_id),
147146
InlineAsmOperand::Out { expr, .. } => never_loop_expr_all(&mut expr.iter(), main_loop_id),
148147
InlineAsmOperand::SplitInOut { in_expr, out_expr, .. } => {
149148
never_loop_expr_all(&mut once(in_expr).chain(out_expr.iter()), main_loop_id)
150149
},
150+
InlineAsmOperand::Const { .. } => NeverLoopResult::Otherwise,
151151
})
152152
.fold(NeverLoopResult::Otherwise, combine_both),
153153
ExprKind::Struct(_, _, None)

clippy_lints/src/utils/inspector.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,6 @@ fn print_expr(cx: &LateContext<'_>, expr: &hir::Expr<'_>, indent: usize) {
306306
match op {
307307
hir::InlineAsmOperand::In { expr, .. }
308308
| hir::InlineAsmOperand::InOut { expr, .. }
309-
| hir::InlineAsmOperand::Const { expr }
310309
| hir::InlineAsmOperand::Sym { expr } => print_expr(cx, expr, indent + 1),
311310
hir::InlineAsmOperand::Out { expr, .. } => {
312311
if let Some(expr) = expr {
@@ -319,6 +318,10 @@ fn print_expr(cx: &LateContext<'_>, expr: &hir::Expr<'_>, indent: usize) {
319318
print_expr(cx, out_expr, indent + 1);
320319
}
321320
},
321+
hir::InlineAsmOperand::Const { anon_const } => {
322+
println!("{}anon_const:", ind);
323+
print_expr(cx, &cx.tcx.hir().body(anon_const.body).value, indent + 1);
324+
}
322325
}
323326
}
324327
},

clippy_utils/src/hir_utils.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,8 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
663663
self.hash_expr(out_expr);
664664
}
665665
},
666-
InlineAsmOperand::Const { expr } | InlineAsmOperand::Sym { expr } => self.hash_expr(expr),
666+
InlineAsmOperand::Const { anon_const } => self.hash_body(anon_const.body),
667+
InlineAsmOperand::Sym { expr } => self.hash_expr(expr),
667668
}
668669
}
669670
},

0 commit comments

Comments
 (0)