Skip to content

Commit ad3d0bc

Browse files
committed
Auto merge of #160284 - JonathanBrouwer:rollup-Jwar7OO, r=JonathanBrouwer
Rollup of 22 pull requests Successful merges: - #160100 (Add "system" option to `override-allocator` directive) - #160220 (Refactor: shrink region ext traits) - #159675 (rustc: Support `--jobs` options for limiting parallelism in various parts of the compiler) - #159999 (Fix invalidation of stdlib in bootstrap when using non-LLVM codegen backends) - #160233 (Bubble bad path error while parsing field to avoid unecessary second error) - #160272 (rustc_metadata: Move native library search code to `rustc_codegen_ssa`) - #154202 (rustfmt: Format `cfg_select!`) - #159520 (Suggest `Vec<T>` instead of `[T]`) - #159710 (Add rustdoc/cargo PGO profiles to reproducible artifacts) - #160034 (Move "macro only" check for `#[allow_internal_unsafe/unstable]` to attribute parser) - #160066 (rustc_middle: lint attribute cleanups) - #160085 (Remove various superfluous lint attributes) - #160113 (Coalesce `rustc_on_unimplemented` attributes and lint malformed filters) - #160119 (fix query cycle in `coroutine_hidden_types` for the next solver) - #160147 (tests: Remove `-Zthreads` options from tests in `ui/parallel-rustc`) - #160157 (Remove outdated comments from `va_list.rs`) - #160159 (More accurately check for interior mutability in `invalid_reference_casting` lint) - #160208 (rustdoc: Fix crash when trying to list attributes on an opaque type) - #160244 (Rename splat to rustc_splat in error messages) - #160246 (dont fire `unused_mut` on `&pin mut self`) - #160247 (Configure backport nominations for rustfmt) - #160274 (renovate: update lock files weekly)
2 parents 64af19d + 8ac3904 commit ad3d0bc

234 files changed

Lines changed: 4622 additions & 1128 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.

