Skip to content

Commit 3dcad10

Browse files
committed
Auto merge of #153026 - JonathanBrouwer:rollup-PAPpAYW, r=JonathanBrouwer
Rollup of 14 pull requests Successful merges: - #153007 (`rust-analyzer` subtree update) - #152670 (Simplify ThinLTO handling) - #152768 (Enable autodiff in ci for all major os) - #152908 (Enable rust.remap-debuginfo in the dist profile) - #152999 (Check importing `crate`/`$crate`/`super` after handling `self`) - #152003 (Reflection TypeId::trait_info_of) - #152976 (Revert relative paths for std links in rustc-docs) - #152985 (Port `#[feature]` to the new attribute system) - #152989 (Port `#[rustc_inherit_overflow_checks]` to the new attribute parsers) - #152991 (fix interpreter tracing output) - #153004 (Superficial tweaks to the query modifier docs in `rustc_middle::query::modifiers`) - #153008 (bootstrap.compiler.toml: update name of primary branch) - #153016 (Migration of `LintDiagnostic` - part 2) - #153020 (rustdoc: Improve sentence for documented empty impl blocks) Failed merges: - #152988 (Port `#[register_tool]` to the new attribute system)
2 parents b3869b9 + bea1d9c commit 3dcad10

170 files changed

Lines changed: 3220 additions & 1697 deletions

File tree

Some content is hidden

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

Cargo.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3515,6 +3515,7 @@ dependencies = [
35153515
"rustc_data_structures",
35163516
"rustc_errors",
35173517
"rustc_feature",
3518+
"rustc_hir",
35183519
"rustc_macros",
35193520
"rustc_session",
35203521
"rustc_span",

compiler/rustc_ast_passes/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ rustc_attr_parsing = { path = "../rustc_attr_parsing" }
1313
rustc_data_structures = { path = "../rustc_data_structures" }
1414
rustc_errors = { path = "../rustc_errors" }
1515
rustc_feature = { path = "../rustc_feature" }
16+
rustc_hir = { path = "../rustc_hir" }
1617
rustc_macros = { path = "../rustc_macros" }
1718
rustc_session = { path = "../rustc_session" }
1819
rustc_span = { path = "../rustc_span" }

compiler/rustc_ast_passes/src/feature_gate.rs

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
use rustc_ast::visit::{self, AssocCtxt, FnCtxt, FnKind, Visitor};
22
use rustc_ast::{self as ast, AttrVec, NodeId, PatKind, attr, token};
3+
use rustc_attr_parsing::AttributeParser;
34
use rustc_errors::msg;
45
use rustc_feature::{AttributeGate, BUILTIN_ATTRIBUTE_MAP, BuiltinAttribute, Features};
6+
use rustc_hir::Attribute;
7+
use rustc_hir::attrs::AttributeKind;
58
use rustc_session::Session;
69
use rustc_session::parse::{feature_err, feature_warn};
710
use rustc_span::source_map::Spanned;
8-
use rustc_span::{Span, Symbol, sym};
11+
use rustc_span::{DUMMY_SP, Span, Symbol, sym};
912
use thin_vec::ThinVec;
1013

1114
use crate::errors;
@@ -647,17 +650,27 @@ fn maybe_stage_features(sess: &Session, features: &Features, krate: &ast::Crate)
647650
return;
648651
}
649652
let mut errored = false;
650-
for attr in krate.attrs.iter().filter(|attr| attr.has_name(sym::feature)) {
653+
654+
if let Some(Attribute::Parsed(AttributeKind::Feature(feature_idents, first_span))) =
655+
AttributeParser::parse_limited(
656+
sess,
657+
&krate.attrs,
658+
sym::feature,
659+
DUMMY_SP,
660+
krate.id,
661+
Some(&features),
662+
)
663+
{
651664
// `feature(...)` used on non-nightly. This is definitely an error.
652665
let mut err = errors::FeatureOnNonNightly {
653-
span: attr.span,
666+
span: first_span,
654667
channel: option_env!("CFG_RELEASE_CHANNEL").unwrap_or("(unknown)"),
655668
stable_features: vec![],
656669
sugg: None,
657670
};
658671

659672
let mut all_stable = true;
660-
for ident in attr.meta_item_list().into_iter().flatten().flat_map(|nested| nested.ident()) {
673+
for ident in feature_idents {
661674
let name = ident.name;
662675
let stable_since = features
663676
.enabled_lang_features()
@@ -672,7 +685,7 @@ fn maybe_stage_features(sess: &Session, features: &Features, krate: &ast::Crate)
672685
}
673686
}
674687
if all_stable {
675-
err.sugg = Some(attr.span);
688+
err.sugg = Some(first_span);
676689
}
677690
sess.dcx().emit_err(err);
678691
errored = true;

compiler/rustc_attr_parsing/src/attributes/crate_level.rs

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,3 +301,49 @@ impl<S: Stage> NoArgsAttributeParser<S> for DefaultLibAllocatorParser {
301301
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Crate)]);
302302
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::DefaultLibAllocator;
303303
}
304+
305+
pub(crate) struct FeatureParser;
306+
307+
impl<S: Stage> CombineAttributeParser<S> for FeatureParser {
308+
const PATH: &[Symbol] = &[sym::feature];
309+
type Item = Ident;
310+
const CONVERT: ConvertFn<Self::Item> = AttributeKind::Feature;
311+
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Crate)]);
312+
const TEMPLATE: AttributeTemplate = template!(List: &["feature1, feature2, ..."]);
313+
314+
fn extend(
315+
cx: &mut AcceptContext<'_, '_, S>,
316+
args: &ArgParser,
317+
) -> impl IntoIterator<Item = Self::Item> {
318+
let ArgParser::List(list) = args else {
319+
cx.expected_list(cx.attr_span, args);
320+
return Vec::new();
321+
};
322+
323+
if list.is_empty() {
324+
cx.warn_empty_attribute(cx.attr_span);
325+
}
326+
327+
let mut res = Vec::new();
328+
329+
for elem in list.mixed() {
330+
let Some(elem) = elem.meta_item() else {
331+
cx.expected_identifier(elem.span());
332+
continue;
333+
};
334+
if let Err(arg_span) = elem.args().no_args() {
335+
cx.expected_no_args(arg_span);
336+
continue;
337+
}
338+
339+
let path = elem.path();
340+
let Some(ident) = path.word() else {
341+
cx.expected_identifier(path.span());
342+
continue;
343+
};
344+
res.push(ident);
345+
}
346+
347+
res
348+
}
349+
}

compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,20 @@ impl<S: Stage> SingleAttributeParser<S> for RustcLegacyConstGenericsParser {
175175
}
176176
}
177177

178+
pub(crate) struct RustcInheritOverflowChecksParser;
179+
180+
impl<S: Stage> NoArgsAttributeParser<S> for RustcInheritOverflowChecksParser {
181+
const PATH: &[Symbol] = &[sym::rustc_inherit_overflow_checks];
182+
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
183+
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
184+
Allow(Target::Fn),
185+
Allow(Target::Method(MethodKind::Inherent)),
186+
Allow(Target::Method(MethodKind::TraitImpl)),
187+
Allow(Target::Closure),
188+
]);
189+
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcInheritOverflowChecks;
190+
}
191+
178192
pub(crate) struct RustcLintOptDenyFieldAccessParser;
179193

180194
impl<S: Stage> SingleAttributeParser<S> for RustcLintOptDenyFieldAccessParser {

compiler/rustc_attr_parsing/src/context.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ attribute_parsers!(
157157
Combine<AllowInternalUnstableParser>,
158158
Combine<CrateTypeParser>,
159159
Combine<DebuggerViualizerParser>,
160+
Combine<FeatureParser>,
160161
Combine<ForceTargetFeatureParser>,
161162
Combine<LinkParser>,
162163
Combine<ReprParser>,
@@ -286,6 +287,7 @@ attribute_parsers!(
286287
Single<WithoutArgs<RustcEvaluateWhereClausesParser>>,
287288
Single<WithoutArgs<RustcHasIncoherentInherentImplsParser>>,
288289
Single<WithoutArgs<RustcHiddenTypeOfOpaquesParser>>,
290+
Single<WithoutArgs<RustcInheritOverflowChecksParser>>,
289291
Single<WithoutArgs<RustcInsignificantDtorParser>>,
290292
Single<WithoutArgs<RustcIntrinsicConstStableIndirectParser>>,
291293
Single<WithoutArgs<RustcIntrinsicParser>>,

compiler/rustc_borrowck/src/lib.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2698,7 +2698,12 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, '_, 'tcx> {
26982698

26992699
let mut_span = tcx.sess.source_map().span_until_non_whitespace(span);
27002700

2701-
tcx.emit_node_span_lint(UNUSED_MUT, lint_root, span, VarNeedNotMut { span: mut_span })
2701+
tcx.emit_diag_node_span_lint(
2702+
UNUSED_MUT,
2703+
lint_root,
2704+
span,
2705+
VarNeedNotMut { span: mut_span },
2706+
)
27022707
}
27032708
}
27042709
}

compiler/rustc_borrowck/src/session_diagnostics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ pub(crate) struct GenericDoesNotLiveLongEnough {
4747
pub span: Span,
4848
}
4949

50-
#[derive(LintDiagnostic)]
50+
#[derive(Diagnostic)]
5151
#[diag("variable does not need to be mutable")]
5252
pub(crate) struct VarNeedNotMut {
5353
#[suggestion(

compiler/rustc_codegen_gcc/src/lib.rs

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,7 @@ use rustc_codegen_ssa::back::write::{
8686
};
8787
use rustc_codegen_ssa::base::codegen_crate;
8888
use rustc_codegen_ssa::target_features::cfg_target_feature;
89-
use rustc_codegen_ssa::traits::{
90-
CodegenBackend, ExtraBackendMethods, ThinBufferMethods, WriteBackendMethods,
91-
};
89+
use rustc_codegen_ssa::traits::{CodegenBackend, ExtraBackendMethods, WriteBackendMethods};
9290
use rustc_codegen_ssa::{CodegenResults, CompiledModule, ModuleCodegen, TargetConfig};
9391
use rustc_data_structures::fx::FxIndexMap;
9492
use rustc_data_structures::profiling::SelfProfilerRef;
@@ -423,20 +421,11 @@ unsafe impl Send for SyncContext {}
423421
// FIXME(antoyo): that shouldn't be Sync. Parallel compilation is currently disabled with "CodegenBackend::supports_parallel()".
424422
unsafe impl Sync for SyncContext {}
425423

426-
pub struct ThinBuffer;
427-
428-
impl ThinBufferMethods for ThinBuffer {
429-
fn data(&self) -> &[u8] {
430-
&[]
431-
}
432-
}
433-
434424
impl WriteBackendMethods for GccCodegenBackend {
435425
type Module = GccContext;
436426
type TargetMachine = ();
437427
type ModuleBuffer = ModuleBuffer;
438428
type ThinData = ();
439-
type ThinBuffer = ThinBuffer;
440429

441430
fn run_and_optimize_fat_lto(
442431
cgcx: &CodegenContext,
@@ -458,7 +447,7 @@ impl WriteBackendMethods for GccCodegenBackend {
458447
// FIXME(bjorn3): Limit LTO exports to these symbols
459448
_exported_symbols_for_lto: &[String],
460449
_each_linked_rlib_for_lto: &[PathBuf],
461-
_modules: Vec<(String, Self::ThinBuffer)>,
450+
_modules: Vec<(String, Self::ModuleBuffer)>,
462451
_cached_modules: Vec<(SerializedModule<Self::ModuleBuffer>, WorkProduct)>,
463452
) -> (Vec<ThinModule<Self>>, Vec<WorkProduct>) {
464453
unreachable!()
@@ -502,11 +491,7 @@ impl WriteBackendMethods for GccCodegenBackend {
502491
back::write::codegen(cgcx, prof, shared_emitter, module, config)
503492
}
504493

505-
fn prepare_thin(_module: ModuleCodegen<Self::Module>) -> (String, Self::ThinBuffer) {
506-
unreachable!()
507-
}
508-
509-
fn serialize_module(_module: ModuleCodegen<Self::Module>) -> (String, Self::ModuleBuffer) {
494+
fn serialize_module(_module: Self::Module, _is_thin: bool) -> Self::ModuleBuffer {
510495
unimplemented!();
511496
}
512497
}

0 commit comments

Comments
 (0)