@@ -4,6 +4,7 @@ use std::path::PathBuf;
44use rustc_ast:: { LitKind , MetaItem , MetaItemInner , MetaItemKind , MetaItemLit } ;
55use rustc_errors:: codes:: * ;
66use rustc_errors:: { ErrorGuaranteed , struct_span_code_err} ;
7+ use rustc_hir as hir;
78use rustc_hir:: def_id:: { DefId , LocalDefId } ;
89use rustc_hir:: { AttrArgs , Attribute } ;
910use rustc_macros:: LintDiagnostic ;
@@ -13,17 +14,14 @@ use rustc_middle::ty::{self, GenericArgsRef, GenericParamDef, GenericParamDefKin
1314use rustc_session:: lint:: builtin:: UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES ;
1415use rustc_span:: { Span , Symbol , sym} ;
1516use tracing:: { debug, info} ;
16- use { rustc_attr_parsing as attr, rustc_hir as hir} ;
1717
1818use super :: { ObligationCauseCode , PredicateObligation } ;
1919use crate :: error_reporting:: TypeErrCtxt ;
2020use crate :: error_reporting:: traits:: on_unimplemented_condition:: { Condition , ConditionOptions } ;
2121use crate :: error_reporting:: traits:: on_unimplemented_format:: {
2222 Ctx , FormatArgs , FormatString , FormatWarning ,
2323} ;
24- use crate :: errors:: {
25- EmptyOnClauseInOnUnimplemented , InvalidOnClauseInOnUnimplemented , NoValueInOnUnimplemented ,
26- } ;
24+ use crate :: errors:: { InvalidOnClause , NoValueInOnUnimplemented } ;
2725use crate :: infer:: InferCtxtExt ;
2826
2927impl < ' tcx > TypeErrCtxt < ' _ , ' tcx > {
@@ -427,18 +425,12 @@ impl<'tcx> OnUnimplementedDirective {
427425 } else {
428426 let cond = item_iter
429427 . 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+ }
442434 } ;
443435
444436 let mut message = None ;
@@ -744,7 +736,7 @@ impl<'tcx> OnUnimplementedDirective {
744736 for command in self . subcommands . iter ( ) . chain ( Some ( self ) ) . rev ( ) {
745737 debug ! ( ?command) ;
746738 if let Some ( ref condition) = command. condition
747- && !condition. matches_predicate ( tcx , condition_options)
739+ && !condition. matches_predicate ( condition_options)
748740 {
749741 debug ! ( "evaluate: skipping {:?} due to condition" , command) ;
750742 continue ;
0 commit comments