Skip to content

Commit 32ab2e6

Browse files
committed
Auto merge of rust-lang#128556 - matthiaskrgr:rollup-zm5bokt, r=matthiaskrgr
Rollup of 6 pull requests Successful merges: - rust-lang#122049 (Promote riscv64gc-unknown-linux-musl to tier 2) - rust-lang#125558 (Tweak type inference for `const` operands in inline asm) - rust-lang#126704 (Added SHA512, SM3, SM4 target-features and `sha512_sm_x86` feature gate) - rust-lang#128161 (nested aux-build in tests/rustdoc/ tests) - rust-lang#128483 (Still more `cfg` cleanups) - rust-lang#128528 (Finish removing `has_cpuid`) r? `@ghost` `@rustbot` modify labels: rollup
2 parents f82eb4d + c6e838e commit 32ab2e6

File tree

71 files changed

+876
-488
lines changed

Some content is hidden

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

71 files changed

+876
-488
lines changed

compiler/rustc_builtin_macros/src/cfg_eval.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ impl CfgEval<'_> {
202202
}
203203

204204
// Now that we have our re-parsed `AttrTokenStream`, recursively configuring
205-
// our attribute target will correctly the tokens as well.
205+
// our attribute target will correctly configure the tokens as well.
206206
flat_map_annotatable(self, annotatable)
207207
}
208208
}

compiler/rustc_codegen_ssa/src/target_features.rs

+1
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ pub fn from_target_feature(
7878
Some(sym::loongarch_target_feature) => rust_features.loongarch_target_feature,
7979
Some(sym::lahfsahf_target_feature) => rust_features.lahfsahf_target_feature,
8080
Some(sym::prfchw_target_feature) => rust_features.prfchw_target_feature,
81+
Some(sym::sha512_sm_x86) => rust_features.sha512_sm_x86,
8182
Some(sym::x86_amx_intrinsics) => rust_features.x86_amx_intrinsics,
8283
Some(sym::xop_target_feature) => rust_features.xop_target_feature,
8384
Some(sym::s390x_target_feature) => rust_features.s390x_target_feature,

compiler/rustc_feature/src/unstable.rs

+2
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,8 @@ declare_features! (
591591
(incomplete, return_type_notation, "1.70.0", Some(109417)),
592592
/// Allows `extern "rust-cold"`.
593593
(unstable, rust_cold_cc, "1.63.0", Some(97544)),
594+
/// Allows use of x86 SHA512, SM3 and SM4 target-features and intrinsics
595+
(unstable, sha512_sm_x86, "CURRENT_RUSTC_VERSION", Some(126624)),
594596
/// Shortern the tail expression lifetime
595597
(unstable, shorter_tail_lifetimes, "1.79.0", Some(123739)),
596598
/// Allows the use of SIMD types in functions declared in `extern` blocks.

compiler/rustc_hir_analysis/src/check/intrinsicck.rs

+15-25
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use rustc_ast::InlineAsmTemplatePiece;
22
use rustc_data_structures::fx::FxIndexSet;
33
use rustc_hir::{self as hir, LangItem};
44
use rustc_middle::bug;
5-
use rustc_middle::ty::{self, Article, FloatTy, IntTy, Ty, TyCtxt, TypeVisitableExt, UintTy};
5+
use rustc_middle::ty::{self, FloatTy, IntTy, Ty, TyCtxt, TypeVisitableExt, UintTy};
66
use rustc_session::lint;
77
use rustc_span::def_id::LocalDefId;
88
use rustc_span::Symbol;
@@ -455,32 +455,22 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
455455
);
456456
}
457457
}
458-
// No special checking is needed for these:
459-
// - Typeck has checked that Const operands are integers.
460-
// - AST lowering guarantees that SymStatic points to a static.
461-
hir::InlineAsmOperand::Const { .. } | hir::InlineAsmOperand::SymStatic { .. } => {}
462-
// Check that sym actually points to a function. Later passes
463-
// depend on this.
458+
// Typeck has checked that Const operands are integers.
459+
hir::InlineAsmOperand::Const { anon_const } => {
460+
debug_assert!(matches!(
461+
self.tcx.type_of(anon_const.def_id).instantiate_identity().kind(),
462+
ty::Error(_) | ty::Int(_) | ty::Uint(_)
463+
));
464+
}
465+
// Typeck has checked that SymFn refers to a function.
464466
hir::InlineAsmOperand::SymFn { anon_const } => {
465-
let ty = self.tcx.type_of(anon_const.def_id).instantiate_identity();
466-
match ty.kind() {
467-
ty::Never | ty::Error(_) => {}
468-
ty::FnDef(..) => {}
469-
_ => {
470-
self.tcx
471-
.dcx()
472-
.struct_span_err(*op_sp, "invalid `sym` operand")
473-
.with_span_label(
474-
self.tcx.def_span(anon_const.def_id),
475-
format!("is {} `{}`", ty.kind().article(), ty),
476-
)
477-
.with_help(
478-
"`sym` operands must refer to either a function or a static",
479-
)
480-
.emit();
481-
}
482-
};
467+
debug_assert!(matches!(
468+
self.tcx.type_of(anon_const.def_id).instantiate_identity().kind(),
469+
ty::Error(_) | ty::FnDef(..)
470+
));
483471
}
472+
// AST lowering guarantees that SymStatic points to a static.
473+
hir::InlineAsmOperand::SymStatic { .. } => {}
484474
// No special checking is needed for labels.
485475
hir::InlineAsmOperand::Label { .. } => {}
486476
}

