Skip to content

Commit ca0755f

Browse files
committed
Auto merge of #144485 - tgross35:rollup-3e11y2g, r=tgross35
Rollup of 9 pull requests Successful merges: - #140871 (Don't lint against named labels in `naked_asm!`) - #141663 (rustdoc: add ways of collapsing all impl blocks) - #143272 (Upgrade the `fortanix-sgx-abi` dependency) - #143585 (`loop_match`: suggest extracting to a `const` item) - #143698 (Fix unused_parens false positive) - #143859 (Guarantee 8 bytes of alignment in Thread::into_raw) - #144042 (Verify llvm-needs-components are not empty and match the --target value) - #144160 (tests: debuginfo: Work around or disable broken tests on powerpc) - #144431 (Disable has_reliable_f128_math on musl targets) r? `@ghost` `@rustbot` modify labels: rollup
2 parents f32b232 + e5b7040 commit ca0755f

File tree

53 files changed

+727
-148
lines changed

Some content is hidden

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

53 files changed

+727
-148
lines changed

compiler/rustc_ast/src/ast.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2849,7 +2849,7 @@ impl InlineAsmOperand {
28492849
}
28502850
}
28512851

2852-
#[derive(Clone, Copy, Encodable, Decodable, Debug, HashStable_Generic, Walkable)]
2852+
#[derive(Clone, Copy, Encodable, Decodable, Debug, HashStable_Generic, Walkable, PartialEq, Eq)]
28532853
pub enum AsmMacro {
28542854
/// The `asm!` macro
28552855
Asm,

compiler/rustc_codegen_llvm/src/llvm_util.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,9 @@ fn update_target_reliable_float_cfg(sess: &Session, cfg: &mut TargetConfig) {
433433
// This rules out anything that doesn't have `long double` = `binary128`; <= 32 bits
434434
// (ld is `f64`), anything other than Linux (Windows and MacOS use `f64`), and `x86`
435435
// (ld is 80-bit extended precision).
436+
//
437+
// musl does not implement the symbols required for f128 math at all.
438+
_ if target_env == "musl" => false,
436439
("x86_64", _) => false,
437440
(_, "linux") if target_pointer_width == 64 => true,
438441
_ => false,

compiler/rustc_lint/src/builtin.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2870,14 +2870,23 @@ impl<'tcx> LateLintPass<'tcx> for AsmLabels {
28702870
if let hir::Expr {
28712871
kind:
28722872
hir::ExprKind::InlineAsm(hir::InlineAsm {
2873-
asm_macro: AsmMacro::Asm | AsmMacro::NakedAsm,
2873+
asm_macro: asm_macro @ (AsmMacro::Asm | AsmMacro::NakedAsm),
28742874
template_strs,
28752875
options,
28762876
..
28772877
}),
28782878
..
28792879
} = expr
28802880
{
2881+
// Non-generic naked functions are allowed to define arbitrary
2882+
// labels.
2883+
if *asm_macro == AsmMacro::NakedAsm {
2884+
let def_id = expr.hir_id.owner.def_id;
2885+
if !cx.tcx.generics_of(def_id).requires_monomorphization(cx.tcx) {
2886+
return;
2887+
}
2888+
}
2889+
28812890
// asm with `options(raw)` does not do replacement with `{` and `}`.
28822891
let raw = options.contains(InlineAsmOptions::RAW);
28832892

compiler/rustc_lint/src/unused.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1340,7 +1340,15 @@ impl EarlyLintPass for UnusedParens {
13401340
self.with_self_ty_parens = false;
13411341
}
13421342
ast::TyKind::Ref(_, mut_ty) | ast::TyKind::Ptr(mut_ty) => {
1343-
self.in_no_bounds_pos.insert(mut_ty.ty.id, NoBoundsException::OneBound);
1343+
// If this type itself appears in no-bounds position, we propagate its
1344+
// potentially tighter constraint or risk a false posive (issue 143653).
1345+
let own_constraint = self.in_no_bounds_pos.get(&ty.id);
1346+
let constraint = match own_constraint {
1347+
Some(NoBoundsException::None) => NoBoundsException::None,
1348+
Some(NoBoundsException::OneBound) => NoBoundsException::OneBound,
1349+
None => NoBoundsException::OneBound,
1350+
};
1351+
self.in_no_bounds_pos.insert(mut_ty.ty.id, constraint);
13441352
}
13451353
ast::TyKind::TraitObject(bounds, _) | ast::TyKind::ImplTrait(_, bounds) => {
13461354
for i in 0..bounds.len() {

compiler/rustc_mir_build/messages.ftl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,16 @@ mir_build_confused = missing patterns are not covered because `{$variable}` is i
8686
8787
mir_build_const_continue_bad_const = could not determine the target branch for this `#[const_continue]`
8888
.label = this value is too generic
89-
.note = the value must be a literal or a monomorphic const
9089
9190
mir_build_const_continue_missing_value = a `#[const_continue]` must break to a label with a value
9291
92+
mir_build_const_continue_not_const = could not determine the target branch for this `#[const_continue]`
93+
.help = try extracting the expression into a `const` item
94+
95+
mir_build_const_continue_not_const_const_block = `const` blocks may use generics, and are not evaluated early enough
96+
mir_build_const_continue_not_const_const_other = this value must be a literal or a monomorphic const
97+
mir_build_const_continue_not_const_constant_parameter = constant parameters may use generics, and are not evaluated early enough
98+
9399
mir_build_const_continue_unknown_jump_target = the target of this `#[const_continue]` is not statically known
94100
.label = this value must be a literal or a monomorphic const
95101

compiler/rustc_mir_build/src/builder/scope.rs

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,9 @@ use tracing::{debug, instrument};
100100

101101
use super::matches::BuiltMatchTree;
102102
use crate::builder::{BlockAnd, BlockAndExtension, BlockFrame, Builder, CFG};
103-
use crate::errors::{ConstContinueBadConst, ConstContinueUnknownJumpTarget};
103+
use crate::errors::{
104+
ConstContinueBadConst, ConstContinueNotMonomorphicConst, ConstContinueUnknownJumpTarget,
105+
};
104106

105107
#[derive(Debug)]
106108
pub(crate) struct Scopes<'tcx> {
@@ -867,7 +869,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
867869
span_bug!(span, "break value must be a scope")
868870
};
869871

870-
let constant = match &self.thir[value].kind {
872+
let expr = &self.thir[value];
873+
let constant = match &expr.kind {
871874
ExprKind::Adt(box AdtExpr { variant_index, fields, base, .. }) => {
872875
assert!(matches!(base, AdtExprBase::None));
873876
assert!(fields.is_empty());
@@ -887,7 +890,27 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
887890
),
888891
}
889892
}
890-
_ => self.as_constant(&self.thir[value]),
893+
894+
ExprKind::Literal { .. }
895+
| ExprKind::NonHirLiteral { .. }
896+
| ExprKind::ZstLiteral { .. }
897+
| ExprKind::NamedConst { .. } => self.as_constant(&self.thir[value]),
898+
899+
other => {
900+
use crate::errors::ConstContinueNotMonomorphicConstReason as Reason;
901+
902+
let span = expr.span;
903+
let reason = match other {
904+
ExprKind::ConstParam { .. } => Reason::ConstantParameter { span },
905+
ExprKind::ConstBlock { .. } => Reason::ConstBlock { span },
906+
_ => Reason::Other { span },
907+
};
908+
909+
self.tcx
910+
.dcx()
911+
.emit_err(ConstContinueNotMonomorphicConst { span: expr.span, reason });
912+
return block.unit();
913+
}
891914
};
892915

893916
let break_index = self

compiler/rustc_mir_build/src/errors.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1213,6 +1213,38 @@ pub(crate) struct LoopMatchArmWithGuard {
12131213
pub span: Span,
12141214
}
12151215

1216+
#[derive(Diagnostic)]
1217+
#[diag(mir_build_const_continue_not_const)]
1218+
#[help]
1219+
pub(crate) struct ConstContinueNotMonomorphicConst {
1220+
#[primary_span]
1221+
pub span: Span,
1222+
1223+
#[subdiagnostic]
1224+
pub reason: ConstContinueNotMonomorphicConstReason,
1225+
}
1226+
1227+
#[derive(Subdiagnostic)]
1228+
pub(crate) enum ConstContinueNotMonomorphicConstReason {
1229+
#[label(mir_build_const_continue_not_const_constant_parameter)]
1230+
ConstantParameter {
1231+
#[primary_span]
1232+
span: Span,
1233+
},
1234+
1235+
#[label(mir_build_const_continue_not_const_const_block)]
1236+
ConstBlock {
1237+
#[primary_span]
1238+
span: Span,
1239+
},
1240+
1241+
#[label(mir_build_const_continue_not_const_const_other)]
1242+
Other {
1243+
#[primary_span]
1244+
span: Span,
1245+
},
1246+
}
1247+
12161248
#[derive(Diagnostic)]
12171249
#[diag(mir_build_const_continue_bad_const)]
12181250
pub(crate) struct ConstContinueBadConst {

library/Cargo.lock

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,10 @@ dependencies = [
9090

9191
[[package]]
9292
name = "fortanix-sgx-abi"
93-
version = "0.5.0"
93+
version = "0.6.1"
9494
source = "registry+https://github.com/rust-lang/crates.io-index"
95-
checksum = "57cafc2274c10fab234f176b25903ce17e690fca7597090d50880e047a0389c5"
95+
checksum = "5efc85edd5b83e8394f4371dd0da6859dff63dd387dab8568fece6af4cde6f84"
9696
dependencies = [
97-
"compiler_builtins",
9897
"rustc-std-workspace-core",
9998
]
10099

library/std/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ rand_xorshift = "0.4.0"
6666
dlmalloc = { version = "0.2.4", features = ['rustc-dep-of-std'] }
6767

6868
[target.x86_64-fortanix-unknown-sgx.dependencies]
69-
fortanix-sgx-abi = { version = "0.5.0", features = [
69+
fortanix-sgx-abi = { version = "0.6.1", features = [
7070
'rustc-dep-of-std',
7171
], public = true }
7272

library/std/src/sys/pal/sgx/abi/usercalls/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ pub fn send(event_set: u64, tcs: Option<Tcs>) -> IoResult<()> {
267267
/// Usercall `insecure_time`. See the ABI documentation for more information.
268268
#[unstable(feature = "sgx_platform", issue = "56975")]
269269
pub fn insecure_time() -> Duration {
270-
let t = unsafe { raw::insecure_time() };
270+
let t = unsafe { raw::insecure_time().0 };
271271
Duration::new(t / 1_000_000_000, (t % 1_000_000_000) as _)
272272
}
273273

0 commit comments

Comments
 (0)