Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 10 pull requests #121995

Closed
wants to merge 28 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
d0873c7
constify a couple thread_local statics
matthiaskrgr Feb 12, 2024
e478111
Improve assert_matches! documentation
Voultapher Feb 28, 2024
d2495fa
Drop link to matches macro and link matches macro to assert_matches.
Voultapher Feb 29, 2024
d6438f5
Apply review comments
Voultapher Mar 2, 2024
fb2b918
Small enhancement to description of From trait
jonaspleyer Mar 3, 2024
c45f0a9
Apply suggestions from code review
Voultapher Mar 3, 2024
aa38c26
Tweak `parse_asm_args`.
nnethercote Dec 20, 2023
3996447
Remove `file_path_mapping` param from `ParseSess::new`.
nnethercote Mar 4, 2024
0d4ebe1
Move `sess` function and use it more.
nnethercote Mar 4, 2024
4260f7e
Rename a misnamed `Session` parameter.
nnethercote Mar 4, 2024
4146136
Extract an arguments struct for `Builder::then_else_break`
Zalathar Feb 27, 2024
9eb927e
Don't run test_get_os_named_thread on win7
roblabla Mar 4, 2024
287fcde
Rename all `ParseSess` variables/fields/lifetimes as `psess`.
nnethercote Mar 4, 2024
e463060
include feedback from workingjubilee
jonaspleyer Mar 4, 2024
ede25ad
Fix LVI tests after making frame pointers easily enableable
raoulstrackx Feb 27, 2024
05e68fa
Fix comment in Atomic{Ptr,Bool}::as_ptr.
Lee-Janggun Mar 4, 2024
1eedca8
Allow a way to add constructors for rustc_type_ir types
compiler-errors Feb 27, 2024
748da32
Update platform-support.md with supported musl version
wesleywiser Mar 4, 2024
c981d0c
Rollup merge of #120976 - matthiaskrgr:constify_TL_statics, r=lcnr
matthiaskrgr Mar 4, 2024
3f7eced
Rollup merge of #121683 - fortanix:raoul/lvi_fixes, r=cuviper
matthiaskrgr Mar 4, 2024
edb71a6
Rollup merge of #121703 - compiler-errors:new, r=lcnr
matthiaskrgr Mar 4, 2024
448ea9b
Rollup merge of #121732 - Voultapher:improve-assert_matches-documenta…
matthiaskrgr Mar 4, 2024
1a53b42
Rollup merge of #121928 - Zalathar:then-else-args, r=Nadrieril
matthiaskrgr Mar 4, 2024
a6bf9f6
Rollup merge of #121939 - jonaspleyer:patch-typo-core-From-descr, r=w…
matthiaskrgr Mar 4, 2024
a6f5eed
Rollup merge of #121968 - roblabla:fix-win7, r=jhpratt
matthiaskrgr Mar 4, 2024
99c4935
Rollup merge of #121969 - nnethercote:ParseSess-cleanups, r=wesleywiser
matthiaskrgr Mar 4, 2024
b742c8d
Rollup merge of #121977 - Lee-Janggun:master, r=WaffleLapkin
matthiaskrgr Mar 4, 2024
679600d
Rollup merge of #121994 - wesleywiser:update_musl_version_docs, r=ehuss
matthiaskrgr Mar 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading