Skip to content

Commit 10d9e28

Browse files
committed
Auto merge of rust-lang#117308 - matthiaskrgr:rollup-54ihjci, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - rust-lang#116534 (Remove -Zdep-tasks.) - rust-lang#116609 (Bump stdarch submodule and remove special handling for LLVM intrinsics that are no longer needed) - rust-lang#116739 (Make `E0277` use short paths) - rust-lang#116945 (When encountering sealed traits, point types that implement it) - rust-lang#117025 (Cleanup and improve `--check-cfg` implementation) - rust-lang#117029 (Add FileCheck annotations to MIR-opt inlining tests ) - rust-lang#117256 (Parse rustc version at compile time) - rust-lang#117277 (fix failure to detect a too-big-type after adding padding) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 17659c7 + b0c996a commit 10d9e28

File tree

62 files changed

+690
-667
lines changed

Some content is hidden

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

62 files changed

+690
-667
lines changed

compiler/rustc_abi/src/layout.rs

+5
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,7 @@ pub trait LayoutCalculator {
539539
// Align the maximum variant size to the largest alignment.
540540
size = size.align_to(align.abi);
541541

542+
// FIXME(oli-obk): deduplicate and harden these checks
542543
if size.bytes() >= dl.obj_size_bound() {
543544
return None;
544545
}
@@ -1103,6 +1104,10 @@ fn univariant<
11031104
inverse_memory_index.into_iter().map(|it| it.index() as u32).collect()
11041105
};
11051106
let size = min_size.align_to(align.abi);
1107+
// FIXME(oli-obk): deduplicate and harden these checks
1108+
if size.bytes() >= dl.obj_size_bound() {
1109+
return None;
1110+
}
11061111
let mut layout_of_single_non_zst_field = None;
11071112
let mut abi = Abi::Aggregate { sized };
11081113
// Try to make this a Scalar/ScalarPair.

compiler/rustc_attr/src/builtin.rs

+13-28
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,9 @@ use rustc_session::config::ExpectedValues;
1010
use rustc_session::lint::builtin::UNEXPECTED_CFGS;
1111
use rustc_session::lint::BuiltinLintDiagnostics;
1212
use rustc_session::parse::{feature_err, ParseSess};
13-
use rustc_session::Session;
13+
use rustc_session::{RustcVersion, Session};
1414
use rustc_span::hygiene::Transparency;
1515
use rustc_span::{symbol::sym, symbol::Symbol, Span};
16-
use std::fmt::{self, Display};
1716
use std::num::NonZeroU32;
1817

1918
use crate::session_diagnostics::{self, IncorrectReprFormatGenericCause};
@@ -24,8 +23,6 @@ use crate::session_diagnostics::{self, IncorrectReprFormatGenericCause};
2423
/// For more, see [this pull request](https://github.com/rust-lang/rust/pull/100591).
2524
pub const VERSION_PLACEHOLDER: &str = "CURRENT_RUSTC_VERSION";
2625

