diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-08-22 14:48:08 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-22 14:48:08 +0000 |
commit | b3bb2e194c814434e80b9b427df37fe24fc70e6c (patch) | |
tree | c4ec2996ceb9c03ff927ead206b66147f3955404 /gcc | |
parent | ac3be517de2c0ec596eeee754b863243cb071098 (diff) | |
parent | 2d681bdeda9e6c049457a20c45d045925595a8e9 (diff) | |
download | gcc-b3bb2e194c814434e80b9b427df37fe24fc70e6c.zip gcc-b3bb2e194c814434e80b9b427df37fe24fc70e6c.tar.gz gcc-b3bb2e194c814434e80b9b427df37fe24fc70e6c.tar.bz2 |
Merge #641
641: Ignore impl trait blocks in overlap pass r=philberty a=philberty
Ignore trait-impls in overlapping check this needs some though for generics traits.
Co-authored-by: Philip Herron <philip.herron@embecosm.com>
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/rust/typecheck/rust-hir-inherent-impl-overlap.h | 4 | ||||
-rw-r--r-- | gcc/testsuite/rust/compile/traits8.rs | 37 |
2 files changed, 41 insertions, 0 deletions
diff --git a/gcc/rust/typecheck/rust-hir-inherent-impl-overlap.h b/gcc/rust/typecheck/rust-hir-inherent-impl-overlap.h index 0879360..134d314 100644 --- a/gcc/rust/typecheck/rust-hir-inherent-impl-overlap.h +++ b/gcc/rust/typecheck/rust-hir-inherent-impl-overlap.h @@ -109,6 +109,10 @@ public: // generate mappings pass.mappings->iterate_impl_items ( [&] (HirId id, HIR::ImplItem *impl_item, HIR::ImplBlock *impl) -> bool { + // ignoring trait-impls might need thought later on + if (impl->has_trait_ref ()) + return true; + pass.process_impl_item (id, impl_item, impl); return true; }); diff --git a/gcc/testsuite/rust/compile/traits8.rs b/gcc/testsuite/rust/compile/traits8.rs new file mode 100644 index 0000000..b25c517 --- /dev/null +++ b/gcc/testsuite/rust/compile/traits8.rs @@ -0,0 +1,37 @@ +trait A { + fn get(self) -> f64; + // { dg-warning "unused name" "" { target *-*-* } .-1 } +} + +trait B { + fn get(self) -> u8; + // { dg-warning "unused name" "" { target *-*-* } .-1 } +} + +struct Foo(u8, f64); + +impl A for Foo { + fn get(self) -> f64 { + self.1 + } +} + +impl B for Foo { + fn get(self) -> u8 { + self.0 + } +} + +fn main() { + let _a; + _a = Foo(123, 456f64); + + let _b: f64; + _b = <Foo as A>::get(_a); + + let _a; + _a = Foo(123, 456f64); + + let _c: u8; + _c = <Foo as B>::get(_a) +} |