Skip to content

Commit 615d0f2

Browse files
committed
Auto merge of #117309 - workingjubilee:rollup-zqb1dun, r=workingjubilee
Rollup of 8 pull requests Successful merges: - #116534 (Remove -Zdep-tasks.) - #116739 (Make `E0277` use short paths) - #116816 (Create `windows/api.rs` for safer FFI) - #116945 (When encountering sealed traits, point types that implement it) - #117025 (Cleanup and improve `--check-cfg` implementation) - #117256 (Parse rustc version at compile time) - #117268 (`rustc_interface` cleanups) - #117277 (fix failure to detect a too-big-type after adding padding) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 17659c7 + 09fd68d commit 615d0f2

File tree

43 files changed

+759
-445
lines changed

Some content is hidden

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

43 files changed

+759
-445
lines changed

Cargo.lock

-1
Original file line numberDiff line numberDiff line change
@@ -4054,7 +4054,6 @@ dependencies = [
40544054
"rustc_hir_analysis",
40554055
"rustc_hir_typeck",
40564056
"rustc_incremental",
4057-
"rustc_index",
40584057
"rustc_lint",
40594058
"rustc_macros",
40604059
"rustc_metadata",

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_driver_impl/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ fn run_compiler(
317317
return Ok(());
318318
}
319319

320-
let cfg = interface::parse_cfgspecs(&early_error_handler, matches.opt_strs("cfg"));
320+
let cfg = interface::parse_cfg(&early_error_handler, matches.opt_strs("cfg"));
321321
let check_cfg = interface::parse_check_cfg(&early_error_handler, matches.opt_strs("check-cfg"));
322322
let (odir, ofile) = make_output(&matches);
323323
let mut config = interface::Config {

compiler/rustc_interface/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ rustc_middle = { path = "../rustc_middle" }
2626
rustc_ast_lowering = { path = "../rustc_ast_lowering" }
2727
rustc_ast_passes = { path = "../rustc_ast_passes" }
2828
rustc_incremental = { path = "../rustc_incremental" }
29-
rustc_index = { path = "../rustc_index" }
3029
rustc_traits = { path = "../rustc_traits" }
3130
rustc_data_structures = { path = "../rustc_data_structures" }
3231
rustc_codegen_ssa = { path = "../rustc_codegen_ssa" }

compiler/rustc_interface/src/callbacks.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ fn track_span_parent(def_id: rustc_span::def_id::LocalDefId) {
2626
})
2727
}
2828

29-
/// This is a callback from `rustc_ast` as it cannot access the implicit state
29+
/// This is a callback from `rustc_errors` as it cannot access the implicit state
3030
/// in `rustc_middle` otherwise. It is used when diagnostic messages are
3131
/// emitted and stores them in the current query, if there is one.
3232
fn track_diagnostic(diagnostic: &mut Diagnostic, f: &mut dyn FnMut(&mut Diagnostic)) {

0 commit comments

Comments
 (0)