Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 849febc

Browse files
committed
Auto merge of rust-lang#137775 - matthiaskrgr:rollup-05i9urn, r=matthiaskrgr
Rollup of 11 pull requests Successful merges: - rust-lang#137045 (Defer repeat expr `Copy` checks to end of type checking) - rust-lang#137171 (Suggest swapping equality on E0277) - rust-lang#137634 (Update `compiler-builtins` to 0.1.149) - rust-lang#137686 (Handle asm const similar to inline const) - rust-lang#137689 (Use `Binder<Vec<Ty>>` instead of `Vec<Binder<Ty>>` in both solvers for sized/auto traits/etc.) - rust-lang#137718 (Use original command for showing sccache stats) - rust-lang#137723 (Make `rust.description` more general-purpose and pass `CFG_VER_DESCRIPTION`) - rust-lang#137730 (checked_ilog tests: deal with a bit of float imprecision) - rust-lang#137735 (Update E0133 docs for 2024 edition) - rust-lang#137742 (unconditionally lower match arm even if it's unneeded for never pattern in match) - rust-lang#137771 (Tweak incorrect ABI suggestion) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 2f58193 + 1a45baa commit 849febc

File tree

66 files changed

+792
-341
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+792
-341
lines changed

compiler/rustc_ast_lowering/messages.ftl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ ast_lowering_invalid_abi_clobber_abi =
8888
invalid ABI for `clobber_abi`
8989
.note = the following ABIs are supported on this target: {$supported_abis}
9090
91-
ast_lowering_invalid_abi_suggestion = did you mean
91+
ast_lowering_invalid_abi_suggestion = there's a similarly named valid ABI `{$suggestion}`
9292
9393
ast_lowering_invalid_asm_template_modifier_const =
9494
asm template modifiers are not allowed for `const` arguments