27-
pub const CURRENT_RUSTC_VERSION: &str = env!("CFG_RELEASE");
28-
2926
pub fn is_builtin_attr(attr: &Attribute) -> bool {
3027
attr.is_doc_comment() || attr.ident().is_some_and(|ident| is_builtin_attr_name(ident.name))
3128
}
@@ -153,7 +150,7 @@ pub enum StabilityLevel {
153150
#[derive(Encodable, Decodable, PartialEq, Copy, Clone, Debug, Eq, Hash)]
154151
#[derive(HashStable_Generic)]
155152
pub enum Since {
156-
Version(Version),
153+
Version(RustcVersion),
157154
/// Stabilized in the upcoming version, whatever number that is.
158155
Current,
159156
/// Failed to parse a stabilization version.
@@ -382,7 +379,7 @@ fn parse_stability(sess: &Session, attr: &Attribute) -> Option<(Symbol, Stabilit
382379
let since = if let Some(since) = since {
383380
if since.as_str() == VERSION_PLACEHOLDER {
384381
Since::Current
385-
} else if let Some(version) = parse_version(since.as_str(), false) {
382+
} else if let Some(version) = parse_version(since) {
386383
Since::Version(version)
387384
} else {
388385
sess.emit_err(session_diagnostics::InvalidSince { span: attr.span });
@@ -567,31 +564,20 @@ fn gate_cfg(gated_cfg: &GatedCfg, cfg_span: Span, sess: &ParseSess, features: &F
567564
}
568565
}
569566

570-
#[derive(Encodable, Decodable, Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
571-
#[derive(HashStable_Generic)]
572-
pub struct Version {
573-
pub major: u16,
574-
pub minor: u16,
575-
pub patch: u16,
576-
}
577-
578-
fn parse_version(s: &str, allow_appendix: bool) -> Option<Version> {
579-
let mut components = s.split('-');
567+
/// Parse a rustc version number written inside string literal in an attribute,
568+
/// like appears in `since = "1.0.0"`. Suffixes like "-dev" and "-nightly" are
569+
/// not accepted in this position, unlike when parsing CFG_RELEASE.
570+
fn parse_version(s: Symbol) -> Option<RustcVersion> {
571+
let mut components = s.as_str().split('-');
580572
let d = components.next()?;
581-
if !allow_appendix && components.next().is_some() {
573+
if components.next().is_some() {
582574
return None;
583575
}
584576
let mut digits = d.splitn(3, '.');
585577
let major = digits.next()?.parse().ok()?;
586578
let minor = digits.next()?.parse().ok()?;
587579
let patch = digits.next().unwrap_or("0").parse().ok()?;
588-
Some(Version { major, minor, patch })
589-
}
590-
591-
impl Display for Version {
592-
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
593-
write!(formatter, "{}.{}.{}", self.major, self.minor, self.patch)
594-
}
580+
Some(RustcVersion { major, minor, patch })
595581
}
596582

597583
/// Evaluate a cfg-like condition (with `any` and `all`), using `eval` to
@@ -623,17 +609,16 @@ pub fn eval_condition(
623609
return false;
624610
}
625611
};
626-
let Some(min_version) = parse_version(min_version.as_str(), false) else {
612+
let Some(min_version) = parse_version(*min_version) else {
627613
sess.emit_warning(session_diagnostics::UnknownVersionLiteral { span: *span });
628614
return false;
629615
};
630-
let rustc_version = parse_version(CURRENT_RUSTC_VERSION, true).unwrap();
631616

632617
// See https://github.com/rust-lang/rust/issues/64796#issuecomment-640851454 for details
633618
if sess.assume_incomplete_release {
634-
rustc_version > min_version
619+
RustcVersion::CURRENT > min_version
635620
} else {
636-
rustc_version >= min_version
621+
RustcVersion::CURRENT >= min_version
637622
}
638623
}
639624
ast::MetaItemKind::List(mis) => {

compiler/rustc_attr/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ pub use StabilityLevel::*;
2727

2828
pub use rustc_ast::attr::*;
2929

30-
pub(crate) use rustc_ast::HashStableContext;
30+
pub(crate) use rustc_session::HashStableContext;
3131

3232
fluent_messages! { "../messages.ftl" }

compiler/rustc_codegen_cranelift/src/intrinsics/llvm_x86.rs

-35
Original file line numberDiff line numberDiff line change
@@ -32,41 +32,6 @@ pub(crate) fn codegen_x86_llvm_intrinsic_call<'tcx>(
3232
ret.write_cvalue(fx, CValue::by_val(res, fx.layout_of(fx.tcx.types.i64)));
3333
}
3434

35-
// Used by `_mm_movemask_epi8` and `_mm256_movemask_epi8`
36-
"llvm.x86.sse2.pmovmskb.128"
37-
| "llvm.x86.avx2.pmovmskb"
38-
| "llvm.x86.sse.movmsk.ps"
39-
| "llvm.x86.sse2.movmsk.pd" => {
40-
intrinsic_args!(fx, args => (a); intrinsic);
41-
42-
let (lane_count, lane_ty) = a.layout().ty.simd_size_and_type(fx.tcx);
43-
let lane_ty = fx.clif_type(lane_ty).unwrap();
44-
assert!(lane_count <= 32);
45-
46-
let mut res = fx.bcx.ins().iconst(types::I32, 0);
47-
48-
for lane in (0..lane_count).rev() {
49-
let a_lane = a.value_lane(fx, lane).load_scalar(fx);
50-
51-
// cast float to int
52-
let a_lane = match lane_ty {
53-
types::F32 => codegen_bitcast(fx, types::I32, a_lane),
54-
types::F64 => codegen_bitcast(fx, types::I64, a_lane),
55-
_ => a_lane,
56-
};
57-
58-
// extract sign bit of an int
59-
let a_lane_sign = fx.bcx.ins().ushr_imm(a_lane, i64::from(lane_ty.bits() - 1));
60-
61-
// shift sign bit into result
62-
let a_lane_sign = clif_intcast(fx, a_lane_sign, types::I32, false);
63-
res = fx.bcx.ins().ishl_imm(res, 1);
64-
res = fx.bcx.ins().bor(res, a_lane_sign);
65-
}
66-
67-
let res = CValue::by_val(res, fx.layout_of(fx.tcx.types.i32));
68-
ret.write_cvalue(fx, res);
69-
}
7035
"llvm.x86.sse.cmp.ps" | "llvm.x86.sse2.cmp.pd" => {
7136
let (x, y, kind) = match args {
7237
[x, y, kind] => (x, y, kind),

0 commit comments

Comments
 (0)