From 80c13ce13403e4aba7a73b765bfd8c40997f196d Mon Sep 17 00:00:00 2001 From: Garrett Berg Date: Fri, 13 Oct 2017 10:04:59 -0600 Subject: [PATCH] fix review comments --- .../persist/dirty_clean.rs | 35 +++++++++---------- .../incremental/hashes/call_expressions.rs | 4 +-- .../incremental/hashes/enum_constructors.rs | 21 ++++++++--- src/test/incremental/hashes/enum_defs.rs | 18 +++------- src/test/incremental/hashes/inherent_impls.rs | 2 ++ src/test/incremental/hashes/type_defs.rs | 20 +++++------ 6 files changed, 51 insertions(+), 49 deletions(-) diff --git a/src/librustc_incremental/persist/dirty_clean.rs b/src/librustc_incremental/persist/dirty_clean.rs index 5f97eaf21d2..0cb920a111d 100644 --- a/src/librustc_incremental/persist/dirty_clean.rs +++ b/src/librustc_incremental/persist/dirty_clean.rs @@ -39,8 +39,6 @@ //! previous revision to compare things to. //! -#![allow(dead_code)] - use std::collections::HashSet; use std::iter::FromIterator; use std::vec::Vec; @@ -141,14 +139,14 @@ const LABELS_CONST: &[&[&str]] = &[ ]; /// Constant/Typedef in an impl -const LABELS_CONST_ASSOCIATED: &[&[&str]] = &[ +const LABELS_CONST_IN_IMPL: &[&[&str]] = &[ BASE_HIR, BASE_CONST, EXTRA_ASSOCIATED, ]; /// Trait-Const/Typedef DepNodes -const LABELS_CONST_TRAIT: &[&[&str]] = &[ +const LABELS_CONST_IN_TRAIT: &[&[&str]] = &[ BASE_HIR, BASE_CONST, EXTRA_ASSOCIATED, @@ -163,7 +161,7 @@ const LABELS_FN: &[&[&str]] = &[ ]; /// Method DepNodes -const LABELS_FN_ASSOCIATED: &[&[&str]] = &[ +const LABELS_FN_IN_IMPL: &[&[&str]] = &[ BASE_HIR, BASE_MIR, BASE_FN, @@ -171,7 +169,7 @@ const LABELS_FN_ASSOCIATED: &[&[&str]] = &[ ]; /// Trait-Method DepNodes -const LABELS_FN_TRAIT: &[&[&str]] = &[ +const LABELS_FN_IN_TRAIT: &[&[&str]] = &[ BASE_HIR, BASE_MIR, BASE_FN, @@ -190,13 +188,14 @@ const LABELS_IMPL: &[&[&str]] = &[ BASE_IMPL, ]; -/// Struct DepNodes -const LABELS_STRUCT: &[&[&str]] = &[ +/// Abstract Data Type (Struct, Enum, Unions) DepNodes +const LABELS_ADT: &[&[&str]] = &[ BASE_HIR, BASE_STRUCT, ]; /// Trait Definition DepNodes +#[allow(dead_code)] const LABELS_TRAIT: &[&[&str]] = &[ BASE_HIR, BASE_TRAIT_DEF, @@ -382,16 +381,16 @@ impl<'a, 'tcx> DirtyCleanVisitor<'a, 'tcx> { HirItem::ItemGlobalAsm(..) => ("ItemGlobalAsm", LABELS_HIR_ONLY), // A type alias, e.g. `type Foo = Bar` - HirItem::ItemTy(..) => ("ItemTy", LABELS_CONST), + HirItem::ItemTy(..) => ("ItemTy", LABELS_HIR_ONLY), // An enum definition, e.g. `enum Foo {C, D}` - HirItem::ItemEnum(..) => ("ItemEnum", LABELS_STRUCT), + HirItem::ItemEnum(..) => ("ItemEnum", LABELS_ADT), // A struct definition, e.g. `struct Foo {x: A}` - HirItem::ItemStruct(..) => ("ItemStruct", LABELS_STRUCT), + HirItem::ItemStruct(..) => ("ItemStruct", LABELS_ADT), // A union definition, e.g. `union Foo {x: A, y: B}` - HirItem::ItemUnion(..) => ("ItemUnion", LABELS_STRUCT), + HirItem::ItemUnion(..) => ("ItemUnion", LABELS_ADT), // Represents a Trait Declaration // FIXME(michaelwoerister): trait declaration is buggy because sometimes some of @@ -426,16 +425,16 @@ impl<'a, 'tcx> DirtyCleanVisitor<'a, 'tcx> { }, HirNode::NodeTraitItem(item) => { match item.node { - TraitItemKind::Method(..) => ("NodeTraitItem", LABELS_FN_TRAIT), - TraitItemKind::Const(..) => ("NodeTraitConst", LABELS_CONST_TRAIT), - TraitItemKind::Type(..) => ("NodeTraitType", LABELS_CONST_TRAIT), + TraitItemKind::Method(..) => ("NodeTraitItem", LABELS_FN_IN_TRAIT), + TraitItemKind::Const(..) => ("NodeTraitConst", LABELS_CONST_IN_TRAIT), + TraitItemKind::Type(..) => ("NodeTraitType", LABELS_CONST_IN_TRAIT), } }, HirNode::NodeImplItem(item) => { match item.node { - ImplItemKind::Method(..) => ("NodeImplItem", LABELS_FN_ASSOCIATED), - ImplItemKind::Const(..) => ("NodeImplConst", LABELS_CONST_ASSOCIATED), - ImplItemKind::Type(..) => ("NodeImplType", LABELS_CONST_ASSOCIATED), + ImplItemKind::Method(..) => ("NodeImplItem", LABELS_FN_IN_IMPL), + ImplItemKind::Const(..) => ("NodeImplConst", LABELS_CONST_IN_IMPL), + ImplItemKind::Type(..) => ("NodeImplType", LABELS_CONST_IN_IMPL), } }, _ => self.tcx.sess.span_fatal( diff --git a/src/test/incremental/hashes/call_expressions.rs b/src/test/incremental/hashes/call_expressions.rs index 6e1014b573a..0090c2aeef9 100644 --- a/src/test/incremental/hashes/call_expressions.rs +++ b/src/test/incremental/hashes/call_expressions.rs @@ -171,13 +171,13 @@ pub fn change_to_ufcs() { s.method1('x', true); } -// FIXME(vitiral): why would this change anything, doesn't the Mir/Hir expand this -// sort of stuff? #[cfg(not(cfail1))] #[rustc_clean(cfg="cfail2", except="HirBody,MirValidated,MirOptimized,TypeckTables")] #[rustc_clean(cfg="cfail3")] #[rustc_metadata_clean(cfg="cfail2")] #[rustc_metadata_clean(cfg="cfail3")] +// One might think this would be expanded in the HirBody/Mir, but it actually +// results in slightly different Hir/Mir. pub fn change_to_ufcs() { let s = Struct; Struct::method1(&s, 'x', true); diff --git a/src/test/incremental/hashes/enum_constructors.rs b/src/test/incremental/hashes/enum_constructors.rs index ffb62f7f7a0..f826d47c3e5 100644 --- a/src/test/incremental/hashes/enum_constructors.rs +++ b/src/test/incremental/hashes/enum_constructors.rs @@ -74,6 +74,8 @@ fn change_field_order_struct_like() -> Enum { #[rustc_clean(cfg="cfail3")] #[rustc_metadata_clean(cfg="cfail2")] #[rustc_metadata_clean(cfg="cfail3")] +// FIXME(michaelwoerister):Interesting. I would have thought that that changes the MIR. And it +// would if it were not all constants fn change_field_order_struct_like() -> Enum { Enum::Struct { y: 4, @@ -156,7 +158,8 @@ mod change_constructor_path_indirectly_struct_like { #[rustc_clean( cfg="cfail2", - except="FnSignature,Hir,HirBody,MirOptimized,MirValidated,TypeckTables" + except="FnSignature,Hir,HirBody,MirOptimized,MirValidated,\ + TypeckTables" )] #[rustc_clean(cfg="cfail3")] #[rustc_metadata_dirty(cfg="cfail2")] @@ -217,7 +220,10 @@ fn change_constructor_path_tuple_like() { } #[cfg(not(cfail1))] -#[rustc_clean(cfg="cfail2", except="HirBody,MirOptimized,MirValidated,TypeckTables")] +#[rustc_clean( + cfg="cfail2", + except="HirBody,MirOptimized,MirValidated,TypeckTables" +)] #[rustc_clean(cfg="cfail3")] #[rustc_metadata_clean(cfg="cfail2")] #[rustc_metadata_clean(cfg="cfail3")] @@ -234,7 +240,10 @@ fn change_constructor_variant_tuple_like() { } #[cfg(not(cfail1))] -#[rustc_clean(cfg="cfail2", except="HirBody,MirOptimized,MirValidated,TypeckTables")] +#[rustc_clean( + cfg="cfail2", + except="HirBody,MirOptimized,MirValidated,TypeckTables" +)] #[rustc_clean(cfg="cfail3")] #[rustc_metadata_clean(cfg="cfail2")] #[rustc_metadata_clean(cfg="cfail3")] @@ -252,7 +261,8 @@ mod change_constructor_path_indirectly_tuple_like { #[rustc_clean( cfg="cfail2", - except="FnSignature,Hir,HirBody,MirOptimized,MirValidated,TypeckTables" + except="FnSignature,Hir,HirBody,MirOptimized,MirValidated,\ + TypeckTables" )] #[rustc_clean(cfg="cfail3")] #[rustc_metadata_dirty(cfg="cfail2")] @@ -335,7 +345,8 @@ mod change_constructor_path_indirectly_c_like { #[rustc_clean( cfg="cfail2", - except="FnSignature,Hir,HirBody,MirOptimized,MirValidated,TypeckTables" + except="FnSignature,Hir,HirBody,MirOptimized,MirValidated,\ + TypeckTables" )] #[rustc_clean(cfg="cfail3")] #[rustc_metadata_dirty(cfg="cfail2")] diff --git a/src/test/incremental/hashes/enum_defs.rs b/src/test/incremental/hashes/enum_defs.rs index 3aaa1f307c7..22393fad3d0 100644 --- a/src/test/incremental/hashes/enum_defs.rs +++ b/src/test/incremental/hashes/enum_defs.rs @@ -444,7 +444,6 @@ enum EnumChangeNameOfTypeParameter { #[rustc_clean(cfg="cfail3")] #[rustc_metadata_dirty(cfg="cfail2")] #[rustc_metadata_clean(cfg="cfail3")] -#[repr(C)] enum EnumChangeNameOfTypeParameter { Variant1(T), } @@ -463,7 +462,6 @@ enum EnumAddTypeParameter { #[rustc_clean(cfg="cfail3")] #[rustc_metadata_dirty(cfg="cfail2")] #[rustc_metadata_clean(cfg="cfail3")] -#[repr(C)] enum EnumAddTypeParameter { Variant1(S), Variant2(T), @@ -482,7 +480,6 @@ enum EnumChangeNameOfLifetimeParameter<'a> { #[rustc_clean(cfg="cfail3")] #[rustc_metadata_dirty(cfg="cfail2")] #[rustc_metadata_clean(cfg="cfail3")] -#[repr(C)] enum EnumChangeNameOfLifetimeParameter<'b> { Variant1(&'b u32), } @@ -501,7 +498,6 @@ enum EnumAddLifetimeParameter<'a> { #[rustc_clean(cfg="cfail3")] #[rustc_metadata_dirty(cfg="cfail2")] #[rustc_metadata_clean(cfg="cfail3")] -#[repr(C)] enum EnumAddLifetimeParameter<'a, 'b> { Variant1(&'a u32), Variant2(&'b u32), @@ -517,11 +513,10 @@ enum EnumAddLifetimeParameterBound<'a, 'b> { } #[cfg(not(cfail1))] -#[rustc_dirty(cfg="cfail2", except="GenericsOfItem")] +#[rustc_dirty(cfg="cfail2", except="GenericsOfItem,TypeOfItem")] #[rustc_clean(cfg="cfail3")] #[rustc_metadata_dirty(cfg="cfail2")] #[rustc_metadata_clean(cfg="cfail3")] -#[repr(C)] enum EnumAddLifetimeParameterBound<'a, 'b: 'a> { Variant1(&'a u32), Variant2(&'b u32), @@ -535,11 +530,10 @@ enum EnumAddLifetimeBoundToParameter<'a, T> { } #[cfg(not(cfail1))] -#[rustc_dirty(cfg="cfail2")] +#[rustc_dirty(cfg="cfail2", except="TypeOfItem")] #[rustc_clean(cfg="cfail3")] #[rustc_metadata_dirty(cfg="cfail2")] #[rustc_metadata_clean(cfg="cfail3")] -#[repr(C)] enum EnumAddLifetimeBoundToParameter<'a, T: 'a> { Variant1(T), Variant2(&'a u32), @@ -558,7 +552,6 @@ enum EnumAddTraitBound { #[rustc_clean(cfg="cfail3")] #[rustc_metadata_dirty(cfg="cfail2")] #[rustc_metadata_clean(cfg="cfail3")] -#[repr(C)] enum EnumAddTraitBound { Variant1(T), } @@ -573,11 +566,10 @@ enum EnumAddLifetimeParameterBoundWhere<'a, 'b> { } #[cfg(not(cfail1))] -#[rustc_dirty(cfg="cfail2", except="GenericsOfItem")] +#[rustc_dirty(cfg="cfail2", except="GenericsOfItem,TypeOfItem")] #[rustc_clean(cfg="cfail3")] #[rustc_metadata_dirty(cfg="cfail2")] #[rustc_metadata_clean(cfg="cfail3")] -#[repr(C)] enum EnumAddLifetimeParameterBoundWhere<'a, 'b> where 'b: 'a { Variant1(&'a u32), Variant2(&'b u32), @@ -593,11 +585,10 @@ enum EnumAddLifetimeBoundToParameterWhere<'a, T> { } #[cfg(not(cfail1))] -#[rustc_dirty(cfg="cfail2")] +#[rustc_dirty(cfg="cfail2", except="TypeOfItem")] #[rustc_clean(cfg="cfail3")] #[rustc_metadata_dirty(cfg="cfail2")] #[rustc_metadata_clean(cfg="cfail3")] -#[repr(C)] enum EnumAddLifetimeBoundToParameterWhere<'a, T> where T: 'a { Variant1(T), Variant2(&'a u32), @@ -616,7 +607,6 @@ enum EnumAddTraitBoundWhere { #[rustc_clean(cfg="cfail3")] #[rustc_metadata_dirty(cfg="cfail2")] #[rustc_metadata_clean(cfg="cfail3")] -#[repr(C)] enum EnumAddTraitBoundWhere where T: Sync { Variant1(T), } diff --git a/src/test/incremental/hashes/inherent_impls.rs b/src/test/incremental/hashes/inherent_impls.rs index 0460d046099..5067b571ee6 100644 --- a/src/test/incremental/hashes/inherent_impls.rs +++ b/src/test/incremental/hashes/inherent_impls.rs @@ -370,6 +370,8 @@ impl Foo { #[rustc_metadata_clean(cfg="cfail2")] #[rustc_metadata_clean(cfg="cfail3")] impl Foo { + // FIXME(michaelwoerister): This is curious but an unused lifetime parameter doesn't seem to + // show up in any of the derived data structures. #[rustc_clean(cfg="cfail2", except="Hir,HirBody")] #[rustc_clean(cfg="cfail3")] #[rustc_metadata_clean(cfg="cfail2")] diff --git a/src/test/incremental/hashes/type_defs.rs b/src/test/incremental/hashes/type_defs.rs index 33bef5d05b7..b0a93eea523 100644 --- a/src/test/incremental/hashes/type_defs.rs +++ b/src/test/incremental/hashes/type_defs.rs @@ -35,7 +35,7 @@ type ChangePrimitiveType = i32; #[cfg(not(cfail1))] -#[rustc_clean(cfg="cfail2", except="Hir,HirBody,TypeOfItem")] +#[rustc_clean(cfg="cfail2", except="Hir,HirBody")] #[rustc_clean(cfg="cfail3")] #[rustc_metadata_clean(cfg="cfail3")] type ChangePrimitiveType = i64; @@ -47,7 +47,7 @@ type ChangePrimitiveType = i64; type ChangeMutability = &'static i32; #[cfg(not(cfail1))] -#[rustc_clean(cfg="cfail2", except="Hir,HirBody,TypeOfItem")] +#[rustc_clean(cfg="cfail2", except="Hir,HirBody")] #[rustc_clean(cfg="cfail3")] #[rustc_metadata_clean(cfg="cfail3")] type ChangeMutability = &'static mut i32; @@ -59,7 +59,7 @@ type ChangeMutability = &'static mut i32; type ChangeLifetime<'a> = (&'static i32, &'a i32); #[cfg(not(cfail1))] -#[rustc_clean(cfg="cfail2", except="Hir,HirBody,TypeOfItem")] +#[rustc_clean(cfg="cfail2", except="Hir,HirBody")] #[rustc_clean(cfg="cfail3")] #[rustc_metadata_clean(cfg="cfail3")] type ChangeLifetime<'a> = (&'a i32, &'a i32); @@ -74,7 +74,7 @@ struct Struct2; type ChangeTypeStruct = Struct1; #[cfg(not(cfail1))] -#[rustc_clean(cfg="cfail2", except="Hir,HirBody,TypeOfItem")] +#[rustc_clean(cfg="cfail2", except="Hir,HirBody")] #[rustc_clean(cfg="cfail3")] #[rustc_metadata_clean(cfg="cfail3")] type ChangeTypeStruct = Struct2; @@ -86,7 +86,7 @@ type ChangeTypeStruct = Struct2; type ChangeTypeTuple = (u32, u64); #[cfg(not(cfail1))] -#[rustc_clean(cfg="cfail2", except="Hir,HirBody,TypeOfItem")] +#[rustc_clean(cfg="cfail2", except="Hir,HirBody")] #[rustc_clean(cfg="cfail3")] #[rustc_metadata_clean(cfg="cfail3")] type ChangeTypeTuple = (u32, i64); @@ -107,7 +107,7 @@ enum Enum2 { type ChangeTypeEnum = Enum1; #[cfg(not(cfail1))] -#[rustc_clean(cfg="cfail2", except="Hir,HirBody,TypeOfItem")] +#[rustc_clean(cfg="cfail2", except="Hir,HirBody")] #[rustc_clean(cfg="cfail3")] #[rustc_metadata_clean(cfg="cfail3")] type ChangeTypeEnum = Enum2; @@ -119,7 +119,7 @@ type ChangeTypeEnum = Enum2; type AddTupleField = (i32, i64); #[cfg(not(cfail1))] -#[rustc_clean(cfg="cfail2", except="Hir,HirBody,TypeOfItem")] +#[rustc_clean(cfg="cfail2", except="Hir,HirBody")] #[rustc_clean(cfg="cfail3")] #[rustc_metadata_clean(cfg="cfail3")] type AddTupleField = (i32, i64, i16); @@ -131,7 +131,7 @@ type AddTupleField = (i32, i64, i16); type ChangeNestedTupleField = (i32, (i64, i16)); #[cfg(not(cfail1))] -#[rustc_clean(cfg="cfail2", except="Hir,HirBody,TypeOfItem")] +#[rustc_clean(cfg="cfail2", except="Hir,HirBody")] #[rustc_clean(cfg="cfail3")] #[rustc_metadata_clean(cfg="cfail3")] type ChangeNestedTupleField = (i32, (i64, i8)); @@ -143,7 +143,7 @@ type ChangeNestedTupleField = (i32, (i64, i8)); type AddTypeParam = (T1, T1); #[cfg(not(cfail1))] -#[rustc_clean(cfg="cfail2", except="Hir,HirBody,TypeOfItem")] +#[rustc_clean(cfg="cfail2", except="Hir,HirBody")] #[rustc_clean(cfg="cfail3")] #[rustc_metadata_clean(cfg="cfail3")] type AddTypeParam = (T1, T2); @@ -179,7 +179,7 @@ type AddTypeParamBoundWhereClause where T1: Clone+Copy = (T1, u32); type AddLifetimeParam<'a> = (&'a u32, &'a u32); #[cfg(not(cfail1))] -#[rustc_clean(cfg="cfail2", except="Hir,HirBody,TypeOfItem")] +#[rustc_clean(cfg="cfail2", except="Hir,HirBody")] #[rustc_clean(cfg="cfail3")] #[rustc_metadata_clean(cfg="cfail3")] type AddLifetimeParam<'a, 'b> = (&'a u32, &'b u32);