Skip to content

Commit 04a67d5

Browse files
committed
Auto merge of #141668 - tgross35:rollup-03gg6lf, r=tgross35
Rollup of 8 pull requests Successful merges: - #140367 (add `asm_cfg`: `#[cfg(...)]` within `asm!`) - #140894 (Make check-cfg diagnostics work in `#[doc(cfg(..))]`) - #141252 (gvn: bail out unavoidable non-ssa locals in repeat) - #141517 (rustdoc: use descriptive tooltip if doctest is conditionally ignored) - #141551 (Make two transmute-related MIR lints into HIR lint) - #141591 (ci: fix llvm test coverage) - #141647 (Bump master `stage0` compiler) - #141659 (Add `Result::map_or_default` and `Option::map_or_default`) r? `@ghost` `@rustbot` modify labels: rollup
2 parents be42293 + da61494 commit 04a67d5

Some content is hidden

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

53 files changed

+2143
-1351
lines changed

compiler/rustc_attr_parsing/src/attributes/cfg.rs

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,29 @@ use rustc_attr_data_structures::RustcVersion;
44
use rustc_feature::{Features, GatedCfg, find_gated_cfg};
55
use rustc_session::Session;
66
use rustc_session::config::ExpectedValues;
7-
use rustc_session::lint::BuiltinLintDiag;
87
use rustc_session::lint::builtin::UNEXPECTED_CFGS;
8+
use rustc_session::lint::{BuiltinLintDiag, Lint};
99
use rustc_session::parse::feature_err;
1010
use rustc_span::{Span, Symbol, sym};
1111

1212
use crate::session_diagnostics::{self, UnsupportedLiteralReason};
1313
use crate::{fluent_generated, parse_version};
1414

