Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Converted Rust Test Case to DejaGnu #3071

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions gcc/testsuite/rust/compile/anon-params-denied-2018.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// { dg-additional-options "-frust-edition=2018" }
trait T {
fn foo(i32); // { dg-error "expecting .:. but .\\). found" "" { target *-*-* } }

fn foo_with_ref(&mut i32); // { dg-error "expecting .:. but .\\). found" "" { target *-*-* } }

fn foo_with_qualified_path(<Bar as T>::Baz); // { dg-error "expecting .:. but .\\). found" "" { target *-*-* } }

fn foo_with_qualified_path_and_ref(&<Bar as T>::Baz); // { dg-error "expecting .:. but .\\). found" "" { target *-*-* } }

fn foo_with_multiple_qualified_paths(<Bar as T>::Baz, <Bar as T>::Baz);
// { dg-error "expecting .:. but .,. found" "" { target *-*-* } .-1 }
// { dg-error "expecting .\\). but .,. found" "" { target *-*-* } .-2 }
// { dg-error "function declaration missing closing parentheses after parameter list" "" { target *-*-* } .-3 }

fn bar_with_default_impl(String, String) {}
// { TODO "expecting .:. but .,. found" "" { target *-*-* } .-1 }
// { TODO "expecting .\\). but .,. found" "" { target *-*-* } .-2 }
//~^ ERROR expected one of `:`
//~| ERROR expected one of `:`
Comment on lines +17 to +20
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are those TODO because gccrs doesn't output an error here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, gccrs doesn't omits output here (see line 16 here: https://godbolt.org/z/MGdE35PPT) maybe due to excess errors. However, it emits output for fn definition, see here: https://godbolt.org/z/WEr89c5xq.


// do not complain about missing `b`
fn baz(a: usize, b, c: usize) -> usize {
// { dg-error "failed to parse trait item in trait" "" { target *-*-* } .-1 }
// { dg-error "failed to parse item in crate" "" { target *-*-* } .-2 }
a + b + c
}
}

fn main() {}
21 changes: 21 additions & 0 deletions gcc/testsuite/rust/compile/anon-params-deprecated.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// { dg-do compile }
// { dg-options "-frust-edition=2015" }
// { dg-additional-options "-Wall" }
// Test for the anonymous_parameters deprecation lint (RFC 1685)

#![warn(anonymous_parameters)]

#[allow(dead_code)]
trait T {
fn foo(i32); // { dg-error "expecting .:. but .\\). found" "" { target *-*-* } }
// WARNING this is accepted in the latest rustc edition

fn bar_with_default_impl(String, String) {}
// { dg-error "expecting .:. but .,. found" "" { target *-*-* } .-1 }
// { dg-error "expecting .\\). but .,. found" "" { target *-*-* } .-2 }
// { dg-error "function declaration missing closing parentheses after parameter list" "" { target *-*-* } .-3 }
}
// { dg-error "failed to parse trait item in trait" "" { target *-*-* } .-1 }
// { dg-error "failed to parse item in crate" "" { target *-*-* } .-2 }

fn main() {}
Loading