@@ -4,6 +4,7 @@ use std::path::PathBuf;
4
4
use rustc_ast:: { LitKind , MetaItem , MetaItemInner , MetaItemKind , MetaItemLit } ;
5
5
use rustc_errors:: codes:: * ;
6
6
use rustc_errors:: { ErrorGuaranteed , struct_span_code_err} ;
7
+ use rustc_hir as hir;
7
8
use rustc_hir:: def_id:: { DefId , LocalDefId } ;
8
9
use rustc_hir:: { AttrArgs , Attribute } ;
9
10
use rustc_macros:: LintDiagnostic ;
@@ -13,17 +14,14 @@ use rustc_middle::ty::{self, GenericArgsRef, GenericParamDef, GenericParamDefKin
13
14
use rustc_session:: lint:: builtin:: UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES ;
14
15
use rustc_span:: { Span , Symbol , sym} ;
15
16
use tracing:: { debug, info} ;
16
- use { rustc_attr_parsing as attr, rustc_hir as hir} ;
17
17
18
18
use super :: { ObligationCauseCode , PredicateObligation } ;
19
19
use crate :: error_reporting:: TypeErrCtxt ;
20
20
use crate :: error_reporting:: traits:: on_unimplemented_condition:: { Condition , ConditionOptions } ;
21
21
use crate :: error_reporting:: traits:: on_unimplemented_format:: {
22
22
Ctx , FormatArgs , FormatString , FormatWarning ,
23
23
} ;
24
- use crate :: errors:: {
25
- EmptyOnClauseInOnUnimplemented , InvalidOnClauseInOnUnimplemented , NoValueInOnUnimplemented ,
26
- } ;
24
+ use crate :: errors:: { InvalidOnClause , NoValueInOnUnimplemented } ;
27
25
use crate :: infer:: InferCtxtExt ;
28
26
29
27
impl < ' tcx > TypeErrCtxt < ' _ , ' tcx > {
@@ -427,18 +425,12 @@ impl<'tcx> OnUnimplementedDirective {
427
425
} else {
428
426
let cond = item_iter
429
427
. next ( )
430
- . ok_or_else ( || tcx. dcx ( ) . emit_err ( EmptyOnClauseInOnUnimplemented { span } ) ) ?
431
- . meta_item_or_bool ( )
432
- . ok_or_else ( || tcx. dcx ( ) . emit_err ( InvalidOnClauseInOnUnimplemented { span } ) ) ?;
433
- attr:: eval_condition ( cond, & tcx. sess , Some ( tcx. features ( ) ) , & mut |cfg| {
434
- if let Some ( value) = cfg. value
435
- && let Err ( guar) = parse_value ( value, cfg. span )
436
- {
437
- errored = Some ( guar) ;
438
- }
439
- true
440
- } ) ;
441
- Some ( Condition { inner : cond. clone ( ) } )
428
+ . ok_or_else ( || tcx. dcx ( ) . emit_err ( InvalidOnClause :: Empty { span } ) ) ?;
429
+
430
+ match Condition :: parse ( cond) {
431
+ Ok ( condition) => Some ( condition) ,
432
+ Err ( e) => return Err ( tcx. dcx ( ) . emit_err ( e) ) ,
433
+ }
442
434
} ;
443
435
444
436
let mut message = None ;
@@ -744,7 +736,7 @@ impl<'tcx> OnUnimplementedDirective {
744
736
for command in self . subcommands . iter ( ) . chain ( Some ( self ) ) . rev ( ) {
745
737
debug ! ( ?command) ;
746
738
if let Some ( ref condition) = command. condition
747
- && !condition. matches_predicate ( tcx , condition_options)
739
+ && !condition. matches_predicate ( condition_options)
748
740
{
749
741
debug ! ( "evaluate: skipping {:?} due to condition" , command) ;
750
742
continue ;
0 commit comments