Skip to content

Commit 6710082

Browse files
committed
Auto merge of rust-lang#121998 - matthiaskrgr:rollup-l7lzwpb, r=matthiaskrgr
Rollup of 10 pull requests Successful merges: - rust-lang#120976 (constify a couple thread_local statics) - rust-lang#121683 (Fix LVI tests after frame pointers are enabled by default) - rust-lang#121703 (Add a way to add constructors for `rustc_type_ir` types) - rust-lang#121732 (Improve assert_matches! documentation) - rust-lang#121928 (Extract an arguments struct for `Builder::then_else_break`) - rust-lang#121939 (Small enhancement to description of From trait) - rust-lang#121968 (Don't run test_get_os_named_thread on win7) - rust-lang#121969 (`ParseSess` cleanups) - rust-lang#121977 (Doc: Fix incorrect reference to integer in Atomic{Ptr,Bool}::as_ptr.) - rust-lang#121994 (Update platform-support.md with supported musl version) r? `@ghost` `@rustbot` modify labels: rollup
2 parents d18480b + 5e13bc4 commit 6710082

File tree

122 files changed

+900
-889
lines changed

Some content is hidden

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

122 files changed

+900
-889
lines changed

compiler/rustc_ast_lowering/src/expr.rs

+4-8
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
125125
let lit_kind = match LitKind::from_token_lit(*token_lit) {
126126
Ok(lit_kind) => lit_kind,
127127
Err(err) => {
128-
let guar = report_lit_error(
129-
&self.tcx.sess.parse_sess,
130-
err,
131-
*token_lit,
132-
e.span,
133-
);
128+
let guar =
129+
report_lit_error(&self.tcx.sess.psess, err, *token_lit, e.span);
134130
LitKind::Err(guar)
135131
}
136132
};
@@ -721,7 +717,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
721717
sym::track_caller,
722718
span,
723719
)))),
724-
id: self.tcx.sess.parse_sess.attr_id_generator.mk_attr_id(),
720+
id: self.tcx.sess.psess.attr_id_generator.mk_attr_id(),
725721
style: AttrStyle::Outer,
726722
span: unstable_span,
727723
}],
@@ -1756,7 +1752,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
17561752

