From 698f8c2f01ea549d77d7dc3338a12e04c11057b9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:02:58 +0200 Subject: Adding upstream version 1.64.0+dfsg1. Signed-off-by: Daniel Baumann --- src/test/incremental/hashes/trait_impls.rs | 620 +++++++++++++++++++++++++++++ 1 file changed, 620 insertions(+) create mode 100644 src/test/incremental/hashes/trait_impls.rs (limited to 'src/test/incremental/hashes/trait_impls.rs') diff --git a/src/test/incremental/hashes/trait_impls.rs b/src/test/incremental/hashes/trait_impls.rs new file mode 100644 index 000000000..f555f555f --- /dev/null +++ b/src/test/incremental/hashes/trait_impls.rs @@ -0,0 +1,620 @@ +// This test case tests the incremental compilation hash (ICH) implementation +// for let expressions. + +// The general pattern followed here is: Change one thing between rev1 and rev2 +// and make sure that the hash has changed, then change nothing between rev2 and +// rev3 and make sure that the hash has not changed. + +// build-pass (FIXME(62277): could be check-pass?) +// revisions: cfail1 cfail2 cfail3 cfail4 cfail5 cfail6 +// compile-flags: -Z query-dep-graph -O +// [cfail1]compile-flags: -Zincremental-ignore-spans +// [cfail2]compile-flags: -Zincremental-ignore-spans +// [cfail3]compile-flags: -Zincremental-ignore-spans +// [cfail4]compile-flags: -Zincremental-relative-spans +// [cfail5]compile-flags: -Zincremental-relative-spans +// [cfail6]compile-flags: -Zincremental-relative-spans + +#![allow(warnings)] +#![feature(rustc_attrs)] +#![feature(specialization)] +#![crate_type="rlib"] + +struct Foo; + +// Change Method Name ----------------------------------------------------------- + +#[cfg(any(cfail1,cfail4))] +pub trait ChangeMethodNameTrait { + fn method_name(); +} + +#[cfg(any(cfail1,cfail4))] +impl ChangeMethodNameTrait for Foo { + fn method_name() { } +} + +#[cfg(not(any(cfail1,cfail4)))] +#[rustc_clean(except="hir_owner,hir_owner_nodes,associated_item_def_ids", cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] +#[rustc_clean(except="hir_owner,hir_owner_nodes,associated_item_def_ids", cfg="cfail5")] +#[rustc_clean(cfg="cfail6")] +pub trait ChangeMethodNameTrait { + #[rustc_clean(cfg="cfail3")] + #[rustc_clean(cfg="cfail6")] + fn method_name2(); +} + +#[cfg(not(any(cfail1,cfail4)))] +#[rustc_clean(except="hir_owner,hir_owner_nodes,associated_item_def_ids", cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] +#[rustc_clean(except="hir_owner,hir_owner_nodes,associated_item_def_ids", cfg="cfail5")] +#[rustc_clean(cfg="cfail6")] +impl ChangeMethodNameTrait for Foo { + #[rustc_clean(cfg="cfail3")] + #[rustc_clean(cfg="cfail6")] + fn method_name2() { } +} + +// Change Method Body ----------------------------------------------------------- +// +// This should affect the method itself, but not the impl. + +pub trait ChangeMethodBodyTrait { + fn method_name(); +} + +#[cfg(any(cfail1,cfail4))] +impl ChangeMethodBodyTrait for Foo { + // ---------------------------------------------------------- + // ------------------------- + // ---------------------------------------------------------- + // ------------------------- + fn method_name() { + // + } +} + +#[cfg(not(any(cfail1,cfail4)))] +#[rustc_clean(cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] +#[rustc_clean(cfg="cfail5")] +#[rustc_clean(cfg="cfail6")] +impl ChangeMethodBodyTrait for Foo { + #[rustc_clean(except="hir_owner_nodes,typeck", cfg="cfail2")] + #[rustc_clean(cfg="cfail3")] + #[rustc_clean(except="hir_owner_nodes,typeck", cfg="cfail5")] + #[rustc_clean(cfg="cfail6")] + fn method_name() { + () + } +} + +// Change Method Body (inlined fn) --------------------------------------------- +// +// This should affect the method itself, but not the impl. + +pub trait ChangeMethodBodyTraitInlined { + fn method_name(); +} + +#[cfg(any(cfail1,cfail4))] +impl ChangeMethodBodyTraitInlined for Foo { + // ------------------------------------------------------------------------ + // ------------------------- + // ------------------------------------------------------------------------ + // ------------------------- + #[inline] + fn method_name() { + // ----- + } +} + +#[cfg(not(any(cfail1,cfail4)))] +#[rustc_clean(cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] +#[rustc_clean(cfg="cfail5")] +#[rustc_clean(cfg="cfail6")] +impl ChangeMethodBodyTraitInlined for Foo { + #[rustc_clean(except="hir_owner_nodes,typeck,optimized_mir", cfg="cfail2")] + #[rustc_clean(cfg="cfail3")] + #[rustc_clean(except="hir_owner_nodes,typeck,optimized_mir", cfg="cfail5")] + #[rustc_clean(cfg="cfail6")] + #[inline] + fn method_name() { + panic!() + } +} + +// Change Method Selfness ------------------------------------------------------ + +#[cfg(any(cfail1,cfail4))] +pub trait ChangeMethodSelfnessTrait { + fn method_name(); +} + +#[cfg(any(cfail1,cfail4))] +impl ChangeMethodSelfnessTrait for Foo { + fn method_name() { } +} + +#[cfg(not(any(cfail1,cfail4)))] +pub trait ChangeMethodSelfnessTrait { + fn method_name(&self); +} + +#[cfg(not(any(cfail1,cfail4)))] +#[rustc_clean(except="hir_owner,hir_owner_nodes", cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] +#[rustc_clean(except="hir_owner,hir_owner_nodes", cfg="cfail5")] +#[rustc_clean(cfg="cfail6")] +impl ChangeMethodSelfnessTrait for Foo { + #[rustc_clean( + except="hir_owner,hir_owner_nodes,associated_item,generics_of,fn_sig,typeck,optimized_mir", + cfg="cfail2", + )] + #[rustc_clean(cfg="cfail3")] + #[rustc_clean( + except="hir_owner,hir_owner_nodes,associated_item,generics_of,fn_sig,typeck,optimized_mir", + cfg="cfail5", + )] + #[rustc_clean(cfg="cfail6")] + fn method_name(&self) { + () + } +} + +// Change Method Selfness ----------------------------------------------------------- + +#[cfg(any(cfail1,cfail4))] +pub trait RemoveMethodSelfnessTrait { + fn method_name(&self); +} + +#[cfg(any(cfail1,cfail4))] +impl RemoveMethodSelfnessTrait for Foo { + fn method_name(&self) { } +} + +#[cfg(not(any(cfail1,cfail4)))] +pub trait RemoveMethodSelfnessTrait { + fn method_name(); +} + +#[cfg(not(any(cfail1,cfail4)))] +#[rustc_clean(except="hir_owner,hir_owner_nodes", cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] +#[rustc_clean(except="hir_owner,hir_owner_nodes", cfg="cfail5")] +#[rustc_clean(cfg="cfail6")] +impl RemoveMethodSelfnessTrait for Foo { + #[rustc_clean( + except="hir_owner,hir_owner_nodes,associated_item,generics_of,fn_sig,typeck,optimized_mir", + cfg="cfail2", + )] + #[rustc_clean(cfg="cfail3")] + #[rustc_clean( + except="hir_owner,hir_owner_nodes,associated_item,generics_of,fn_sig,typeck,optimized_mir", + cfg="cfail5", + )] + #[rustc_clean(cfg="cfail6")] + fn method_name() {} +} + +// Change Method Selfmutness ----------------------------------------------------------- + +#[cfg(any(cfail1,cfail4))] +pub trait ChangeMethodSelfmutnessTrait { + fn method_name(&self); +} + +#[cfg(any(cfail1,cfail4))] +impl ChangeMethodSelfmutnessTrait for Foo { + // ----------------------------------------------------------------------------------------- + // ------------------------- + // ----------------------------------------------------------------------------------------- + // ------------------------- + fn method_name(& self) {} +} + +#[cfg(not(any(cfail1,cfail4)))] +pub trait ChangeMethodSelfmutnessTrait { + fn method_name(&mut self); +} + +#[cfg(not(any(cfail1,cfail4)))] +#[rustc_clean(cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] +#[rustc_clean(cfg="cfail5")] +#[rustc_clean(cfg="cfail6")] +impl ChangeMethodSelfmutnessTrait for Foo { + #[rustc_clean(except="hir_owner,hir_owner_nodes,fn_sig,typeck,optimized_mir", cfg="cfail2")] + #[rustc_clean(cfg="cfail3")] + #[rustc_clean(except="hir_owner,hir_owner_nodes,fn_sig,typeck,optimized_mir", cfg="cfail5")] + #[rustc_clean(cfg="cfail6")] + fn method_name(&mut self) {} +} + +// Change item kind ----------------------------------------------------------- + +#[cfg(any(cfail1,cfail4))] +pub trait ChangeItemKindTrait { + fn name(); +} + +#[cfg(any(cfail1,cfail4))] +impl ChangeItemKindTrait for Foo { + fn name() { } +} + +#[cfg(not(any(cfail1,cfail4)))] +pub trait ChangeItemKindTrait { + type name; +} + +#[cfg(not(any(cfail1,cfail4)))] +#[rustc_clean(except="hir_owner,hir_owner_nodes,associated_item_def_ids", cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] +#[rustc_clean(except="hir_owner,hir_owner_nodes,associated_item_def_ids", cfg="cfail5")] +#[rustc_clean(cfg="cfail6")] +impl ChangeItemKindTrait for Foo { + type name = (); +} + +// Remove item ----------------------------------------------------------- + +#[cfg(any(cfail1,cfail4))] +pub trait RemoveItemTrait { + type TypeName; + fn method_name(); +} + +#[cfg(any(cfail1,cfail4))] +impl RemoveItemTrait for Foo { + type TypeName = (); + fn method_name() { } +} + +#[cfg(not(any(cfail1,cfail4)))] +pub trait RemoveItemTrait { + type TypeName; +} + +#[cfg(not(any(cfail1,cfail4)))] +#[rustc_clean(except="hir_owner,hir_owner_nodes,associated_item_def_ids", cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] +#[rustc_clean(except="hir_owner,hir_owner_nodes,associated_item_def_ids", cfg="cfail5")] +#[rustc_clean(cfg="cfail6")] +impl RemoveItemTrait for Foo { + type TypeName = (); +} + +// Add item ----------------------------------------------------------- + +#[cfg(any(cfail1,cfail4))] +pub trait AddItemTrait { + type TypeName; +} + +#[cfg(any(cfail1,cfail4))] +impl AddItemTrait for Foo { + type TypeName = (); +} + +#[cfg(not(any(cfail1,cfail4)))] +pub trait AddItemTrait { + type TypeName; + fn method_name(); +} + +#[cfg(not(any(cfail1,cfail4)))] +#[rustc_clean(except="hir_owner,hir_owner_nodes,associated_item_def_ids", cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] +#[rustc_clean(except="hir_owner,hir_owner_nodes,associated_item_def_ids", cfg="cfail5")] +#[rustc_clean(cfg="cfail6")] +impl AddItemTrait for Foo { + type TypeName = (); + fn method_name() { } +} + +// Change has-value ----------------------------------------------------------- + +#[cfg(any(cfail1,cfail4))] +pub trait ChangeHasValueTrait { + //-------------------------------------------------------------- + //-------------------------- + //-------------------------------------------------------------- + //-------------------------- + fn method_name() ; +} + +#[cfg(any(cfail1,cfail4))] +impl ChangeHasValueTrait for Foo { + fn method_name() { } +} + +#[cfg(not(any(cfail1,cfail4)))] +#[rustc_clean(except="hir_owner_nodes", cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] +#[rustc_clean(except="hir_owner_nodes", cfg="cfail5")] +#[rustc_clean(cfg="cfail6")] +pub trait ChangeHasValueTrait { + #[rustc_clean(except="hir_owner,hir_owner_nodes", cfg="cfail2")] + #[rustc_clean(cfg="cfail3")] + #[rustc_clean(except="hir_owner,hir_owner_nodes", cfg="cfail5")] + #[rustc_clean(cfg="cfail6")] + fn method_name() { } +} + +#[cfg(not(any(cfail1,cfail4)))] +#[rustc_clean(cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] +#[rustc_clean(cfg="cfail5")] +#[rustc_clean(cfg="cfail6")] +impl ChangeHasValueTrait for Foo { + fn method_name() { } +} + +// Add default + +pub trait AddDefaultTrait { + fn method_name(); +} + +#[cfg(any(cfail1,cfail4))] +impl AddDefaultTrait for Foo { + // ------------------------------------------------------------- + // ------------------------- + // ------------------------------------------------------------- + // ------------------------- + fn method_name() { } +} + +#[cfg(not(any(cfail1,cfail4)))] +#[rustc_clean(cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] +#[rustc_clean(cfg="cfail5")] +#[rustc_clean(cfg="cfail6")] +impl AddDefaultTrait for Foo { + #[rustc_clean(except="hir_owner,hir_owner_nodes", cfg="cfail2")] + #[rustc_clean(cfg="cfail3")] + #[rustc_clean(except="hir_owner,hir_owner_nodes", cfg="cfail5")] + #[rustc_clean(cfg="cfail6")] + default fn method_name() { } +} + +// Add arguments + +#[cfg(any(cfail1,cfail4))] +pub trait AddArgumentTrait { + fn method_name(&self); +} + +#[cfg(any(cfail1,cfail4))] +impl AddArgumentTrait for Foo { + // ----------------------------------------------------------------------------------------- + // ------------------------- + // ----------------------------------------------------------------------------------------- + // ------------------------- + fn method_name(&self ) { } +} + +#[cfg(not(any(cfail1,cfail4)))] +pub trait AddArgumentTrait { + fn method_name(&self, x: u32); +} + +#[cfg(not(any(cfail1,cfail4)))] +#[rustc_clean(cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] +#[rustc_clean(cfg="cfail5")] +#[rustc_clean(cfg="cfail6")] +impl AddArgumentTrait for Foo { + #[rustc_clean(except="hir_owner,hir_owner_nodes,fn_sig,typeck,optimized_mir", cfg="cfail2")] + #[rustc_clean(cfg="cfail3")] + #[rustc_clean(except="hir_owner,hir_owner_nodes,fn_sig,typeck,optimized_mir", cfg="cfail5")] + #[rustc_clean(cfg="cfail6")] + fn method_name(&self, _x: u32) { } +} + +// Change argument type + +#[cfg(any(cfail1,cfail4))] +pub trait ChangeArgumentTypeTrait { + fn method_name(&self, x: u32); +} + +#[cfg(any(cfail1,cfail4))] +impl ChangeArgumentTypeTrait for Foo { + // ----------------------------------------------------------------------------------------- + // ------------------------- + // ----------------------------------------------------------------------------------------- + // ------------------------- + fn method_name(&self, _x: u32 ) { } +} + +#[cfg(not(any(cfail1,cfail4)))] +pub trait ChangeArgumentTypeTrait { + fn method_name(&self, x: char); +} + +#[cfg(not(any(cfail1,cfail4)))] +#[rustc_clean(cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] +#[rustc_clean(cfg="cfail5")] +#[rustc_clean(cfg="cfail6")] +impl ChangeArgumentTypeTrait for Foo { + #[rustc_clean(except="hir_owner,hir_owner_nodes,fn_sig,typeck,optimized_mir", cfg="cfail2")] + #[rustc_clean(cfg="cfail3")] + #[rustc_clean(except="hir_owner,hir_owner_nodes,fn_sig,typeck,optimized_mir", cfg="cfail5")] + #[rustc_clean(cfg="cfail6")] + fn method_name(&self, _x: char) { } +} + + + +struct Bar(T); + +// Add Type Parameter To Impl -------------------------------------------------- +trait AddTypeParameterToImpl { + fn id(t: T) -> T; +} + +#[cfg(any(cfail1,cfail4))] +impl AddTypeParameterToImpl for Bar { + fn id(t: u32) -> u32 { t } +} + +#[cfg(not(any(cfail1,cfail4)))] +#[rustc_clean(except="hir_owner,hir_owner_nodes,generics_of,impl_trait_ref", cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] +#[rustc_clean(except="hir_owner,hir_owner_nodes,generics_of,impl_trait_ref", cfg="cfail5")] +#[rustc_clean(cfg="cfail6")] +impl AddTypeParameterToImpl for Bar { + #[rustc_clean( + except="hir_owner,hir_owner_nodes,generics_of,fn_sig,type_of,typeck,optimized_mir", + cfg="cfail2", + )] + #[rustc_clean(cfg="cfail3")] + #[rustc_clean( + except="hir_owner,hir_owner_nodes,generics_of,fn_sig,type_of,typeck,optimized_mir", + cfg="cfail5", + )] + #[rustc_clean(cfg="cfail6")] + fn id(t: TTT) -> TTT { t } +} + + + +// Change Self Type of Impl ---------------------------------------------------- +trait ChangeSelfTypeOfImpl { + fn id(self) -> Self; +} + +#[cfg(any(cfail1,cfail4))] +impl ChangeSelfTypeOfImpl for u32 { + fn id(self) -> Self { self } +} + +#[cfg(not(any(cfail1,cfail4)))] +#[rustc_clean(except="hir_owner,hir_owner_nodes,impl_trait_ref", cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] +#[rustc_clean(except="hir_owner,hir_owner_nodes,impl_trait_ref", cfg="cfail5")] +#[rustc_clean(cfg="cfail6")] +impl ChangeSelfTypeOfImpl for u64 { + #[rustc_clean(except="fn_sig,typeck,optimized_mir", cfg="cfail2")] + #[rustc_clean(cfg="cfail3")] + #[rustc_clean(except="fn_sig,typeck,optimized_mir", cfg="cfail5")] + #[rustc_clean(cfg="cfail6")] + fn id(self) -> Self { self } +} + + + +// Add Lifetime Bound to Impl -------------------------------------------------- +trait AddLifetimeBoundToImplParameter { + fn id(self) -> Self; +} + +#[cfg(any(cfail1,cfail4))] +impl AddLifetimeBoundToImplParameter for T { + fn id(self) -> Self { self } +} + +#[cfg(not(any(cfail1,cfail4)))] +#[rustc_clean(except="hir_owner,hir_owner_nodes", cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] +#[rustc_clean(except="hir_owner,hir_owner_nodes", cfg="cfail5")] +#[rustc_clean(cfg="cfail6")] +impl AddLifetimeBoundToImplParameter for T { + #[rustc_clean(cfg="cfail2")] + #[rustc_clean(cfg="cfail3")] + #[rustc_clean(cfg="cfail5")] + #[rustc_clean(cfg="cfail6")] + fn id(self) -> Self { self } +} + + + +// Add Trait Bound to Impl Parameter ------------------------------------------- +trait AddTraitBoundToImplParameter { + fn id(self) -> Self; +} + +#[cfg(any(cfail1,cfail4))] +impl AddTraitBoundToImplParameter for T { + fn id(self) -> Self { self } +} + +#[cfg(not(any(cfail1,cfail4)))] +#[rustc_clean(except="hir_owner,hir_owner_nodes", cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] +#[rustc_clean(except="hir_owner,hir_owner_nodes", cfg="cfail5")] +#[rustc_clean(cfg="cfail6")] +impl AddTraitBoundToImplParameter for T { + #[rustc_clean(cfg="cfail2")] + #[rustc_clean(cfg="cfail3")] + #[rustc_clean(cfg="cfail5")] + #[rustc_clean(cfg="cfail6")] + fn id(self) -> Self { self } +} + + + +// Add #[no_mangle] to Method -------------------------------------------------- +trait AddNoMangleToMethod { + fn add_no_mangle_to_method(&self) { } +} + +#[cfg(any(cfail1,cfail4))] +impl AddNoMangleToMethod for Foo { + // ------------------------- + // ------------------------- + // ------------------------- + // ------------------------- + // --------- + fn add_no_mangle_to_method(&self) { } +} + +#[cfg(not(any(cfail1,cfail4)))] +#[rustc_clean(cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] +#[rustc_clean(cfg="cfail5")] +#[rustc_clean(cfg="cfail6")] +impl AddNoMangleToMethod for Foo { + #[rustc_clean(cfg="cfail2")] + #[rustc_clean(cfg="cfail3")] + #[rustc_clean(cfg="cfail5")] + #[rustc_clean(cfg="cfail6")] + #[no_mangle] + fn add_no_mangle_to_method(&self) { } +} + + +// Make Method #[inline] ------------------------------------------------------- +trait MakeMethodInline { + fn make_method_inline(&self) -> u8 { 0 } +} + +#[cfg(any(cfail1,cfail4))] +impl MakeMethodInline for Foo { + // ------------------------- + // ------------------------- + // ------------------------- + // ------------------------- + // ------ + fn make_method_inline(&self) -> u8 { 0 } +} + +#[cfg(not(any(cfail1,cfail4)))] +#[rustc_clean(cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] +#[rustc_clean(cfg="cfail5")] +#[rustc_clean(cfg="cfail6")] +impl MakeMethodInline for Foo { + #[rustc_clean(cfg="cfail2")] + #[rustc_clean(cfg="cfail3")] + #[rustc_clean(cfg="cfail5")] + #[rustc_clean(cfg="cfail6")] + #[inline] + fn make_method_inline(&self) -> u8 { 0 } +} -- cgit v1.2.3