Skip to content

Commit

Permalink
Auto merge of #121998 - matthiaskrgr:rollup-l7lzwpb, r=matthiaskrgr
Browse files Browse the repository at this point in the history
Rollup of 10 pull requests

Successful merges:

 - #120976 (constify a couple thread_local statics)
 - #121683 (Fix LVI tests after frame pointers are enabled by default)
 - #121703 (Add a way to add constructors for `rustc_type_ir` types)
 - #121732 (Improve assert_matches! documentation)
 - #121928 (Extract an arguments struct for `Builder::then_else_break`)
 - #121939 (Small enhancement to description of From trait)
 - #121968 (Don't run test_get_os_named_thread on win7)
 - #121969 (`ParseSess` cleanups)
 - #121977 (Doc: Fix incorrect reference to integer in Atomic{Ptr,Bool}::as_ptr.)
 - #121994 (Update platform-support.md with supported musl version)

r? `@ghost`
`@rustbot` modify labels: rollup
  • Loading branch information
bors committed Mar 4, 2024
2 parents d18480b + 5e13bc4 commit 50e77f1
Show file tree
Hide file tree
Showing 122 changed files with 900 additions and 889 deletions.
12 changes: 4 additions & 8 deletions compiler/rustc_ast_lowering/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
let lit_kind = match LitKind::from_token_lit(*token_lit) {
Ok(lit_kind) => lit_kind,
Err(err) => {
let guar = report_lit_error(
&self.tcx.sess.parse_sess,
err,
*token_lit,
e.span,
);
let guar =
report_lit_error(&self.tcx.sess.psess, err, *token_lit, e.span);
LitKind::Err(guar)
}
};
Expand Down Expand Up @@ -721,7 +717,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
sym::track_caller,
span,
)))),
id: self.tcx.sess.parse_sess.attr_id_generator.mk_attr_id(),
id: self.tcx.sess.psess.attr_id_generator.mk_attr_id(),
style: AttrStyle::Outer,
span: unstable_span,
}],
Expand Down Expand Up @@ -1756,7 +1752,7 @@ impl<'hir> LoweringContext<'_, 'hir> {

