Skip to content

Commit

Permalink
gccrs: Add test case to show issue is fixed
Browse files Browse the repository at this point in the history
This was fixed as part of: c63ecb2

Fixes #3402

gcc/testsuite/ChangeLog:

	* rust/compile/nr2/exclude: nr2 cant handle this
	* rust/compile/issue-3402-1.rs: New test.
	* rust/compile/issue-3402-2.rs: New test.

Signed-off-by: Philip Herron <[email protected]>
  • Loading branch information
philberty committed Feb 4, 2025
1 parent f2164b7 commit 4d7e7d9
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
29 changes: 29 additions & 0 deletions gcc/testsuite/rust/compile/issue-3402-1.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
pub struct Foo {
a: i32,
// { dg-warning "field is never read" "" { target *-*-* } .-1 }
}
pub struct Bar(i32);

#[lang = "sized"]
trait Sized {}

pub mod core {
pub mod default {
pub trait Default: Sized {
fn default() -> Self;
}

impl Default for i32 {
fn default() -> Self {
0
}
}
}
}

impl ::core::default::Default for Bar {
#[inline]
fn default() -> Bar {
Bar(core::default::Default::default())
}
}
18 changes: 18 additions & 0 deletions gcc/testsuite/rust/compile/issue-3402-2.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
pub struct Bar(i32);

#[lang = "sized"]
trait Sized {}

pub trait A: Sized {
fn foo() -> Self;
}

impl A for i32 {
fn foo() -> Self {
0
}
}

pub fn bar() {
let _ = Bar(A::foo());
}
1 change: 1 addition & 0 deletions gcc/testsuite/rust/compile/nr2/exclude
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,5 @@ try-trait.rs
derive-debug1.rs
issue-3382.rs
derive-default1.rs
issue-3402-1.rs
# please don't delete the trailing newline

0 comments on commit 4d7e7d9

Please sign in to comment.