compiler/rustc_ast_lowering/src/asm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
195195
}
196196
}
197197
InlineAsmOperand::Const { anon_const } => hir::InlineAsmOperand::Const {
198-
anon_const: self.lower_anon_const_to_anon_const(anon_const),
198+
anon_const: self.lower_const_block(anon_const),
199199
},
200200
InlineAsmOperand::Sym { sym } => {
201201
let static_def_id = self

compiler/rustc_ast_lowering/src/errors.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,9 @@ pub(crate) struct TupleStructWithDefault {
4646
#[derive(Subdiagnostic)]
4747
#[suggestion(
4848
ast_lowering_invalid_abi_suggestion,
49-
code = "{suggestion}",
50-
applicability = "maybe-incorrect"
49+
code = "\"{suggestion}\"",
50+
applicability = "maybe-incorrect",
51+
style = "verbose"
5152
)]
5253
pub(crate) struct InvalidAbiSuggestion {
5354
#[primary_span]

compiler/rustc_ast_lowering/src/expr.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -671,10 +671,13 @@ impl<'hir> LoweringContext<'_, 'hir> {
671671
let span = self.lower_span(arm.span);
672672
self.lower_attrs(hir_id, &arm.attrs, arm.span);
673673
let is_never_pattern = pat.is_never_pattern();
674-
let body = if let Some(body) = &arm.body
674+
// We need to lower the body even if it's unneeded for never pattern in match,
675+
// ensure that we can get HirId for DefId if need (issue #137708).
676+
let body = arm.body.as_ref().map(|x| self.lower_expr(x));
677+
let body = if let Some(body) = body
675678
&& !is_never_pattern
676679
{
677-
self.lower_expr(body)
680+
body
678681
} else {
679682
// Either `body.is_none()` or `is_never_pattern` here.
680683
if !is_never_pattern {

compiler/rustc_ast_lowering/src/item.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1510,7 +1510,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
15101510
span: abi.span,
15111511
suggestion: suggested_name.map(|suggested_name| InvalidAbiSuggestion {
15121512
span: abi.span,
1513-
suggestion: format!("\"{suggested_name}\""),
1513+
suggestion: suggested_name.to_string(),
15141514
}),
15151515
command: "rustc --print=calling-conventions".to_string(),
15161516
});

compiler/rustc_codegen_cranelift/patches/0029-stdlib-Disable-f16-and-f128-in-compiler-builtins.patch

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ index 7165c3e48af..968552ad435 100644
1616

1717
[dependencies]
1818
core = { path = "../core", public = true }
19-
-compiler_builtins = { version = "=0.1.148", features = ['rustc-dep-of-std'] }
20-
+compiler_builtins = { version = "=0.1.148", features = ['rustc-dep-of-std', 'no-f16-f128'] }
19+
-compiler_builtins = { version = "=0.1.149", features = ['rustc-dep-of-std'] }
20+
+compiler_builtins = { version = "=0.1.149", features = ['rustc-dep-of-std', 'no-f16-f128'] }
2121

2222
[dev-dependencies]
2323
rand = { version = "0.8.5", default-features = false, features = ["alloc"] }

compiler/rustc_error_codes/src/error_codes/E0133.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ unsafe fn g() {
4545
```
4646

4747
Linting against this is controlled via the `unsafe_op_in_unsafe_fn` lint, which
48-
is `allow` by default but will be upgraded to `warn` in a future edition.
48+
is `warn` by default in the 2024 edition and `allow` by default in earlier
49+
editions.
4950

5051
[unsafe-section]: https://doc.rust-lang.org/book/ch19-01-unsafe-rust.html

compiler/rustc_hir/src/hir.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3506,7 +3506,7 @@ pub enum InlineAsmOperand<'hir> {
35063506
out_expr: Option<&'hir Expr<'hir>>,
35073507
},
35083508
Const {
3509-
anon_const: &'hir AnonConst,
3509+
anon_const: ConstBlock,
35103510
},
35113511
SymFn {
35123512
expr: &'hir Expr<'hir>,

compiler/rustc_hir/src/intravisit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1447,7 +1447,7 @@ pub fn walk_inline_asm<'v, V: Visitor<'v>>(
14471447
visit_opt!(visitor, visit_expr, out_expr);
14481448
}
14491449
InlineAsmOperand::Const { anon_const, .. } => {
1450-
try_visit!(visitor.visit_anon_const(anon_const));
1450+
try_visit!(visitor.visit_inline_const(anon_const));
14511451
}
14521452
InlineAsmOperand::SymFn { expr, .. } => {
14531453
try_visit!(visitor.visit_expr(expr));

compiler/rustc_hir_analysis/src/check/intrinsicck.rs

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
use std::assert_matches::debug_assert_matches;
2-
31
use rustc_abi::FieldIdx;
42
use rustc_ast::InlineAsmTemplatePiece;
53
use rustc_data_structures::fx::FxIndexSet;
@@ -21,6 +19,7 @@ pub struct InlineAsmCtxt<'a, 'tcx: 'a> {
2119
typing_env: ty::TypingEnv<'tcx>,
2220
target_features: &'tcx FxIndexSet<Symbol>,
2321
expr_ty: Box<dyn Fn(&hir::Expr<'tcx>) -> Ty<'tcx> + 'a>,
22+
node_ty: Box<dyn Fn(hir::HirId) -> Ty<'tcx> + 'a>,
2423
}
2524

2625
enum NonAsmTypeReason<'tcx> {
@@ -35,20 +34,26 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
3534
tcx: TyCtxt<'tcx>,
3635
def_id: LocalDefId,
3736
typing_env: ty::TypingEnv<'tcx>,
38-
get_operand_ty: impl Fn(&hir::Expr<'tcx>) -> Ty<'tcx> + 'a,
37+
expr_ty: impl Fn(&hir::Expr<'tcx>) -> Ty<'tcx> + 'a,
38+
node_ty: impl Fn(hir::HirId) -> Ty<'tcx> + 'a,
3939
) -> Self {
4040
InlineAsmCtxt {
4141
tcx,
4242
typing_env,
4343
target_features: tcx.asm_target_features(def_id),
44-
expr_ty: Box::new(get_operand_ty),
44+
expr_ty: Box::new(expr_ty),
45+
node_ty: Box::new(node_ty),
4546
}
4647
}
4748

4849
fn expr_ty(&self, expr: &hir::Expr<'tcx>) -> Ty<'tcx> {
4950
(self.expr_ty)(expr)
5051
}
5152

53+
fn node_ty(&self, hir_id: hir::HirId) -> Ty<'tcx> {
54+
(self.node_ty)(hir_id)
55+
}
56+
5257
// FIXME(compiler-errors): This could use `<$ty as Pointee>::Metadata == ()`
5358
fn is_thin_ptr_ty(&self, ty: Ty<'tcx>) -> bool {
5459
// Type still may have region variables, but `Sized` does not depend
@@ -487,12 +492,23 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
487492
);
488493
}
489494
}
490-
// Typeck has checked that Const operands are integers.
491495
hir::InlineAsmOperand::Const { anon_const } => {
492-
debug_assert_matches!(
493-
self.tcx.type_of(anon_const.def_id).instantiate_identity().kind(),
494-
ty::Error(_) | ty::Int(_) | ty::Uint(_)
495-
);
496+
let ty = self.node_ty(anon_const.hir_id);
497+
match ty.kind() {
498+
ty::Error(_) => {}
499+
_ if ty.is_integral() => {}
500+
_ => {
501+
self.tcx
502+
.dcx()
503+
.struct_span_err(op_sp, "invalid type for `const` operand")
504+
.with_span_label(
505+
self.tcx.def_span(anon_const.def_id),
506+
format!("is {} `{}`", ty.kind().article(), ty),
507+
)
508+
.with_help("`const` operands must be of an integer type")
509+
.emit();
510+
}
511+
}
496512
}
497513
// Typeck has checked that SymFn refers to a function.
498514
hir::InlineAsmOperand::SymFn { expr } => {

0 commit comments

Comments
 (0)