// `#[allow(unreachable_code)]`
let attr = attr::mk_attr_nested_word(
&self.tcx.sess.parse_sess.attr_id_generator,
&self.tcx.sess.psess.attr_id_generator,
AttrStyle::Outer,
sym::allow,
sym::unreachable_code,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_ast_passes/src/ast_validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -835,7 +835,7 @@ fn validate_generic_param_order(

impl<'a> Visitor<'a> for AstValidator<'a> {
fn visit_attribute(&mut self, attr: &Attribute) {
validate_attr::check_attr(&self.session.parse_sess, attr);
validate_attr::check_attr(&self.session.psess, attr);
}

fn visit_ty(&mut self, ty: &'a Ty) {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_ast_passes/src/feature_gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session, features: &Features) {
check_incompatible_features(sess, features);
let mut visitor = PostExpansionVisitor { sess, features };

let spans = sess.parse_sess.gated_spans.spans.borrow();
let spans = sess.psess.gated_spans.spans.borrow();
macro_rules! gate_all {
($gate:ident, $msg:literal) => {
if let Some(spans) = spans.get(&sym::$gate) {
Expand Down
14 changes: 7 additions & 7 deletions compiler/rustc_attr/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -524,9 +524,9 @@ pub fn cfg_matches(
) -> bool {
eval_condition(cfg, sess, features, &mut |cfg| {
try_gate_cfg(cfg.name, cfg.span, sess, features);
match sess.parse_sess.check_config.expecteds.get(&cfg.name) {
match sess.psess.check_config.expecteds.get(&cfg.name) {
Some(ExpectedValues::Some(values)) if !values.contains(&cfg.value) => {
sess.parse_sess.buffer_lint_with_diagnostic(
sess.psess.buffer_lint_with_diagnostic(
UNEXPECTED_CFGS,
cfg.span,
lint_node_id,
Expand All @@ -541,8 +541,8 @@ pub fn cfg_matches(
),
);
}
None if sess.parse_sess.check_config.exhaustive_names => {
sess.parse_sess.buffer_lint_with_diagnostic(
None if sess.psess.check_config.exhaustive_names => {
sess.psess.buffer_lint_with_diagnostic(
UNEXPECTED_CFGS,
cfg.span,
lint_node_id,
Expand All @@ -555,7 +555,7 @@ pub fn cfg_matches(
}
_ => { /* not unexpected */ }
}
sess.parse_sess.config.contains(&(cfg.name, cfg.value))
sess.psess.config.contains(&(cfg.name, cfg.value))
})
}

Expand Down Expand Up @@ -598,7 +598,7 @@ pub fn eval_condition(
features: Option<&Features>,
eval: &mut impl FnMut(Condition) -> bool,
) -> bool {
let dcx = &sess.parse_sess.dcx;
let dcx = &sess.psess.dcx;
match &cfg.kind {
ast::MetaItemKind::List(mis) if cfg.name_or_empty() == sym::version => {
try_gate_cfg(sym::version, cfg.span, sess, features);
Expand Down Expand Up @@ -626,7 +626,7 @@ pub fn eval_condition(
};

// See https://github.com/rust-lang/rust/issues/64796#issuecomment-640851454 for details
if sess.parse_sess.assume_incomplete_release {
if sess.psess.assume_incomplete_release {
RustcVersion::CURRENT > min_version
} else {
RustcVersion::CURRENT >= min_version
Expand Down
17 changes: 7 additions & 10 deletions compiler/rustc_builtin_macros/src/asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use rustc_index::bit_set::GrowableBitSet;
use rustc_parse::parser::Parser;
use rustc_parse_format as parse;
use rustc_session::lint;
use rustc_session::parse::ParseSess;
use rustc_span::symbol::Ident;
use rustc_span::symbol::{kw, sym, Symbol};
use rustc_span::{ErrorGuaranteed, InnerSpan, Span};
Expand All @@ -36,19 +35,17 @@ fn parse_args<'a>(
is_global_asm: bool,
) -> PResult<'a, AsmArgs> {
let mut p = ecx.new_parser_from_tts(tts);
let sess = &ecx.sess.parse_sess;
parse_asm_args(&mut p, sess, sp, is_global_asm)
parse_asm_args(&mut p, sp, is_global_asm)
}

// Primarily public for rustfmt consumption.
// Internal consumers should continue to leverage `expand_asm`/`expand__global_asm`
pub fn parse_asm_args<'a>(
p: &mut Parser<'a>,
sess: &'a ParseSess,
sp: Span,
is_global_asm: bool,
) -> PResult<'a, AsmArgs> {
let dcx = &sess.dcx;
let dcx = &p.psess.dcx;

if p.token == token::Eof {
return Err(dcx.create_err(errors::AsmRequiresTemplate { span: sp }));
Expand Down Expand Up @@ -299,7 +296,7 @@ pub fn parse_asm_args<'a>(
fn err_duplicate_option(p: &mut Parser<'_>, symbol: Symbol, span: Span) {
// Tool-only output
let full_span = if p.token.kind == token::Comma { span.to(p.token.span) } else { span };
p.sess.dcx.emit_err(errors::AsmOptAlreadyprovided { span, symbol, full_span });
p.psess.dcx.emit_err(errors::AsmOptAlreadyprovided { span, symbol, full_span });
}

/// Try to set the provided option in the provided `AsmArgs`.
Expand Down Expand Up @@ -371,7 +368,7 @@ fn parse_clobber_abi<'a>(p: &mut Parser<'a>, args: &mut AsmArgs) -> PResult<'a,
p.expect(&token::OpenDelim(Delimiter::Parenthesis))?;

if p.eat(&token::CloseDelim(Delimiter::Parenthesis)) {
return Err(p.sess.dcx.create_err(errors::NonABI { span: p.token.span }));
return Err(p.psess.dcx.create_err(errors::NonABI { span: p.token.span }));
}

let mut new_abis = Vec::new();
Expand All @@ -382,7 +379,7 @@ fn parse_clobber_abi<'a>(p: &mut Parser<'a>, args: &mut AsmArgs) -> PResult<'a,
}
Err(opt_lit) => {
let span = opt_lit.map_or(p.token.span, |lit| lit.span);
let mut err = p.sess.dcx.struct_span_err(span, "expected string literal");
let mut err = p.psess.dcx.struct_span_err(span, "expected string literal");
err.span_label(span, "not a string literal");
return Err(err);
}
Expand Down Expand Up @@ -498,15 +495,15 @@ fn expand_preparsed_asm(
};

if template_str.contains(".intel_syntax") {
ecx.parse_sess().buffer_lint(
ecx.psess().buffer_lint(
lint::builtin::BAD_ASM_STYLE,
find_span(".intel_syntax"),
ecx.current_expansion.lint_node_id,
"avoid using `.intel_syntax`, Intel syntax is the default",
);
}
if template_str.contains(".att_syntax") {
ecx.parse_sess().buffer_lint(
ecx.psess().buffer_lint(
lint::builtin::BAD_ASM_STYLE,
find_span(".att_syntax"),
ecx.current_expansion.lint_node_id,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_builtin_macros/src/cfg_accessible.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ impl MultiItemModifier for Expander {
) -> ExpandResult<Vec<Annotatable>, Annotatable> {
let template = AttributeTemplate { list: Some("path"), ..Default::default() };
validate_attr::check_builtin_meta_item(
&ecx.sess.parse_sess,
&ecx.sess.psess,
meta_item,
ast::AttrStyle::Outer,
sym::cfg_accessible,
Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_builtin_macros/src/cfg_eval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,7 @@ impl CfgEval<'_, '_> {
// Re-parse the tokens, setting the `capture_cfg` flag to save extra information
// to the captured `AttrTokenStream` (specifically, we capture
// `AttrTokenTree::AttributesData` for all occurrences of `#[cfg]` and `#[cfg_attr]`)
let mut parser =
rustc_parse::stream_to_parser(&self.cfg.sess.parse_sess, orig_tokens, None);
let mut parser = rustc_parse::stream_to_parser(&self.cfg.sess.psess, orig_tokens, None);
parser.capture_cfg = true;
match parse_annotatable_with(&mut parser) {
Ok(a) => annotatable = a,
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_builtin_macros/src/cmdline_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ use rustc_ast::{self as ast, AttrItem, AttrStyle};
use rustc_session::parse::ParseSess;
use rustc_span::FileName;

pub fn inject(krate: &mut ast::Crate, parse_sess: &ParseSess, attrs: &[String]) {
pub fn inject(krate: &mut ast::Crate, psess: &ParseSess, attrs: &[String]) {
for raw_attr in attrs {
let mut parser = rustc_parse::new_parser_from_source_str(
parse_sess,
psess,
FileName::cli_crate_attr_source_code(raw_attr),
raw_attr.clone(),
);
Expand All @@ -25,12 +25,12 @@ pub fn inject(krate: &mut ast::Crate, parse_sess: &ParseSess, attrs: &[String])
};
let end_span = parser.token.span;
if parser.token != token::Eof {
parse_sess.dcx.emit_err(errors::InvalidCrateAttr { span: start_span.to(end_span) });
psess.dcx.emit_err(errors::InvalidCrateAttr { span: start_span.to(end_span) });
continue;
}

krate.attrs.push(mk_attr(
&parse_sess.attr_id_generator,
&psess.attr_id_generator,
AttrStyle::Inner,
path,
args,
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_builtin_macros/src/concat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ pub fn expand_concat(
guar = Some(guarantee);
}
Err(err) => {
guar = Some(report_lit_error(&cx.sess.parse_sess, err, token_lit, e.span));
guar = Some(report_lit_error(&cx.sess.psess, err, token_lit, e.span));
}
},
// We also want to allow negative numeric literals.
Expand All @@ -52,7 +52,7 @@ pub fn expand_concat(
Ok(LitKind::Int(i, _)) => accumulator.push_str(&format!("-{i}")),
Ok(LitKind::Float(f, _)) => accumulator.push_str(&format!("-{f}")),
Err(err) => {
guar = Some(report_lit_error(&cx.sess.parse_sess, err, token_lit, e.span));
guar = Some(report_lit_error(&cx.sess.psess, err, token_lit, e.span));
}
_ => missing_literal.push(e.span),
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_builtin_macros/src/concat_bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ fn invalid_type_err(
Ok(LitKind::Int(_, _)) => dcx.emit_err(ConcatBytesNonU8 { span }),
Ok(LitKind::ByteStr(..) | LitKind::Byte(_)) => unreachable!(),
Ok(LitKind::Err(guar)) => guar,
Err(err) => report_lit_error(&cx.sess.parse_sess, err, token_lit, span),
Err(err) => report_lit_error(&cx.sess.psess, err, token_lit, span),
}
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_builtin_macros/src/derive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ impl MultiItemModifier for Expander {
let template =
AttributeTemplate { list: Some("Trait1, Trait2, ..."), ..Default::default() };
validate_attr::check_builtin_meta_item(
&sess.parse_sess,
&sess.psess,
meta_item,
ast::AttrStyle::Outer,
sym::derive,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_builtin_macros/src/deriving/generic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1624,7 +1624,7 @@ impl<'a> TraitDef<'a> {
};

if let Some(ty) = exception {
cx.sess.parse_sess.buffer_lint_with_diagnostic(
cx.sess.psess.buffer_lint_with_diagnostic(
BYTE_SLICE_IN_PACKED_STRUCT_WITH_DERIVE,
sp,
ast::CRATE_NODE_ID,
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_builtin_macros/src/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pub fn expand_option_env<'cx>(

let sp = cx.with_def_site_ctxt(sp);
let value = lookup_env(cx, var);
cx.sess.parse_sess.env_depinfo.borrow_mut().insert((var, value));
cx.sess.psess.env_depinfo.borrow_mut().insert((var, value));
let e = match value {
None => {
let lt = cx.lifetime(sp, Ident::new(kw::StaticLifetime, sp));
Expand Down Expand Up @@ -94,7 +94,7 @@ pub fn expand_env<'cx>(

let span = cx.with_def_site_ctxt(sp);
let value = lookup_env(cx, var);
cx.sess.parse_sess.env_depinfo.borrow_mut().insert((var, value));
cx.sess.psess.env_depinfo.borrow_mut().insert((var, value));
let e = match value {
None => {
let ExprKind::Lit(token::Lit {
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_builtin_macros/src/source_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ pub fn expand_include<'cx>(
return DummyResult::any(sp, guar);
}
};
let p = new_parser_from_file(cx.parse_sess(), &file, Some(sp));
let p = new_parser_from_file(cx.psess(), &file, Some(sp));

// If in the included file we have e.g., `mod bar;`,
// then the path of `bar.rs` should be relative to the directory of `file`.
Expand All @@ -136,7 +136,7 @@ pub fn expand_include<'cx>(
fn make_expr(mut self: Box<ExpandResult<'a>>) -> Option<P<ast::Expr>> {
let expr = parse_expr(&mut self.p).ok()?;
if self.p.token != token::Eof {
self.p.sess.buffer_lint(
self.p.psess.buffer_lint(
INCOMPLETE_INCLUDE,
self.p.token.span,
self.node_id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub fn inject(
features: &Features,
) -> usize {
let orig_num_items = krate.items.len();
let edition = sess.parse_sess.edition;
let edition = sess.psess.edition;

// the first name in this list is the crate name of the crate with the prelude
let names: &[Symbol] = if attr::contains_name(pre_configured_attrs, sym::no_core) {
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_builtin_macros/src/test_harness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ struct InnerItemLinter<'a> {
impl<'a> Visitor<'a> for InnerItemLinter<'_> {
fn visit_item(&mut self, i: &'a ast::Item) {
if let Some(attr) = attr::find_by_name(&i.attrs, sym::rustc_test_marker) {
self.sess.parse_sess.buffer_lint(
self.sess.psess.buffer_lint(
UNNAMEABLE_TEST_ITEMS,
attr.span,
i.id,
Expand Down Expand Up @@ -200,7 +200,7 @@ impl<'a> MutVisitor for EntryPointCleaner<'a> {
EntryPointType::MainNamed | EntryPointType::RustcMainAttr | EntryPointType::Start => {
item.map(|ast::Item { id, ident, attrs, kind, vis, span, tokens }| {
let allow_dead_code = attr::mk_attr_nested_word(
&self.sess.parse_sess.attr_id_generator,
&self.sess.psess.attr_id_generator,
ast::AttrStyle::Outer,
sym::allow,
sym::dead_code,
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_builtin_macros/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pub fn check_builtin_macro_attribute(ecx: &ExtCtxt<'_>, meta_item: &MetaItem, na
// All the built-in macro attributes are "words" at the moment.
let template = AttributeTemplate { word: true, ..Default::default() };
validate_attr::check_builtin_meta_item(
&ecx.sess.parse_sess,
&ecx.sess.psess,
meta_item,
AttrStyle::Outer,
name,
Expand Down Expand Up @@ -37,7 +37,7 @@ pub fn warn_on_duplicate_attribute(ecx: &ExtCtxt<'_>, item: &Annotatable, name:
};
if let Some(attrs) = attrs {
if let Some(attr) = attr::find_by_name(attrs, name) {
ecx.parse_sess().buffer_lint(
ecx.psess().buffer_lint(
DUPLICATE_MACRO_ATTRIBUTES,
attr.span,
ecx.current_expansion.lint_node_id,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_ssa/src/assert_module_sources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ impl<'tcx> AssertModuleSource<'tcx> {
/// Scan for a `cfg="foo"` attribute and check whether we have a
/// cfg flag called `foo`.
fn check_config(&self, attr: &ast::Attribute) -> bool {
let config = &self.tcx.sess.parse_sess.config;
let config = &self.tcx.sess.psess.config;
let value = self.field(attr, sym::cfg);
debug!("check_config(config={:?}, value={:?})", config, value);
if config.iter().any(|&(name, _)| name == value) {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_data_structures/src/sync/worker_local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pub struct Registry(Arc<RegistryData>);
thread_local! {
/// The registry associated with the thread.
/// This allows the `WorkerLocal` type to clone the registry in its constructor.
static REGISTRY: OnceCell<Registry> = OnceCell::new();
static REGISTRY: OnceCell<Registry> = const { OnceCell::new() };
}

struct ThreadData {
Expand Down
Loading

0 comments on commit 50e77f1

Please sign in to comment.