From 15e71b6e43e28ffaa9db70c39fdf82be062e5cfd Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Wed, 24 Apr 2024 10:46:43 +1000 Subject: [PATCH 01/16] Make `LazyAttrTokenStream::encode` panic. It's unreachable, because AST JSON printing support was removed some time ago. --- compiler/rustc_ast/src/tokenstream.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_ast/src/tokenstream.rs b/compiler/rustc_ast/src/tokenstream.rs index 880f92bbe7bdc..08d65a5ffa588 100644 --- a/compiler/rustc_ast/src/tokenstream.rs +++ b/compiler/rustc_ast/src/tokenstream.rs @@ -140,9 +140,8 @@ impl fmt::Debug for LazyAttrTokenStream { } impl Encodable for LazyAttrTokenStream { - fn encode(&self, s: &mut S) { - // Used by AST json printing. - Encodable::encode(&self.to_attr_token_stream(), s); + fn encode(&self, _s: &mut S) { + panic!("Attempted to encode LazyAttrTokenStream"); } } From d5ec9b458a4a584164cbfc6a53298560091ecd8c Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Wed, 24 Apr 2024 13:18:17 +1000 Subject: [PATCH 02/16] Remove `MetaItemKind::value_str`. `MetaItem::value_str` is good enough. And this makes `MetaItem::value_str` more like `MetaItem::meta_item_list` and `name_value_literal`. --- compiler/rustc_ast/src/attr/mod.rs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/compiler/rustc_ast/src/attr/mod.rs b/compiler/rustc_ast/src/attr/mod.rs index 5e3fc7e335775..e67c5fd9a5afd 100644 --- a/compiler/rustc_ast/src/attr/mod.rs +++ b/compiler/rustc_ast/src/attr/mod.rs @@ -298,7 +298,10 @@ impl MetaItem { } pub fn value_str(&self) -> Option { - self.kind.value_str() + match &self.kind { + MetaItemKind::NameValue(v) => v.kind.str(), + _ => None, + } } fn from_tokens<'a, I>(tokens: &mut iter::Peekable) -> Option @@ -362,13 +365,6 @@ impl MetaItem { } impl MetaItemKind { - pub fn value_str(&self) -> Option { - match self { - MetaItemKind::NameValue(v) => v.kind.str(), - _ => None, - } - } - fn list_from_tokens(tokens: TokenStream) -> Option> { let mut tokens = tokens.trees().peekable(); let mut result = ThinVec::new(); From 8d4655d9ec9befc5cdcbb8d7a2961a75aecfc145 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Wed, 24 Apr 2024 14:25:59 +1000 Subject: [PATCH 03/16] Rename `NestedMetaItem::name_value_literal`. It's a highly misleading name, because it's completely different to `MetaItem::name_value_literal`. Specifically, it doesn't match `MetaItemKind::NameValue` (e.g. `#[foo = 3]`), it matches `MetaItemKind::List` (e.g. `#[foo(3)]`). --- compiler/rustc_ast/src/attr/mod.rs | 5 +++-- compiler/rustc_attr/src/builtin.rs | 2 +- compiler/rustc_codegen_ssa/src/codegen_attrs.rs | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/compiler/rustc_ast/src/attr/mod.rs b/compiler/rustc_ast/src/attr/mod.rs index e67c5fd9a5afd..0f12fd3197520 100644 --- a/compiler/rustc_ast/src/attr/mod.rs +++ b/compiler/rustc_ast/src/attr/mod.rs @@ -464,8 +464,9 @@ impl NestedMetaItem { self.meta_item().and_then(|meta_item| meta_item.meta_item_list()) } - /// Returns a name and single literal value tuple of the `MetaItem`. - pub fn name_value_literal(&self) -> Option<(Symbol, &MetaItemLit)> { + /// If it's a singleton list of the form `foo(lit)`, returns the `foo` and + /// the `lit`. + pub fn singleton_lit_list(&self) -> Option<(Symbol, &MetaItemLit)> { self.meta_item().and_then(|meta_item| { meta_item.meta_item_list().and_then(|meta_item_list| { if meta_item_list.len() == 1 diff --git a/compiler/rustc_attr/src/builtin.rs b/compiler/rustc_attr/src/builtin.rs index 439f13e763570..1c2077372e1cc 100644 --- a/compiler/rustc_attr/src/builtin.rs +++ b/compiler/rustc_attr/src/builtin.rs @@ -986,7 +986,7 @@ pub fn parse_repr_attr(sess: &Session, attr: &Attribute) -> Vec { recognised = true; acc.push(h); } - } else if let Some((name, value)) = item.name_value_literal() { + } else if let Some((name, value)) = item.singleton_lit_list() { let mut literal_error = None; let mut err_span = item.span(); if name == sym::align { diff --git a/compiler/rustc_codegen_ssa/src/codegen_attrs.rs b/compiler/rustc_codegen_ssa/src/codegen_attrs.rs index 9c9e134f0337e..c28b0d644e675 100644 --- a/compiler/rustc_codegen_ssa/src/codegen_attrs.rs +++ b/compiler/rustc_codegen_ssa/src/codegen_attrs.rs @@ -435,7 +435,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs { sym::repr => { codegen_fn_attrs.alignment = if let Some(items) = attr.meta_item_list() && let [item] = items.as_slice() - && let Some((sym::align, literal)) = item.name_value_literal() + && let Some((sym::align, literal)) = item.singleton_lit_list() { rustc_attr::parse_alignment(&literal.kind) .map_err(|msg| { From 748b0a2e35681643abccf99f81a2eaa12c0b1342 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Wed, 24 Apr 2024 15:21:16 +1000 Subject: [PATCH 04/16] Remove unnecessary `pub`s in `mut_visit.rs`. This makes it clearer what is actually used outside of this crate. --- compiler/rustc_ast/src/mut_visit.rs | 125 +++++++++++++--------------- 1 file changed, 60 insertions(+), 65 deletions(-) diff --git a/compiler/rustc_ast/src/mut_visit.rs b/compiler/rustc_ast/src/mut_visit.rs index c4e49d7dbea44..8cb1391471591 100644 --- a/compiler/rustc_ast/src/mut_visit.rs +++ b/compiler/rustc_ast/src/mut_visit.rs @@ -335,7 +335,7 @@ pub fn visit_clobber(t: &mut T, f: impl FnOnce(T) -> T) { // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`. #[inline] -pub fn visit_vec(elems: &mut Vec, mut visit_elem: F) +fn visit_vec(elems: &mut Vec, mut visit_elem: F) where F: FnMut(&mut T), { @@ -346,7 +346,7 @@ where // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`. #[inline] -pub fn visit_thin_vec(elems: &mut ThinVec, mut visit_elem: F) +fn visit_thin_vec(elems: &mut ThinVec, mut visit_elem: F) where F: FnMut(&mut T), { @@ -357,7 +357,7 @@ where // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`. #[inline] -pub fn visit_opt(opt: &mut Option, mut visit_elem: F) +fn visit_opt(opt: &mut Option, mut visit_elem: F) where F: FnMut(&mut T), { @@ -367,36 +367,37 @@ where } // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`. -pub fn visit_attrs(attrs: &mut AttrVec, vis: &mut T) { +fn visit_attrs(attrs: &mut AttrVec, vis: &mut T) { for attr in attrs.iter_mut() { vis.visit_attribute(attr); } } // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`. -pub fn visit_exprs(exprs: &mut Vec>, vis: &mut T) { +#[allow(unused)] +fn visit_exprs(exprs: &mut Vec>, vis: &mut T) { exprs.flat_map_in_place(|expr| vis.filter_map_expr(expr)) } // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`. -pub fn visit_thin_exprs(exprs: &mut ThinVec>, vis: &mut T) { +fn visit_thin_exprs(exprs: &mut ThinVec>, vis: &mut T) { exprs.flat_map_in_place(|expr| vis.filter_map_expr(expr)) } // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`. -pub fn visit_bounds(bounds: &mut GenericBounds, vis: &mut T) { +fn visit_bounds(bounds: &mut GenericBounds, vis: &mut T) { visit_vec(bounds, |bound| vis.visit_param_bound(bound)); } // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`. -pub fn visit_fn_sig(FnSig { header, decl, span }: &mut FnSig, vis: &mut T) { +fn visit_fn_sig(FnSig { header, decl, span }: &mut FnSig, vis: &mut T) { vis.visit_fn_header(header); vis.visit_fn_decl(decl); vis.visit_span(span); } // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`. -pub fn visit_attr_args(args: &mut AttrArgs, vis: &mut T) { +fn visit_attr_args(args: &mut AttrArgs, vis: &mut T) { match args { AttrArgs::Empty => {} AttrArgs::Delimited(args) => visit_delim_args(args, vis), @@ -411,7 +412,7 @@ pub fn visit_attr_args(args: &mut AttrArgs, vis: &mut T) { } // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`. -pub fn visit_delim_args(args: &mut DelimArgs, vis: &mut T) { +fn visit_delim_args(args: &mut DelimArgs, vis: &mut T) { let DelimArgs { dspan, delim: _, tokens } = args; visit_delim_span(dspan, vis); visit_tts(tokens, vis); @@ -435,7 +436,7 @@ pub fn noop_flat_map_pat_field( smallvec![fp] } -pub fn noop_visit_use_tree(use_tree: &mut UseTree, vis: &mut T) { +fn noop_visit_use_tree(use_tree: &mut UseTree, vis: &mut T) { let UseTree { prefix, kind, span } = use_tree; vis.visit_path(prefix); match kind { @@ -462,7 +463,7 @@ pub fn noop_flat_map_arm(mut arm: Arm, vis: &mut T) -> SmallVec<[ smallvec![arm] } -pub fn noop_visit_constraint( +fn noop_visit_constraint( AssocConstraint { id, ident, gen_args, kind, span }: &mut AssocConstraint, vis: &mut T, ) { @@ -541,7 +542,7 @@ pub fn noop_visit_ty(ty: &mut P, vis: &mut T) { visit_lazy_tts(tokens, vis); } -pub fn noop_visit_foreign_mod(foreign_mod: &mut ForeignMod, vis: &mut T) { +fn noop_visit_foreign_mod(foreign_mod: &mut ForeignMod, vis: &mut T) { let ForeignMod { unsafety, abi: _, items } = foreign_mod; visit_unsafety(unsafety, vis); items.flat_map_in_place(|item| vis.flat_map_foreign_item(item)); @@ -562,11 +563,11 @@ pub fn noop_flat_map_variant( smallvec![variant] } -pub fn noop_visit_ident(Ident { name: _, span }: &mut Ident, vis: &mut T) { +fn noop_visit_ident(Ident { name: _, span }: &mut Ident, vis: &mut T) { vis.visit_span(span); } -pub fn noop_visit_path(Path { segments, span, tokens }: &mut Path, vis: &mut T) { +fn noop_visit_path(Path { segments, span, tokens }: &mut Path, vis: &mut T) { vis.visit_span(span); for PathSegment { ident, id, args } in segments { vis.visit_ident(ident); @@ -576,7 +577,7 @@ pub fn noop_visit_path(Path { segments, span, tokens }: &mut Path visit_lazy_tts(tokens, vis); } -pub fn noop_visit_qself(qself: &mut Option>, vis: &mut T) { +fn noop_visit_qself(qself: &mut Option>, vis: &mut T) { visit_opt(qself, |qself| { let QSelf { ty, path_span, position: _ } = &mut **qself; vis.visit_ty(ty); @@ -584,14 +585,14 @@ pub fn noop_visit_qself(qself: &mut Option>, vis: &mut T }) } -pub fn noop_visit_generic_args(generic_args: &mut GenericArgs, vis: &mut T) { +fn noop_visit_generic_args(generic_args: &mut GenericArgs, vis: &mut T) { match generic_args { GenericArgs::AngleBracketed(data) => vis.visit_angle_bracketed_parameter_data(data), GenericArgs::Parenthesized(data) => vis.visit_parenthesized_parameter_data(data), } } -pub fn noop_visit_generic_arg(arg: &mut GenericArg, vis: &mut T) { +fn noop_visit_generic_arg(arg: &mut GenericArg, vis: &mut T) { match arg { GenericArg::Lifetime(lt) => vis.visit_lifetime(lt), GenericArg::Type(ty) => vis.visit_ty(ty), @@ -599,7 +600,7 @@ pub fn noop_visit_generic_arg(arg: &mut GenericArg, vis: &mut T) } } -pub fn noop_visit_angle_bracketed_parameter_data( +fn noop_visit_angle_bracketed_parameter_data( data: &mut AngleBracketedArgs, vis: &mut T, ) { @@ -611,7 +612,7 @@ pub fn noop_visit_angle_bracketed_parameter_data( vis.visit_span(span); } -pub fn noop_visit_parenthesized_parameter_data( +fn noop_visit_parenthesized_parameter_data( args: &mut ParenthesizedArgs, vis: &mut T, ) { @@ -621,7 +622,7 @@ pub fn noop_visit_parenthesized_parameter_data( vis.visit_span(span); } -pub fn noop_visit_local(local: &mut P, vis: &mut T) { +fn noop_visit_local(local: &mut P, vis: &mut T) { let Local { id, pat, ty, kind, span, colon_sp, attrs, tokens } = local.deref_mut(); vis.visit_id(id); vis.visit_pat(pat); @@ -642,7 +643,7 @@ pub fn noop_visit_local(local: &mut P, vis: &mut T) { visit_lazy_tts(tokens, vis); } -pub fn noop_visit_attribute(attr: &mut Attribute, vis: &mut T) { +fn noop_visit_attribute(attr: &mut Attribute, vis: &mut T) { let Attribute { kind, id: _, style: _, span } = attr; match kind { AttrKind::Normal(normal) => { @@ -658,25 +659,25 @@ pub fn noop_visit_attribute(attr: &mut Attribute, vis: &mut T) { vis.visit_span(span); } -pub fn noop_visit_mac(mac: &mut MacCall, vis: &mut T) { +fn noop_visit_mac(mac: &mut MacCall, vis: &mut T) { let MacCall { path, args } = mac; vis.visit_path(path); visit_delim_args(args, vis); } -pub fn noop_visit_macro_def(macro_def: &mut MacroDef, vis: &mut T) { +fn noop_visit_macro_def(macro_def: &mut MacroDef, vis: &mut T) { let MacroDef { body, macro_rules: _ } = macro_def; visit_delim_args(body, vis); } -pub fn noop_visit_meta_list_item(li: &mut NestedMetaItem, vis: &mut T) { +fn noop_visit_meta_list_item(li: &mut NestedMetaItem, vis: &mut T) { match li { NestedMetaItem::MetaItem(mi) => vis.visit_meta_item(mi), NestedMetaItem::Lit(_lit) => {} } } -pub fn noop_visit_meta_item(mi: &mut MetaItem, vis: &mut T) { +fn noop_visit_meta_item(mi: &mut MetaItem, vis: &mut T) { let MetaItem { path: _, kind, span } = mi; match kind { MetaItemKind::Word => {} @@ -697,7 +698,7 @@ pub fn noop_flat_map_param(mut param: Param, vis: &mut T) -> Smal } // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`. -pub fn visit_attr_tt(tt: &mut AttrTokenTree, vis: &mut T) { +fn visit_attr_tt(tt: &mut AttrTokenTree, vis: &mut T) { match tt { AttrTokenTree::Token(token, _) => { visit_token(token, vis); @@ -724,7 +725,7 @@ pub fn visit_attr_tt(tt: &mut AttrTokenTree, vis: &mut T) { } // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`. -pub fn visit_tt(tt: &mut TokenTree, vis: &mut T) { +fn visit_tt(tt: &mut TokenTree, vis: &mut T) { match tt { TokenTree::Token(token, _) => { visit_token(token, vis); @@ -738,24 +739,21 @@ pub fn visit_tt(tt: &mut TokenTree, vis: &mut T) { } // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`. -pub fn visit_tts(TokenStream(tts): &mut TokenStream, vis: &mut T) { +fn visit_tts(TokenStream(tts): &mut TokenStream, vis: &mut T) { if T::VISIT_TOKENS && !tts.is_empty() { let tts = Lrc::make_mut(tts); visit_vec(tts, |tree| visit_tt(tree, vis)); } } -pub fn visit_attr_tts(AttrTokenStream(tts): &mut AttrTokenStream, vis: &mut T) { +fn visit_attr_tts(AttrTokenStream(tts): &mut AttrTokenStream, vis: &mut T) { if T::VISIT_TOKENS && !tts.is_empty() { let tts = Lrc::make_mut(tts); visit_vec(tts, |tree| visit_attr_tt(tree, vis)); } } -pub fn visit_lazy_tts_opt_mut( - lazy_tts: Option<&mut LazyAttrTokenStream>, - vis: &mut T, -) { +fn visit_lazy_tts_opt_mut(lazy_tts: Option<&mut LazyAttrTokenStream>, vis: &mut T) { if T::VISIT_TOKENS { if let Some(lazy_tts) = lazy_tts { let mut tts = lazy_tts.to_attr_token_stream(); @@ -765,7 +763,7 @@ pub fn visit_lazy_tts_opt_mut( } } -pub fn visit_lazy_tts(lazy_tts: &mut Option, vis: &mut T) { +fn visit_lazy_tts(lazy_tts: &mut Option, vis: &mut T) { visit_lazy_tts_opt_mut(lazy_tts.as_mut(), vis); } @@ -818,7 +816,7 @@ pub fn visit_token(t: &mut Token, vis: &mut T) { // contain multiple items, but decided against it when I looked at // `parse_item_or_view_item` and tried to figure out what I would do with // multiple items there.... -pub fn visit_nonterminal(nt: &mut token::Nonterminal, vis: &mut T) { +fn visit_nonterminal(nt: &mut token::Nonterminal, vis: &mut T) { match nt { token::NtItem(item) => visit_clobber(item, |item| { // This is probably okay, because the only visitors likely to @@ -851,7 +849,7 @@ pub fn visit_nonterminal(nt: &mut token::Nonterminal, vis: &mut T } // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`. -pub fn visit_defaultness(defaultness: &mut Defaultness, vis: &mut T) { +fn visit_defaultness(defaultness: &mut Defaultness, vis: &mut T) { match defaultness { Defaultness::Default(span) => vis.visit_span(span), Defaultness::Final => {} @@ -859,7 +857,7 @@ pub fn visit_defaultness(defaultness: &mut Defaultness, vis: &mut } // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`. -pub fn visit_unsafety(unsafety: &mut Unsafe, vis: &mut T) { +fn visit_unsafety(unsafety: &mut Unsafe, vis: &mut T) { match unsafety { Unsafe::Yes(span) => vis.visit_span(span), Unsafe::No => {} @@ -867,7 +865,7 @@ pub fn visit_unsafety(unsafety: &mut Unsafe, vis: &mut T) { } // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`. -pub fn visit_polarity(polarity: &mut ImplPolarity, vis: &mut T) { +fn visit_polarity(polarity: &mut ImplPolarity, vis: &mut T) { match polarity { ImplPolarity::Positive => {} ImplPolarity::Negative(span) => vis.visit_span(span), @@ -875,14 +873,14 @@ pub fn visit_polarity(polarity: &mut ImplPolarity, vis: &mut T) { } // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`. -pub fn visit_constness(constness: &mut Const, vis: &mut T) { +fn visit_constness(constness: &mut Const, vis: &mut T) { match constness { Const::Yes(span) => vis.visit_span(span), Const::No => {} } } -pub fn noop_visit_closure_binder(binder: &mut ClosureBinder, vis: &mut T) { +fn noop_visit_closure_binder(binder: &mut ClosureBinder, vis: &mut T) { match binder { ClosureBinder::NotPresent => {} ClosureBinder::For { span: _, generic_params } => { @@ -891,7 +889,7 @@ pub fn noop_visit_closure_binder(binder: &mut ClosureBinder, vis: } } -pub fn noop_visit_coroutine_kind(coroutine_kind: &mut CoroutineKind, vis: &mut T) { +fn noop_visit_coroutine_kind(coroutine_kind: &mut CoroutineKind, vis: &mut T) { match coroutine_kind { CoroutineKind::Async { span, closure_id, return_impl_trait_id } | CoroutineKind::Gen { span, closure_id, return_impl_trait_id } @@ -903,27 +901,27 @@ pub fn noop_visit_coroutine_kind(coroutine_kind: &mut CoroutineKi } } -pub fn noop_visit_fn_decl(decl: &mut P, vis: &mut T) { +fn noop_visit_fn_decl(decl: &mut P, vis: &mut T) { let FnDecl { inputs, output } = decl.deref_mut(); inputs.flat_map_in_place(|param| vis.flat_map_param(param)); noop_visit_fn_ret_ty(output, vis); } -pub fn noop_visit_fn_ret_ty(fn_ret_ty: &mut FnRetTy, vis: &mut T) { +fn noop_visit_fn_ret_ty(fn_ret_ty: &mut FnRetTy, vis: &mut T) { match fn_ret_ty { FnRetTy::Default(span) => vis.visit_span(span), FnRetTy::Ty(ty) => vis.visit_ty(ty), } } -pub fn noop_visit_param_bound(pb: &mut GenericBound, vis: &mut T) { +fn noop_visit_param_bound(pb: &mut GenericBound, vis: &mut T) { match pb { GenericBound::Trait(ty, _modifier) => vis.visit_poly_trait_ref(ty), GenericBound::Outlives(lifetime) => noop_visit_lifetime(lifetime, vis), } } -pub fn noop_visit_precise_capturing_arg(arg: &mut PreciseCapturingArg, vis: &mut T) { +fn noop_visit_precise_capturing_arg(arg: &mut PreciseCapturingArg, vis: &mut T) { match arg { PreciseCapturingArg::Lifetime(lt) => { vis.visit_lifetime(lt); @@ -960,7 +958,7 @@ pub fn noop_flat_map_generic_param( smallvec![param] } -pub fn noop_visit_label(Label { ident }: &mut Label, vis: &mut T) { +fn noop_visit_label(Label { ident }: &mut Label, vis: &mut T) { vis.visit_ident(ident); } @@ -969,20 +967,20 @@ fn noop_visit_lifetime(Lifetime { id, ident }: &mut Lifetime, vis vis.visit_ident(ident); } -pub fn noop_visit_generics(generics: &mut Generics, vis: &mut T) { +fn noop_visit_generics(generics: &mut Generics, vis: &mut T) { let Generics { params, where_clause, span } = generics; params.flat_map_in_place(|param| vis.flat_map_generic_param(param)); vis.visit_where_clause(where_clause); vis.visit_span(span); } -pub fn noop_visit_where_clause(wc: &mut WhereClause, vis: &mut T) { +fn noop_visit_where_clause(wc: &mut WhereClause, vis: &mut T) { let WhereClause { has_where_token: _, predicates, span } = wc; visit_thin_vec(predicates, |predicate| vis.visit_where_predicate(predicate)); vis.visit_span(span); } -pub fn noop_visit_where_predicate(pred: &mut WherePredicate, vis: &mut T) { +fn noop_visit_where_predicate(pred: &mut WherePredicate, vis: &mut T) { match pred { WherePredicate::BoundPredicate(bp) => { let WhereBoundPredicate { span, bound_generic_params, bounded_ty, bounds } = bp; @@ -1006,7 +1004,7 @@ pub fn noop_visit_where_predicate(pred: &mut WherePredicate, vis: } } -pub fn noop_visit_variant_data(vdata: &mut VariantData, vis: &mut T) { +fn noop_visit_variant_data(vdata: &mut VariantData, vis: &mut T) { match vdata { VariantData::Struct { fields, .. } => { fields.flat_map_in_place(|field| vis.flat_map_field_def(field)); @@ -1019,12 +1017,12 @@ pub fn noop_visit_variant_data(vdata: &mut VariantData, vis: &mut } } -pub fn noop_visit_trait_ref(TraitRef { path, ref_id }: &mut TraitRef, vis: &mut T) { +fn noop_visit_trait_ref(TraitRef { path, ref_id }: &mut TraitRef, vis: &mut T) { vis.visit_path(path); vis.visit_id(ref_id); } -pub fn noop_visit_poly_trait_ref(p: &mut PolyTraitRef, vis: &mut T) { +fn noop_visit_poly_trait_ref(p: &mut PolyTraitRef, vis: &mut T) { let PolyTraitRef { bound_generic_params, trait_ref, span } = p; bound_generic_params.flat_map_in_place(|param| vis.flat_map_generic_param(param)); vis.visit_trait_ref(trait_ref); @@ -1058,7 +1056,7 @@ pub fn noop_flat_map_expr_field( smallvec![f] } -pub fn noop_visit_mt(MutTy { ty, mutbl: _ }: &mut MutTy, vis: &mut T) { +fn noop_visit_mt(MutTy { ty, mutbl: _ }: &mut MutTy, vis: &mut T) { vis.visit_ty(ty); } @@ -1219,7 +1217,7 @@ fn visit_const_item( visit_opt(expr, |expr| visitor.visit_expr(expr)); } -pub fn noop_visit_fn_header(header: &mut FnHeader, vis: &mut T) { +fn noop_visit_fn_header(header: &mut FnHeader, vis: &mut T) { let FnHeader { unsafety, coroutine_kind, constness, ext: _ } = header; visit_constness(constness, vis); coroutine_kind.as_mut().map(|coroutine_kind| vis.visit_coroutine_kind(coroutine_kind)); @@ -1337,12 +1335,12 @@ pub fn noop_visit_pat(pat: &mut P, vis: &mut T) { visit_lazy_tts(tokens, vis); } -pub fn noop_visit_anon_const(AnonConst { id, value }: &mut AnonConst, vis: &mut T) { +fn noop_visit_anon_const(AnonConst { id, value }: &mut AnonConst, vis: &mut T) { vis.visit_id(id); vis.visit_expr(value); } -pub fn noop_visit_inline_asm(asm: &mut InlineAsm, vis: &mut T) { +fn noop_visit_inline_asm(asm: &mut InlineAsm, vis: &mut T) { for (op, _) in &mut asm.operands { match op { InlineAsmOperand::In { expr, .. } @@ -1362,7 +1360,7 @@ pub fn noop_visit_inline_asm(asm: &mut InlineAsm, vis: &mut T) { } } -pub fn noop_visit_inline_asm_sym( +fn noop_visit_inline_asm_sym( InlineAsmSym { id, qself, path }: &mut InlineAsmSym, vis: &mut T, ) { @@ -1371,7 +1369,7 @@ pub fn noop_visit_inline_asm_sym( vis.visit_path(path); } -pub fn noop_visit_format_args(fmt: &mut FormatArgs, vis: &mut T) { +fn noop_visit_format_args(fmt: &mut FormatArgs, vis: &mut T) { for arg in fmt.arguments.all_args_mut() { if let FormatArgumentKind::Named(name) = &mut arg.kind { vis.visit_ident(name); @@ -1588,10 +1586,7 @@ pub fn noop_flat_map_stmt( stmts } -pub fn noop_flat_map_stmt_kind( - kind: StmtKind, - vis: &mut T, -) -> SmallVec<[StmtKind; 1]> { +fn noop_flat_map_stmt_kind(kind: StmtKind, vis: &mut T) -> SmallVec<[StmtKind; 1]> { match kind { StmtKind::Let(mut local) => smallvec![StmtKind::Let({ vis.visit_local(&mut local); @@ -1611,7 +1606,7 @@ pub fn noop_flat_map_stmt_kind( } } -pub fn noop_visit_vis(visibility: &mut Visibility, vis: &mut T) { +fn noop_visit_vis(visibility: &mut Visibility, vis: &mut T) { match &mut visibility.kind { VisibilityKind::Public | VisibilityKind::Inherited => {} VisibilityKind::Restricted { path, id, shorthand: _ } => { @@ -1622,7 +1617,7 @@ pub fn noop_visit_vis(visibility: &mut Visibility, vis: &mut T) { vis.visit_span(&mut visibility.span); } -pub fn noop_visit_capture_by(capture_by: &mut CaptureBy, vis: &mut T) { +fn noop_visit_capture_by(capture_by: &mut CaptureBy, vis: &mut T) { match capture_by { CaptureBy::Ref => {} CaptureBy::Value { move_kw } => { From 78e7c7b9f9f6a671255ff0fb88b5a6fd6dbc7a58 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Wed, 24 Apr 2024 09:45:47 +1000 Subject: [PATCH 05/16] Whitespace fixes. --- compiler/rustc_session/src/options.rs | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/compiler/rustc_session/src/options.rs b/compiler/rustc_session/src/options.rs index d51080589481b..6a556e2a1f517 100644 --- a/compiler/rustc_session/src/options.rs +++ b/compiler/rustc_session/src/options.rs @@ -1,5 +1,4 @@ use crate::config::*; - use crate::search_paths::SearchPath; use crate::utils::NativeLib; use crate::{lint, EarlyDiagCtxt}; @@ -8,20 +7,17 @@ use rustc_data_structures::profiling::TimePassesFormat; use rustc_data_structures::stable_hasher::Hash64; use rustc_errors::ColorConfig; use rustc_errors::{LanguageIdentifier, TerminalUrl}; +use rustc_feature::UnstableFeatures; +use rustc_span::edition::Edition; +use rustc_span::RealFileName; +use rustc_span::SourceFileHashAlgorithm; use rustc_target::spec::{ CodeModel, LinkerFlavorCli, MergeFunctions, PanicStrategy, SanitizerSet, WasmCAbi, }; use rustc_target::spec::{ RelocModel, RelroLevel, SplitDebuginfo, StackProtector, TargetTriple, TlsModel, }; - -use rustc_feature::UnstableFeatures; -use rustc_span::edition::Edition; -use rustc_span::RealFileName; -use rustc_span::SourceFileHashAlgorithm; - use std::collections::BTreeMap; - use std::hash::{DefaultHasher, Hasher}; use std::num::{IntErrorKind, NonZero}; use std::path::PathBuf; @@ -118,8 +114,8 @@ top_level_options!( /// incremental compilation cache before proceeding. /// /// - `[TRACKED_NO_CRATE_HASH]` - /// Same as `[TRACKED]`, but will not affect the crate hash. This is useful for options that only - /// affect the incremental cache. + /// Same as `[TRACKED]`, but will not affect the crate hash. This is useful for options that + /// only affect the incremental cache. /// /// - `[UNTRACKED]` /// Incremental compilation is not influenced by this option. From 2a7fe14acd4b4da3623797166b81aa35d6704508 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Tue, 23 Apr 2024 15:02:23 +0200 Subject: [PATCH 06/16] Use a type alias for a CI job --- src/ci/github-actions/calculate-job-matrix.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/ci/github-actions/calculate-job-matrix.py b/src/ci/github-actions/calculate-job-matrix.py index c24cefa8d8962..a54081f83f162 100755 --- a/src/ci/github-actions/calculate-job-matrix.py +++ b/src/ci/github-actions/calculate-job-matrix.py @@ -19,8 +19,10 @@ JOBS_YAML_PATH = Path(__file__).absolute().parent / "jobs.yml" +Job = Dict[str, Any] -def name_jobs(jobs: List[Dict], prefix: str) -> List[Dict]: + +def name_jobs(jobs: List[Dict], prefix: str) -> List[Job]: """ Add a `name` attribute to each job, based on its image and the given `prefix`. """ @@ -29,7 +31,7 @@ def name_jobs(jobs: List[Dict], prefix: str) -> List[Dict]: return jobs -def add_base_env(jobs: List[Dict], environment: Dict[str, str]) -> List[Dict]: +def add_base_env(jobs: List[Job], environment: Dict[str, str]) -> List[Job]: """ Prepends `environment` to the `env` attribute of each job. The `env` of each job has higher precedence than `environment`. @@ -77,7 +79,7 @@ def find_job_type(ctx: GitHubCtx) -> Optional[JobType]: return None -def calculate_jobs(job_type: JobType, job_data: Dict[str, Any]) -> List[Dict[str, Any]]: +def calculate_jobs(job_type: JobType, job_data: Dict[str, Any]) -> List[Job]: if job_type == JobType.PR: return add_base_env(name_jobs(job_data["pr"], "PR"), job_data["envs"]["pr"]) elif job_type == JobType.Try: From e25735908fc4ee84011252bedfedf51e1de22b95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Tue, 23 Apr 2024 15:06:18 +0200 Subject: [PATCH 07/16] Skip jobs based on the active channel in Python --- src/ci/github-actions/calculate-job-matrix.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/ci/github-actions/calculate-job-matrix.py b/src/ci/github-actions/calculate-job-matrix.py index a54081f83f162..84c4ee406685a 100755 --- a/src/ci/github-actions/calculate-job-matrix.py +++ b/src/ci/github-actions/calculate-job-matrix.py @@ -17,6 +17,7 @@ import yaml +CI_DIR = Path(__file__).absolute().parent.parent JOBS_YAML_PATH = Path(__file__).absolute().parent / "jobs.yml" Job = Dict[str, Any] @@ -90,6 +91,13 @@ def calculate_jobs(job_type: JobType, job_data: Dict[str, Any]) -> List[Job]: return [] +def skip_jobs(jobs: List[Dict[str, Any]], channel: str) -> List[Job]: + """ + Skip CI jobs that are not supposed to be executed on the given `channel`. + """ + return [j for j in jobs if j.get("CI_ONLY_WHEN_CHANNEL", channel) == channel] + + def get_github_ctx() -> GitHubCtx: return GitHubCtx( event_name=os.environ["GITHUB_EVENT_NAME"], @@ -109,9 +117,13 @@ def get_github_ctx() -> GitHubCtx: job_type = find_job_type(github_ctx) logging.info(f"Job type: {job_type}") + with open(CI_DIR / "channel") as f: + channel = f.read().strip() + jobs = [] if job_type is not None: jobs = calculate_jobs(job_type, data) + jobs = skip_jobs(jobs, channel) logging.info(f"Output:\n{yaml.dump(jobs, indent=4)}") print(f"jobs={json.dumps(jobs)}") From 246ee5363710a6cc505400f02addc5db56ff0977 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Tue, 23 Apr 2024 15:06:44 +0200 Subject: [PATCH 08/16] Remove `should-skip-this.sh` --- .github/workflows/ci.yml | 3 --- src/ci/github-actions/ci.yml | 4 ---- src/ci/scripts/should-skip-this.sh | 21 --------------------- 3 files changed, 28 deletions(-) delete mode 100755 src/ci/scripts/should-skip-this.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 872b671b031e7..149640140d9f0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -94,9 +94,6 @@ jobs: env: EXTRA_VARIABLES: "${{ toJson(matrix.env) }}" if: success() && !env.SKIP_JOB - - name: decide whether to skip this job - run: src/ci/scripts/should-skip-this.sh - if: success() && !env.SKIP_JOB - name: ensure the channel matches the target branch run: src/ci/scripts/verify-channel.sh if: success() && !env.SKIP_JOB diff --git a/src/ci/github-actions/ci.yml b/src/ci/github-actions/ci.yml index 19d6b517552f4..9947bb44ed4d9 100644 --- a/src/ci/github-actions/ci.yml +++ b/src/ci/github-actions/ci.yml @@ -163,10 +163,6 @@ x--expand-yaml-anchors--remove: EXTRA_VARIABLES: ${{ toJson(matrix.env) }} <<: *step - - name: decide whether to skip this job - run: src/ci/scripts/should-skip-this.sh - <<: *step - - name: ensure the channel matches the target branch run: src/ci/scripts/verify-channel.sh <<: *step diff --git a/src/ci/scripts/should-skip-this.sh b/src/ci/scripts/should-skip-this.sh deleted file mode 100755 index 48127166ad080..0000000000000 --- a/src/ci/scripts/should-skip-this.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash -# Set the SKIP_JOB environment variable if this job is not supposed to run on the current builder. - -set -euo pipefail -IFS=$'\n\t' - -source "$(cd "$(dirname "$0")" && pwd)/../shared.sh" - -if [[ -n "${CI_ONLY_WHEN_CHANNEL-}" ]]; then - if [[ "${CI_ONLY_WHEN_CHANNEL}" = "$(cat src/ci/channel)" ]]; then - echo "The channel is the expected one" - else - echo "Not executing this job as the channel is not the expected one" - ciCommandSetEnv SKIP_JOB 1 - exit 0 - fi -fi - - -echo "Executing the job since there is no skip rule preventing the execution" -exit 0 From 4942a35f24b1e97c8ca119a2bada670fbba6e477 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Tue, 23 Apr 2024 15:09:22 +0200 Subject: [PATCH 09/16] Remove step YAML anchor and `env.SKIP_JOB` --- .github/workflows/ci.yml | 28 ++-------------------------- src/ci/github-actions/ci.yml | 32 ++------------------------------ 2 files changed, 4 insertions(+), 56 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 149640140d9f0..3651ef2c614ef 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -88,79 +88,57 @@ jobs: run: "echo \"[CI_PR_NUMBER=$num]\"" env: num: "${{ github.event.number }}" - if: "success() && !env.SKIP_JOB && github.event_name == 'pull_request'" + if: "success() && github.event_name == 'pull_request'" - name: add extra environment variables run: src/ci/scripts/setup-environment.sh env: EXTRA_VARIABLES: "${{ toJson(matrix.env) }}" - if: success() && !env.SKIP_JOB - name: ensure the channel matches the target branch run: src/ci/scripts/verify-channel.sh - if: success() && !env.SKIP_JOB - name: collect CPU statistics run: src/ci/scripts/collect-cpu-stats.sh - if: success() && !env.SKIP_JOB - name: show the current environment run: src/ci/scripts/dump-environment.sh - if: success() && !env.SKIP_JOB - name: install awscli run: src/ci/scripts/install-awscli.sh - if: success() && !env.SKIP_JOB - name: install sccache run: src/ci/scripts/install-sccache.sh - if: success() && !env.SKIP_JOB - name: select Xcode run: src/ci/scripts/select-xcode.sh - if: success() && !env.SKIP_JOB - name: install clang run: src/ci/scripts/install-clang.sh - if: success() && !env.SKIP_JOB - name: install tidy run: src/ci/scripts/install-tidy.sh - if: success() && !env.SKIP_JOB - name: install WIX run: src/ci/scripts/install-wix.sh - if: success() && !env.SKIP_JOB - name: disable git crlf conversion run: src/ci/scripts/disable-git-crlf-conversion.sh - if: success() && !env.SKIP_JOB - name: checkout submodules run: src/ci/scripts/checkout-submodules.sh - if: success() && !env.SKIP_JOB - name: install MSYS2 run: src/ci/scripts/install-msys2.sh - if: success() && !env.SKIP_JOB - name: install MinGW run: src/ci/scripts/install-mingw.sh - if: success() && !env.SKIP_JOB - name: install ninja run: src/ci/scripts/install-ninja.sh - if: success() && !env.SKIP_JOB - name: enable ipv6 on Docker run: src/ci/scripts/enable-docker-ipv6.sh - if: success() && !env.SKIP_JOB - name: disable git crlf conversion run: src/ci/scripts/disable-git-crlf-conversion.sh - if: success() && !env.SKIP_JOB - name: ensure line endings are correct run: src/ci/scripts/verify-line-endings.sh - if: success() && !env.SKIP_JOB - name: ensure backported commits are in upstream branches run: src/ci/scripts/verify-backported-commits.sh - if: success() && !env.SKIP_JOB - name: ensure the stable version number is correct run: src/ci/scripts/verify-stable-version-number.sh - if: success() && !env.SKIP_JOB - name: run the build run: src/ci/scripts/run-build-from-ci.sh 2>&1 env: AWS_ACCESS_KEY_ID: "${{ env.CACHES_AWS_ACCESS_KEY_ID }}" AWS_SECRET_ACCESS_KEY: "${{ secrets[format('AWS_SECRET_ACCESS_KEY_{0}', env.CACHES_AWS_ACCESS_KEY_ID)] }}" TOOLSTATE_REPO_ACCESS_TOKEN: "${{ secrets.TOOLSTATE_REPO_ACCESS_TOKEN }}" - if: success() && !env.SKIP_JOB - name: create github artifacts run: src/ci/scripts/create-doc-artifacts.sh - if: success() && !env.SKIP_JOB - name: upload artifacts to github uses: actions/upload-artifact@v4 with: @@ -168,13 +146,12 @@ jobs: path: obj/artifacts/doc if-no-files-found: ignore retention-days: 5 - if: success() && !env.SKIP_JOB - name: upload artifacts to S3 run: src/ci/scripts/upload-artifacts.sh env: AWS_ACCESS_KEY_ID: "${{ env.ARTIFACTS_AWS_ACCESS_KEY_ID }}" AWS_SECRET_ACCESS_KEY: "${{ secrets[format('AWS_SECRET_ACCESS_KEY_{0}', env.ARTIFACTS_AWS_ACCESS_KEY_ID)] }}" - if: "success() && !env.SKIP_JOB && (github.event_name == 'push' || env.DEPLOY == '1' || env.DEPLOY_ALT == '1')" + if: "success() && (github.event_name == 'push' || env.DEPLOY == '1' || env.DEPLOY_ALT == '1')" master: name: master runs-on: ubuntu-latest @@ -199,7 +176,6 @@ jobs: shell: bash env: TOOLSTATE_REPO_ACCESS_TOKEN: "${{ secrets.TOOLSTATE_REPO_ACCESS_TOKEN }}" - if: success() && !env.SKIP_JOB try-success: needs: - job diff --git a/src/ci/github-actions/ci.yml b/src/ci/github-actions/ci.yml index 9947bb44ed4d9..bc4b1b815cf37 100644 --- a/src/ci/github-actions/ci.yml +++ b/src/ci/github-actions/ci.yml @@ -107,9 +107,6 @@ x--expand-yaml-anchors--remove: - &job-aarch64-linux os: [self-hosted, ARM64, linux] - - &step - if: success() && !env.SKIP_JOB - - &base-ci-job defaults: run: @@ -151,7 +148,7 @@ x--expand-yaml-anchors--remove: run: echo "[CI_PR_NUMBER=$num]" env: num: ${{ github.event.number }} - if: success() && !env.SKIP_JOB && github.event_name == 'pull_request' + if: success() && github.event_name == 'pull_request' - name: add extra environment variables run: src/ci/scripts/setup-environment.sh @@ -161,67 +158,51 @@ x--expand-yaml-anchors--remove: # are passed to the `setup-environment.sh` script encoded in JSON, # which then uses log commands to actually set them. EXTRA_VARIABLES: ${{ toJson(matrix.env) }} - <<: *step - name: ensure the channel matches the target branch run: src/ci/scripts/verify-channel.sh - <<: *step - name: collect CPU statistics run: src/ci/scripts/collect-cpu-stats.sh - <<: *step - name: show the current environment run: src/ci/scripts/dump-environment.sh - <<: *step - name: install awscli run: src/ci/scripts/install-awscli.sh - <<: *step - name: install sccache run: src/ci/scripts/install-sccache.sh - <<: *step - name: select Xcode run: src/ci/scripts/select-xcode.sh - <<: *step - name: install clang run: src/ci/scripts/install-clang.sh - <<: *step - name: install tidy run: src/ci/scripts/install-tidy.sh - <<: *step - name: install WIX run: src/ci/scripts/install-wix.sh - <<: *step - name: disable git crlf conversion run: src/ci/scripts/disable-git-crlf-conversion.sh - <<: *step - name: checkout submodules run: src/ci/scripts/checkout-submodules.sh - <<: *step - name: install MSYS2 run: src/ci/scripts/install-msys2.sh - <<: *step - name: install MinGW run: src/ci/scripts/install-mingw.sh - <<: *step - name: install ninja run: src/ci/scripts/install-ninja.sh - <<: *step - name: enable ipv6 on Docker run: src/ci/scripts/enable-docker-ipv6.sh - <<: *step # Disable automatic line ending conversion (again). On Windows, when we're # installing dependencies, something switches the git configuration directory or @@ -230,19 +211,15 @@ x--expand-yaml-anchors--remove: # appropriate line endings. - name: disable git crlf conversion run: src/ci/scripts/disable-git-crlf-conversion.sh - <<: *step - name: ensure line endings are correct run: src/ci/scripts/verify-line-endings.sh - <<: *step - name: ensure backported commits are in upstream branches run: src/ci/scripts/verify-backported-commits.sh - <<: *step - name: ensure the stable version number is correct run: src/ci/scripts/verify-stable-version-number.sh - <<: *step - name: run the build # Redirect stderr to stdout to avoid reordering the two streams in the GHA logs. @@ -251,11 +228,9 @@ x--expand-yaml-anchors--remove: AWS_ACCESS_KEY_ID: ${{ env.CACHES_AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets[format('AWS_SECRET_ACCESS_KEY_{0}', env.CACHES_AWS_ACCESS_KEY_ID)] }} TOOLSTATE_REPO_ACCESS_TOKEN: ${{ secrets.TOOLSTATE_REPO_ACCESS_TOKEN }} - <<: *step - name: create github artifacts run: src/ci/scripts/create-doc-artifacts.sh - <<: *step - name: upload artifacts to github uses: actions/upload-artifact@v4 @@ -265,7 +240,6 @@ x--expand-yaml-anchors--remove: path: obj/artifacts/doc if-no-files-found: ignore retention-days: 5 - <<: *step - name: upload artifacts to S3 run: src/ci/scripts/upload-artifacts.sh @@ -277,8 +251,7 @@ x--expand-yaml-anchors--remove: # adding the condition is helpful as this way CI will not silently skip # deploying artifacts from a dist builder if the variables are misconfigured, # erroring about invalid credentials instead. - if: success() && !env.SKIP_JOB && (github.event_name == 'push' || env.DEPLOY == '1' || env.DEPLOY_ALT == '1') - <<: *step + if: success() && (github.event_name == 'push' || env.DEPLOY == '1' || env.DEPLOY_ALT == '1') # These snippets are used by the try-success, try-failure, auto-success and auto-failure jobs. # Check out their documentation for more information on why they're needed. @@ -395,7 +368,6 @@ jobs: shell: bash env: TOOLSTATE_REPO_ACCESS_TOKEN: ${{ secrets.TOOLSTATE_REPO_ACCESS_TOKEN }} - <<: *step # These jobs don't actually test anything, but they're used to tell bors the # build completed, as there is no practical way to detect when a workflow is From c59bc9a06ab0de13d96f02616b9476c5426fe54c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Wed, 24 Apr 2024 12:15:17 +0200 Subject: [PATCH 10/16] Fix documentation --- src/ci/github-actions/jobs.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ci/github-actions/jobs.yml b/src/ci/github-actions/jobs.yml index ec58bd0924e86..0f5dfaa578570 100644 --- a/src/ci/github-actions/jobs.yml +++ b/src/ci/github-actions/jobs.yml @@ -79,7 +79,7 @@ pr: <<: *job-linux-16c # Jobs that run when you perform a try build (@bors try) -# These jobs automatically inherit envs.production, to avoid repeating +# These jobs automatically inherit envs.try, to avoid repeating # it in each job definition. try: - image: dist-x86_64-linux @@ -88,7 +88,7 @@ try: <<: *job-linux-16c # Main CI jobs that have to be green to merge a commit into master -# These jobs automatically inherit envs.production, to avoid repeating +# These jobs automatically inherit envs.auto, to avoid repeating # it in each job definition. auto: ############################# From c36d78ed64d005046c0e57e28dee314ae64cb0ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Wed, 24 Apr 2024 12:32:25 +0200 Subject: [PATCH 11/16] Turn CI_ONLY_WHEN_CHANNEL from an environment variable to a job attribute --- src/ci/github-actions/calculate-job-matrix.py | 2 +- src/ci/github-actions/jobs.yml | 17 ++++++++--------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/ci/github-actions/calculate-job-matrix.py b/src/ci/github-actions/calculate-job-matrix.py index 84c4ee406685a..124c22bd979f1 100755 --- a/src/ci/github-actions/calculate-job-matrix.py +++ b/src/ci/github-actions/calculate-job-matrix.py @@ -95,7 +95,7 @@ def skip_jobs(jobs: List[Dict[str, Any]], channel: str) -> List[Job]: """ Skip CI jobs that are not supposed to be executed on the given `channel`. """ - return [j for j in jobs if j.get("CI_ONLY_WHEN_CHANNEL", channel) == channel] + return [j for j in jobs if j.get("only_on_channel", channel) == channel] def get_github_ctx() -> GitHubCtx: diff --git a/src/ci/github-actions/jobs.yml b/src/ci/github-actions/jobs.yml index 0f5dfaa578570..df6c5d6079d1a 100644 --- a/src/ci/github-actions/jobs.yml +++ b/src/ci/github-actions/jobs.yml @@ -200,24 +200,23 @@ auto: # channel name on the output), and this builder prevents landing # changes that would result in broken builds after a promotion. - image: x86_64-gnu-stable + # Only run this job on the nightly channel. Running this on beta + # could cause failures when `dev: 1` in `stage0.txt`, and running + # this on stable is useless. + only_on_channel: nightly env: IMAGE: x86_64-gnu RUST_CI_OVERRIDE_RELEASE_CHANNEL: stable - # Only run this job on the nightly channel. Running this on beta - # could cause failures when `dev: 1` in `stage0.txt`, and running - # this on stable is useless. - CI_ONLY_WHEN_CHANNEL: nightly <<: *job-linux-4c - image: x86_64-gnu-aux <<: *job-linux-4c - image: x86_64-gnu-integration - env: - # Only run this job on the nightly channel. Fuchsia requires - # nightly features to compile, and this job would fail if - # executed on beta and stable. - CI_ONLY_WHEN_CHANNEL: nightly + # Only run this job on the nightly channel. Fuchsia requires + # nightly features to compile, and this job would fail if + # executed on beta and stable. + only_on_channel: nightly <<: *job-linux-8c - image: x86_64-gnu-debug From f2b3f3e295c917e85d961ec1eb2bee5997b8f880 Mon Sep 17 00:00:00 2001 From: Urgau Date: Wed, 24 Apr 2024 22:06:54 +0200 Subject: [PATCH 12/16] tests/ui: prepare some tests for --check-cfg by default --- .../feature-gate-cfg-target-compact.rs | 8 ++++---- .../feature-gate-cfg-target-compact.stderr | 16 ++++++++-------- tests/ui/issues/issue-11085.rs | 7 +++---- tests/ui/issues/issue-24434.rs | 3 +-- tests/ui/macros/macro-meta-items.rs | 6 +++--- tests/ui/macros/syntax-extension-cfg.rs | 12 ++++++------ 6 files changed, 25 insertions(+), 27 deletions(-) diff --git a/tests/ui/feature-gates/feature-gate-cfg-target-compact.rs b/tests/ui/feature-gates/feature-gate-cfg-target-compact.rs index df81b7d2297ea..e9dd81cea1bfd 100644 --- a/tests/ui/feature-gates/feature-gate-cfg-target-compact.rs +++ b/tests/ui/feature-gates/feature-gate-cfg-target-compact.rs @@ -1,13 +1,13 @@ -#[cfg(target(os = "x"))] //~ ERROR compact `cfg(target(..))` is experimental +#[cfg(target(os = "linux"))] //~ ERROR compact `cfg(target(..))` is experimental struct Foo(u64, u64); -#[cfg_attr(target(os = "x"), x)] //~ ERROR compact `cfg(target(..))` is experimental +#[cfg_attr(target(os = "linux"), non_exhaustive)] //~ ERROR compact `cfg(target(..))` is experimental struct Bar(u64, u64); -#[cfg(not(any(all(target(os = "x")))))] //~ ERROR compact `cfg(target(..))` is experimental +#[cfg(not(any(all(target(os = "linux")))))] //~ ERROR compact `cfg(target(..))` is experimental fn foo() {} fn main() { - cfg!(target(os = "x")); + cfg!(target(os = "linux")); //~^ ERROR compact `cfg(target(..))` is experimental and subject to change } diff --git a/tests/ui/feature-gates/feature-gate-cfg-target-compact.stderr b/tests/ui/feature-gates/feature-gate-cfg-target-compact.stderr index 1fd59651957ed..75c5ab37a4dce 100644 --- a/tests/ui/feature-gates/feature-gate-cfg-target-compact.stderr +++ b/tests/ui/feature-gates/feature-gate-cfg-target-compact.stderr @@ -1,8 +1,8 @@ error[E0658]: compact `cfg(target(..))` is experimental and subject to change --> $DIR/feature-gate-cfg-target-compact.rs:1:7 | -LL | #[cfg(target(os = "x"))] - | ^^^^^^^^^^^^^^^^ +LL | #[cfg(target(os = "linux"))] + | ^^^^^^^^^^^^^^^^^^^^ | = note: see issue #96901 for more information = help: add `#![feature(cfg_target_compact)]` to the crate attributes to enable @@ -11,8 +11,8 @@ LL | #[cfg(target(os = "x"))] error[E0658]: compact `cfg(target(..))` is experimental and subject to change --> $DIR/feature-gate-cfg-target-compact.rs:4:12 | -LL | #[cfg_attr(target(os = "x"), x)] - | ^^^^^^^^^^^^^^^^ +LL | #[cfg_attr(target(os = "linux"), non_exhaustive)] + | ^^^^^^^^^^^^^^^^^^^^ | = note: see issue #96901 for more information = help: add `#![feature(cfg_target_compact)]` to the crate attributes to enable @@ -21,8 +21,8 @@ LL | #[cfg_attr(target(os = "x"), x)] error[E0658]: compact `cfg(target(..))` is experimental and subject to change --> $DIR/feature-gate-cfg-target-compact.rs:7:19 | -LL | #[cfg(not(any(all(target(os = "x")))))] - | ^^^^^^^^^^^^^^^^ +LL | #[cfg(not(any(all(target(os = "linux")))))] + | ^^^^^^^^^^^^^^^^^^^^ | = note: see issue #96901 for more information = help: add `#![feature(cfg_target_compact)]` to the crate attributes to enable @@ -31,8 +31,8 @@ LL | #[cfg(not(any(all(target(os = "x")))))] error[E0658]: compact `cfg(target(..))` is experimental and subject to change --> $DIR/feature-gate-cfg-target-compact.rs:11:10 | -LL | cfg!(target(os = "x")); - | ^^^^^^^^^^^^^^^^ +LL | cfg!(target(os = "linux")); + | ^^^^^^^^^^^^^^^^^^^^ | = note: see issue #96901 for more information = help: add `#![feature(cfg_target_compact)]` to the crate attributes to enable diff --git a/tests/ui/issues/issue-11085.rs b/tests/ui/issues/issue-11085.rs index 300be10226c6c..f646ba35cbfae 100644 --- a/tests/ui/issues/issue-11085.rs +++ b/tests/ui/issues/issue-11085.rs @@ -1,9 +1,8 @@ //@ run-pass -#![allow(dead_code)] -//@ compile-flags: --cfg foo - //@ pretty-expanded FIXME #23616 +#![allow(dead_code)] + struct Foo { #[cfg(FALSE)] bar: baz, @@ -11,7 +10,7 @@ struct Foo { } struct Foo2 { - #[cfg(foo)] + #[cfg(all())] foo: isize, } diff --git a/tests/ui/issues/issue-24434.rs b/tests/ui/issues/issue-24434.rs index 4cf1f8b50f7c4..991084c274093 100644 --- a/tests/ui/issues/issue-24434.rs +++ b/tests/ui/issues/issue-24434.rs @@ -1,7 +1,6 @@ //@ check-pass -//@ compile-flags:--cfg set1 -#![cfg_attr(set1, feature(rustc_attrs))] +#![cfg_attr(all(), feature(rustc_attrs))] #![rustc_dummy] fn main() {} diff --git a/tests/ui/macros/macro-meta-items.rs b/tests/ui/macros/macro-meta-items.rs index 10c57fba24483..d44a3184bc69d 100644 --- a/tests/ui/macros/macro-meta-items.rs +++ b/tests/ui/macros/macro-meta-items.rs @@ -16,7 +16,7 @@ macro_rules! emit { } // item -compiles_fine!(bar); +compiles_fine!(FALSE); emit!(foo); fn foo() { @@ -25,7 +25,7 @@ fn foo() { pub fn main() { // statement - compiles_fine!(baz); - emit!(baz); + compiles_fine!(FALSE); + emit!(FALSE); println!("{}", MISTYPED); } diff --git a/tests/ui/macros/syntax-extension-cfg.rs b/tests/ui/macros/syntax-extension-cfg.rs index 56d869f3dc121..b819e8c33d804 100644 --- a/tests/ui/macros/syntax-extension-cfg.rs +++ b/tests/ui/macros/syntax-extension-cfg.rs @@ -14,11 +14,11 @@ pub fn main() { if cfg!(not(all(foo, qux="foo"))) { panic!() } if cfg!(all(not(all(foo, qux="foo")))) { panic!() } - if cfg!(not_a_cfg) { panic!() } - if cfg!(all(not_a_cfg, foo, qux="foo")) { panic!() } - if cfg!(all(not_a_cfg, foo, qux="foo")) { panic!() } - if ! cfg!(any(not_a_cfg, foo)) { panic!() } + if cfg!(FALSE) { panic!() } + if cfg!(all(FALSE, foo, qux="foo")) { panic!() } + if cfg!(all(FALSE, foo, qux="foo")) { panic!() } + if ! cfg!(any(FALSE, foo)) { panic!() } - if ! cfg!(not(not_a_cfg)) { panic!() } - if ! cfg!(all(not(not_a_cfg), foo, qux="foo")) { panic!() } + if ! cfg!(not(FALSE)) { panic!() } + if ! cfg!(all(not(FALSE), foo, qux="foo")) { panic!() } } From 16372f86f3878ec40cd2b05b942f4b6e911149d7 Mon Sep 17 00:00:00 2001 From: Urgau Date: Tue, 9 Apr 2024 14:07:30 +0200 Subject: [PATCH 13/16] compiletest: add no-auto-check-cfg directive this directive prevents compiletest from adding any implicit and automatic --check-cfg arguments --- src/tools/compiletest/src/header.rs | 7 +++ tests/ui/check-cfg/allow-at-crate-level.rs | 1 + tests/ui/check-cfg/allow-macro-cfg.rs | 1 + tests/ui/check-cfg/allow-same-level.rs | 1 + tests/ui/check-cfg/allow-same-level.stderr | 2 +- tests/ui/check-cfg/allow-top-level.rs | 1 + tests/ui/check-cfg/allow-upper-level.rs | 1 + tests/ui/check-cfg/cargo-feature.none.stderr | 8 +-- tests/ui/check-cfg/cargo-feature.rs | 1 + tests/ui/check-cfg/cargo-feature.some.stderr | 8 +-- .../cfg-value-for-cfg-name-duplicate.rs | 1 + .../cfg-value-for-cfg-name-duplicate.stderr | 2 +- .../cfg-value-for-cfg-name-multiple.rs | 1 + .../cfg-value-for-cfg-name-multiple.stderr | 2 +- tests/ui/check-cfg/cfg-value-for-cfg-name.rs | 1 + .../check-cfg/cfg-value-for-cfg-name.stderr | 4 +- tests/ui/check-cfg/compact-names.rs | 1 + tests/ui/check-cfg/compact-names.stderr | 2 +- tests/ui/check-cfg/compact-values.rs | 1 + tests/ui/check-cfg/compact-values.stderr | 2 +- tests/ui/check-cfg/concat-values.rs | 1 + tests/ui/check-cfg/concat-values.stderr | 4 +- tests/ui/check-cfg/diagnotics.cargo.stderr | 12 ++-- tests/ui/check-cfg/diagnotics.rs | 1 + tests/ui/check-cfg/diagnotics.rustc.stderr | 12 ++-- tests/ui/check-cfg/empty-values.rs | 1 + tests/ui/check-cfg/empty-values.stderr | 4 +- .../exhaustive-names-values.empty_cfg.stderr | 8 +-- .../exhaustive-names-values.feature.stderr | 6 +- .../exhaustive-names-values.full.stderr | 6 +- tests/ui/check-cfg/exhaustive-names-values.rs | 1 + tests/ui/check-cfg/exhaustive-names.rs | 1 + tests/ui/check-cfg/exhaustive-names.stderr | 2 +- .../exhaustive-values.empty_cfg.stderr | 2 +- tests/ui/check-cfg/exhaustive-values.rs | 1 + .../exhaustive-values.without_names.stderr | 2 +- tests/ui/check-cfg/invalid-arguments.rs | 1 + tests/ui/check-cfg/mix.rs | 1 + tests/ui/check-cfg/mix.stderr | 54 +++++++++--------- .../check-cfg/no-expected-values.empty.stderr | 4 +- .../check-cfg/no-expected-values.mixed.stderr | 4 +- tests/ui/check-cfg/no-expected-values.rs | 1 + .../no-expected-values.simple.stderr | 4 +- tests/ui/check-cfg/order-independant.rs | 1 + .../order-independant.values_after.stderr | 2 +- .../order-independant.values_before.stderr | 2 +- tests/ui/check-cfg/stmt-no-ice.rs | 1 + tests/ui/check-cfg/stmt-no-ice.stderr | 2 +- tests/ui/check-cfg/unexpected-cfg-name.rs | 1 + tests/ui/check-cfg/unexpected-cfg-name.stderr | 2 +- tests/ui/check-cfg/unexpected-cfg-value.rs | 1 + .../ui/check-cfg/unexpected-cfg-value.stderr | 4 +- tests/ui/check-cfg/unknown-values.rs | 1 + .../ui/check-cfg/values-none.explicit.stderr | 4 +- .../ui/check-cfg/values-none.implicit.stderr | 4 +- tests/ui/check-cfg/values-none.rs | 1 + tests/ui/check-cfg/values-target-json.rs | 1 + tests/ui/check-cfg/well-known-names.rs | 1 + tests/ui/check-cfg/well-known-names.stderr | 8 +-- tests/ui/check-cfg/well-known-values.rs | 1 + tests/ui/check-cfg/well-known-values.stderr | 56 +++++++++---------- 61 files changed, 155 insertions(+), 119 deletions(-) diff --git a/src/tools/compiletest/src/header.rs b/src/tools/compiletest/src/header.rs index f5d7ce1c5f9a0..578e93b79374c 100644 --- a/src/tools/compiletest/src/header.rs +++ b/src/tools/compiletest/src/header.rs @@ -208,6 +208,8 @@ pub struct TestProps { pub llvm_cov_flags: Vec, /// Extra flags to pass to LLVM's `filecheck` tool, in tests that use it. pub filecheck_flags: Vec, + /// Don't automatically insert any `--check-cfg` args + pub no_auto_check_cfg: bool, } mod directives { @@ -249,6 +251,7 @@ mod directives { pub const COMPARE_OUTPUT_LINES_BY_SUBSET: &'static str = "compare-output-lines-by-subset"; pub const LLVM_COV_FLAGS: &'static str = "llvm-cov-flags"; pub const FILECHECK_FLAGS: &'static str = "filecheck-flags"; + pub const NO_AUTO_CHECK_CFG: &'static str = "no-auto-check-cfg"; // This isn't a real directive, just one that is probably mistyped often pub const INCORRECT_COMPILER_FLAGS: &'static str = "compiler-flags"; } @@ -304,6 +307,7 @@ impl TestProps { remap_src_base: false, llvm_cov_flags: vec![], filecheck_flags: vec![], + no_auto_check_cfg: false, } } @@ -567,6 +571,8 @@ impl TestProps { if let Some(flags) = config.parse_name_value_directive(ln, FILECHECK_FLAGS) { self.filecheck_flags.extend(split_flags(&flags)); } + + config.set_name_directive(ln, NO_AUTO_CHECK_CFG, &mut self.no_auto_check_cfg); }, ); @@ -860,6 +866,7 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[ "needs-unwind", "needs-wasmtime", "needs-xray", + "no-auto-check-cfg", "no-prefer-dynamic", "normalize-stderr-32bit", "normalize-stderr-64bit", diff --git a/tests/ui/check-cfg/allow-at-crate-level.rs b/tests/ui/check-cfg/allow-at-crate-level.rs index 03b4676ad5f10..9dc2416a3a938 100644 --- a/tests/ui/check-cfg/allow-at-crate-level.rs +++ b/tests/ui/check-cfg/allow-at-crate-level.rs @@ -1,6 +1,7 @@ // This test check that #![allow(unexpected_cfgs)] works with --cfg // //@ check-pass +//@ no-auto-check-cfg //@ compile-flags: --cfg=unexpected --check-cfg=cfg() #![allow(unexpected_cfgs)] diff --git a/tests/ui/check-cfg/allow-macro-cfg.rs b/tests/ui/check-cfg/allow-macro-cfg.rs index 3db6e18d77a8d..b3c706d6d2b74 100644 --- a/tests/ui/check-cfg/allow-macro-cfg.rs +++ b/tests/ui/check-cfg/allow-macro-cfg.rs @@ -1,6 +1,7 @@ // This test check that local #[allow(unexpected_cfgs)] works // //@ check-pass +//@ no-auto-check-cfg //@ compile-flags: --check-cfg=cfg() #[allow(unexpected_cfgs)] diff --git a/tests/ui/check-cfg/allow-same-level.rs b/tests/ui/check-cfg/allow-same-level.rs index e932ece6ee771..ff724174cea54 100644 --- a/tests/ui/check-cfg/allow-same-level.rs +++ b/tests/ui/check-cfg/allow-same-level.rs @@ -1,6 +1,7 @@ // This test check that #[allow(unexpected_cfgs)] doesn't work if put on the same level // //@ check-pass +//@ no-auto-check-cfg //@ compile-flags: --check-cfg=cfg() #[allow(unexpected_cfgs)] diff --git a/tests/ui/check-cfg/allow-same-level.stderr b/tests/ui/check-cfg/allow-same-level.stderr index 349f41cb142c8..99e81d3bba6d0 100644 --- a/tests/ui/check-cfg/allow-same-level.stderr +++ b/tests/ui/check-cfg/allow-same-level.stderr @@ -1,5 +1,5 @@ warning: unexpected `cfg` condition name: `FALSE` - --> $DIR/allow-same-level.rs:7:7 + --> $DIR/allow-same-level.rs:8:7 | LL | #[cfg(FALSE)] | ^^^^^ diff --git a/tests/ui/check-cfg/allow-top-level.rs b/tests/ui/check-cfg/allow-top-level.rs index 0f88543d8478d..cf94ed5da428f 100644 --- a/tests/ui/check-cfg/allow-top-level.rs +++ b/tests/ui/check-cfg/allow-top-level.rs @@ -1,6 +1,7 @@ // This test check that a top-level #![allow(unexpected_cfgs)] works // //@ check-pass +//@ no-auto-check-cfg //@ compile-flags: --check-cfg=cfg() #![allow(unexpected_cfgs)] diff --git a/tests/ui/check-cfg/allow-upper-level.rs b/tests/ui/check-cfg/allow-upper-level.rs index d03d0cab37b7d..2e6664c30d395 100644 --- a/tests/ui/check-cfg/allow-upper-level.rs +++ b/tests/ui/check-cfg/allow-upper-level.rs @@ -1,6 +1,7 @@ // This test check that #[allow(unexpected_cfgs)] work if put on an upper level // //@ check-pass +//@ no-auto-check-cfg //@ compile-flags: --check-cfg=cfg() #[allow(unexpected_cfgs)] diff --git a/tests/ui/check-cfg/cargo-feature.none.stderr b/tests/ui/check-cfg/cargo-feature.none.stderr index 0b914c2bc3559..09a1c95026722 100644 --- a/tests/ui/check-cfg/cargo-feature.none.stderr +++ b/tests/ui/check-cfg/cargo-feature.none.stderr @@ -1,5 +1,5 @@ warning: unexpected `cfg` condition value: `serde` - --> $DIR/cargo-feature.rs:13:7 + --> $DIR/cargo-feature.rs:14:7 | LL | #[cfg(feature = "serde")] | ^^^^^^^^^^^^^^^^^ help: remove the condition @@ -10,7 +10,7 @@ LL | #[cfg(feature = "serde")] = note: `#[warn(unexpected_cfgs)]` on by default warning: unexpected `cfg` condition value: (none) - --> $DIR/cargo-feature.rs:17:7 + --> $DIR/cargo-feature.rs:18:7 | LL | #[cfg(feature)] | ^^^^^^^ help: remove the condition @@ -20,7 +20,7 @@ LL | #[cfg(feature)] = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition name: `tokio_unstable` - --> $DIR/cargo-feature.rs:21:7 + --> $DIR/cargo-feature.rs:22:7 | LL | #[cfg(tokio_unstable)] | ^^^^^^^^^^^^^^ @@ -30,7 +30,7 @@ LL | #[cfg(tokio_unstable)] = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition name: `CONFIG_NVME` - --> $DIR/cargo-feature.rs:25:7 + --> $DIR/cargo-feature.rs:26:7 | LL | #[cfg(CONFIG_NVME = "m")] | ^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/check-cfg/cargo-feature.rs b/tests/ui/check-cfg/cargo-feature.rs index ced0d381d2df0..13faf7f28200d 100644 --- a/tests/ui/check-cfg/cargo-feature.rs +++ b/tests/ui/check-cfg/cargo-feature.rs @@ -3,6 +3,7 @@ // list of all the expected names // //@ check-pass +//@ no-auto-check-cfg //@ revisions: some none //@ rustc-env:CARGO_CRATE_NAME=foo //@ [none]compile-flags: --check-cfg=cfg(feature,values()) diff --git a/tests/ui/check-cfg/cargo-feature.some.stderr b/tests/ui/check-cfg/cargo-feature.some.stderr index 1a4ef89efc1a6..4db9c66fc8692 100644 --- a/tests/ui/check-cfg/cargo-feature.some.stderr +++ b/tests/ui/check-cfg/cargo-feature.some.stderr @@ -1,5 +1,5 @@ warning: unexpected `cfg` condition value: `serde` - --> $DIR/cargo-feature.rs:13:7 + --> $DIR/cargo-feature.rs:14:7 | LL | #[cfg(feature = "serde")] | ^^^^^^^^^^^^^^^^^ @@ -10,7 +10,7 @@ LL | #[cfg(feature = "serde")] = note: `#[warn(unexpected_cfgs)]` on by default warning: unexpected `cfg` condition value: (none) - --> $DIR/cargo-feature.rs:17:7 + --> $DIR/cargo-feature.rs:18:7 | LL | #[cfg(feature)] | ^^^^^^^- help: specify a config value: `= "bitcode"` @@ -20,7 +20,7 @@ LL | #[cfg(feature)] = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition name: `tokio_unstable` - --> $DIR/cargo-feature.rs:21:7 + --> $DIR/cargo-feature.rs:22:7 | LL | #[cfg(tokio_unstable)] | ^^^^^^^^^^^^^^ @@ -30,7 +30,7 @@ LL | #[cfg(tokio_unstable)] = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `m` - --> $DIR/cargo-feature.rs:25:7 + --> $DIR/cargo-feature.rs:26:7 | LL | #[cfg(CONFIG_NVME = "m")] | ^^^^^^^^^^^^^^--- diff --git a/tests/ui/check-cfg/cfg-value-for-cfg-name-duplicate.rs b/tests/ui/check-cfg/cfg-value-for-cfg-name-duplicate.rs index 79d4e45c13b47..dd82ccd2c5125 100644 --- a/tests/ui/check-cfg/cfg-value-for-cfg-name-duplicate.rs +++ b/tests/ui/check-cfg/cfg-value-for-cfg-name-duplicate.rs @@ -2,6 +2,7 @@ // This test checks we won't suggest more than 3 span suggestions for cfg names // //@ check-pass +//@ no-auto-check-cfg //@ compile-flags: --check-cfg=cfg(foo,values("value")) --check-cfg=cfg(bar,values("value")) --check-cfg=cfg(bee,values("value")) --check-cfg=cfg(cow,values("value")) #[cfg(value)] diff --git a/tests/ui/check-cfg/cfg-value-for-cfg-name-duplicate.stderr b/tests/ui/check-cfg/cfg-value-for-cfg-name-duplicate.stderr index 23ae4c55e42be..f1393c5581950 100644 --- a/tests/ui/check-cfg/cfg-value-for-cfg-name-duplicate.stderr +++ b/tests/ui/check-cfg/cfg-value-for-cfg-name-duplicate.stderr @@ -1,5 +1,5 @@ warning: unexpected `cfg` condition name: `value` - --> $DIR/cfg-value-for-cfg-name-duplicate.rs:7:7 + --> $DIR/cfg-value-for-cfg-name-duplicate.rs:8:7 | LL | #[cfg(value)] | ^^^^^ diff --git a/tests/ui/check-cfg/cfg-value-for-cfg-name-multiple.rs b/tests/ui/check-cfg/cfg-value-for-cfg-name-multiple.rs index f2fd050bb75ac..3a94b6a607238 100644 --- a/tests/ui/check-cfg/cfg-value-for-cfg-name-multiple.rs +++ b/tests/ui/check-cfg/cfg-value-for-cfg-name-multiple.rs @@ -2,6 +2,7 @@ // This test checks that when a single cfg has a value for user's specified name // //@ check-pass +//@ no-auto-check-cfg //@ compile-flags: --check-cfg=cfg(foo,values("my_value")) --check-cfg=cfg(bar,values("my_value")) #[cfg(my_value)] diff --git a/tests/ui/check-cfg/cfg-value-for-cfg-name-multiple.stderr b/tests/ui/check-cfg/cfg-value-for-cfg-name-multiple.stderr index b5faaf6029c49..3d4f430c2bbba 100644 --- a/tests/ui/check-cfg/cfg-value-for-cfg-name-multiple.stderr +++ b/tests/ui/check-cfg/cfg-value-for-cfg-name-multiple.stderr @@ -1,5 +1,5 @@ warning: unexpected `cfg` condition name: `my_value` - --> $DIR/cfg-value-for-cfg-name-multiple.rs:7:7 + --> $DIR/cfg-value-for-cfg-name-multiple.rs:8:7 | LL | #[cfg(my_value)] | ^^^^^^^^ diff --git a/tests/ui/check-cfg/cfg-value-for-cfg-name.rs b/tests/ui/check-cfg/cfg-value-for-cfg-name.rs index e8f9095655b53..50f2fbab60365 100644 --- a/tests/ui/check-cfg/cfg-value-for-cfg-name.rs +++ b/tests/ui/check-cfg/cfg-value-for-cfg-name.rs @@ -3,6 +3,7 @@ // suggest to use `#[cfg(target_os = "linux")]` instead of `#[cfg(linux)]` // //@ check-pass +//@ no-auto-check-cfg //@ compile-flags: --check-cfg=cfg() #[cfg(linux)] diff --git a/tests/ui/check-cfg/cfg-value-for-cfg-name.stderr b/tests/ui/check-cfg/cfg-value-for-cfg-name.stderr index 01586a6c71d2d..142d10076e9fc 100644 --- a/tests/ui/check-cfg/cfg-value-for-cfg-name.stderr +++ b/tests/ui/check-cfg/cfg-value-for-cfg-name.stderr @@ -1,5 +1,5 @@ warning: unexpected `cfg` condition name: `linux` - --> $DIR/cfg-value-for-cfg-name.rs:8:7 + --> $DIR/cfg-value-for-cfg-name.rs:9:7 | LL | #[cfg(linux)] | ^^^^^ help: found config with similar value: `target_os = "linux"` @@ -10,7 +10,7 @@ LL | #[cfg(linux)] = note: `#[warn(unexpected_cfgs)]` on by default warning: unexpected `cfg` condition name: `linux` - --> $DIR/cfg-value-for-cfg-name.rs:13:7 + --> $DIR/cfg-value-for-cfg-name.rs:14:7 | LL | #[cfg(linux = "os-name")] | ^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/check-cfg/compact-names.rs b/tests/ui/check-cfg/compact-names.rs index ddbd20b99b28e..931afdf986f4f 100644 --- a/tests/ui/check-cfg/compact-names.rs +++ b/tests/ui/check-cfg/compact-names.rs @@ -1,6 +1,7 @@ // This test check that we correctly emit an warning for compact cfg // //@ check-pass +//@ no-auto-check-cfg //@ compile-flags: --check-cfg=cfg() #![feature(cfg_target_compact)] diff --git a/tests/ui/check-cfg/compact-names.stderr b/tests/ui/check-cfg/compact-names.stderr index 929501b420a7b..dd19f6066203c 100644 --- a/tests/ui/check-cfg/compact-names.stderr +++ b/tests/ui/check-cfg/compact-names.stderr @@ -1,5 +1,5 @@ warning: unexpected `cfg` condition name: `target_architecture` - --> $DIR/compact-names.rs:11:28 + --> $DIR/compact-names.rs:12:28 | LL | #[cfg(target(os = "linux", architecture = "arm"))] | ^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/check-cfg/compact-values.rs b/tests/ui/check-cfg/compact-values.rs index bda4686ebd742..f13c23f689572 100644 --- a/tests/ui/check-cfg/compact-values.rs +++ b/tests/ui/check-cfg/compact-values.rs @@ -1,6 +1,7 @@ // This test check that we correctly emit an warning for compact cfg // //@ check-pass +//@ no-auto-check-cfg //@ compile-flags: --check-cfg=cfg() #![feature(cfg_target_compact)] diff --git a/tests/ui/check-cfg/compact-values.stderr b/tests/ui/check-cfg/compact-values.stderr index 45d084c46bfa9..4fe921dd24b20 100644 --- a/tests/ui/check-cfg/compact-values.stderr +++ b/tests/ui/check-cfg/compact-values.stderr @@ -1,5 +1,5 @@ warning: unexpected `cfg` condition value: `X` - --> $DIR/compact-values.rs:11:28 + --> $DIR/compact-values.rs:12:28 | LL | #[cfg(target(os = "linux", pointer_width = "X"))] | ^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/check-cfg/concat-values.rs b/tests/ui/check-cfg/concat-values.rs index c546590a2c1ff..6cbc5d6074cfb 100644 --- a/tests/ui/check-cfg/concat-values.rs +++ b/tests/ui/check-cfg/concat-values.rs @@ -1,4 +1,5 @@ //@ check-pass +//@ no-auto-check-cfg //@ compile-flags: --check-cfg=cfg(my_cfg,values("foo")) --check-cfg=cfg(my_cfg,values("bar")) //@ compile-flags: --check-cfg=cfg(my_cfg,values()) diff --git a/tests/ui/check-cfg/concat-values.stderr b/tests/ui/check-cfg/concat-values.stderr index ca8b58f73e5f3..a508c3976617d 100644 --- a/tests/ui/check-cfg/concat-values.stderr +++ b/tests/ui/check-cfg/concat-values.stderr @@ -1,5 +1,5 @@ warning: unexpected `cfg` condition value: (none) - --> $DIR/concat-values.rs:5:7 + --> $DIR/concat-values.rs:6:7 | LL | #[cfg(my_cfg)] | ^^^^^^ @@ -10,7 +10,7 @@ LL | #[cfg(my_cfg)] = note: `#[warn(unexpected_cfgs)]` on by default warning: unexpected `cfg` condition value: `unk` - --> $DIR/concat-values.rs:9:7 + --> $DIR/concat-values.rs:10:7 | LL | #[cfg(my_cfg = "unk")] | ^^^^^^^^^^^^^^ diff --git a/tests/ui/check-cfg/diagnotics.cargo.stderr b/tests/ui/check-cfg/diagnotics.cargo.stderr index 05c52bf59fad6..16417fe010544 100644 --- a/tests/ui/check-cfg/diagnotics.cargo.stderr +++ b/tests/ui/check-cfg/diagnotics.cargo.stderr @@ -1,5 +1,5 @@ warning: unexpected `cfg` condition name: `featur` - --> $DIR/diagnotics.rs:7:7 + --> $DIR/diagnotics.rs:8:7 | LL | #[cfg(featur)] | ^^^^^^ help: there is a config with a similar name: `feature` @@ -9,7 +9,7 @@ LL | #[cfg(featur)] = note: `#[warn(unexpected_cfgs)]` on by default warning: unexpected `cfg` condition name: `featur` - --> $DIR/diagnotics.rs:11:7 + --> $DIR/diagnotics.rs:12:7 | LL | #[cfg(featur = "foo")] | ^^^^^^^^^^^^^^ @@ -21,7 +21,7 @@ LL | #[cfg(feature = "foo")] | ~~~~~~~ warning: unexpected `cfg` condition name: `featur` - --> $DIR/diagnotics.rs:15:7 + --> $DIR/diagnotics.rs:16:7 | LL | #[cfg(featur = "fo")] | ^^^^^^^^^^^^^ @@ -34,7 +34,7 @@ LL | #[cfg(feature = "foo")] | ~~~~~~~~~~~~~~~ warning: unexpected `cfg` condition name: `no_value` - --> $DIR/diagnotics.rs:22:7 + --> $DIR/diagnotics.rs:23:7 | LL | #[cfg(no_value)] | ^^^^^^^^ help: there is a config with a similar name: `no_values` @@ -43,7 +43,7 @@ LL | #[cfg(no_value)] = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition name: `no_value` - --> $DIR/diagnotics.rs:26:7 + --> $DIR/diagnotics.rs:27:7 | LL | #[cfg(no_value = "foo")] | ^^^^^^^^^^^^^^^^ @@ -56,7 +56,7 @@ LL | #[cfg(no_values)] | ~~~~~~~~~ warning: unexpected `cfg` condition value: `bar` - --> $DIR/diagnotics.rs:30:7 + --> $DIR/diagnotics.rs:31:7 | LL | #[cfg(no_values = "bar")] | ^^^^^^^^^-------- diff --git a/tests/ui/check-cfg/diagnotics.rs b/tests/ui/check-cfg/diagnotics.rs index cccd6f9bbc3e9..b8268ec560624 100644 --- a/tests/ui/check-cfg/diagnotics.rs +++ b/tests/ui/check-cfg/diagnotics.rs @@ -1,4 +1,5 @@ //@ check-pass +//@ no-auto-check-cfg //@ revisions: cargo rustc //@ [rustc]unset-rustc-env:CARGO_CRATE_NAME //@ [cargo]rustc-env:CARGO_CRATE_NAME=foo diff --git a/tests/ui/check-cfg/diagnotics.rustc.stderr b/tests/ui/check-cfg/diagnotics.rustc.stderr index 0a938d2143e95..0bd6ce156bb6d 100644 --- a/tests/ui/check-cfg/diagnotics.rustc.stderr +++ b/tests/ui/check-cfg/diagnotics.rustc.stderr @@ -1,5 +1,5 @@ warning: unexpected `cfg` condition name: `featur` - --> $DIR/diagnotics.rs:7:7 + --> $DIR/diagnotics.rs:8:7 | LL | #[cfg(featur)] | ^^^^^^ help: there is a config with a similar name: `feature` @@ -10,7 +10,7 @@ LL | #[cfg(featur)] = note: `#[warn(unexpected_cfgs)]` on by default warning: unexpected `cfg` condition name: `featur` - --> $DIR/diagnotics.rs:11:7 + --> $DIR/diagnotics.rs:12:7 | LL | #[cfg(featur = "foo")] | ^^^^^^^^^^^^^^ @@ -23,7 +23,7 @@ LL | #[cfg(feature = "foo")] | ~~~~~~~ warning: unexpected `cfg` condition name: `featur` - --> $DIR/diagnotics.rs:15:7 + --> $DIR/diagnotics.rs:16:7 | LL | #[cfg(featur = "fo")] | ^^^^^^^^^^^^^ @@ -37,7 +37,7 @@ LL | #[cfg(feature = "foo")] | ~~~~~~~~~~~~~~~ warning: unexpected `cfg` condition name: `no_value` - --> $DIR/diagnotics.rs:22:7 + --> $DIR/diagnotics.rs:23:7 | LL | #[cfg(no_value)] | ^^^^^^^^ help: there is a config with a similar name: `no_values` @@ -46,7 +46,7 @@ LL | #[cfg(no_value)] = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition name: `no_value` - --> $DIR/diagnotics.rs:26:7 + --> $DIR/diagnotics.rs:27:7 | LL | #[cfg(no_value = "foo")] | ^^^^^^^^^^^^^^^^ @@ -59,7 +59,7 @@ LL | #[cfg(no_values)] | ~~~~~~~~~ warning: unexpected `cfg` condition value: `bar` - --> $DIR/diagnotics.rs:30:7 + --> $DIR/diagnotics.rs:31:7 | LL | #[cfg(no_values = "bar")] | ^^^^^^^^^-------- diff --git a/tests/ui/check-cfg/empty-values.rs b/tests/ui/check-cfg/empty-values.rs index cad2d351b9620..cf7a7d7d1c034 100644 --- a/tests/ui/check-cfg/empty-values.rs +++ b/tests/ui/check-cfg/empty-values.rs @@ -1,6 +1,7 @@ // Check that we detect unexpected value when none are allowed // //@ check-pass +//@ no-auto-check-cfg //@ compile-flags: --check-cfg=cfg(foo,values()) #[cfg(foo = "foo")] diff --git a/tests/ui/check-cfg/empty-values.stderr b/tests/ui/check-cfg/empty-values.stderr index 1f773b10316e0..7f57a4ba59344 100644 --- a/tests/ui/check-cfg/empty-values.stderr +++ b/tests/ui/check-cfg/empty-values.stderr @@ -1,5 +1,5 @@ warning: unexpected `cfg` condition value: `foo` - --> $DIR/empty-values.rs:6:7 + --> $DIR/empty-values.rs:7:7 | LL | #[cfg(foo = "foo")] | ^^^^^^^^^^^ help: remove the condition @@ -10,7 +10,7 @@ LL | #[cfg(foo = "foo")] = note: `#[warn(unexpected_cfgs)]` on by default warning: unexpected `cfg` condition value: (none) - --> $DIR/empty-values.rs:10:7 + --> $DIR/empty-values.rs:11:7 | LL | #[cfg(foo)] | ^^^ help: remove the condition diff --git a/tests/ui/check-cfg/exhaustive-names-values.empty_cfg.stderr b/tests/ui/check-cfg/exhaustive-names-values.empty_cfg.stderr index 9537d4f517291..91afe766c8dbc 100644 --- a/tests/ui/check-cfg/exhaustive-names-values.empty_cfg.stderr +++ b/tests/ui/check-cfg/exhaustive-names-values.empty_cfg.stderr @@ -1,5 +1,5 @@ warning: unexpected `cfg` condition name: `unknown_key` - --> $DIR/exhaustive-names-values.rs:9:7 + --> $DIR/exhaustive-names-values.rs:10:7 | LL | #[cfg(unknown_key = "value")] | ^^^^^^^^^^^^^^^^^^^^^ @@ -10,7 +10,7 @@ LL | #[cfg(unknown_key = "value")] = note: `#[warn(unexpected_cfgs)]` on by default warning: unexpected `cfg` condition value: `value` - --> $DIR/exhaustive-names-values.rs:13:7 + --> $DIR/exhaustive-names-values.rs:14:7 | LL | #[cfg(test = "value")] | ^^^^---------- @@ -21,7 +21,7 @@ LL | #[cfg(test = "value")] = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition name: `feature` - --> $DIR/exhaustive-names-values.rs:17:7 + --> $DIR/exhaustive-names-values.rs:18:7 | LL | #[cfg(feature = "unk")] | ^^^^^^^^^^^^^^^ @@ -30,7 +30,7 @@ LL | #[cfg(feature = "unk")] = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition name: `feature` - --> $DIR/exhaustive-names-values.rs:24:7 + --> $DIR/exhaustive-names-values.rs:25:7 | LL | #[cfg(feature = "std")] | ^^^^^^^^^^^^^^^ diff --git a/tests/ui/check-cfg/exhaustive-names-values.feature.stderr b/tests/ui/check-cfg/exhaustive-names-values.feature.stderr index d63d862795349..93b0621e224b2 100644 --- a/tests/ui/check-cfg/exhaustive-names-values.feature.stderr +++ b/tests/ui/check-cfg/exhaustive-names-values.feature.stderr @@ -1,5 +1,5 @@ warning: unexpected `cfg` condition name: `unknown_key` - --> $DIR/exhaustive-names-values.rs:9:7 + --> $DIR/exhaustive-names-values.rs:10:7 | LL | #[cfg(unknown_key = "value")] | ^^^^^^^^^^^^^^^^^^^^^ @@ -10,7 +10,7 @@ LL | #[cfg(unknown_key = "value")] = note: `#[warn(unexpected_cfgs)]` on by default warning: unexpected `cfg` condition value: `value` - --> $DIR/exhaustive-names-values.rs:13:7 + --> $DIR/exhaustive-names-values.rs:14:7 | LL | #[cfg(test = "value")] | ^^^^---------- @@ -21,7 +21,7 @@ LL | #[cfg(test = "value")] = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `unk` - --> $DIR/exhaustive-names-values.rs:17:7 + --> $DIR/exhaustive-names-values.rs:18:7 | LL | #[cfg(feature = "unk")] | ^^^^^^^^^^^^^^^ diff --git a/tests/ui/check-cfg/exhaustive-names-values.full.stderr b/tests/ui/check-cfg/exhaustive-names-values.full.stderr index d63d862795349..93b0621e224b2 100644 --- a/tests/ui/check-cfg/exhaustive-names-values.full.stderr +++ b/tests/ui/check-cfg/exhaustive-names-values.full.stderr @@ -1,5 +1,5 @@ warning: unexpected `cfg` condition name: `unknown_key` - --> $DIR/exhaustive-names-values.rs:9:7 + --> $DIR/exhaustive-names-values.rs:10:7 | LL | #[cfg(unknown_key = "value")] | ^^^^^^^^^^^^^^^^^^^^^ @@ -10,7 +10,7 @@ LL | #[cfg(unknown_key = "value")] = note: `#[warn(unexpected_cfgs)]` on by default warning: unexpected `cfg` condition value: `value` - --> $DIR/exhaustive-names-values.rs:13:7 + --> $DIR/exhaustive-names-values.rs:14:7 | LL | #[cfg(test = "value")] | ^^^^---------- @@ -21,7 +21,7 @@ LL | #[cfg(test = "value")] = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `unk` - --> $DIR/exhaustive-names-values.rs:17:7 + --> $DIR/exhaustive-names-values.rs:18:7 | LL | #[cfg(feature = "unk")] | ^^^^^^^^^^^^^^^ diff --git a/tests/ui/check-cfg/exhaustive-names-values.rs b/tests/ui/check-cfg/exhaustive-names-values.rs index f6c3e1f575adf..a6190f15dbb4b 100644 --- a/tests/ui/check-cfg/exhaustive-names-values.rs +++ b/tests/ui/check-cfg/exhaustive-names-values.rs @@ -1,6 +1,7 @@ // Check warning for unexpected cfg in the code. // //@ check-pass +//@ no-auto-check-cfg //@ revisions: empty_cfg feature full //@ [empty_cfg]compile-flags: --check-cfg=cfg() //@ [feature]compile-flags: --check-cfg=cfg(feature,values("std")) diff --git a/tests/ui/check-cfg/exhaustive-names.rs b/tests/ui/check-cfg/exhaustive-names.rs index 23bde4dff5505..5d77cc10ca4d3 100644 --- a/tests/ui/check-cfg/exhaustive-names.rs +++ b/tests/ui/check-cfg/exhaustive-names.rs @@ -1,6 +1,7 @@ // Check warning for unexpected cfg // //@ check-pass +//@ no-auto-check-cfg //@ compile-flags: --check-cfg=cfg() #[cfg(unknown_key = "value")] diff --git a/tests/ui/check-cfg/exhaustive-names.stderr b/tests/ui/check-cfg/exhaustive-names.stderr index c42adec94b2bf..f4eb5a640ae6a 100644 --- a/tests/ui/check-cfg/exhaustive-names.stderr +++ b/tests/ui/check-cfg/exhaustive-names.stderr @@ -1,5 +1,5 @@ warning: unexpected `cfg` condition name: `unknown_key` - --> $DIR/exhaustive-names.rs:6:7 + --> $DIR/exhaustive-names.rs:7:7 | LL | #[cfg(unknown_key = "value")] | ^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/check-cfg/exhaustive-values.empty_cfg.stderr b/tests/ui/check-cfg/exhaustive-values.empty_cfg.stderr index 63ba2c686254c..a3c0f36aee8b3 100644 --- a/tests/ui/check-cfg/exhaustive-values.empty_cfg.stderr +++ b/tests/ui/check-cfg/exhaustive-values.empty_cfg.stderr @@ -1,5 +1,5 @@ warning: unexpected `cfg` condition value: `value` - --> $DIR/exhaustive-values.rs:8:7 + --> $DIR/exhaustive-values.rs:9:7 | LL | #[cfg(test = "value")] | ^^^^---------- diff --git a/tests/ui/check-cfg/exhaustive-values.rs b/tests/ui/check-cfg/exhaustive-values.rs index 029b2ff2c6914..b4ce2ac98dc05 100644 --- a/tests/ui/check-cfg/exhaustive-values.rs +++ b/tests/ui/check-cfg/exhaustive-values.rs @@ -1,6 +1,7 @@ // Check warning for unexpected cfg value // //@ check-pass +//@ no-auto-check-cfg //@ revisions: empty_cfg without_names //@ [empty_cfg]compile-flags: --check-cfg=cfg() //@ [without_names]compile-flags: --check-cfg=cfg(any()) diff --git a/tests/ui/check-cfg/exhaustive-values.without_names.stderr b/tests/ui/check-cfg/exhaustive-values.without_names.stderr index 63ba2c686254c..a3c0f36aee8b3 100644 --- a/tests/ui/check-cfg/exhaustive-values.without_names.stderr +++ b/tests/ui/check-cfg/exhaustive-values.without_names.stderr @@ -1,5 +1,5 @@ warning: unexpected `cfg` condition value: `value` - --> $DIR/exhaustive-values.rs:8:7 + --> $DIR/exhaustive-values.rs:9:7 | LL | #[cfg(test = "value")] | ^^^^---------- diff --git a/tests/ui/check-cfg/invalid-arguments.rs b/tests/ui/check-cfg/invalid-arguments.rs index 84087a16e80eb..c0b58ede97f40 100644 --- a/tests/ui/check-cfg/invalid-arguments.rs +++ b/tests/ui/check-cfg/invalid-arguments.rs @@ -1,6 +1,7 @@ // Check that invalid --check-cfg are rejected // //@ check-fail +//@ no-auto-check-cfg //@ revisions: anything_else //@ revisions: string_for_name_1 string_for_name_2 multiple_any multiple_values //@ revisions: multiple_values_any not_empty_any not_empty_values_any diff --git a/tests/ui/check-cfg/mix.rs b/tests/ui/check-cfg/mix.rs index ab8a180bc6f41..ac244f4fc09df 100644 --- a/tests/ui/check-cfg/mix.rs +++ b/tests/ui/check-cfg/mix.rs @@ -3,6 +3,7 @@ // we correctly lint on the `cfg!` macro and `cfg_attr` attribute. // //@ check-pass +//@ no-auto-check-cfg //@ compile-flags: --cfg feature="bar" --cfg unknown_name //@ compile-flags: --check-cfg=cfg(feature,values("foo")) diff --git a/tests/ui/check-cfg/mix.stderr b/tests/ui/check-cfg/mix.stderr index feb4f21b0ca43..eefa88c073e7a 100644 --- a/tests/ui/check-cfg/mix.stderr +++ b/tests/ui/check-cfg/mix.stderr @@ -1,5 +1,5 @@ warning: unexpected `cfg` condition name: `widnows` - --> $DIR/mix.rs:12:7 + --> $DIR/mix.rs:13:7 | LL | #[cfg(widnows)] | ^^^^^^^ help: there is a config with a similar name: `windows` @@ -9,7 +9,7 @@ LL | #[cfg(widnows)] = note: `#[warn(unexpected_cfgs)]` on by default warning: unexpected `cfg` condition value: (none) - --> $DIR/mix.rs:16:7 + --> $DIR/mix.rs:17:7 | LL | #[cfg(feature)] | ^^^^^^^- help: specify a config value: `= "foo"` @@ -19,7 +19,7 @@ LL | #[cfg(feature)] = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `bar` - --> $DIR/mix.rs:23:7 + --> $DIR/mix.rs:24:7 | LL | #[cfg(feature = "bar")] | ^^^^^^^^^^^^^^^ @@ -29,7 +29,7 @@ LL | #[cfg(feature = "bar")] = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `zebra` - --> $DIR/mix.rs:27:7 + --> $DIR/mix.rs:28:7 | LL | #[cfg(feature = "zebra")] | ^^^^^^^^^^^^^^^^^ @@ -39,7 +39,7 @@ LL | #[cfg(feature = "zebra")] = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition name: `uu` - --> $DIR/mix.rs:31:12 + --> $DIR/mix.rs:32:12 | LL | #[cfg_attr(uu, test)] | ^^ @@ -49,7 +49,7 @@ LL | #[cfg_attr(uu, test)] = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition name: `widnows` - --> $DIR/mix.rs:40:10 + --> $DIR/mix.rs:41:10 | LL | cfg!(widnows); | ^^^^^^^ help: there is a config with a similar name: `windows` @@ -58,7 +58,7 @@ LL | cfg!(widnows); = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `bar` - --> $DIR/mix.rs:43:10 + --> $DIR/mix.rs:44:10 | LL | cfg!(feature = "bar"); | ^^^^^^^^^^^^^^^ @@ -68,7 +68,7 @@ LL | cfg!(feature = "bar"); = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `zebra` - --> $DIR/mix.rs:45:10 + --> $DIR/mix.rs:46:10 | LL | cfg!(feature = "zebra"); | ^^^^^^^^^^^^^^^^^ @@ -78,7 +78,7 @@ LL | cfg!(feature = "zebra"); = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition name: `xxx` - --> $DIR/mix.rs:47:10 + --> $DIR/mix.rs:48:10 | LL | cfg!(xxx = "foo"); | ^^^^^^^^^^^ @@ -87,7 +87,7 @@ LL | cfg!(xxx = "foo"); = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition name: `xxx` - --> $DIR/mix.rs:49:10 + --> $DIR/mix.rs:50:10 | LL | cfg!(xxx); | ^^^ @@ -96,7 +96,7 @@ LL | cfg!(xxx); = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition name: `xxx` - --> $DIR/mix.rs:51:14 + --> $DIR/mix.rs:52:14 | LL | cfg!(any(xxx, windows)); | ^^^ @@ -105,7 +105,7 @@ LL | cfg!(any(xxx, windows)); = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `bad` - --> $DIR/mix.rs:53:14 + --> $DIR/mix.rs:54:14 | LL | cfg!(any(feature = "bad", windows)); | ^^^^^^^^^^^^^^^ @@ -115,7 +115,7 @@ LL | cfg!(any(feature = "bad", windows)); = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition name: `xxx` - --> $DIR/mix.rs:55:23 + --> $DIR/mix.rs:56:23 | LL | cfg!(any(windows, xxx)); | ^^^ @@ -124,7 +124,7 @@ LL | cfg!(any(windows, xxx)); = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition name: `xxx` - --> $DIR/mix.rs:57:20 + --> $DIR/mix.rs:58:20 | LL | cfg!(all(unix, xxx)); | ^^^ @@ -133,7 +133,7 @@ LL | cfg!(all(unix, xxx)); = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition name: `aa` - --> $DIR/mix.rs:59:14 + --> $DIR/mix.rs:60:14 | LL | cfg!(all(aa, bb)); | ^^ @@ -142,7 +142,7 @@ LL | cfg!(all(aa, bb)); = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition name: `bb` - --> $DIR/mix.rs:59:18 + --> $DIR/mix.rs:60:18 | LL | cfg!(all(aa, bb)); | ^^ @@ -151,7 +151,7 @@ LL | cfg!(all(aa, bb)); = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition name: `aa` - --> $DIR/mix.rs:62:14 + --> $DIR/mix.rs:63:14 | LL | cfg!(any(aa, bb)); | ^^ @@ -160,7 +160,7 @@ LL | cfg!(any(aa, bb)); = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition name: `bb` - --> $DIR/mix.rs:62:18 + --> $DIR/mix.rs:63:18 | LL | cfg!(any(aa, bb)); | ^^ @@ -169,7 +169,7 @@ LL | cfg!(any(aa, bb)); = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `zebra` - --> $DIR/mix.rs:65:20 + --> $DIR/mix.rs:66:20 | LL | cfg!(any(unix, feature = "zebra")); | ^^^^^^^^^^^^^^^^^ @@ -179,7 +179,7 @@ LL | cfg!(any(unix, feature = "zebra")); = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition name: `xxx` - --> $DIR/mix.rs:67:14 + --> $DIR/mix.rs:68:14 | LL | cfg!(any(xxx, feature = "zebra")); | ^^^ @@ -188,7 +188,7 @@ LL | cfg!(any(xxx, feature = "zebra")); = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `zebra` - --> $DIR/mix.rs:67:19 + --> $DIR/mix.rs:68:19 | LL | cfg!(any(xxx, feature = "zebra")); | ^^^^^^^^^^^^^^^^^ @@ -198,7 +198,7 @@ LL | cfg!(any(xxx, feature = "zebra")); = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition name: `xxx` - --> $DIR/mix.rs:70:14 + --> $DIR/mix.rs:71:14 | LL | cfg!(any(xxx, unix, xxx)); | ^^^ @@ -207,7 +207,7 @@ LL | cfg!(any(xxx, unix, xxx)); = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition name: `xxx` - --> $DIR/mix.rs:70:25 + --> $DIR/mix.rs:71:25 | LL | cfg!(any(xxx, unix, xxx)); | ^^^ @@ -216,7 +216,7 @@ LL | cfg!(any(xxx, unix, xxx)); = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `zebra` - --> $DIR/mix.rs:73:14 + --> $DIR/mix.rs:74:14 | LL | cfg!(all(feature = "zebra", feature = "zebra", feature = "zebra")); | ^^^^^^^^^^^^^^^^^ @@ -226,7 +226,7 @@ LL | cfg!(all(feature = "zebra", feature = "zebra", feature = "zebra")); = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `zebra` - --> $DIR/mix.rs:73:33 + --> $DIR/mix.rs:74:33 | LL | cfg!(all(feature = "zebra", feature = "zebra", feature = "zebra")); | ^^^^^^^^^^^^^^^^^ @@ -236,7 +236,7 @@ LL | cfg!(all(feature = "zebra", feature = "zebra", feature = "zebra")); = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `zebra` - --> $DIR/mix.rs:73:52 + --> $DIR/mix.rs:74:52 | LL | cfg!(all(feature = "zebra", feature = "zebra", feature = "zebra")); | ^^^^^^^^^^^^^^^^^ @@ -246,7 +246,7 @@ LL | cfg!(all(feature = "zebra", feature = "zebra", feature = "zebra")); = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `zebra` - --> $DIR/mix.rs:77:10 + --> $DIR/mix.rs:78:10 | LL | cfg!(target_feature = "zebra"); | ^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/check-cfg/no-expected-values.empty.stderr b/tests/ui/check-cfg/no-expected-values.empty.stderr index 0f181cc2ab12d..9c7d970f35e53 100644 --- a/tests/ui/check-cfg/no-expected-values.empty.stderr +++ b/tests/ui/check-cfg/no-expected-values.empty.stderr @@ -1,5 +1,5 @@ warning: unexpected `cfg` condition value: `foo` - --> $DIR/no-expected-values.rs:10:7 + --> $DIR/no-expected-values.rs:11:7 | LL | #[cfg(feature = "foo")] | ^^^^^^^-------- @@ -12,7 +12,7 @@ LL | #[cfg(feature = "foo")] = note: `#[warn(unexpected_cfgs)]` on by default warning: unexpected `cfg` condition value: `foo` - --> $DIR/no-expected-values.rs:14:7 + --> $DIR/no-expected-values.rs:15:7 | LL | #[cfg(test = "foo")] | ^^^^-------- diff --git a/tests/ui/check-cfg/no-expected-values.mixed.stderr b/tests/ui/check-cfg/no-expected-values.mixed.stderr index 0f181cc2ab12d..9c7d970f35e53 100644 --- a/tests/ui/check-cfg/no-expected-values.mixed.stderr +++ b/tests/ui/check-cfg/no-expected-values.mixed.stderr @@ -1,5 +1,5 @@ warning: unexpected `cfg` condition value: `foo` - --> $DIR/no-expected-values.rs:10:7 + --> $DIR/no-expected-values.rs:11:7 | LL | #[cfg(feature = "foo")] | ^^^^^^^-------- @@ -12,7 +12,7 @@ LL | #[cfg(feature = "foo")] = note: `#[warn(unexpected_cfgs)]` on by default warning: unexpected `cfg` condition value: `foo` - --> $DIR/no-expected-values.rs:14:7 + --> $DIR/no-expected-values.rs:15:7 | LL | #[cfg(test = "foo")] | ^^^^-------- diff --git a/tests/ui/check-cfg/no-expected-values.rs b/tests/ui/check-cfg/no-expected-values.rs index 42e7f45fa7a9c..58e0e0a10e249 100644 --- a/tests/ui/check-cfg/no-expected-values.rs +++ b/tests/ui/check-cfg/no-expected-values.rs @@ -1,6 +1,7 @@ // Check that we detect unexpected value when none are allowed // //@ check-pass +//@ no-auto-check-cfg //@ revisions: simple mixed empty //@ compile-flags: --check-cfg=cfg(values,simple,mixed,empty) //@ [simple]compile-flags: --check-cfg=cfg(test) --check-cfg=cfg(feature) diff --git a/tests/ui/check-cfg/no-expected-values.simple.stderr b/tests/ui/check-cfg/no-expected-values.simple.stderr index 0f181cc2ab12d..9c7d970f35e53 100644 --- a/tests/ui/check-cfg/no-expected-values.simple.stderr +++ b/tests/ui/check-cfg/no-expected-values.simple.stderr @@ -1,5 +1,5 @@ warning: unexpected `cfg` condition value: `foo` - --> $DIR/no-expected-values.rs:10:7 + --> $DIR/no-expected-values.rs:11:7 | LL | #[cfg(feature = "foo")] | ^^^^^^^-------- @@ -12,7 +12,7 @@ LL | #[cfg(feature = "foo")] = note: `#[warn(unexpected_cfgs)]` on by default warning: unexpected `cfg` condition value: `foo` - --> $DIR/no-expected-values.rs:14:7 + --> $DIR/no-expected-values.rs:15:7 | LL | #[cfg(test = "foo")] | ^^^^-------- diff --git a/tests/ui/check-cfg/order-independant.rs b/tests/ui/check-cfg/order-independant.rs index 671d2e764d30c..6acd1a41bab37 100644 --- a/tests/ui/check-cfg/order-independant.rs +++ b/tests/ui/check-cfg/order-independant.rs @@ -1,5 +1,6 @@ //@ check-pass // +//@ no-auto-check-cfg //@ revisions: values_before values_after //@ compile-flags: --check-cfg=cfg(values_before,values_after) //@ [values_before]compile-flags: --check-cfg=cfg(a,values("b")) --check-cfg=cfg(a) diff --git a/tests/ui/check-cfg/order-independant.values_after.stderr b/tests/ui/check-cfg/order-independant.values_after.stderr index 7e18df8e1c293..69c3aa32020f5 100644 --- a/tests/ui/check-cfg/order-independant.values_after.stderr +++ b/tests/ui/check-cfg/order-independant.values_after.stderr @@ -1,5 +1,5 @@ warning: unexpected `cfg` condition value: `unk` - --> $DIR/order-independant.rs:11:7 + --> $DIR/order-independant.rs:12:7 | LL | #[cfg(a = "unk")] | ^^^^^^^^^ diff --git a/tests/ui/check-cfg/order-independant.values_before.stderr b/tests/ui/check-cfg/order-independant.values_before.stderr index 7e18df8e1c293..69c3aa32020f5 100644 --- a/tests/ui/check-cfg/order-independant.values_before.stderr +++ b/tests/ui/check-cfg/order-independant.values_before.stderr @@ -1,5 +1,5 @@ warning: unexpected `cfg` condition value: `unk` - --> $DIR/order-independant.rs:11:7 + --> $DIR/order-independant.rs:12:7 | LL | #[cfg(a = "unk")] | ^^^^^^^^^ diff --git a/tests/ui/check-cfg/stmt-no-ice.rs b/tests/ui/check-cfg/stmt-no-ice.rs index 866a5836db0dc..edd9febbe3770 100644 --- a/tests/ui/check-cfg/stmt-no-ice.rs +++ b/tests/ui/check-cfg/stmt-no-ice.rs @@ -1,6 +1,7 @@ // This test checks that there is no ICE with this code // //@ check-pass +//@ no-auto-check-cfg //@ compile-flags:--check-cfg=cfg() fn main() { diff --git a/tests/ui/check-cfg/stmt-no-ice.stderr b/tests/ui/check-cfg/stmt-no-ice.stderr index e686cdddc1c27..a6c72b0e6bff1 100644 --- a/tests/ui/check-cfg/stmt-no-ice.stderr +++ b/tests/ui/check-cfg/stmt-no-ice.stderr @@ -1,5 +1,5 @@ warning: unexpected `cfg` condition name: `crossbeam_loom` - --> $DIR/stmt-no-ice.rs:7:11 + --> $DIR/stmt-no-ice.rs:8:11 | LL | #[cfg(crossbeam_loom)] | ^^^^^^^^^^^^^^ diff --git a/tests/ui/check-cfg/unexpected-cfg-name.rs b/tests/ui/check-cfg/unexpected-cfg-name.rs index 365c29d10fbb0..8178df8b87c5b 100644 --- a/tests/ui/check-cfg/unexpected-cfg-name.rs +++ b/tests/ui/check-cfg/unexpected-cfg-name.rs @@ -1,6 +1,7 @@ // Check warning for unexpected configuration name // //@ check-pass +//@ no-auto-check-cfg //@ compile-flags: --check-cfg=cfg() #[cfg(widnows)] diff --git a/tests/ui/check-cfg/unexpected-cfg-name.stderr b/tests/ui/check-cfg/unexpected-cfg-name.stderr index 0b265078aa501..c652c8e27bc69 100644 --- a/tests/ui/check-cfg/unexpected-cfg-name.stderr +++ b/tests/ui/check-cfg/unexpected-cfg-name.stderr @@ -1,5 +1,5 @@ warning: unexpected `cfg` condition name: `widnows` - --> $DIR/unexpected-cfg-name.rs:6:7 + --> $DIR/unexpected-cfg-name.rs:7:7 | LL | #[cfg(widnows)] | ^^^^^^^ help: there is a config with a similar name: `windows` diff --git a/tests/ui/check-cfg/unexpected-cfg-value.rs b/tests/ui/check-cfg/unexpected-cfg-value.rs index 583cf40c48518..b6efcaac44cee 100644 --- a/tests/ui/check-cfg/unexpected-cfg-value.rs +++ b/tests/ui/check-cfg/unexpected-cfg-value.rs @@ -1,6 +1,7 @@ // Check for unexpected configuration value in the code. // //@ check-pass +//@ no-auto-check-cfg //@ compile-flags: --cfg=feature="rand" //@ compile-flags: --check-cfg=cfg(feature,values("serde","full")) diff --git a/tests/ui/check-cfg/unexpected-cfg-value.stderr b/tests/ui/check-cfg/unexpected-cfg-value.stderr index c300120849202..efcf65bb707e3 100644 --- a/tests/ui/check-cfg/unexpected-cfg-value.stderr +++ b/tests/ui/check-cfg/unexpected-cfg-value.stderr @@ -1,5 +1,5 @@ warning: unexpected `cfg` condition value: `sedre` - --> $DIR/unexpected-cfg-value.rs:7:7 + --> $DIR/unexpected-cfg-value.rs:8:7 | LL | #[cfg(feature = "sedre")] | ^^^^^^^^^^------- @@ -12,7 +12,7 @@ LL | #[cfg(feature = "sedre")] = note: `#[warn(unexpected_cfgs)]` on by default warning: unexpected `cfg` condition value: `rand` - --> $DIR/unexpected-cfg-value.rs:14:7 + --> $DIR/unexpected-cfg-value.rs:15:7 | LL | #[cfg(feature = "rand")] | ^^^^^^^^^^^^^^^^ diff --git a/tests/ui/check-cfg/unknown-values.rs b/tests/ui/check-cfg/unknown-values.rs index 7b2b00fe9d4ca..ef0590d76d2c0 100644 --- a/tests/ui/check-cfg/unknown-values.rs +++ b/tests/ui/check-cfg/unknown-values.rs @@ -1,6 +1,7 @@ // Check that no warning is emitted for unknown cfg value // //@ check-pass +//@ no-auto-check-cfg //@ revisions: simple mixed with_values //@ compile-flags: --check-cfg=cfg(simple,mixed,with_values) //@ [simple]compile-flags: --check-cfg=cfg(foo,values(any())) diff --git a/tests/ui/check-cfg/values-none.explicit.stderr b/tests/ui/check-cfg/values-none.explicit.stderr index f75cc08f551e5..000eabdb22ede 100644 --- a/tests/ui/check-cfg/values-none.explicit.stderr +++ b/tests/ui/check-cfg/values-none.explicit.stderr @@ -1,5 +1,5 @@ warning: unexpected `cfg` condition value: `too` - --> $DIR/values-none.rs:10:7 + --> $DIR/values-none.rs:11:7 | LL | #[cfg(foo = "too")] | ^^^-------- @@ -12,7 +12,7 @@ LL | #[cfg(foo = "too")] = note: `#[warn(unexpected_cfgs)]` on by default warning: unexpected `cfg` condition value: `bar` - --> $DIR/values-none.rs:15:7 + --> $DIR/values-none.rs:16:7 | LL | #[cfg(foo = "bar")] | ^^^-------- diff --git a/tests/ui/check-cfg/values-none.implicit.stderr b/tests/ui/check-cfg/values-none.implicit.stderr index f75cc08f551e5..000eabdb22ede 100644 --- a/tests/ui/check-cfg/values-none.implicit.stderr +++ b/tests/ui/check-cfg/values-none.implicit.stderr @@ -1,5 +1,5 @@ warning: unexpected `cfg` condition value: `too` - --> $DIR/values-none.rs:10:7 + --> $DIR/values-none.rs:11:7 | LL | #[cfg(foo = "too")] | ^^^-------- @@ -12,7 +12,7 @@ LL | #[cfg(foo = "too")] = note: `#[warn(unexpected_cfgs)]` on by default warning: unexpected `cfg` condition value: `bar` - --> $DIR/values-none.rs:15:7 + --> $DIR/values-none.rs:16:7 | LL | #[cfg(foo = "bar")] | ^^^-------- diff --git a/tests/ui/check-cfg/values-none.rs b/tests/ui/check-cfg/values-none.rs index bd9c0255b7db2..6856d2f33af07 100644 --- a/tests/ui/check-cfg/values-none.rs +++ b/tests/ui/check-cfg/values-none.rs @@ -1,5 +1,6 @@ //@ check-pass // +//@ no-auto-check-cfg //@ revisions: explicit implicit //@ [explicit]compile-flags: --check-cfg=cfg(foo,values(none())) //@ [implicit]compile-flags: --check-cfg=cfg(foo) diff --git a/tests/ui/check-cfg/values-target-json.rs b/tests/ui/check-cfg/values-target-json.rs index f3a27043e6714..b52decdf6c0c4 100644 --- a/tests/ui/check-cfg/values-target-json.rs +++ b/tests/ui/check-cfg/values-target-json.rs @@ -1,6 +1,7 @@ // This test checks that we don't lint values defined by a custom target (target json) // //@ check-pass +//@ no-auto-check-cfg //@ needs-llvm-components: x86 //@ compile-flags: --crate-type=lib --check-cfg=cfg() --target={{src-base}}/check-cfg/my-awesome-platform.json diff --git a/tests/ui/check-cfg/well-known-names.rs b/tests/ui/check-cfg/well-known-names.rs index c277b84d9bd6f..b84710ca8399f 100644 --- a/tests/ui/check-cfg/well-known-names.rs +++ b/tests/ui/check-cfg/well-known-names.rs @@ -1,6 +1,7 @@ // This test checks that we lint on non well known names and that we don't lint on well known names // //@ check-pass +//@ no-auto-check-cfg //@ compile-flags: --check-cfg=cfg() #[cfg(target_oz = "linux")] diff --git a/tests/ui/check-cfg/well-known-names.stderr b/tests/ui/check-cfg/well-known-names.stderr index b2db777e8a842..2f07174b905b6 100644 --- a/tests/ui/check-cfg/well-known-names.stderr +++ b/tests/ui/check-cfg/well-known-names.stderr @@ -1,5 +1,5 @@ warning: unexpected `cfg` condition name: `target_oz` - --> $DIR/well-known-names.rs:6:7 + --> $DIR/well-known-names.rs:7:7 | LL | #[cfg(target_oz = "linux")] | ^^^^^^^^^^^^^^^^^^^ @@ -13,7 +13,7 @@ LL | #[cfg(target_os = "linux")] | ~~~~~~~~~ warning: unexpected `cfg` condition name: `features` - --> $DIR/well-known-names.rs:13:7 + --> $DIR/well-known-names.rs:14:7 | LL | #[cfg(features = "foo")] | ^^^^^^^^^^^^^^^^ @@ -23,7 +23,7 @@ LL | #[cfg(features = "foo")] = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition name: `feature` - --> $DIR/well-known-names.rs:17:7 + --> $DIR/well-known-names.rs:18:7 | LL | #[cfg(feature = "foo")] | ^^^^^^^^^^^^^^^ @@ -32,7 +32,7 @@ LL | #[cfg(feature = "foo")] = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition name: `uniw` - --> $DIR/well-known-names.rs:21:7 + --> $DIR/well-known-names.rs:22:7 | LL | #[cfg(uniw)] | ^^^^ help: there is a config with a similar name: `unix` diff --git a/tests/ui/check-cfg/well-known-values.rs b/tests/ui/check-cfg/well-known-values.rs index 4c010a62d2101..b821f8092dd61 100644 --- a/tests/ui/check-cfg/well-known-values.rs +++ b/tests/ui/check-cfg/well-known-values.rs @@ -5,6 +5,7 @@ // values since the suggestion shows them. // //@ check-pass +//@ no-auto-check-cfg //@ compile-flags: --check-cfg=cfg() //@ compile-flags: -Zcheck-cfg-all-expected diff --git a/tests/ui/check-cfg/well-known-values.stderr b/tests/ui/check-cfg/well-known-values.stderr index dceb6f4c03067..1f338f066b4c7 100644 --- a/tests/ui/check-cfg/well-known-values.stderr +++ b/tests/ui/check-cfg/well-known-values.stderr @@ -1,5 +1,5 @@ warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:27:5 + --> $DIR/well-known-values.rs:28:5 | LL | clippy = "_UNEXPECTED_VALUE", | ^^^^^^---------------------- @@ -11,7 +11,7 @@ LL | clippy = "_UNEXPECTED_VALUE", = note: `#[warn(unexpected_cfgs)]` on by default warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:29:5 + --> $DIR/well-known-values.rs:30:5 | LL | debug_assertions = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^---------------------- @@ -22,7 +22,7 @@ LL | debug_assertions = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:31:5 + --> $DIR/well-known-values.rs:32:5 | LL | doc = "_UNEXPECTED_VALUE", | ^^^---------------------- @@ -33,7 +33,7 @@ LL | doc = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:33:5 + --> $DIR/well-known-values.rs:34:5 | LL | doctest = "_UNEXPECTED_VALUE", | ^^^^^^^---------------------- @@ -44,7 +44,7 @@ LL | doctest = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:35:5 + --> $DIR/well-known-values.rs:36:5 | LL | miri = "_UNEXPECTED_VALUE", | ^^^^---------------------- @@ -55,7 +55,7 @@ LL | miri = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:37:5 + --> $DIR/well-known-values.rs:38:5 | LL | overflow_checks = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^---------------------- @@ -66,7 +66,7 @@ LL | overflow_checks = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:39:5 + --> $DIR/well-known-values.rs:40:5 | LL | panic = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -75,7 +75,7 @@ LL | panic = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:41:5 + --> $DIR/well-known-values.rs:42:5 | LL | proc_macro = "_UNEXPECTED_VALUE", | ^^^^^^^^^^---------------------- @@ -86,7 +86,7 @@ LL | proc_macro = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:43:5 + --> $DIR/well-known-values.rs:44:5 | LL | relocation_model = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -95,7 +95,7 @@ LL | relocation_model = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:45:5 + --> $DIR/well-known-values.rs:46:5 | LL | sanitize = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -104,7 +104,7 @@ LL | sanitize = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:47:5 + --> $DIR/well-known-values.rs:48:5 | LL | target_abi = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -113,7 +113,7 @@ LL | target_abi = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:49:5 + --> $DIR/well-known-values.rs:50:5 | LL | target_arch = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -122,7 +122,7 @@ LL | target_arch = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:51:5 + --> $DIR/well-known-values.rs:52:5 | LL | target_endian = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -131,7 +131,7 @@ LL | target_endian = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:53:5 + --> $DIR/well-known-values.rs:54:5 | LL | target_env = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -140,7 +140,7 @@ LL | target_env = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:55:5 + --> $DIR/well-known-values.rs:56:5 | LL | target_family = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -149,7 +149,7 @@ LL | target_family = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:57:5 + --> $DIR/well-known-values.rs:58:5 | LL | target_feature = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -158,7 +158,7 @@ LL | target_feature = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:59:5 + --> $DIR/well-known-values.rs:60:5 | LL | target_has_atomic = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -167,7 +167,7 @@ LL | target_has_atomic = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:61:5 + --> $DIR/well-known-values.rs:62:5 | LL | target_has_atomic_equal_alignment = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -176,7 +176,7 @@ LL | target_has_atomic_equal_alignment = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:63:5 + --> $DIR/well-known-values.rs:64:5 | LL | target_has_atomic_load_store = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -185,7 +185,7 @@ LL | target_has_atomic_load_store = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:65:5 + --> $DIR/well-known-values.rs:66:5 | LL | target_os = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -194,7 +194,7 @@ LL | target_os = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:67:5 + --> $DIR/well-known-values.rs:68:5 | LL | target_pointer_width = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -203,7 +203,7 @@ LL | target_pointer_width = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:69:5 + --> $DIR/well-known-values.rs:70:5 | LL | target_thread_local = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^---------------------- @@ -214,7 +214,7 @@ LL | target_thread_local = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:71:5 + --> $DIR/well-known-values.rs:72:5 | LL | target_vendor = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -223,7 +223,7 @@ LL | target_vendor = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:73:5 + --> $DIR/well-known-values.rs:74:5 | LL | test = "_UNEXPECTED_VALUE", | ^^^^---------------------- @@ -234,7 +234,7 @@ LL | test = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:75:5 + --> $DIR/well-known-values.rs:76:5 | LL | ub_checks = "_UNEXPECTED_VALUE", | ^^^^^^^^^---------------------- @@ -245,7 +245,7 @@ LL | ub_checks = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:77:5 + --> $DIR/well-known-values.rs:78:5 | LL | unix = "_UNEXPECTED_VALUE", | ^^^^---------------------- @@ -256,7 +256,7 @@ LL | unix = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:79:5 + --> $DIR/well-known-values.rs:80:5 | LL | windows = "_UNEXPECTED_VALUE", | ^^^^^^^---------------------- @@ -267,7 +267,7 @@ LL | windows = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `linuz` - --> $DIR/well-known-values.rs:85:7 + --> $DIR/well-known-values.rs:86:7 | LL | #[cfg(target_os = "linuz")] // testing that we suggest `linux` | ^^^^^^^^^^^^------- From b6ed8136c7a47fe1c95cad39cfc8077c9ec4727b Mon Sep 17 00:00:00 2001 From: Urgau Date: Sun, 7 Apr 2024 00:33:37 +0200 Subject: [PATCH 14/16] compiletest: add enable-by-default check-cfg --- src/tools/compiletest/src/runtest.rs | 25 ++++++++++++++++--- .../rustdoc-ui/argfile/commandline-argfile.rs | 6 ++--- tests/ui/argfile/commandline-argfile.rs | 6 ++--- tests/ui/cfg/cfg-in-crate-1.rs | 3 ++- tests/ui/cfg/cfg-macros-foo.rs | 2 +- tests/ui/cfg/cfg-path-error.rs | 2 ++ tests/ui/cfg/cfg-path-error.stderr | 8 +++--- tests/ui/cfg/cfg_attr.rs | 4 ++- tests/ui/cfg/cfgs-on-items.rs | 3 +-- tests/ui/cfg/diagnostics-not-a-def.rs | 3 +++ tests/ui/cfg/diagnostics-not-a-def.stderr | 2 +- tests/ui/cfg/diagnostics-same-crate.rs | 2 ++ tests/ui/cfg/diagnostics-same-crate.stderr | 24 +++++++++--------- tests/ui/cfg/expanded-cfg.rs | 2 ++ ...-compat-crate-attributes-using-cfg_attr.rs | 2 +- .../conditional-compilation/cfg-attr-cfg-2.rs | 3 +-- .../cfg-attr-cfg-2.stderr | 2 +- .../cfg-attr-crate-2.rs | 2 +- .../cfg-attr-multi-invalid-1.rs | 2 +- .../cfg-attr-multi-invalid-2.rs | 2 +- .../cfg-generic-params.rs | 2 +- tests/ui/conditional-compilation/test-cfg.rs | 2 +- .../extern-prelude-extern-crate-cfg.rs | 2 +- tests/ui/macros/macro-comma-support-rpass.rs | 1 + tests/ui/macros/macro-meta-items.rs | 3 ++- tests/ui/macros/macro-with-attrs1.rs | 2 +- tests/ui/macros/syntax-extension-cfg.rs | 2 +- tests/ui/methods/method-lookup-order.rs | 3 +++ .../attribute/attr-unquoted-ident.fixed | 2 ++ .../parser/attribute/attr-unquoted-ident.rs | 2 ++ .../attribute/attr-unquoted-ident.stderr | 4 +-- tests/ui/regions/regions-refcell.rs | 1 + ...gest-import-without-clobbering-attrs.fixed | 4 +-- ...suggest-import-without-clobbering-attrs.rs | 4 +-- .../param-attrs-allowed.rs | 2 +- .../rfc-2565-param-attrs/param-attrs-cfg.rs | 2 +- ...-54400-unused-extern-crate-attr-span.fixed | 2 +- ...sue-54400-unused-extern-crate-attr-span.rs | 2 +- .../shell-argfiles-via-argfile.rs | 1 + tests/ui/shell-argfiles/shell-argfiles.args | 1 + tests/ui/target-feature/no-llvm-leaks.rs | 22 ++++++++++------ 41 files changed, 110 insertions(+), 61 deletions(-) diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 1dd639a89188b..b4727340cf561 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -1027,12 +1027,31 @@ impl<'test> TestCx<'test> { } fn set_revision_flags(&self, cmd: &mut Command) { + // Normalize revisions to be lowercase and replace `-`s with `_`s. + // Otherwise the `--cfg` flag is not valid. + let normalize_revision = |revision: &str| revision.to_lowercase().replace("-", "_"); + if let Some(revision) = self.revision { - // Normalize revisions to be lowercase and replace `-`s with `_`s. - // Otherwise the `--cfg` flag is not valid. - let normalized_revision = revision.to_lowercase().replace("-", "_"); + let normalized_revision = normalize_revision(revision); cmd.args(&["--cfg", &normalized_revision]); } + + if !self.props.no_auto_check_cfg { + let mut check_cfg = String::with_capacity(25); + + // Generate `cfg(FALSE, REV1, ..., REVN)` (for all possible revisions) + // + // For compatibility reason we consider the `FALSE` cfg to be expected + // since it is extensively used in the testsuite. + check_cfg.push_str("cfg(FALSE"); + for revision in &self.props.revisions { + check_cfg.push_str(","); + check_cfg.push_str(&normalize_revision(&revision)); + } + check_cfg.push_str(")"); + + cmd.args(&["--check-cfg", &check_cfg]); + } } fn typecheck_source(&self, src: String) -> ProcRes { diff --git a/tests/rustdoc-ui/argfile/commandline-argfile.rs b/tests/rustdoc-ui/argfile/commandline-argfile.rs index b0b314f53ceb7..d5a1cd0a5ed7a 100644 --- a/tests/rustdoc-ui/argfile/commandline-argfile.rs +++ b/tests/rustdoc-ui/argfile/commandline-argfile.rs @@ -1,7 +1,8 @@ // Check to see if we can get parameters from an @argsfile file // //@ check-pass -//@ compile-flags: --cfg cmdline_set @{{src-base}}/argfile/commandline-argfile.args +//@ compile-flags: --cfg cmdline_set --check-cfg=cfg(cmdline_set,unbroken) +//@ compile-flags: @{{src-base}}/argfile/commandline-argfile.args #[cfg(not(cmdline_set))] compile_error!("cmdline_set not set"); @@ -9,5 +10,4 @@ compile_error!("cmdline_set not set"); #[cfg(not(unbroken))] compile_error!("unbroken not set"); -fn main() { -} +fn main() {} diff --git a/tests/ui/argfile/commandline-argfile.rs b/tests/ui/argfile/commandline-argfile.rs index 387a8d033b3cd..b7f1e8ed6aaa9 100644 --- a/tests/ui/argfile/commandline-argfile.rs +++ b/tests/ui/argfile/commandline-argfile.rs @@ -1,7 +1,8 @@ // Check to see if we can get parameters from an @argsfile file // //@ build-pass -//@ compile-flags: --cfg cmdline_set @{{src-base}}/argfile/commandline-argfile.args +//@ compile-flags: --cfg cmdline_set --check-cfg=cfg(cmdline_set,unbroken) +//@ compile-flags: @{{src-base}}/argfile/commandline-argfile.args #[cfg(not(cmdline_set))] compile_error!("cmdline_set not set"); @@ -9,5 +10,4 @@ compile_error!("cmdline_set not set"); #[cfg(not(unbroken))] compile_error!("unbroken not set"); -fn main() { -} +fn main() {} diff --git a/tests/ui/cfg/cfg-in-crate-1.rs b/tests/ui/cfg/cfg-in-crate-1.rs index 07e1c3727f988..4339ce004778b 100644 --- a/tests/ui/cfg/cfg-in-crate-1.rs +++ b/tests/ui/cfg/cfg-in-crate-1.rs @@ -1,5 +1,6 @@ //@ run-pass -//@ compile-flags: --cfg bar -D warnings +//@ compile-flags: --cfg bar --check-cfg=cfg(bar) -D warnings + #![cfg(bar)] fn main() {} diff --git a/tests/ui/cfg/cfg-macros-foo.rs b/tests/ui/cfg/cfg-macros-foo.rs index 7cdf2df5c8f61..4f6ec583db219 100644 --- a/tests/ui/cfg/cfg-macros-foo.rs +++ b/tests/ui/cfg/cfg-macros-foo.rs @@ -1,5 +1,5 @@ //@ run-pass -//@ compile-flags: --cfg foo +//@ compile-flags: --cfg foo --check-cfg=cfg(foo) // check that cfg correctly chooses between the macro impls (see also // cfg-macros-notfoo.rs) diff --git a/tests/ui/cfg/cfg-path-error.rs b/tests/ui/cfg/cfg-path-error.rs index 1e52922d0793f..9db1f190bdc06 100644 --- a/tests/ui/cfg/cfg-path-error.rs +++ b/tests/ui/cfg/cfg-path-error.rs @@ -1,5 +1,7 @@ //@ check-fail +#![allow(unexpected_cfgs)] // invalid cfgs + #[cfg(any(foo, foo::bar))] //~^ERROR `cfg` predicate key must be an identifier fn foo1() {} diff --git a/tests/ui/cfg/cfg-path-error.stderr b/tests/ui/cfg/cfg-path-error.stderr index 84b44b2b0c24a..4f68fa32a9ac2 100644 --- a/tests/ui/cfg/cfg-path-error.stderr +++ b/tests/ui/cfg/cfg-path-error.stderr @@ -1,23 +1,23 @@ error: `cfg` predicate key must be an identifier - --> $DIR/cfg-path-error.rs:3:16 + --> $DIR/cfg-path-error.rs:5:16 | LL | #[cfg(any(foo, foo::bar))] | ^^^^^^^^ error: `cfg` predicate key must be an identifier - --> $DIR/cfg-path-error.rs:7:11 + --> $DIR/cfg-path-error.rs:9:11 | LL | #[cfg(any(foo::bar, foo))] | ^^^^^^^^ error: `cfg` predicate key must be an identifier - --> $DIR/cfg-path-error.rs:11:16 + --> $DIR/cfg-path-error.rs:13:16 | LL | #[cfg(all(foo, foo::bar))] | ^^^^^^^^ error: `cfg` predicate key must be an identifier - --> $DIR/cfg-path-error.rs:15:11 + --> $DIR/cfg-path-error.rs:17:11 | LL | #[cfg(all(foo::bar, foo))] | ^^^^^^^^ diff --git a/tests/ui/cfg/cfg_attr.rs b/tests/ui/cfg/cfg_attr.rs index 4bd024ef5f40c..ba4adafd3a568 100644 --- a/tests/ui/cfg/cfg_attr.rs +++ b/tests/ui/cfg/cfg_attr.rs @@ -1,6 +1,8 @@ //@ run-pass //@ compile-flags:--cfg set1 --cfg set2 -#![allow(dead_code)] + +#![allow(dead_code, unexpected_cfgs)] + use std::fmt::Debug; struct NotDebugable; diff --git a/tests/ui/cfg/cfgs-on-items.rs b/tests/ui/cfg/cfgs-on-items.rs index b3b38cfadb553..8992a8fca9c38 100644 --- a/tests/ui/cfg/cfgs-on-items.rs +++ b/tests/ui/cfg/cfgs-on-items.rs @@ -1,8 +1,7 @@ //@ run-pass -//@ compile-flags: --cfg fooA --cfg fooB +//@ compile-flags: --cfg fooA --cfg fooB --check-cfg=cfg(fooA,fooB,fooC,bar) // fooA AND !bar - #[cfg(all(fooA, not(bar)))] fn foo1() -> isize { 1 } diff --git a/tests/ui/cfg/diagnostics-not-a-def.rs b/tests/ui/cfg/diagnostics-not-a-def.rs index 7293947122675..1912cf9f61665 100644 --- a/tests/ui/cfg/diagnostics-not-a-def.rs +++ b/tests/ui/cfg/diagnostics-not-a-def.rs @@ -1,4 +1,7 @@ +#![feature(lint_reasons)] + pub mod inner { + #[expect(unexpected_cfgs)] pub fn i_am_here() { #[cfg(feature = "another one that doesn't exist")] loop {} diff --git a/tests/ui/cfg/diagnostics-not-a-def.stderr b/tests/ui/cfg/diagnostics-not-a-def.stderr index 6941f850e5f70..89bbf574871b8 100644 --- a/tests/ui/cfg/diagnostics-not-a-def.stderr +++ b/tests/ui/cfg/diagnostics-not-a-def.stderr @@ -1,5 +1,5 @@ error[E0425]: cannot find function `i_am_not` in module `inner` - --> $DIR/diagnostics-not-a-def.rs:11:12 + --> $DIR/diagnostics-not-a-def.rs:14:12 | LL | inner::i_am_not(); | ^^^^^^^^ not found in `inner` diff --git a/tests/ui/cfg/diagnostics-same-crate.rs b/tests/ui/cfg/diagnostics-same-crate.rs index d9ff8d61e9243..b2a0fb58dd6b5 100644 --- a/tests/ui/cfg/diagnostics-same-crate.rs +++ b/tests/ui/cfg/diagnostics-same-crate.rs @@ -1,3 +1,5 @@ +#![allow(unexpected_cfgs)] // since we want to recognize them as unexpected + pub mod inner { #[cfg(FALSE)] pub fn uwu() {} diff --git a/tests/ui/cfg/diagnostics-same-crate.stderr b/tests/ui/cfg/diagnostics-same-crate.stderr index 83a44587238a5..86421736b8c60 100644 --- a/tests/ui/cfg/diagnostics-same-crate.stderr +++ b/tests/ui/cfg/diagnostics-same-crate.stderr @@ -1,72 +1,72 @@ error[E0432]: unresolved import `super::inner::doesnt_exist` - --> $DIR/diagnostics-same-crate.rs:28:9 + --> $DIR/diagnostics-same-crate.rs:30:9 | LL | use super::inner::doesnt_exist; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ no `doesnt_exist` in `inner` | note: found an item that was configured out - --> $DIR/diagnostics-same-crate.rs:7:13 + --> $DIR/diagnostics-same-crate.rs:9:13 | LL | pub mod doesnt_exist { | ^^^^^^^^^^^^ error[E0432]: unresolved import `super::inner::doesnt_exist` - --> $DIR/diagnostics-same-crate.rs:31:23 + --> $DIR/diagnostics-same-crate.rs:33:23 | LL | use super::inner::doesnt_exist::hi; | ^^^^^^^^^^^^ could not find `doesnt_exist` in `inner` | note: found an item that was configured out - --> $DIR/diagnostics-same-crate.rs:7:13 + --> $DIR/diagnostics-same-crate.rs:9:13 | LL | pub mod doesnt_exist { | ^^^^^^^^^^^^ error[E0433]: failed to resolve: could not find `doesnt_exist` in `inner` - --> $DIR/diagnostics-same-crate.rs:50:12 + --> $DIR/diagnostics-same-crate.rs:52:12 | LL | inner::doesnt_exist::hello(); | ^^^^^^^^^^^^ could not find `doesnt_exist` in `inner` | note: found an item that was configured out - --> $DIR/diagnostics-same-crate.rs:7:13 + --> $DIR/diagnostics-same-crate.rs:9:13 | LL | pub mod doesnt_exist { | ^^^^^^^^^^^^ error[E0425]: cannot find function `uwu` in module `inner` - --> $DIR/diagnostics-same-crate.rs:45:12 + --> $DIR/diagnostics-same-crate.rs:47:12 | LL | inner::uwu(); | ^^^ not found in `inner` | note: found an item that was configured out - --> $DIR/diagnostics-same-crate.rs:3:12 + --> $DIR/diagnostics-same-crate.rs:5:12 | LL | pub fn uwu() {} | ^^^ error[E0425]: cannot find function `meow` in module `inner::right` - --> $DIR/diagnostics-same-crate.rs:54:19 + --> $DIR/diagnostics-same-crate.rs:56:19 | LL | inner::right::meow(); | ^^^^ not found in `inner::right` | note: found an item that was configured out - --> $DIR/diagnostics-same-crate.rs:22:16 + --> $DIR/diagnostics-same-crate.rs:24:16 | LL | pub fn meow() {} | ^^^^ = note: the item is gated behind the `what-a-cool-feature` feature error[E0425]: cannot find function `uwu` in this scope - --> $DIR/diagnostics-same-crate.rs:41:5 + --> $DIR/diagnostics-same-crate.rs:43:5 | LL | uwu(); | ^^^ not found in this scope error[E0425]: cannot find function `vanished` in this scope - --> $DIR/diagnostics-same-crate.rs:61:5 + --> $DIR/diagnostics-same-crate.rs:63:5 | LL | vanished(); | ^^^^^^^^ not found in this scope diff --git a/tests/ui/cfg/expanded-cfg.rs b/tests/ui/cfg/expanded-cfg.rs index 75860146e745f..ecafa40cadc9e 100644 --- a/tests/ui/cfg/expanded-cfg.rs +++ b/tests/ui/cfg/expanded-cfg.rs @@ -1,5 +1,7 @@ //@ check-pass +#![allow(unexpected_cfgs)] // since we different cfgs + macro_rules! mac { {} => { #[cfg(attr)] diff --git a/tests/ui/cfg/future-compat-crate-attributes-using-cfg_attr.rs b/tests/ui/cfg/future-compat-crate-attributes-using-cfg_attr.rs index 96e326e02ad44..3ced3a630e334 100644 --- a/tests/ui/cfg/future-compat-crate-attributes-using-cfg_attr.rs +++ b/tests/ui/cfg/future-compat-crate-attributes-using-cfg_attr.rs @@ -1,5 +1,5 @@ //@ check-fail -//@ compile-flags:--cfg foo +//@ compile-flags:--cfg foo --check-cfg=cfg(foo) #![cfg_attr(foo, crate_type="bin")] //~^ERROR `crate_type` within diff --git a/tests/ui/conditional-compilation/cfg-attr-cfg-2.rs b/tests/ui/conditional-compilation/cfg-attr-cfg-2.rs index ae0afc7dfa77e..c801bbccedd6e 100644 --- a/tests/ui/conditional-compilation/cfg-attr-cfg-2.rs +++ b/tests/ui/conditional-compilation/cfg-attr-cfg-2.rs @@ -1,6 +1,5 @@ -// //@ error-pattern: `main` function not found -//@ compile-flags: --cfg foo +//@ compile-flags: --cfg foo --check-cfg=cfg(foo,bar) // main is conditionally compiled, but the conditional compilation // is conditional too! diff --git a/tests/ui/conditional-compilation/cfg-attr-cfg-2.stderr b/tests/ui/conditional-compilation/cfg-attr-cfg-2.stderr index 5f7fea0965f65..64595241dc729 100644 --- a/tests/ui/conditional-compilation/cfg-attr-cfg-2.stderr +++ b/tests/ui/conditional-compilation/cfg-attr-cfg-2.stderr @@ -1,5 +1,5 @@ error[E0601]: `main` function not found in crate `cfg_attr_cfg_2` - --> $DIR/cfg-attr-cfg-2.rs:9:14 + --> $DIR/cfg-attr-cfg-2.rs:8:14 | LL | fn main() { } | ^ consider adding a `main` function to `$DIR/cfg-attr-cfg-2.rs` diff --git a/tests/ui/conditional-compilation/cfg-attr-crate-2.rs b/tests/ui/conditional-compilation/cfg-attr-crate-2.rs index 710dbd8e81841..4b7d1c4523498 100644 --- a/tests/ui/conditional-compilation/cfg-attr-crate-2.rs +++ b/tests/ui/conditional-compilation/cfg-attr-crate-2.rs @@ -1,6 +1,6 @@ // https://github.com/rust-lang/rust/issues/21833#issuecomment-72353044 -//@ compile-flags: --cfg broken +//@ compile-flags: --cfg broken --check-cfg=cfg(broken) #![crate_type = "lib"] #![cfg_attr(broken, no_core)] //~ ERROR the `#[no_core]` attribute is an experimental feature diff --git a/tests/ui/conditional-compilation/cfg-attr-multi-invalid-1.rs b/tests/ui/conditional-compilation/cfg-attr-multi-invalid-1.rs index de2c7557a6db7..d881634abc347 100644 --- a/tests/ui/conditional-compilation/cfg-attr-multi-invalid-1.rs +++ b/tests/ui/conditional-compilation/cfg-attr-multi-invalid-1.rs @@ -1,4 +1,4 @@ -//@ compile-flags: --cfg broken +//@ compile-flags: --cfg broken --check-cfg=cfg(broken) #![crate_type = "lib"] #![cfg_attr(broken, no_core, no_std)] diff --git a/tests/ui/conditional-compilation/cfg-attr-multi-invalid-2.rs b/tests/ui/conditional-compilation/cfg-attr-multi-invalid-2.rs index e222b79c9d877..6cac52983b53b 100644 --- a/tests/ui/conditional-compilation/cfg-attr-multi-invalid-2.rs +++ b/tests/ui/conditional-compilation/cfg-attr-multi-invalid-2.rs @@ -1,4 +1,4 @@ -//@ compile-flags: --cfg broken +//@ compile-flags: --cfg broken --check-cfg=cfg(broken) #![crate_type = "lib"] #![cfg_attr(broken, no_std, no_core)] diff --git a/tests/ui/conditional-compilation/cfg-generic-params.rs b/tests/ui/conditional-compilation/cfg-generic-params.rs index 2a83be214988b..4bb8f8ae94f69 100644 --- a/tests/ui/conditional-compilation/cfg-generic-params.rs +++ b/tests/ui/conditional-compilation/cfg-generic-params.rs @@ -1,4 +1,4 @@ -//@ compile-flags:--cfg yes +//@ compile-flags:--cfg yes --check-cfg=cfg(yes,no) fn f_lt<#[cfg(yes)] 'a: 'a, #[cfg(FALSE)] T>() {} fn f_ty<#[cfg(FALSE)] 'a: 'a, #[cfg(yes)] T>() {} diff --git a/tests/ui/conditional-compilation/test-cfg.rs b/tests/ui/conditional-compilation/test-cfg.rs index 7c6c692072de4..adbbc309be447 100644 --- a/tests/ui/conditional-compilation/test-cfg.rs +++ b/tests/ui/conditional-compilation/test-cfg.rs @@ -1,4 +1,4 @@ -//@ compile-flags: --cfg foo +//@ compile-flags: --cfg foo --check-cfg=cfg(foo,bar) #[cfg(all(foo, bar))] // foo AND bar fn foo() {} diff --git a/tests/ui/imports/extern-prelude-extern-crate-cfg.rs b/tests/ui/imports/extern-prelude-extern-crate-cfg.rs index 346d63dabe7ee..49b90e4391534 100644 --- a/tests/ui/imports/extern-prelude-extern-crate-cfg.rs +++ b/tests/ui/imports/extern-prelude-extern-crate-cfg.rs @@ -1,5 +1,5 @@ //@ build-pass (FIXME(62277): could be check-pass?) -//@ compile-flags:--cfg my_feature +//@ compile-flags:--cfg my_feature --check-cfg=cfg(my_feature) #![no_std] diff --git a/tests/ui/macros/macro-comma-support-rpass.rs b/tests/ui/macros/macro-comma-support-rpass.rs index 724bd5af2dcff..5a4bac70b1ce6 100644 --- a/tests/ui/macros/macro-comma-support-rpass.rs +++ b/tests/ui/macros/macro-comma-support-rpass.rs @@ -51,6 +51,7 @@ fn assert_ne() { } #[test] +#[allow(unexpected_cfgs)] fn cfg() { let _ = cfg!(pants); let _ = cfg!(pants,); diff --git a/tests/ui/macros/macro-meta-items.rs b/tests/ui/macros/macro-meta-items.rs index d44a3184bc69d..35ef10fef5a84 100644 --- a/tests/ui/macros/macro-meta-items.rs +++ b/tests/ui/macros/macro-meta-items.rs @@ -1,6 +1,7 @@ //@ run-pass +//@ compile-flags: --cfg foo --check-cfg=cfg(foo) + #![allow(dead_code)] -//@ compile-flags: --cfg foo macro_rules! compiles_fine { ($at:meta) => { diff --git a/tests/ui/macros/macro-with-attrs1.rs b/tests/ui/macros/macro-with-attrs1.rs index cfd5691fe94bd..a3030e744db71 100644 --- a/tests/ui/macros/macro-with-attrs1.rs +++ b/tests/ui/macros/macro-with-attrs1.rs @@ -1,5 +1,5 @@ //@ run-pass -//@ compile-flags: --cfg foo +//@ compile-flags: --cfg foo --check-cfg=cfg(foo) #[cfg(foo)] diff --git a/tests/ui/macros/syntax-extension-cfg.rs b/tests/ui/macros/syntax-extension-cfg.rs index b819e8c33d804..6e7f3e2ed5d44 100644 --- a/tests/ui/macros/syntax-extension-cfg.rs +++ b/tests/ui/macros/syntax-extension-cfg.rs @@ -1,6 +1,6 @@ //@ run-pass //@ compile-flags: --cfg foo --cfg qux="foo" - +//@ compile-flags: --check-cfg=cfg(foo) --check-cfg=cfg(qux,values("foo")) pub fn main() { // check diff --git a/tests/ui/methods/method-lookup-order.rs b/tests/ui/methods/method-lookup-order.rs index 08ad6483d089e..f794e5a72415e 100644 --- a/tests/ui/methods/method-lookup-order.rs +++ b/tests/ui/methods/method-lookup-order.rs @@ -18,6 +18,9 @@ //@ revisions: b00001 b00010 b00011 b00100 b00101 b00110 b00111 b01000 b01001 b01100 b01101 b10000 b10001 b10010 b10011 b10101 b10111 b11000 b11001 b11101 +//@ compile-flags: --check-cfg=cfg(inherent_mut,bar_for_foo,mutbar_for_foo) +//@ compile-flags: --check-cfg=cfg(valbar_for_et_foo,valbar_for_etmut_foo) + //@[b00001]compile-flags: --cfg inherent_mut //@[b00010]compile-flags: --cfg bar_for_foo //@[b00011]compile-flags: --cfg inherent_mut --cfg bar_for_foo diff --git a/tests/ui/parser/attribute/attr-unquoted-ident.fixed b/tests/ui/parser/attribute/attr-unquoted-ident.fixed index 636508b5615aa..bc861ef69fb7c 100644 --- a/tests/ui/parser/attribute/attr-unquoted-ident.fixed +++ b/tests/ui/parser/attribute/attr-unquoted-ident.fixed @@ -1,6 +1,8 @@ //@ compile-flags: -Zdeduplicate-diagnostics=yes //@ run-rustfix +#![allow(unexpected_cfgs)] + fn main() { #[cfg(key="foo")] //~^ ERROR expected unsuffixed literal, found `foo` diff --git a/tests/ui/parser/attribute/attr-unquoted-ident.rs b/tests/ui/parser/attribute/attr-unquoted-ident.rs index 9b9a9f7840352..8bdb8605ebb4f 100644 --- a/tests/ui/parser/attribute/attr-unquoted-ident.rs +++ b/tests/ui/parser/attribute/attr-unquoted-ident.rs @@ -1,6 +1,8 @@ //@ compile-flags: -Zdeduplicate-diagnostics=yes //@ run-rustfix +#![allow(unexpected_cfgs)] + fn main() { #[cfg(key=foo)] //~^ ERROR expected unsuffixed literal, found `foo` diff --git a/tests/ui/parser/attribute/attr-unquoted-ident.stderr b/tests/ui/parser/attribute/attr-unquoted-ident.stderr index bc028f39be61c..99484a51110f1 100644 --- a/tests/ui/parser/attribute/attr-unquoted-ident.stderr +++ b/tests/ui/parser/attribute/attr-unquoted-ident.stderr @@ -1,5 +1,5 @@ error: expected unsuffixed literal, found `foo` - --> $DIR/attr-unquoted-ident.rs:5:15 + --> $DIR/attr-unquoted-ident.rs:7:15 | LL | #[cfg(key=foo)] | ^^^ @@ -10,7 +10,7 @@ LL | #[cfg(key="foo")] | + + error: expected unsuffixed literal, found `foo` - --> $DIR/attr-unquoted-ident.rs:11:15 + --> $DIR/attr-unquoted-ident.rs:13:15 | LL | #[cfg(key=foo bar baz)] | ^^^ diff --git a/tests/ui/regions/regions-refcell.rs b/tests/ui/regions/regions-refcell.rs index 29eb5161a6c37..c27ffe6b6a8c0 100644 --- a/tests/ui/regions/regions-refcell.rs +++ b/tests/ui/regions/regions-refcell.rs @@ -3,6 +3,7 @@ // attempting to bootstrap librustc with new destructor lifetime // semantics. +#![allow(unexpected_cfgs)] // for the cfg-as-descriptions use std::collections::HashMap; use std::cell::RefCell; diff --git a/tests/ui/resolve/suggest-import-without-clobbering-attrs.fixed b/tests/ui/resolve/suggest-import-without-clobbering-attrs.fixed index d05c0f058069c..607c9af492713 100644 --- a/tests/ui/resolve/suggest-import-without-clobbering-attrs.fixed +++ b/tests/ui/resolve/suggest-import-without-clobbering-attrs.fixed @@ -1,8 +1,8 @@ //@ run-rustfix -//@ compile-flags: --cfg=whatever -Aunused +//@ compile-flags: -Aunused use y::z; -#[cfg(whatever)] +#[cfg(all())] use y::Whatever; mod y { diff --git a/tests/ui/resolve/suggest-import-without-clobbering-attrs.rs b/tests/ui/resolve/suggest-import-without-clobbering-attrs.rs index 0be2e558e42cd..6cc53fb108658 100644 --- a/tests/ui/resolve/suggest-import-without-clobbering-attrs.rs +++ b/tests/ui/resolve/suggest-import-without-clobbering-attrs.rs @@ -1,7 +1,7 @@ //@ run-rustfix -//@ compile-flags: --cfg=whatever -Aunused +//@ compile-flags: -Aunused -#[cfg(whatever)] +#[cfg(all())] use y::Whatever; mod y { diff --git a/tests/ui/rfcs/rfc-2565-param-attrs/param-attrs-allowed.rs b/tests/ui/rfcs/rfc-2565-param-attrs/param-attrs-allowed.rs index e35f743d96aad..4b8d2406784a7 100644 --- a/tests/ui/rfcs/rfc-2565-param-attrs/param-attrs-allowed.rs +++ b/tests/ui/rfcs/rfc-2565-param-attrs/param-attrs-allowed.rs @@ -1,5 +1,5 @@ //@ check-pass -//@ compile-flags: --cfg something +//@ compile-flags: --cfg something --check-cfg=cfg(nothing,something) #![deny(unused_mut)] diff --git a/tests/ui/rfcs/rfc-2565-param-attrs/param-attrs-cfg.rs b/tests/ui/rfcs/rfc-2565-param-attrs/param-attrs-cfg.rs index babeaf67eb2e0..e7a5d59958b58 100644 --- a/tests/ui/rfcs/rfc-2565-param-attrs/param-attrs-cfg.rs +++ b/tests/ui/rfcs/rfc-2565-param-attrs/param-attrs-cfg.rs @@ -1,4 +1,4 @@ -//@ compile-flags: --cfg something +//@ compile-flags: --cfg something --check-cfg=cfg(nothing,something) //@ edition:2018 #![feature(async_closure)] diff --git a/tests/ui/rust-2018/issue-54400-unused-extern-crate-attr-span.fixed b/tests/ui/rust-2018/issue-54400-unused-extern-crate-attr-span.fixed index f4506dd929ea4..878d1dc72ccb1 100644 --- a/tests/ui/rust-2018/issue-54400-unused-extern-crate-attr-span.fixed +++ b/tests/ui/rust-2018/issue-54400-unused-extern-crate-attr-span.fixed @@ -4,7 +4,7 @@ //@ edition:2018 #![deny(rust_2018_idioms)] -#![allow(dead_code)] +#![allow(dead_code, unexpected_cfgs)] // The suggestion span should include the attribute. diff --git a/tests/ui/rust-2018/issue-54400-unused-extern-crate-attr-span.rs b/tests/ui/rust-2018/issue-54400-unused-extern-crate-attr-span.rs index 4f1cb71dc5185..573942bd09552 100644 --- a/tests/ui/rust-2018/issue-54400-unused-extern-crate-attr-span.rs +++ b/tests/ui/rust-2018/issue-54400-unused-extern-crate-attr-span.rs @@ -4,7 +4,7 @@ //@ edition:2018 #![deny(rust_2018_idioms)] -#![allow(dead_code)] +#![allow(dead_code, unexpected_cfgs)] // The suggestion span should include the attribute. diff --git a/tests/ui/shell-argfiles/shell-argfiles-via-argfile.rs b/tests/ui/shell-argfiles/shell-argfiles-via-argfile.rs index b907fd3bbc758..2c07542bd75e5 100644 --- a/tests/ui/shell-argfiles/shell-argfiles-via-argfile.rs +++ b/tests/ui/shell-argfiles/shell-argfiles-via-argfile.rs @@ -1,6 +1,7 @@ // Check to see if we can get parameters from an @argsfile file // //@ build-pass +//@ no-auto-check-cfg //@ compile-flags: @{{src-base}}/shell-argfiles/shell-argfiles-via-argfile.args @shell:{{src-base}}/shell-argfiles/shell-argfiles-via-argfile-shell.args #[cfg(not(shell_args_set))] diff --git a/tests/ui/shell-argfiles/shell-argfiles.args b/tests/ui/shell-argfiles/shell-argfiles.args index e5bb4b807ec4d..6c596b0bbc05e 100644 --- a/tests/ui/shell-argfiles/shell-argfiles.args +++ b/tests/ui/shell-argfiles/shell-argfiles.args @@ -1,3 +1,4 @@ --cfg unquoted_set '--cfg' 'single_quoted_set' "--cfg" "double_quoted_set" +--check-cfg 'cfg(cmdline_set, unquoted_set, single_quoted_set, double_quoted_set)' diff --git a/tests/ui/target-feature/no-llvm-leaks.rs b/tests/ui/target-feature/no-llvm-leaks.rs index b4a391e184e82..73cec0a4496a7 100644 --- a/tests/ui/target-feature/no-llvm-leaks.rs +++ b/tests/ui/target-feature/no-llvm-leaks.rs @@ -6,7 +6,7 @@ //@ build-pass #![no_core] #![crate_type = "rlib"] -#![feature(intrinsics, rustc_attrs, no_core, lang_items, staged_api)] +#![feature(intrinsics, rustc_attrs, no_core, lang_items, staged_api, lint_reasons)] #![stable(feature = "test", since = "1.0.0")] // Supporting minimal rust core code @@ -43,22 +43,30 @@ macro_rules! assert { #[cfg(target_arch = "aarch64")] fn check_aarch64() { - // This checks that the rustc feature name is used, not the LLVM feature. + // These checks that the rustc feature name is used, not the LLVM feature. + assert!(cfg!(target_feature = "neon")); - assert!(cfg!(not(target_feature = "fp-armv8"))); + // #[expect(unexpected_cfgs)] except that 32-bit arm actually use fp-armv8 + { assert!(cfg!(not(target_feature = "fp-armv8"))); } + assert!(cfg!(target_feature = "fhm")); - assert!(cfg!(not(target_feature = "fp16fml"))); + #[expect(unexpected_cfgs)] + { assert!(cfg!(not(target_feature = "fp16fml"))); } + assert!(cfg!(target_feature = "fp16")); - assert!(cfg!(not(target_feature = "fullfp16"))); + #[expect(unexpected_cfgs)] + { assert!(cfg!(not(target_feature = "fullfp16"))); } } #[cfg(target_arch = "x86_64")] fn check_x86_64() { // This checks that the rustc feature name is used, not the LLVM feature. assert!(cfg!(target_feature = "rdrand")); - assert!(cfg!(not(target_feature = "rdrnd"))); + #[expect(unexpected_cfgs)] + { assert!(cfg!(not(target_feature = "rdrnd"))); } // Likewise: We enable LLVM's crc32 feature with SSE4.2, but Rust says it's just SSE4.2 assert!(cfg!(target_feature = "sse4.2")); - assert!(cfg!(not(target_feature = "crc32"))); + #[expect(unexpected_cfgs)] + { assert!(cfg!(not(target_feature = "crc32"))); } } From 2ae0765ffb743de9845ee953bb6020db866e5b63 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Thu, 25 Apr 2024 10:14:17 +1000 Subject: [PATCH 15/16] Add comments about attribute tokens. This clarifies something that has puzzled me for some time. --- compiler/rustc_ast/src/ast.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/compiler/rustc_ast/src/ast.rs b/compiler/rustc_ast/src/ast.rs index bddb50568d41b..dc3377f6bad36 100644 --- a/compiler/rustc_ast/src/ast.rs +++ b/compiler/rustc_ast/src/ast.rs @@ -2786,6 +2786,7 @@ pub enum AttrKind { #[derive(Clone, Encodable, Decodable, Debug)] pub struct NormalAttr { pub item: AttrItem, + // Tokens for the full attribute, e.g. `#[foo]`, `#![bar]`. pub tokens: Option, } @@ -2802,6 +2803,7 @@ impl NormalAttr { pub struct AttrItem { pub path: Path, pub args: AttrArgs, + // Tokens for the meta item, e.g. just the `foo` within `#[foo]` or `#![foo]`. pub tokens: Option, } From f3530cf003745af53f82c8286ab63597b615095e Mon Sep 17 00:00:00 2001 From: Jover Zhang Date: Sat, 20 Apr 2024 19:25:53 +0800 Subject: [PATCH 16/16] Rewrite `no-input-file.stderr` test in Rust and support diff --- Cargo.lock | 7 ++ src/tools/run-make-support/Cargo.toml | 1 + src/tools/run-make-support/src/diff/mod.rs | 81 +++++++++++++++++++ src/tools/run-make-support/src/diff/tests.rs | 39 +++++++++ src/tools/run-make-support/src/lib.rs | 2 + src/tools/run-make-support/src/rustc.rs | 7 ++ .../tidy/src/allowed_run_make_makefiles.txt | 1 - tests/run-make/no-input-file/Makefile | 4 - tests/run-make/no-input-file/rmake.rs | 9 +++ 9 files changed, 146 insertions(+), 5 deletions(-) create mode 100644 src/tools/run-make-support/src/diff/mod.rs create mode 100644 src/tools/run-make-support/src/diff/tests.rs delete mode 100644 tests/run-make/no-input-file/Makefile create mode 100644 tests/run-make/no-input-file/rmake.rs diff --git a/Cargo.lock b/Cargo.lock index 552b446a1e753..8a9701acae11f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3343,6 +3343,7 @@ version = "0.0.0" dependencies = [ "object 0.34.0", "regex", + "similar", "wasmparser", ] @@ -5138,6 +5139,12 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" +[[package]] +name = "similar" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa42c91313f1d05da9b26f267f931cf178d4aba455b4c4622dd7355eb80c6640" + [[package]] name = "siphasher" version = "0.3.11" diff --git a/src/tools/run-make-support/Cargo.toml b/src/tools/run-make-support/Cargo.toml index 3ea35c7940c21..61a24c97e77a2 100644 --- a/src/tools/run-make-support/Cargo.toml +++ b/src/tools/run-make-support/Cargo.toml @@ -5,5 +5,6 @@ edition = "2021" [dependencies] object = "0.34.0" +similar = "2.5.0" wasmparser = "0.118.2" regex = "1.8" # 1.8 to avoid memchr 2.6.0, as 2.5.0 is pinned in the workspace diff --git a/src/tools/run-make-support/src/diff/mod.rs b/src/tools/run-make-support/src/diff/mod.rs new file mode 100644 index 0000000000000..54532c6e35bab --- /dev/null +++ b/src/tools/run-make-support/src/diff/mod.rs @@ -0,0 +1,81 @@ +use similar::TextDiff; +use std::path::Path; + +#[cfg(test)] +mod tests; + +pub fn diff() -> Diff { + Diff::new() +} + +#[derive(Debug)] +pub struct Diff { + expected: Option, + expected_name: Option, + actual: Option, + actual_name: Option, +} + +impl Diff { + /// Construct a bare `diff` invocation. + pub fn new() -> Self { + Self { expected: None, expected_name: None, actual: None, actual_name: None } + } + + /// Specify the expected output for the diff from a file. + pub fn expected_file>(&mut self, path: P) -> &mut Self { + let path = path.as_ref(); + let content = std::fs::read_to_string(path).expect("failed to read file"); + let name = path.to_string_lossy().to_string(); + + self.expected = Some(content); + self.expected_name = Some(name); + self + } + + /// Specify the expected output for the diff from a given text string. + pub fn expected_text>(&mut self, name: &str, text: T) -> &mut Self { + self.expected = Some(String::from_utf8_lossy(text.as_ref()).to_string()); + self.expected_name = Some(name.to_string()); + self + } + + /// Specify the actual output for the diff from a file. + pub fn actual_file>(&mut self, path: P) -> &mut Self { + let path = path.as_ref(); + let content = std::fs::read_to_string(path).expect("failed to read file"); + let name = path.to_string_lossy().to_string(); + + self.actual = Some(content); + self.actual_name = Some(name); + self + } + + /// Specify the actual output for the diff from a given text string. + pub fn actual_text>(&mut self, name: &str, text: T) -> &mut Self { + self.actual = Some(String::from_utf8_lossy(text.as_ref()).to_string()); + self.actual_name = Some(name.to_string()); + self + } + + /// Executes the diff process, prints any differences to the standard error. + #[track_caller] + pub fn run(&self) { + let expected = self.expected.as_ref().expect("expected text not set"); + let actual = self.actual.as_ref().expect("actual text not set"); + let expected_name = self.expected_name.as_ref().unwrap(); + let actual_name = self.actual_name.as_ref().unwrap(); + + let output = TextDiff::from_lines(expected, actual) + .unified_diff() + .header(expected_name, actual_name) + .to_string(); + + if !output.is_empty() { + panic!( + "test failed: `{}` is different from `{}`\n\n{}", + expected_name, actual_name, output + ) + } + } +} diff --git a/src/tools/run-make-support/src/diff/tests.rs b/src/tools/run-make-support/src/diff/tests.rs new file mode 100644 index 0000000000000..e6d72544b7ebc --- /dev/null +++ b/src/tools/run-make-support/src/diff/tests.rs @@ -0,0 +1,39 @@ +#[cfg(test)] +mod tests { + use crate::*; + + #[test] + fn test_diff() { + let expected = "foo\nbar\nbaz\n"; + let actual = "foo\nbar\nbaz\n"; + diff().expected_text("EXPECTED_TEXT", expected).actual_text("ACTUAL_TEXT", actual).run(); + } + + #[test] + fn test_should_panic() { + let expected = "foo\nbar\nbaz\n"; + let actual = "foo\nbaz\nbar\n"; + + let output = std::panic::catch_unwind(|| { + diff() + .expected_text("EXPECTED_TEXT", expected) + .actual_text("ACTUAL_TEXT", actual) + .run(); + }) + .unwrap_err(); + + let expected_output = "\ +test failed: `EXPECTED_TEXT` is different from `ACTUAL_TEXT` + +--- EXPECTED_TEXT ++++ ACTUAL_TEXT +@@ -1,3 +1,3 @@ + foo ++baz + bar +-baz +"; + + assert_eq!(output.downcast_ref::().unwrap(), expected_output); + } +} diff --git a/src/tools/run-make-support/src/lib.rs b/src/tools/run-make-support/src/lib.rs index e723e824ed6c8..76e8838d27c72 100644 --- a/src/tools/run-make-support/src/lib.rs +++ b/src/tools/run-make-support/src/lib.rs @@ -5,6 +5,7 @@ pub mod cc; pub mod clang; +pub mod diff; pub mod llvm_readobj; pub mod run; pub mod rustc; @@ -20,6 +21,7 @@ pub use wasmparser; pub use cc::{cc, extra_c_flags, extra_cxx_flags, Cc}; pub use clang::{clang, Clang}; +pub use diff::{diff, Diff}; pub use llvm_readobj::{llvm_readobj, LlvmReadobj}; pub use run::{run, run_fail}; pub use rustc::{aux_build, rustc, Rustc}; diff --git a/src/tools/run-make-support/src/rustc.rs b/src/tools/run-make-support/src/rustc.rs index 9bf41c6e2e9a5..ddaae3236c2b5 100644 --- a/src/tools/run-make-support/src/rustc.rs +++ b/src/tools/run-make-support/src/rustc.rs @@ -148,6 +148,13 @@ impl Rustc { self } + /// Specify the print request. + pub fn print(&mut self, request: &str) -> &mut Self { + self.cmd.arg("--print"); + self.cmd.arg(request); + self + } + /// Add an extra argument to the linker invocation, via `-Clink-arg`. pub fn link_arg(&mut self, link_arg: &str) -> &mut Self { self.cmd.arg(format!("-Clink-arg={link_arg}")); diff --git a/src/tools/tidy/src/allowed_run_make_makefiles.txt b/src/tools/tidy/src/allowed_run_make_makefiles.txt index f0ed0ae806fd8..4598a658b314e 100644 --- a/src/tools/tidy/src/allowed_run_make_makefiles.txt +++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt @@ -189,7 +189,6 @@ run-make/no-builtins-attribute/Makefile run-make/no-builtins-lto/Makefile run-make/no-cdylib-as-rdylib/Makefile run-make/no-duplicate-libs/Makefile -run-make/no-input-file/Makefile run-make/no-intermediate-extras/Makefile run-make/obey-crate-type-flag/Makefile run-make/optimization-remarks-dir-pgo/Makefile diff --git a/tests/run-make/no-input-file/Makefile b/tests/run-make/no-input-file/Makefile deleted file mode 100644 index a754573a52410..0000000000000 --- a/tests/run-make/no-input-file/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -include ../tools.mk - -all: - $(RUSTC) --print crate-name 2>&1 | diff - no-input-file.stderr diff --git a/tests/run-make/no-input-file/rmake.rs b/tests/run-make/no-input-file/rmake.rs new file mode 100644 index 0000000000000..26df7e80dfbff --- /dev/null +++ b/tests/run-make/no-input-file/rmake.rs @@ -0,0 +1,9 @@ +extern crate run_make_support; + +use run_make_support::{diff, rustc}; + +fn main() { + let output = rustc().print("crate-name").run_fail_assert_exit_code(1); + + diff().expected_file("no-input-file.stderr").actual_text("output", output.stderr).run(); +}