.github/renovate.json5

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@
55
"github>rust-lang/renovate:actions",
66
// Open a PR to migrate the config when Renovate deprecates syntax
77
":configMigration",
8-
// Refresh lock files on the first day of each month
9-
// (still gated by dashboard approval for now)
10-
":maintainLockFilesMonthly",
8+
// Refresh lock files weekly
9+
":maintainLockFilesWeekly",
1110
],
1211
// Cargo manifests in this repository use unstable features.
1312
"env": {
@@ -30,6 +29,11 @@
3029
"matchManagers": ["github-actions"],
3130
"dependencyDashboardApproval": false
3231
},
32+
{
33+
// No dashboard approval necessary for lock file maintenance
34+
"matchUpdateTypes": ["lockFileMaintenance"],
35+
"dependencyDashboardApproval": false
36+
},
3337
{
3438
// Update all Cargo.lock files except library/Cargo.lock in one PR.
3539
"matchManagers": ["cargo"],

Cargo.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4355,6 +4355,7 @@ version = "0.0.0"
43554355
dependencies = [
43564356
"fluent-bundle",
43574357
"fluent-syntax",
4358+
"indexmap",
43584359
"proc-macro2",
43594360
"quote",
43604361
"syn",

INSTALL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ See [the rustc-dev-guide for more info][sysllvm].
9696
--set llvm.libzstd=true \
9797
--set llvm.ninja=false \
9898
--set rust.debug-assertions=false \
99-
--set rust.override-allocator=jemalloc \
99+
--set build.allocator=jemalloc \
100100
--set rust.bootstrap-override-lld=true \
101101
--set rust.lto=thin \
102102
--set rust.codegen-units=1

bootstrap.example.toml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,12 @@
544544
# For example, exclude = ["tests/ui", "src/tools/tidy"].
545545
#build.exclude = []
546546

547+
# Link the compiler and LLVM against the specified allocator instead of the default libc allocator.
548+
# This option is only tested on Linux and OSX. It can also be configured per-target in the
549+
# [target.<tuple>] section.
550+
# Possible options: "system" (default), "jemalloc"
551+
#build.allocator = "jemalloc"
552+
547553
# =============================================================================
548554
# General install configuration options
549555
# =============================================================================
@@ -859,15 +865,9 @@
859865
# Useful for reproducible builds. Generally only set for releases
860866
#rust.remap-debuginfo = false
861867

862-
# Link the compiler and LLVM against the specified allocator instead of the default libc allocator.
863-
# This option is only tested on Linux and OSX. It can also be configured per-target in the
864-
# [target.<tuple>] section.
865-
# Possible options: "jemalloc"
866-
#rust.override-allocator = "jemalloc"
867-
868-
# Deprecated alias for `rust.override-allocator`. Setting this to `true` is
869-
# equivalent to `rust.override-allocator = "jemalloc"`. If both are set, they
870-
# must agree.
868+
# Deprecated alias for `build.allocator`. Setting this to `true` is
869+
# equivalent to `build.allocator = "jemalloc"`. Both cannot be set in the same section
870+
# (`rust` or `target.[target]`)
871871
#rust.jemalloc = false
872872

873873
# Run tests in various test suites with the "nll compare mode" in addition to
@@ -1177,10 +1177,10 @@
11771177
#optimized-compiler-builtins = build.optimized-compiler-builtins (bool or path)
11781178

11791179
# Link the compiler and LLVM against the specified allocator instead of the default libc allocator.
1180-
# This overrides the global `rust.override-allocator` option. See that option for more info.
1181-
#override-allocator = rust.override-allocator (string)
1180+
# This overrides the global `build.allocator` option. See that option for more info.
1181+
#allocator = build.allocator (string)
11821182

1183-
# Deprecated alias for `override-allocator`. See `rust.jemalloc` for more info.
1183+
# Deprecated alias for `allocator`. See `rust.jemalloc` for more info.
11841184
#jemalloc = rust.jemalloc (bool)
11851185

11861186
# The linker configuration that will *override* the default linker used for Linux

compiler/rustc_ast/src/ast.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3008,7 +3008,7 @@ impl Param {
30083008
}),
30093009
),
30103010
SelfKind::Pinned(lt, mutbl) => (
3011-
mutbl,
3011+
Mutability::Not,
30123012
Box::new(Ty {
30133013
id: DUMMY_NODE_ID,
30143014
kind: TyKind::PinnedRef(lt, MutTy { ty: infer_ty, mutbl }),

compiler/rustc_attr_parsing/src/attributes/allow_unstable.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use std::iter;
22

33
use rustc_feature::AttributeStability;
44

5+
use super::macro_attrs::check_macro_only;
56
use super::prelude::*;
67
use crate::session_diagnostics;
78

@@ -28,6 +29,10 @@ impl CombineAttributeParser for AllowInternalUnstableParser {
2829
.into_iter()
2930
.zip(iter::repeat(cx.attr_span))
3031
}
32+
33+
fn finalize_check(cx: &FinalizeCheckContext<'_, '_>, attr_span: Span) {
34+
check_macro_only(cx, attr_span);
35+
}
3136
}
3237

3338
pub(crate) struct UnstableFeatureBoundParser;

compiler/rustc_attr_parsing/src/attributes/diagnostic/mod.rs

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@ use rustc_parse_format::{
88
Argument, FormatSpec, ParseError, ParseMode, Parser, Piece as RpfPiece, Position,
99
};
1010
use rustc_session::lint::builtin::{
11-
MALFORMED_DIAGNOSTIC_ATTRIBUTES, MALFORMED_DIAGNOSTIC_FORMAT_LITERALS,
11+
MALFORMED_DIAGNOSTIC_ATTRIBUTES, MALFORMED_DIAGNOSTIC_FILTERS,
12+
MALFORMED_DIAGNOSTIC_FORMAT_LITERALS,
1213
};
1314
use rustc_span::{Ident, InnerSpan, Span, Symbol, kw, sym};
1415
use thin_vec::{ThinVec, thin_vec};
1516

1617
use crate::context::AcceptContext;
1718
use crate::diagnostics::{
18-
DupesNotAllowed, FormatWarning, IgnoredDiagnosticOption, InvalidOnClause,
19-
MalFormedDiagnosticAttributeLint, MissingOptionsForDiagnosticAttribute,
20-
NonMetaItemDiagnosticAttribute, WrappedParserError,
19+
FormatWarning, IgnoredDiagnosticOption, InvalidOnClause, MalFormedDiagnosticAttributeLint,
20+
MissingOptionsForDiagnosticAttribute, NonMetaItemDiagnosticAttribute, WrappedParserError,
2121
};
2222
use crate::parser::{ArgParser, MetaItemListParser, MetaItemOrLitParser, MetaItemParser};
2323

@@ -129,13 +129,14 @@ fn merge_directives(
129129
later: (Span, Directive),
130130
) {
131131
if let Some((_, first)) = first {
132-
if first.is_rustc_attr || later.1.is_rustc_attr {
133-
cx.emit_err(DupesNotAllowed);
134-
}
135-
136-
merge(cx, &mut first.message, later.1.message, sym::message);
137-
merge(cx, &mut first.label, later.1.label, sym::label);
138-
first.notes.extend(later.1.notes);
132+
let Directive { is_rustc_attr, filters, message, label, notes, parent_label } = later.1;
133+
134+
first.is_rustc_attr |= is_rustc_attr;
135+
first.filters.extend(filters);
136+
merge(cx, &mut first.message, message, sym::message);
137+
merge(cx, &mut first.label, label, sym::label);
138+
first.notes.extend(notes);
139+
merge(cx, &mut first.parent_label, parent_label, sym::parent_label);
139140
} else {
140141
*first = Some(later);
141142
}
@@ -215,7 +216,7 @@ fn parse_directive_items<'p>(
215216
let mut message: Option<(Span, _)> = None;
216217
let mut label: Option<(Span, _)> = None;
217218
let mut notes = ThinVec::new();
218-
let mut parent_label = None;
219+
let mut parent_label: Option<(Span, FormatString)> = None;
219220
let mut filters = ThinVec::new();
220221

221222
for item in items {
@@ -346,10 +347,11 @@ fn parse_directive_items<'p>(
346347
}
347348
(Mode::RustcOnUnimplemented, sym::parent_label) => {
348349
let value = or_malformed!(value?);
349-
if parent_label.is_none() {
350-
parent_label = Some(parse_format(value));
350+
if let Some(parent_label) = &parent_label {
351+
duplicate!(name, parent_label.0)
351352
} else {
352-
duplicate!(name, span)
353+
let format = parse_format(value);
354+
parent_label = Some((format.span, format));
353355
}
354356
}
355357
(Mode::RustcOnUnimplemented, sym::on) => {
@@ -359,7 +361,11 @@ fn parse_directive_items<'p>(
359361
let filter = if let Some(c) = iter.next() {
360362
c
361363
} else {
362-
cx.emit_err(InvalidOnClause::Empty { span });
364+
cx.emit_lint(
365+
MALFORMED_DIAGNOSTIC_FILTERS,
366+
InvalidOnClause::Empty { span },
367+
span,
368+
);
363369
continue;
364370
};
365371

@@ -378,7 +384,7 @@ fn parse_directive_items<'p>(
378384
filters.push((filter, directive));
379385
}
380386
Err(e) => {
381-
cx.emit_err(e);
387+
cx.emit_lint(MALFORMED_DIAGNOSTIC_FILTERS, e, span);
382388
}
383389
}
384390
} else {

compiler/rustc_attr_parsing/src/attributes/macro_attrs.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
use rustc_feature::AttributeStability;
22
use rustc_hir::attrs::{CollapseMacroDebuginfo, MacroUseArgs};
3+
use rustc_hir::find_attr;
34
use rustc_session::lint::builtin::INVALID_MACRO_EXPORT_ARGUMENTS;
45

56
use super::prelude::*;
7+
use crate::session_diagnostics::MacroOnlyAttribute;
68

79
pub(crate) struct MacroEscapeParser;
810
impl NoArgsAttributeParser for MacroEscapeParser {
@@ -113,6 +115,17 @@ impl AttributeParser for MacroUseParser {
113115
}
114116
}
115117

118+
/// `#[allow_internal_unsafe]` and `#[allow_internal_unstable]` may only be applied to macros.
119+
/// Applying them to a function is only allowed if that function is a procedural macro, i.e. it
120+
/// also carries `#[proc_macro]`, `#[proc_macro_attribute]`, or `#[proc_macro_derive]`.
121+
pub(crate) fn check_macro_only(cx: &FinalizeCheckContext<'_, '_>, attr_span: Span) {
122+
if cx.target == Target::Fn
123+
&& !find_attr!(cx.parsed_attrs, ProcMacro | ProcMacroAttribute | ProcMacroDerive { .. })
124+
{
125+
cx.emit_err(MacroOnlyAttribute { attr_span, span: cx.target_span });
126+
}
127+
}
128+
116129
pub(crate) struct AllowInternalUnsafeParser;
117130

118131
impl NoArgsAttributeParser for AllowInternalUnsafeParser {
@@ -126,6 +139,10 @@ impl NoArgsAttributeParser for AllowInternalUnsafeParser {
126139
]);
127140
const STABILITY: AttributeStability = unstable!(allow_internal_unsafe);
128141
const CREATE: fn(Span) -> AttributeKind = |span| AttributeKind::AllowInternalUnsafe(span);
142+
143+
fn finalize_check(cx: &FinalizeCheckContext<'_, '_>, attr_span: Span) {
144+
check_macro_only(cx, attr_span);
145+
}
129146
}
130147

131148
pub(crate) struct MacroExportParser;

compiler/rustc_attr_parsing/src/diagnostics.rs

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use rustc_errors::{Applicability, DiagArgValue, E0232, E0264, MultiSpan};
1+
use rustc_errors::{Applicability, DiagArgValue, E0264, MultiSpan};
22
use rustc_hir::AttrPath;
33
use rustc_macros::{Diagnostic, Subdiagnostic};
44
use rustc_span::{Ident, Span, Symbol};
@@ -764,39 +764,39 @@ pub(crate) mod unexpected_cfg_value {
764764

765765
#[derive(Diagnostic)]
766766
pub(crate) enum InvalidOnClause {
767-
#[diag("empty `on`-clause in `#[rustc_on_unimplemented]`", code = E0232)]
767+
#[diag("empty `on`-clause in `#[rustc_on_unimplemented]`")]
768768
Empty {
769769
#[primary_span]
770770
#[label("empty `on`-clause here")]
771771
span: Span,
772772
},
773-
#[diag("expected a single predicate in `not(..)`", code = E0232)]
773+
#[diag("expected a single predicate in `not(..)`")]
774774
ExpectedOnePredInNot {
775775
#[primary_span]
776776
#[label("unexpected quantity of predicates here")]
777777
span: Span,
778778
},
779-
#[diag("literals inside `on`-clauses are not supported", code = E0232)]
779+
#[diag("literals inside `on`-clauses are not supported")]
780780
UnsupportedLiteral {
781781
#[primary_span]
782782
#[label("unexpected literal here")]
783783
span: Span,
784784
},
785-
#[diag("expected an identifier inside this `on`-clause", code = E0232)]
785+
#[diag("expected an identifier inside this `on`-clause")]
786786
ExpectedIdentifier {
787787
#[primary_span]
788788
#[label("expected an identifier here, not `{$path}`")]
789789
span: Span,
790790
path: AttrPath,
791791
},
792-
#[diag("this predicate is invalid", code = E0232)]
792+
#[diag("this predicate is invalid")]
793793
InvalidPredicate {
794794
#[primary_span]
795795
#[label("expected one of `any`, `all` or `not` here, not `{$invalid_pred}`")]
796796
span: Span,
797797
invalid_pred: Symbol,
798798
},
799-
#[diag("invalid flag in `on`-clause", code = E0232)]
799+
#[diag("invalid flag in `on`-clause")]
800800
InvalidFlag {
801801
#[primary_span]
802802
#[label(
@@ -807,12 +807,6 @@ pub(crate) enum InvalidOnClause {
807807
},
808808
}
809809

810-
#[derive(Diagnostic)]
811-
#[diag(
812-
"using multiple `rustc_on_unimplemented` (or mixing it with `diagnostic::on_unimplemented`) is not supported"
813-
)]
814-
pub(crate) struct DupesNotAllowed;
815-
816810
#[derive(Diagnostic)]
817811
#[diag("usage of the unsafe `{$attr_path}` attribute")]
818812
#[note("{$note}")]

compiler/rustc_attr_parsing/src/session_diagnostics.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,15 @@ pub(crate) struct RustcPubTransparent {
2929
pub span: Span,
3030
}
3131

32+
#[derive(Diagnostic)]
33+
#[diag("attribute should be applied to a macro")]
34+
pub(crate) struct MacroOnlyAttribute {
35+
#[primary_span]
36+
pub attr_span: Span,
37+
#[label("not a macro")]
38+
pub span: Span,
39+
}
40+
3241
#[derive(Diagnostic)]
3342
#[diag("{$attr_str} attribute cannot have empty value")]
3443
pub(crate) struct DocAliasEmpty<'a> {

0 commit comments

Comments
 (0)