From 074ef54bfbab9c4185cd70702ac58c97a8345255 Mon Sep 17 00:00:00 2001 From: Avi Dessauer Date: Thu, 23 Jan 2020 19:35:17 -0500 Subject: [PATCH] Additional trait default parameter stability tests --- .../auxiliary/unstable_generic_param.rs | 8 +++++++- .../generics-default-stability.rs | 14 +++++++++++--- .../generics-default-stability.stderr | 18 +++++++++++++++++- 3 files changed, 35 insertions(+), 5 deletions(-) diff --git a/src/test/ui/stability-attribute/auxiliary/unstable_generic_param.rs b/src/test/ui/stability-attribute/auxiliary/unstable_generic_param.rs index 9f4889f59a564..7596fa07cbad4 100644 --- a/src/test/ui/stability-attribute/auxiliary/unstable_generic_param.rs +++ b/src/test/ui/stability-attribute/auxiliary/unstable_generic_param.rs @@ -10,7 +10,13 @@ pub trait Trait1<#[unstable(feature = "unstable_default", issue = "none")] T = ( } #[stable(feature = "stable_test_feature", since = "1.0.0")] -pub trait Trait2 { +pub trait Trait2<#[unstable(feature = "unstable_default", issue = "none")] T = usize> { + #[stable(feature = "stable_test_feature", since = "1.0.0")] + fn foo() -> T; +} + +#[stable(feature = "stable_test_feature", since = "1.0.0")] +pub trait Trait3 { #[stable(feature = "stable_test_feature", since = "1.0.0")] fn foo() -> T; } diff --git a/src/test/ui/stability-attribute/generics-default-stability.rs b/src/test/ui/stability-attribute/generics-default-stability.rs index 0963bbec76bdc..1006d701117ff 100644 --- a/src/test/ui/stability-attribute/generics-default-stability.rs +++ b/src/test/ui/stability-attribute/generics-default-stability.rs @@ -16,7 +16,15 @@ impl Trait1 for S { //~ ERROR use of unstable library feature 'unstable_d fn foo() -> usize { 0 } } -impl Trait2 for S { +impl Trait1 for S { //~ ERROR use of unstable library feature 'unstable_default' + fn foo() -> usize { 0 } +} + +impl Trait2 for S { //~ ERROR use of unstable library feature 'unstable_default' + fn foo() -> usize { 0 } +} + +impl Trait3 for S { fn foo() -> usize { 0 } // ok } @@ -25,9 +33,9 @@ fn main() { let _ = Struct1 { field: 1 }; //~ ERROR use of unstable library feature 'unstable_default' let _: Struct1 = Struct1 { field: 1 }; //~ ERROR use of unstable library feature 'unstable_default' - let _: Struct1 = Struct1 { field: 1 }; //~ ERROR use of unstable library feature 'unstable_default' + let _: Struct1 = Struct1 { field: 1 }; //~ ERROR use of unstable library feature 'unstable_default' - let _ = STRUCT1; + let _ = STRUCT1; // ok let _: Struct1 = STRUCT1; // ok let _: Struct1 = STRUCT1; //~ ERROR use of unstable library feature 'unstable_default' let _: Struct1 = STRUCT1; //~ ERROR use of unstable library feature 'unstable_default' diff --git a/src/test/ui/stability-attribute/generics-default-stability.stderr b/src/test/ui/stability-attribute/generics-default-stability.stderr index fb6deb7f477e4..1b7f4b85b59ba 100644 --- a/src/test/ui/stability-attribute/generics-default-stability.stderr +++ b/src/test/ui/stability-attribute/generics-default-stability.stderr @@ -6,6 +6,22 @@ LL | impl Trait1 for S { | = help: add `#![feature(unstable_default)]` to the crate attributes to enable -error: aborting due to previous error +error[E0658]: use of unstable library feature 'unstable_default' + --> $DIR/generics-default-stability.rs:19:13 + | +LL | impl Trait1 for S { + | ^^^^^ + | + = help: add `#![feature(unstable_default)]` to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_default' + --> $DIR/generics-default-stability.rs:23:13 + | +LL | impl Trait2 for S { + | ^^^^^ + | + = help: add `#![feature(unstable_default)]` to the crate attributes to enable + +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0658`.