diff options
| author | kadmin <julianknodt@gmail.com> | 2021-03-18 06:38:11 +0000 |
|---|---|---|
| committer | kadmin <julianknodt@gmail.com> | 2021-03-23 17:16:20 +0000 |
| commit | ea2af704669f630c4184bb2c0befeb6cb7d78d29 (patch) | |
| tree | 46c29de5cd49cd5482bbfea8cd7e5bded86c6e49 /src/test | |
| parent | 9fe793ae5df4bc9ea73c8e55c66616bd6e5fe565 (diff) | |
| download | rust-ea2af704669f630c4184bb2c0befeb6cb7d78d29.tar.gz rust-ea2af704669f630c4184bb2c0befeb6cb7d78d29.zip | |
Update with comments
A bunch of nits fixed, and a new test for pretty printing the AST.
Diffstat (limited to 'src/test')
3 files changed, 53 insertions, 0 deletions
diff --git a/src/test/ui/const-generics/defaults/default-annotation.rs b/src/test/ui/const-generics/defaults/default-annotation.rs new file mode 100644 index 00000000000..e6e8d732bee --- /dev/null +++ b/src/test/ui/const-generics/defaults/default-annotation.rs @@ -0,0 +1,20 @@ +// run-pass +#![feature(staged_api)] + +#![feature(const_generics)] +#![feature(const_generics_defaults)] +#![allow(incomplete_features)] + +#![stable(feature = "const_default_test", since="none")] + + +#[unstable(feature = "const_default_stable", issue="none")] +pub struct ConstDefaultUnstable<const N: usize = 3>; + +#[stable(feature = "const_default_unstable", since="none")] +pub struct ConstDefaultStable<const N: usize = { + #[stable(feature = "const_default_unstable_val", since="none")] + 3 +}>; + +fn main() {} diff --git a/src/test/ui/const-generics/defaults/pretty-printing-ast.rs b/src/test/ui/const-generics/defaults/pretty-printing-ast.rs new file mode 100644 index 00000000000..a25d4baca1a --- /dev/null +++ b/src/test/ui/const-generics/defaults/pretty-printing-ast.rs @@ -0,0 +1,13 @@ +// Test the AST pretty printer correctly handles default values for const generics +// check-pass +// compile-flags: -Z unpretty=expanded + +#![crate_type = "lib"] +#![feature(const_generics_defaults)] +#![allow(incomplete_features)] + +trait Foo<const KIND: bool = true> {} + +fn foo<const SIZE: usize = 5>() {} + +struct Range<const FROM: usize = 0, const LEN: usize = 0, const TO: usize = {FROM + LEN}>; diff --git a/src/test/ui/const-generics/defaults/pretty-printing-ast.stdout b/src/test/ui/const-generics/defaults/pretty-printing-ast.stdout new file mode 100644 index 00000000000..f7a1d2ca4b2 --- /dev/null +++ b/src/test/ui/const-generics/defaults/pretty-printing-ast.stdout @@ -0,0 +1,20 @@ +#![feature(prelude_import)] +#![no_std] +// Test the AST pretty printer correctly handles default values for const generics +// check-pass +// compile-flags: -Z unpretty=expanded + +#![crate_type = "lib"] +#![feature(const_generics_defaults)] +#![allow(incomplete_features)] +#[prelude_import] +use ::std::prelude::rust_2015::*; +#[macro_use] +extern crate std; + +trait Foo<const KIND : bool = true> { } + +fn foo<const SIZE : usize = 5>() { } + +struct Range<const FROM : usize = 0, const LEN : usize = 0, const TO : usize = + { FROM + LEN }>; |
