Skip to content
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
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version.workspace = true
edition.workspace = true
publish = false

autobins = false
autotests = false

[lib]
path = "src/lib/lib.rs"
Expand Down
3 changes: 0 additions & 3 deletions src/lib/fmter/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -375,9 +375,6 @@ impl Fmt for ast::Contract<'_> {
if let Some(requires) = requires {
fmt!(cx, " contract_requires ");
requires.fmt(cx);
if ensures.is_some() {
fmt!(cx, " ");
}
}
if let Some(ensures) = ensures {
fmt!(cx, " contract_ensures ");
Expand Down
25 changes: 25 additions & 0 deletions test/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Tests

## Unit Tests

They are located in `src/lib/parser/test.rs`, not here in `test/`.

* they are mostly for edge cases for now but that'll slowly change
* they consist of positive and negative behavior test cases
* they work with the AST nodes and error 'codes'

## Per-Feature Smoke Tests

The test cases are located in `test/smoke/feature/`.

* the directory is meant to be fed to `etc/check.rs`
* that script compares the exit status of `rasur` and `rustc` per file
* the default edition is Rust 2015; pass `-e, --edition <EDITION>` to override;
`--edition all` or `-eall` makes the script test each file under all editions
* the test cases do contain a custom test directive / parameter / configuration
language (prefixed by `//:`) for setting edition-aware test expectations;
however, these annotations aren't interpreted yet by the script
* they mainly consist of positive behavior tests
* they allow us to detect the removal of unstable syntax;
such removals often implies test removals in r-l/r, so we wouldn't be able to
if that happened when running rasur against r-l/r's test suite
7 changes: 7 additions & 0 deletions test/smoke/feature/async_for_loop-lookalike-2015.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// In Rust 2015, the `await (x)` is just tuple struct pattern.
//: (2015) accept (2018->) reject

fn func() {
for await (x) in [] {}
struct await(i32);
}
11 changes: 11 additions & 0 deletions test/smoke/feature/async_for_loop.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// issue: <https://github.com/rust-lang/rust/issues/118898>
//: (2018->) accept (2015) reject
#![rustfmt::skip]

fn func() {
for await x in xs {}
for await _ in xs.await {}
for await () in xs {}
for await! in xs {}
for await[0] in xs {}
}
11 changes: 11 additions & 0 deletions test/smoke/feature/async_trait_bounds.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// issue: <https://github.com/rust-lang/rust/issues/62290>
//: (2018->) accept (2015) reject
#![rustfmt::skip]

fn func<T: async Trait>(_: dyn async Trait) -> impl async Trait
where
T: async Trait,
(): const async Trait,
for<> async Trait(): for<> async Trait() -> (),
{
}
6 changes: 6 additions & 0 deletions test/smoke/feature/auto_traits.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// issue: <https://github.com/rust-lang/rust/issues/13231>
//: accept

auto trait Trait {}
unsafe auto trait Trait {}
const auto trait Trait {}
19 changes: 19 additions & 0 deletions test/smoke/feature/box_patterns.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// issue: <https://github.com/rust-lang/rust/issues/29641>
//: accept
#![rustfmt::skip]

fn func(box (): Ty) {
let box _;
let box x;
let box ref x;
let box mut ref x;
let box [];
let Ty { x: box _ };
let Ty { box x };
let Ty { box ref x };
let Ty { box mut ref x };

match () {
|box 0| box 1 => |box 0| 1,
}
}
12 changes: 12 additions & 0 deletions test/smoke/feature/builtin_syntax.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// issue: <https://github.com/rust-lang/rust/issues/110680>
//: accept

fn func() {
let builtin # deref(0);
let builtin # deref(x | y);
let _ = builtin # type_ascribe(!0, !);
let _ = builtin # offset_of(Ty, x.0.1.y.z.2);
let _ = builtin # wrap_binder(0 * 1);
let _ = builtin # unwrap_binder(*&());
let _: builtin # field_of((), 0);
}
18 changes: 18 additions & 0 deletions test/smoke/feature/closure_lifetime_binder.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// issue: <https://github.com/rust-lang/rust/issues/97362>
//: accept
#![rustfmt::skip]

fn func() {
for<> || ();
let _ = for<'a> |_| {};
let _ = for<T> |_| {};
let _ = for<const N: usize> |_| {};
let _ = for<#[a] T> |_| {};
let _ = for<#[a] const N: usize> |_| {};
for<'a: 'static, 'b, T, U = (), T = (),> |_| {};

// "lookalikes" (extended paths):
for<T as Trait>::Ty in .. {}
for<() as Trait>::Ty in .. {}
for<(T)>::Ty in .. {}
}
14 changes: 14 additions & 0 deletions test/smoke/feature/const_block_items.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// issue: <https://github.com/rust-lang/rust/issues/149226>
//: accept

const {}

const {
scope();
loop {}
}

#[cfg(false)]
const { "..." }

const fn func() {}
12 changes: 12 additions & 0 deletions test/smoke/feature/const_closures.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// issue: <https://github.com/rust-lang/rust/issues/106003>
//: accept
#![rustfmt::skip]

fn func() {
let _ = const || {};
let _ = const |_| ();
let _ = for<> const || {};
let _ = const move || {};
let _ = const use || {};
const | | {};
}
25 changes: 25 additions & 0 deletions test/smoke/feature/const_trait_impl.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// issue: <https://github.com/rust-lang/rust/issues/143874>
//: accept
#![rustfmt::skip]

const trait Trait {}
const unsafe trait Trait {}
const auto trait Trait {}
const unsafe auto trait Trait {}

impl const Trait for () {}
impl const !Trait for () {}
impl const () {}
impl const impl Trait {}

const impl Trait for () {}
const impl !Trait for () {}
const impl () {}
const impl impl Trait {}

fn func<T: const Trait, U: [const] Trait, V: ~const Trait>()
where
(): const Trait + [const] Trait + ~const Trait,
for<> const Trait: for<> const Trait() -> (),
for<> ~const Trait: for<> ~const Trait() -> (),
{}
16 changes: 16 additions & 0 deletions test/smoke/feature/contracts_internals.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// issue: <https://github.com/rust-lang/rust/issues/128044>
//: accept
#![rustfmt::skip]

fn func() contract_requires {} {}
fn func() contract_ensures () {}
fn func() contract_ensures {};
fn func() contract_requires { 0 } contract_ensures 0 {}
fn func() -> () contract_requires { 0 } contract_ensures 0 {}
fn func()
contract_requires { fn func(); }
contract_ensures 1 + 2 * 3;

// "lookalikes" (paths):
fn func() -> contract_requires { 0 }
fn func() -> contract_ensures { 0 }
Empty file.
6 changes: 6 additions & 0 deletions test/smoke/feature/decl_macro.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// issue: <https://github.com/rust-lang/rust/issues/39412>
//: accept

macro makro {}
pub macro makro { @ @ @ }
macro makro() { @ @ @ }
18 changes: 18 additions & 0 deletions test/smoke/feature/default_field_values.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// issue: <https://github.com/rust-lang/rust/issues/132162>
//: accept

struct Type {
x: i32 = 0,
pub x: i32 = { 1 + 2 },
unsafe x: i32 = unsafe { 0 },
#[a] x: Trait() -> Trait += (),
}

struct Type(i32 = 0, pub i32 = {}, #[a] [[[_]]] = ..);

fn func() {
// This was already syntactically legal before the introduction of DFVs.
// Still, I'm listing it here because it's related.
_ = Type { .. };
_ = Type { x, x: x, .. };
}
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file added test/smoke/feature/mut_ref.rs
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file added test/smoke/feature/super_let.rs
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file added test/smoke/feature/yeet_expr.rs
Empty file.
Empty file.