@@ -9,7 +9,7 @@ use rustc_macros::HashStable_Generic;
9
9
use rustc_session:: config:: ExpectedValues ;
10
10
use rustc_session:: lint:: builtin:: UNEXPECTED_CFGS ;
11
11
use rustc_session:: lint:: BuiltinLintDiagnostics ;
12
- use rustc_session:: parse:: { feature_err, ParseSess } ;
12
+ use rustc_session:: parse:: feature_err;
13
13
use rustc_session:: { RustcVersion , Session } ;
14
14
use rustc_span:: hygiene:: Transparency ;
15
15
use rustc_span:: { symbol:: sym, symbol:: Symbol , Span } ;
@@ -518,15 +518,15 @@ pub struct Condition {
518
518
/// Tests if a cfg-pattern matches the cfg set
519
519
pub fn cfg_matches (
520
520
cfg : & ast:: MetaItem ,
521
- sess : & ParseSess ,
521
+ sess : & Session ,
522
522
lint_node_id : NodeId ,
523
523
features : Option < & Features > ,
524
524
) -> bool {
525
525
eval_condition ( cfg, sess, features, & mut |cfg| {
526
526
try_gate_cfg ( cfg. name , cfg. span , sess, features) ;
527
- match sess. check_config . expecteds . get ( & cfg. name ) {
527
+ match sess. parse_sess . check_config . expecteds . get ( & cfg. name ) {
528
528
Some ( ExpectedValues :: Some ( values) ) if !values. contains ( & cfg. value ) => {
529
- sess. buffer_lint_with_diagnostic (
529
+ sess. parse_sess . buffer_lint_with_diagnostic (
530
530
UNEXPECTED_CFGS ,
531
531
cfg. span ,
532
532
lint_node_id,
@@ -541,8 +541,8 @@ pub fn cfg_matches(
541
541
) ,
542
542
) ;
543
543
}
544
- None if sess. check_config . exhaustive_names => {
545
- sess. buffer_lint_with_diagnostic (
544
+ None if sess. parse_sess . check_config . exhaustive_names => {
545
+ sess. parse_sess . buffer_lint_with_diagnostic (
546
546
UNEXPECTED_CFGS ,
547
547
cfg. span ,
548
548
lint_node_id,
@@ -555,18 +555,18 @@ pub fn cfg_matches(
555
555
}
556
556
_ => { /* not unexpected */ }
557
557
}
558
- sess. config . contains ( & ( cfg. name , cfg. value ) )
558
+ sess. parse_sess . config . contains ( & ( cfg. name , cfg. value ) )
559
559
} )
560
560
}
561
561
562
- fn try_gate_cfg ( name : Symbol , span : Span , sess : & ParseSess , features : Option < & Features > ) {
562
+ fn try_gate_cfg ( name : Symbol , span : Span , sess : & Session , features : Option < & Features > ) {
563
563
let gate = find_gated_cfg ( |sym| sym == name) ;
564
564
if let ( Some ( feats) , Some ( gated_cfg) ) = ( features, gate) {
565
565
gate_cfg ( gated_cfg, span, sess, feats) ;
566
566
}
567
567
}
568
568
569
- fn gate_cfg ( gated_cfg : & GatedCfg , cfg_span : Span , sess : & ParseSess , features : & Features ) {
569
+ fn gate_cfg ( gated_cfg : & GatedCfg , cfg_span : Span , sess : & Session , features : & Features ) {
570
570
let ( cfg, feature, has_feature) = gated_cfg;
571
571
if !has_feature ( features) && !cfg_span. allows_unstable ( * feature) {
572
572
let explain = format ! ( "`cfg({cfg})` is experimental and subject to change" ) ;
@@ -594,11 +594,11 @@ fn parse_version(s: Symbol) -> Option<RustcVersion> {
594
594
/// evaluate individual items.
595
595
pub fn eval_condition (
596
596
cfg : & ast:: MetaItem ,
597
- sess : & ParseSess ,
597
+ sess : & Session ,
598
598
features : Option < & Features > ,
599
599
eval : & mut impl FnMut ( Condition ) -> bool ,
600
600
) -> bool {
601
- let dcx = & sess. dcx ;
601
+ let dcx = & sess. parse_sess . dcx ;
602
602
match & cfg. kind {
603
603
ast:: MetaItemKind :: List ( mis) if cfg. name_or_empty ( ) == sym:: version => {
604
604
try_gate_cfg ( sym:: version, cfg. span , sess, features) ;
@@ -626,7 +626,7 @@ pub fn eval_condition(
626
626
} ;
627
627
628
628
// See https://github.com/rust-lang/rust/issues/64796#issuecomment-640851454 for details
629
- if sess. assume_incomplete_release {
629
+ if sess. parse_sess . assume_incomplete_release {
630
630
RustcVersion :: CURRENT > min_version
631
631
} else {
632
632
RustcVersion :: CURRENT >= min_version
0 commit comments