15+
/// Emitter of a builtin lint from `cfg_matches`.
16+
///
17+
/// Used to support emiting a lint (currently on check-cfg), either:
18+
/// - as an early buffered lint (in `rustc`)
19+
/// - or has a "normal" lint from HIR (in `rustdoc`)
20+
pub trait CfgMatchesLintEmitter {
21+
fn emit_span_lint(&self, sess: &Session, lint: &'static Lint, sp: Span, diag: BuiltinLintDiag);
22+
}
23+
24+
impl CfgMatchesLintEmitter for NodeId {
25+
fn emit_span_lint(&self, sess: &Session, lint: &'static Lint, sp: Span, diag: BuiltinLintDiag) {
26+
sess.psess.buffer_lint(lint, sp, *self, diag);
27+
}
28+
}
29+
1530
#[derive(Clone, Debug)]
1631
pub struct Condition {
1732
pub name: Symbol,
@@ -25,28 +40,28 @@ pub struct Condition {
2540
pub fn cfg_matches(
2641
cfg: &MetaItemInner,
2742
sess: &Session,
28-
lint_node_id: NodeId,
43+
lint_emitter: impl CfgMatchesLintEmitter,
2944
features: Option<&Features>,
3045
) -> bool {
3146
eval_condition(cfg, sess, features, &mut |cfg| {
3247
try_gate_cfg(cfg.name, cfg.span, sess, features);
3348
match sess.psess.check_config.expecteds.get(&cfg.name) {
3449
Some(ExpectedValues::Some(values)) if !values.contains(&cfg.value) => {
35-
sess.psess.buffer_lint(
50+
lint_emitter.emit_span_lint(
51+
sess,
3652
UNEXPECTED_CFGS,
3753
cfg.span,
38-
lint_node_id,
3954
BuiltinLintDiag::UnexpectedCfgValue(
4055
(cfg.name, cfg.name_span),
4156
cfg.value.map(|v| (v, cfg.value_span.unwrap())),
4257
),
4358
);
4459
}
4560
None if sess.psess.check_config.exhaustive_names => {
46-
sess.psess.buffer_lint(
61+
lint_emitter.emit_span_lint(
62+
sess,
4763
UNEXPECTED_CFGS,
4864
cfg.span,
49-
lint_node_id,
5065
BuiltinLintDiag::UnexpectedCfgName(
5166
(cfg.name, cfg.name_span),
5267
cfg.value.map(|v| (v, cfg.value_span.unwrap())),

compiler/rustc_builtin_macros/messages.ftl

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
builtin_macros_alloc_error_must_be_fn = alloc_error_handler must be a function
22
builtin_macros_alloc_must_statics = allocators must be statics
33
4+
builtin_macros_asm_attribute_not_supported =
5+
this attribute is not supported on assembly
6+
builtin_macros_asm_cfg =
7+
the `#[cfg(/* ... */)]` and `#[cfg_attr(/* ... */)]` attributes on assembly are unstable
8+
49
builtin_macros_asm_clobber_abi = clobber_abi
510
builtin_macros_asm_clobber_no_reg = asm with `clobber_abi` must specify explicit registers for outputs
611
builtin_macros_asm_clobber_outputs = generic outputs
@@ -9,17 +14,6 @@ builtin_macros_asm_duplicate_arg = duplicate argument named `{$name}`
914
.label = previously here
1015
.arg = duplicate argument
1116
12-
builtin_macros_asm_expected_comma = expected token: `,`
13-
.label = expected `,`
14-
15-
builtin_macros_asm_expected_other = expected operand, {$is_inline_asm ->
16-
[false] options
17-
*[true] clobber_abi, options
18-
}, or additional template string
19-
20-
builtin_macros_asm_expected_string_literal = expected string literal
21-
.label = not a string literal
22-
2317
builtin_macros_asm_explicit_register_name = explicit register arguments cannot have names
2418
2519
builtin_macros_asm_mayunwind = asm labels are not allowed with the `may_unwind` option
@@ -45,17 +39,8 @@ builtin_macros_asm_pure_combine = the `pure` option must be combined with either
4539
4640
builtin_macros_asm_pure_no_output = asm with the `pure` option must have at least one output
4741
48-
builtin_macros_asm_requires_template = requires at least a template string argument
49-
50-
builtin_macros_asm_sym_no_path = expected a path for argument to `sym`
51-
52-
builtin_macros_asm_underscore_input = _ cannot be used for input operands
53-
5442
builtin_macros_asm_unsupported_clobber_abi = `clobber_abi` cannot be used with `{$macro_name}!`
5543
56-
builtin_macros_asm_unsupported_operand = the `{$symbol}` operand cannot be used with `{$macro_name}!`
57-
.label = the `{$symbol}` operand is not meaningful for global-scoped inline assembly, remove it
58-
5944
builtin_macros_asm_unsupported_option = the `{$symbol}` option cannot be used with `{$macro_name}!`
6045
.label = the `{$symbol}` option is not meaningful for global-scoped inline assembly
6146
.suggestion = remove this option
@@ -162,7 +147,10 @@ builtin_macros_expected_comma_in_list = expected token: `,`
162147
163148
builtin_macros_expected_one_cfg_pattern = expected 1 cfg-pattern
164149
165-
builtin_macros_expected_register_class_or_explicit_register = expected register class or explicit register
150+
builtin_macros_expected_other = expected operand, {$is_inline_asm ->
151+
[false] options
152+
*[true] clobber_abi, options
153+
}, or additional template string
166154
167155
builtin_macros_export_macro_rules = cannot export macro_rules! macros from a `proc-macro` crate type currently
168156
@@ -255,8 +243,6 @@ builtin_macros_no_default_variant = `#[derive(Default)]` on enum with no `#[defa
255243
.label = this enum needs a unit variant marked with `#[default]`
256244
.suggestion = make this unit variant default by placing `#[default]` on it
257245
258-
builtin_macros_non_abi = at least one abi must be provided as an argument to `clobber_abi`
259-
260246
builtin_macros_non_exhaustive_default = default variant must be exhaustive
261247
.label = declared `#[non_exhaustive]` here
262248
.help = consider a manual implementation of `Default`

0 commit comments

Comments
 (0)