compiler/rustc_hir_analysis/src/collect/type_of.rs

+59-7
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use rustc_hir::HirId;
77
use rustc_middle::query::plumbing::CyclePlaceholder;
88
use rustc_middle::ty::print::with_forced_trimmed_paths;
99
use rustc_middle::ty::util::IntTypeExt;
10-
use rustc_middle::ty::{self, IsSuggestable, Ty, TyCtxt, TypeVisitableExt};
10+
use rustc_middle::ty::{self, Article, IsSuggestable, Ty, TyCtxt, TypeVisitableExt};
1111
use rustc_middle::{bug, span_bug};
1212
use rustc_span::symbol::Ident;
1313
use rustc_span::{Span, DUMMY_SP};
@@ -34,6 +34,20 @@ fn anon_const_type_of<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> Ty<'tcx> {
3434
let parent_node_id = tcx.parent_hir_id(hir_id);
3535
let parent_node = tcx.hir_node(parent_node_id);
3636

37+
let find_sym_fn = |&(op, op_sp)| match op {
38+
hir::InlineAsmOperand::SymFn { anon_const } if anon_const.hir_id == hir_id => {
39+
Some((anon_const, op_sp))
40+
}
41+
_ => None,
42+
};
43+
44+
let find_const = |&(op, op_sp)| match op {
45+
hir::InlineAsmOperand::Const { anon_const } if anon_const.hir_id == hir_id => {
46+
Some((anon_const, op_sp))
47+
}
48+
_ => None,
49+
};
50+
3751
match parent_node {
3852
// Anon consts "inside" the type system.
3953
Node::ConstArg(&ConstArg {
@@ -45,13 +59,51 @@ fn anon_const_type_of<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> Ty<'tcx> {
4559
// Anon consts outside the type system.
4660
Node::Expr(&Expr { kind: ExprKind::InlineAsm(asm), .. })
4761
| Node::Item(&Item { kind: ItemKind::GlobalAsm(asm), .. })
48-
if asm.operands.iter().any(|(op, _op_sp)| match op {
49-
hir::InlineAsmOperand::Const { anon_const }
50-
| hir::InlineAsmOperand::SymFn { anon_const } => anon_const.hir_id == hir_id,
51-
_ => false,
52-
}) =>
62+
if let Some((anon_const, op_sp)) = asm.operands.iter().find_map(find_sym_fn) =>
5363
{
54-
tcx.typeck(def_id).node_type(hir_id)
64+
let ty = tcx.typeck(def_id).node_type(hir_id);
65+
66+
match ty.kind() {
67+
ty::Error(_) => ty,
68+
ty::FnDef(..) => ty,
69+
_ => {
70+
let guar = tcx
71+
.dcx()
72+
.struct_span_err(op_sp, "invalid `sym` operand")
73+
.with_span_label(
74+
tcx.def_span(anon_const.def_id),
75+
format!("is {} `{}`", ty.kind().article(), ty),
76+
)
77+
.with_help("`sym` operands must refer to either a function or a static")
78+
.emit();
79+
80+
Ty::new_error(tcx, guar)
81+
}
82+
}
83+
}
84+
Node::Expr(&Expr { kind: ExprKind::InlineAsm(asm), .. })
85+
| Node::Item(&Item { kind: ItemKind::GlobalAsm(asm), .. })
86+
if let Some((anon_const, op_sp)) = asm.operands.iter().find_map(find_const) =>
87+
{
88+
let ty = tcx.typeck(def_id).node_type(hir_id);
89+
90+
match ty.kind() {
91+
ty::Error(_) => ty,
92+
ty::Int(_) | ty::Uint(_) => ty,
93+
_ => {
94+
let guar = tcx
95+
.dcx()
96+
.struct_span_err(op_sp, "invalid type for `const` operand")
97+
.with_span_label(
98+
tcx.def_span(anon_const.def_id),
99+
format!("is {} `{}`", ty.kind().article(), ty),
100+
)
101+
.with_help("`const` operands must be of an integer type")
102+
.emit();
103+
104+
Ty::new_error(tcx, guar)
105+
}
106+
}
55107
}
56108
Node::Variant(Variant { disr_expr: Some(ref e), .. }) if e.hir_id == hir_id => {
57109
tcx.adt_def(tcx.hir().get_parent_item(hir_id)).repr().discr_type().to_ty(tcx)

compiler/rustc_hir_typeck/src/lib.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -265,11 +265,10 @@ fn infer_type_if_missing<'tcx>(fcx: &FnCtxt<'_, 'tcx>, node: Node<'tcx>) -> Opti
265265
Node::Expr(&hir::Expr { kind: hir::ExprKind::InlineAsm(asm), span, .. })
266266
| Node::Item(&hir::Item { kind: hir::ItemKind::GlobalAsm(asm), span, .. }) => {
267267
asm.operands.iter().find_map(|(op, _op_sp)| match op {
268-
hir::InlineAsmOperand::Const { anon_const } if anon_const.hir_id == id => {
269-
// Inline assembly constants must be integers.
270-
Some(fcx.next_int_var())
271-
}
272-
hir::InlineAsmOperand::SymFn { anon_const } if anon_const.hir_id == id => {
268+
hir::InlineAsmOperand::Const { anon_const }
269+
| hir::InlineAsmOperand::SymFn { anon_const }
270+
if anon_const.hir_id == id =>
271+
{
273272
Some(fcx.next_ty_var(span))
274273
}
275274
_ => None,

compiler/rustc_parse/src/parser/attr.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use rustc_span::{sym, BytePos, Span};
88
use thin_vec::ThinVec;
99
use tracing::debug;
1010

11-
use super::{AttrWrapper, Capturing, FnParseMode, ForceCollect, Parser, PathStyle};
11+
use super::{AttrWrapper, Capturing, FnParseMode, ForceCollect, Parser, ParserRange, PathStyle};
1212
use crate::{errors, fluent_generated as fluent, maybe_whole};
1313

1414
// Public for rustfmt usage
@@ -313,8 +313,8 @@ impl<'a> Parser<'a> {
313313
// inner attribute, for possible later processing in a `LazyAttrTokenStream`.
314314
if let Capturing::Yes = self.capture_state.capturing {
315315
let end_pos = self.num_bump_calls;
316-
let range = start_pos..end_pos;
317-
self.capture_state.inner_attr_ranges.insert(attr.id, range);
316+
let parser_range = ParserRange(start_pos..end_pos);
317+
self.capture_state.inner_attr_parser_ranges.insert(attr.id, parser_range);
318318
}
319319
attrs.push(attr);
320320
} else {

0 commit comments

Comments
 (0)