Skip to content

Commit 324fa7b

Browse files
Make rustc_attr_parsing::eval_config_entry take impl CfgMatchesLintEmitter instead of NodeId
1 parent dcedf5a commit 324fa7b

File tree

6 files changed

+13
-13
lines changed

6 files changed

+13
-13
lines changed

compiler/rustc_attr_parsing/src/attributes/cfg.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use rustc_ast::token::Delimiter;
22
use rustc_ast::tokenstream::DelimSpan;
3-
use rustc_ast::{AttrItem, Attribute, CRATE_NODE_ID, LitKind, NodeId, ast, token};
3+
use rustc_ast::{AttrItem, Attribute, CRATE_NODE_ID, LitKind, ast, token};
44
use rustc_errors::{Applicability, PResult};
55
use rustc_feature::{AttrSuggestionStyle, AttributeTemplate, Features, template};
66
use rustc_hir::attrs::CfgEntry;
@@ -199,14 +199,14 @@ pub(crate) fn parse_name_value<S: Stage>(
199199
pub fn eval_config_entry(
200200
sess: &Session,
201201
cfg_entry: &CfgEntry,
202-
id: NodeId,
202+
lint_emitter: &impl CfgMatchesLintEmitter,
203203
emit_lints: ShouldEmit,
204204
) -> EvalConfigResult {
205205
match cfg_entry {
206206
CfgEntry::All(subs, ..) => {
207207
let mut all = None;
208208
for sub in subs {
209-
let res = eval_config_entry(sess, sub, id, emit_lints);
209+
let res = eval_config_entry(sess, sub, lint_emitter, emit_lints);
210210
// We cannot short-circuit because `eval_config_entry` emits some lints
211211
if !res.as_bool() {
212212
all.get_or_insert(res);
@@ -217,7 +217,7 @@ pub fn eval_config_entry(
217217
CfgEntry::Any(subs, span) => {
218218
let mut any = None;
219219
for sub in subs {
220-
let res = eval_config_entry(sess, sub, id, emit_lints);
220+
let res = eval_config_entry(sess, sub, lint_emitter, emit_lints);
221221
// We cannot short-circuit because `eval_config_entry` emits some lints
222222
if res.as_bool() {
223223
any.get_or_insert(res);
@@ -229,7 +229,7 @@ pub fn eval_config_entry(
229229
})
230230
}
231231
CfgEntry::Not(sub, span) => {
232-
if eval_config_entry(sess, sub, id, emit_lints).as_bool() {
232+
if eval_config_entry(sess, sub, lint_emitter, emit_lints).as_bool() {
233233
EvalConfigResult::False { reason: cfg_entry.clone(), reason_span: *span }
234234
} else {
235235
EvalConfigResult::True
@@ -248,15 +248,15 @@ pub fn eval_config_entry(
248248
Some(ExpectedValues::Some(values))
249249
if !values.contains(&value.map(|(v, _)| v)) =>
250250
{
251-
id.emit_span_lint(
251+
lint_emitter.emit_span_lint(
252252
sess,
253253
UNEXPECTED_CFGS,
254254
*span,
255255
BuiltinLintDiag::UnexpectedCfgValue((*name, *name_span), *value),
256256
);
257257
}
258258
None if sess.psess.check_config.exhaustive_names => {
259-
id.emit_span_lint(
259+
lint_emitter.emit_span_lint(
260260
sess,
261261
UNEXPECTED_CFGS,
262262
*span,

compiler/rustc_builtin_macros/src/cfg.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ pub(crate) fn expand_cfg(
2929
let matches_cfg = attr::eval_config_entry(
3030
cx.sess,
3131
&cfg,
32-
cx.current_expansion.lint_node_id,
32+
&cx.current_expansion.lint_node_id,
3333
ShouldEmit::ErrorsAndLints,
3434
)
3535
.as_bool();

compiler/rustc_builtin_macros/src/cfg_select.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ fn select_arm(ecx: &ExtCtxt<'_>, branches: CfgSelectBranches) -> Option<(TokenSt
1515
if let EvalConfigResult::True = attr::eval_config_entry(
1616
&ecx.sess,
1717
&cfg,
18-
ecx.current_expansion.lint_node_id,
18+
&ecx.current_expansion.lint_node_id,
1919
ShouldEmit::ErrorsAndLints,
2020
) {
2121
// FIXME(#149215) Ideally we should short-circuit here, but `eval_config_entry` currently emits lints so we cannot do this yet.

compiler/rustc_codegen_ssa/src/back/link.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3030,7 +3030,7 @@ fn add_dynamic_crate(cmd: &mut dyn Linker, sess: &Session, cratepath: &Path) {
30303030
fn relevant_lib(sess: &Session, lib: &NativeLib) -> bool {
30313031
match lib.cfg {
30323032
Some(ref cfg) => {
3033-
eval_config_entry(sess, cfg, CRATE_NODE_ID, ShouldEmit::ErrorsAndLints).as_bool()
3033+
eval_config_entry(sess, cfg, &CRATE_NODE_ID, ShouldEmit::ErrorsAndLints).as_bool()
30343034
}
30353035
None => true,
30363036
}

compiler/rustc_expand/src/config.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ impl<'a> StripUnconfigured<'a> {
321321
if !attr::eval_config_entry(
322322
self.sess,
323323
&cfg_predicate,
324-
ast::CRATE_NODE_ID,
324+
&ast::CRATE_NODE_ID,
325325
ShouldEmit::ErrorsAndLints,
326326
)
327327
.as_bool()
@@ -442,7 +442,7 @@ impl<'a> StripUnconfigured<'a> {
442442
return EvalConfigResult::True;
443443
};
444444

445-
eval_config_entry(self.sess, &cfg, self.lint_node_id, emit_errors)
445+
eval_config_entry(self.sess, &cfg, &self.lint_node_id, emit_errors)
446446
}
447447

448448
/// If attributes are not allowed on expressions, emit an error for `attr`

compiler/rustc_metadata/src/native_libs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ pub(crate) fn collect(tcx: TyCtxt<'_>, LocalCrate: LocalCrate) -> Vec<NativeLib>
189189
pub(crate) fn relevant_lib(sess: &Session, lib: &NativeLib) -> bool {
190190
match lib.cfg {
191191
Some(ref cfg) => {
192-
eval_config_entry(sess, cfg, CRATE_NODE_ID, ShouldEmit::ErrorsAndLints).as_bool()
192+
eval_config_entry(sess, cfg, &CRATE_NODE_ID, ShouldEmit::ErrorsAndLints).as_bool()
193193
}
194194
None => true,
195195
}

0 commit comments

Comments
 (0)