Skip to content

Commit 7691105

Browse files
committed
gccrs: remove bad type checking diagnostic
This was a bad diagnostic added when I was working on slices and iterators also the name of the function is also bad. This is all about setting up associated types based on the current context of the bounds assocated with the associated trait bounds on this function. The tell tale is that this didnt have an associated rust error code so this is most definetly not the correct error diagnostic. Fixes #3403 gcc/rust/ChangeLog: * typecheck/rust-tyty-subst.cc (SubstitutionRef::monomorphize): remove diagnostic gcc/testsuite/ChangeLog: * rust/compile/nr2/exclude: nr2 cant handle this * rust/compile/issue-3403.rs: New test. Signed-off-by: Philip Herron <[email protected]>
1 parent 5fb06c9 commit 7691105

File tree

3 files changed

+40
-20
lines changed

3 files changed

+40
-20
lines changed

gcc/rust/typecheck/rust-tyty-subst.cc

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -934,27 +934,8 @@ SubstitutionRef::monomorphize ()
934934
auto associated
935935
= Resolver::lookup_associated_impl_block (bound, binding,
936936
&ambigious);
937-
if (associated == nullptr && ambigious)
938-
{
939-
// go for the first one? or error out?
940-
auto &mappings = Analysis::Mappings::get ();
941-
const auto &type_param = subst.get_generic_param ();
942-
const auto *trait_ref = bound.get ();
943-
944-
rich_location r (line_table, type_param.get_locus ());
945-
r.add_range (bound.get_locus ());
946-
r.add_range (mappings.lookup_location (binding->get_ref ()));
947-
948-
rust_error_at (r, "ambiguous type bound for trait %s and type %s",
949-
trait_ref->get_name ().c_str (),
950-
binding->get_name ().c_str ());
951-
return false;
952-
}
953-
954937
if (associated != nullptr)
955-
{
956-
associated->setup_associated_types (binding, bound);
957-
}
938+
associated->setup_associated_types (binding, bound);
958939
}
959940
}
960941

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
pub struct Foo {
2+
a: i32,
3+
// { dg-warning "field is never read" "" { target *-*-* } .-1 }
4+
}
5+
pub struct Bar(i32);
6+
7+
#[lang = "sized"]
8+
trait Sized {}
9+
10+
pub mod core {
11+
pub mod default {
12+
pub trait Default: Sized {
13+
fn default() -> Self;
14+
}
15+
16+
impl Default for i32 {
17+
fn default() -> Self {
18+
0
19+
}
20+
}
21+
}
22+
}
23+
24+
impl ::core::default::Default for Bar {
25+
#[inline]
26+
fn default() -> Bar {
27+
Bar(core::default::Default::default())
28+
}
29+
}
30+
31+
impl ::core::default::Default for Foo {
32+
#[inline]
33+
fn default() -> Foo {
34+
Foo {
35+
a: core::default::Default::default(),
36+
}
37+
}
38+
}

gcc/testsuite/rust/compile/nr2/exclude

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,4 +123,5 @@ derive-default1.rs
123123
issue-3402-1.rs
124124
for-loop1.rs
125125
for-loop2.rs
126+
issue-3403.rs
126127
# please don't delete the trailing newline

0 commit comments

Comments
 (0)