17571753
// `#[allow(unreachable_code)]`
17581754
let attr = attr::mk_attr_nested_word(
1759-
&self.tcx.sess.parse_sess.attr_id_generator,
1755+
&self.tcx.sess.psess.attr_id_generator,
17601756
AttrStyle::Outer,
17611757
sym::allow,
17621758
sym::unreachable_code,

compiler/rustc_ast_passes/src/ast_validation.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -835,7 +835,7 @@ fn validate_generic_param_order(
835835

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

841841
fn visit_ty(&mut self, ty: &'a Ty) {

compiler/rustc_ast_passes/src/feature_gate.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session, features: &Features) {
507507
check_incompatible_features(sess, features);
508508
let mut visitor = PostExpansionVisitor { sess, features };
509509

510-
let spans = sess.parse_sess.gated_spans.spans.borrow();
510+
let spans = sess.psess.gated_spans.spans.borrow();
511511
macro_rules! gate_all {
512512
($gate:ident, $msg:literal) => {
513513
if let Some(spans) = spans.get(&sym::$gate) {

compiler/rustc_attr/src/builtin.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -524,9 +524,9 @@ pub fn cfg_matches(
524524
) -> bool {
525525
eval_condition(cfg, sess, features, &mut |cfg| {
526526
try_gate_cfg(cfg.name, cfg.span, sess, features);
527-
match sess.parse_sess.check_config.expecteds.get(&cfg.name) {
527+
match sess.psess.check_config.expecteds.get(&cfg.name) {
528528
Some(ExpectedValues::Some(values)) if !values.contains(&cfg.value) => {
529-
sess.parse_sess.buffer_lint_with_diagnostic(
529+
sess.psess.buffer_lint_with_diagnostic(
530530
UNEXPECTED_CFGS,
531531
cfg.span,
532532
lint_node_id,
@@ -541,8 +541,8 @@ pub fn cfg_matches(
541541
),
542542
);
543543
}
544-
None if sess.parse_sess.check_config.exhaustive_names => {
545-
sess.parse_sess.buffer_lint_with_diagnostic(
544+
None if sess.psess.check_config.exhaustive_names => {
545+
sess.psess.buffer_lint_with_diagnostic(
546546
UNEXPECTED_CFGS,
547547
cfg.span,
548548
lint_node_id,
@@ -555,7 +555,7 @@ pub fn cfg_matches(
555555
}
556556
_ => { /* not unexpected */ }
557557
}
558-
sess.parse_sess.config.contains(&(cfg.name, cfg.value))
558+
sess.psess.config.contains(&(cfg.name, cfg.value))
559559
})
560560
}
561561

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

628628
// See https://github.com/rust-lang/rust/issues/64796#issuecomment-640851454 for details
629-
if sess.parse_sess.assume_incomplete_release {
629+
if sess.psess.assume_incomplete_release {
630630
RustcVersion::CURRENT > min_version
631631
} else {
632632
RustcVersion::CURRENT >= min_version

compiler/rustc_builtin_macros/src/asm.rs

+7-10
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ use rustc_index::bit_set::GrowableBitSet;
1010
use rustc_parse::parser::Parser;
1111
use rustc_parse_format as parse;
1212
use rustc_session::lint;
13-
use rustc_session::parse::ParseSess;
1413
use rustc_span::symbol::Ident;
1514
use rustc_span::symbol::{kw, sym, Symbol};
1615
use rustc_span::{ErrorGuaranteed, InnerSpan, Span};
@@ -36,19 +35,17 @@ fn parse_args<'a>(
3635
is_global_asm: bool,
3736
) -> PResult<'a, AsmArgs> {
3837
let mut p = ecx.new_parser_from_tts(tts);
39-
let sess = &ecx.sess.parse_sess;
40-
parse_asm_args(&mut p, sess, sp, is_global_asm)
38+
parse_asm_args(&mut p, sp, is_global_asm)
4139
}
4240

4341
// Primarily public for rustfmt consumption.
4442
// Internal consumers should continue to leverage `expand_asm`/`expand__global_asm`
4543
pub fn parse_asm_args<'a>(
4644
p: &mut Parser<'a>,
47-
sess: &'a ParseSess,
4845
sp: Span,
4946
is_global_asm: bool,
5047
) -> PResult<'a, AsmArgs> {
51-
let dcx = &sess.dcx;
48+
let dcx = &p.psess.dcx;
5249

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

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

373370
if p.eat(&token::CloseDelim(Delimiter::Parenthesis)) {
374-
return Err(p.sess.dcx.create_err(errors::NonABI { span: p.token.span }));
371+
return Err(p.psess.dcx.create_err(errors::NonABI { span: p.token.span }));
375372
}
376373

377374
let mut new_abis = Vec::new();
@@ -382,7 +379,7 @@ fn parse_clobber_abi<'a>(p: &mut Parser<'a>, args: &mut AsmArgs) -> PResult<'a,
382379
}
383380
Err(opt_lit) => {
384381
let span = opt_lit.map_or(p.token.span, |lit| lit.span);
385-
let mut err = p.sess.dcx.struct_span_err(span, "expected string literal");
382+
let mut err = p.psess.dcx.struct_span_err(span, "expected string literal");
386383
err.span_label(span, "not a string literal");
387384
return Err(err);
388385
}
@@ -498,15 +495,15 @@ fn expand_preparsed_asm(
498495
};
499496

500497
if template_str.contains(".intel_syntax") {
501-
ecx.parse_sess().buffer_lint(
498+
ecx.psess().buffer_lint(
502499
lint::builtin::BAD_ASM_STYLE,
503500
find_span(".intel_syntax"),
504501
ecx.current_expansion.lint_node_id,
505502
"avoid using `.intel_syntax`, Intel syntax is the default",
506503
);
507504
}
508505
if template_str.contains(".att_syntax") {
509-
ecx.parse_sess().buffer_lint(
506+
ecx.psess().buffer_lint(
510507
lint::builtin::BAD_ASM_STYLE,
511508
find_span(".att_syntax"),
512509
ecx.current_expansion.lint_node_id,

compiler/rustc_builtin_macros/src/cfg_accessible.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ impl MultiItemModifier for Expander {
4646
) -> ExpandResult<Vec<Annotatable>, Annotatable> {
4747
let template = AttributeTemplate { list: Some("path"), ..Default::default() };
4848
validate_attr::check_builtin_meta_item(
49-
&ecx.sess.parse_sess,
49+
&ecx.sess.psess,
5050
meta_item,
5151
ast::AttrStyle::Outer,
5252
sym::cfg_accessible,

compiler/rustc_builtin_macros/src/cfg_eval.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,7 @@ impl CfgEval<'_, '_> {
195195
// Re-parse the tokens, setting the `capture_cfg` flag to save extra information
196196
// to the captured `AttrTokenStream` (specifically, we capture
197197
// `AttrTokenTree::AttributesData` for all occurrences of `#[cfg]` and `#[cfg_attr]`)
198-
let mut parser =
199-
rustc_parse::stream_to_parser(&self.cfg.sess.parse_sess, orig_tokens, None);
198+
let mut parser = rustc_parse::stream_to_parser(&self.cfg.sess.psess, orig_tokens, None);
200199
parser.capture_cfg = true;
201200
match parse_annotatable_with(&mut parser) {
202201
Ok(a) => annotatable = a,

compiler/rustc_builtin_macros/src/cmdline_attrs.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ use rustc_ast::{self as ast, AttrItem, AttrStyle};
77
use rustc_session::parse::ParseSess;
88
use rustc_span::FileName;
99

10-
pub fn inject(krate: &mut ast::Crate, parse_sess: &ParseSess, attrs: &[String]) {
10+
pub fn inject(krate: &mut ast::Crate, psess: &ParseSess, attrs: &[String]) {
1111
for raw_attr in attrs {
1212
let mut parser = rustc_parse::new_parser_from_source_str(
13-
parse_sess,
13+
psess,
1414
FileName::cli_crate_attr_source_code(raw_attr),
1515
raw_attr.clone(),
1616
);
@@ -25,12 +25,12 @@ pub fn inject(krate: &mut ast::Crate, parse_sess: &ParseSess, attrs: &[String])
2525
};
2626
let end_span = parser.token.span;
2727
if parser.token != token::Eof {
28-
parse_sess.dcx.emit_err(errors::InvalidCrateAttr { span: start_span.to(end_span) });
28+
psess.dcx.emit_err(errors::InvalidCrateAttr { span: start_span.to(end_span) });
2929
continue;
3030
}
3131

3232
krate.attrs.push(mk_attr(
33-
&parse_sess.attr_id_generator,
33+
&psess.attr_id_generator,
3434
AttrStyle::Inner,
3535
path,
3636
args,

compiler/rustc_builtin_macros/src/concat.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ pub fn expand_concat(
4343
guar = Some(guarantee);
4444
}
4545
Err(err) => {
46-
guar = Some(report_lit_error(&cx.sess.parse_sess, err, token_lit, e.span));
46+
guar = Some(report_lit_error(&cx.sess.psess, err, token_lit, e.span));
4747
}
4848
},
4949
// We also want to allow negative numeric literals.
@@ -52,7 +52,7 @@ pub fn expand_concat(
5252
Ok(LitKind::Int(i, _)) => accumulator.push_str(&format!("-{i}")),
5353
Ok(LitKind::Float(f, _)) => accumulator.push_str(&format!("-{f}")),
5454
Err(err) => {
55-
guar = Some(report_lit_error(&cx.sess.parse_sess, err, token_lit, e.span));
55+
guar = Some(report_lit_error(&cx.sess.psess, err, token_lit, e.span));
5656
}
5757
_ => missing_literal.push(e.span),
5858
}

compiler/rustc_builtin_macros/src/concat_bytes.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ fn invalid_type_err(
5555
Ok(LitKind::Int(_, _)) => dcx.emit_err(ConcatBytesNonU8 { span }),
5656
Ok(LitKind::ByteStr(..) | LitKind::Byte(_)) => unreachable!(),
5757
Ok(LitKind::Err(guar)) => guar,
58-
Err(err) => report_lit_error(&cx.sess.parse_sess, err, token_lit, span),
58+
Err(err) => report_lit_error(&cx.sess.psess, err, token_lit, span),
5959
}
6060
}
6161

compiler/rustc_builtin_macros/src/derive.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ impl MultiItemModifier for Expander {
3434
let template =
3535
AttributeTemplate { list: Some("Trait1, Trait2, ..."), ..Default::default() };
3636
validate_attr::check_builtin_meta_item(
37-
&sess.parse_sess,
37+
&sess.psess,
3838
meta_item,
3939
ast::AttrStyle::Outer,
4040
sym::derive,

compiler/rustc_builtin_macros/src/deriving/generic/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1624,7 +1624,7 @@ impl<'a> TraitDef<'a> {
16241624
};
16251625

16261626
if let Some(ty) = exception {
1627-
cx.sess.parse_sess.buffer_lint_with_diagnostic(
1627+
cx.sess.psess.buffer_lint_with_diagnostic(
16281628
BYTE_SLICE_IN_PACKED_STRUCT_WITH_DERIVE,
16291629
sp,
16301630
ast::CRATE_NODE_ID,

compiler/rustc_builtin_macros/src/env.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ pub fn expand_option_env<'cx>(
3939

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

9595
let span = cx.with_def_site_ctxt(sp);
9696
let value = lookup_env(cx, var);
97-
cx.sess.parse_sess.env_depinfo.borrow_mut().insert((var, value));
97+
cx.sess.psess.env_depinfo.borrow_mut().insert((var, value));
9898
let e = match value {
9999
None => {
100100
let ExprKind::Lit(token::Lit {

compiler/rustc_builtin_macros/src/source_util.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ pub fn expand_include<'cx>(
118118
return DummyResult::any(sp, guar);
119119
}
120120
};
121-
let p = new_parser_from_file(cx.parse_sess(), &file, Some(sp));
121+
let p = new_parser_from_file(cx.psess(), &file, Some(sp));
122122

123123
// If in the included file we have e.g., `mod bar;`,
124124
// then the path of `bar.rs` should be relative to the directory of `file`.
@@ -136,7 +136,7 @@ pub fn expand_include<'cx>(
136136
fn make_expr(mut self: Box<ExpandResult<'a>>) -> Option<P<ast::Expr>> {
137137
let expr = parse_expr(&mut self.p).ok()?;
138138
if self.p.token != token::Eof {
139-
self.p.sess.buffer_lint(
139+
self.p.psess.buffer_lint(
140140
INCOMPLETE_INCLUDE,
141141
self.p.token.span,
142142
self.node_id,

compiler/rustc_builtin_macros/src/standard_library_imports.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub fn inject(
1717
features: &Features,
1818
) -> usize {
1919
let orig_num_items = krate.items.len();
20-
let edition = sess.parse_sess.edition;
20+
let edition = sess.psess.edition;
2121

2222
// the first name in this list is the crate name of the crate with the prelude
2323
let names: &[Symbol] = if attr::contains_name(pre_configured_attrs, sym::no_core) {

compiler/rustc_builtin_macros/src/test_harness.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ struct InnerItemLinter<'a> {
159159
impl<'a> Visitor<'a> for InnerItemLinter<'_> {
160160
fn visit_item(&mut self, i: &'a ast::Item) {
161161
if let Some(attr) = attr::find_by_name(&i.attrs, sym::rustc_test_marker) {
162-
self.sess.parse_sess.buffer_lint(
162+
self.sess.psess.buffer_lint(
163163
UNNAMEABLE_TEST_ITEMS,
164164
attr.span,
165165
i.id,
@@ -200,7 +200,7 @@ impl<'a> MutVisitor for EntryPointCleaner<'a> {
200200
EntryPointType::MainNamed | EntryPointType::RustcMainAttr | EntryPointType::Start => {
201201
item.map(|ast::Item { id, ident, attrs, kind, vis, span, tokens }| {
202202
let allow_dead_code = attr::mk_attr_nested_word(
203-
&self.sess.parse_sess.attr_id_generator,
203+
&self.sess.psess.attr_id_generator,
204204
ast::AttrStyle::Outer,
205205
sym::allow,
206206
sym::dead_code,

compiler/rustc_builtin_macros/src/util.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ pub fn check_builtin_macro_attribute(ecx: &ExtCtxt<'_>, meta_item: &MetaItem, na
99
// All the built-in macro attributes are "words" at the moment.
1010
let template = AttributeTemplate { word: true, ..Default::default() };
1111
validate_attr::check_builtin_meta_item(
12-
&ecx.sess.parse_sess,
12+
&ecx.sess.psess,
1313
meta_item,
1414
AttrStyle::Outer,
1515
name,
@@ -37,7 +37,7 @@ pub fn warn_on_duplicate_attribute(ecx: &ExtCtxt<'_>, item: &Annotatable, name:
3737
};
3838
if let Some(attrs) = attrs {
3939
if let Some(attr) = attr::find_by_name(attrs, name) {
40-
ecx.parse_sess().buffer_lint(
40+
ecx.psess().buffer_lint(
4141
DUPLICATE_MACRO_ATTRIBUTES,
4242
attr.span,
4343
ecx.current_expansion.lint_node_id,

compiler/rustc_codegen_ssa/src/assert_module_sources.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ impl<'tcx> AssertModuleSource<'tcx> {
176176
/// Scan for a `cfg="foo"` attribute and check whether we have a
177177
/// cfg flag called `foo`.
178178
fn check_config(&self, attr: &ast::Attribute) -> bool {
179-
let config = &self.tcx.sess.parse_sess.config;
179+
let config = &self.tcx.sess.psess.config;
180180
let value = self.field(attr, sym::cfg);
181181
debug!("check_config(config={:?}, value={:?})", config, value);
182182
if config.iter().any(|&(name, _)| name == value) {

compiler/rustc_data_structures/src/sync/worker_local.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ pub struct Registry(Arc<RegistryData>);
4242
thread_local! {
4343
/// The registry associated with the thread.
4444
/// This allows the `WorkerLocal` type to clone the registry in its constructor.
45-
static REGISTRY: OnceCell<Registry> = OnceCell::new();
45+
static REGISTRY: OnceCell<Registry> = const { OnceCell::new() };
4646
}
4747

4848
struct ThreadData {

0 commit comments

Comments
 (0)