Skip to content

Commit

Permalink
Test stability on default parameter of deprecated
Browse files Browse the repository at this point in the history
  • Loading branch information
Avi-D-coder authored and Jacob Hughes committed Sep 23, 2020
1 parent f665ccd commit a1892f1
Show file tree
Hide file tree
Showing 3 changed files with 170 additions and 1 deletion.
Expand Up @@ -41,6 +41,20 @@ pub struct Struct3<A = isize, #[unstable(feature = "unstable_default", issue = "
pub field2: B,
}

#[rustc_deprecated(since = "1.1.0", reason = "test")]
#[stable(feature = "stable_test_feature", since = "1.0.0")]
pub struct Struct4<A = usize> {
#[stable(feature = "stable_test_feature", since = "1.0.0")]
pub field: A,
}

#[rustc_deprecated(since = "1.1.0", reason = "test")]
#[stable(feature = "stable_test_feature", since = "1.0.0")]
pub struct Struct5<#[unstable(feature = "unstable_default", issue = "none")] A = usize> {
#[stable(feature = "stable_test_feature", since = "1.0.0")]
pub field: A,
}

#[stable(feature = "stable_test_feature", since = "1.0.0")]
pub const STRUCT1: Struct1 = Struct1 { field: 1 };

Expand All @@ -49,3 +63,9 @@ pub const STRUCT2: Struct2 = Struct2 { field: 1 };

#[stable(feature = "stable_test_feature", since = "1.0.0")]
pub const STRUCT3: Struct3 = Struct3 { field1: 1, field2: 2 };

#[stable(feature = "stable_test_feature", since = "1.0.0")]
pub const STRUCT4: Struct4 = Struct4 { field: 1 };

#[stable(feature = "stable_test_feature", since = "1.0.0")]
pub const STRUCT5: Struct5 = Struct5 { field: 1 };
27 changes: 27 additions & 0 deletions src/test/ui/stability-attribute/generics-default-stability.rs
Expand Up @@ -76,4 +76,31 @@ fn main() {
let _: Struct3<usize> = Struct3 { field1: 0, field2: 0 }; // ok
let _ = STRUCT3.field2 + 1; // ok
let _ = STRUCT3.field2 + 1usize; // ok

let _ = STRUCT4;
let _: Struct4<isize> = Struct4 { field: 1 };
//~^ use of deprecated item 'unstable_generic_param::Struct4': test [deprecated]
//~^^ use of deprecated item 'unstable_generic_param::Struct4': test [deprecated]
//~^^^ use of deprecated item 'unstable_generic_param::Struct4::field': test [deprecated]
let _ = STRUCT4;
let _: Struct4 = STRUCT4; //~ use of deprecated item 'unstable_generic_param::Struct4': test [deprecated]
let _: Struct4<usize> = STRUCT4; //~ use of deprecated item 'unstable_generic_param::Struct4': test [deprecated]
let _: Struct4<isize> = Struct4 { field: 0 };
//~^ use of deprecated item 'unstable_generic_param::Struct4': test [deprecated]
//~^^ use of deprecated item 'unstable_generic_param::Struct4': test [deprecated]
//~^^^ use of deprecated item 'unstable_generic_param::Struct4::field': test [deprecated]

let _ = STRUCT5;
let _: Struct5<isize> = Struct5 { field: 1 }; //~ ERROR use of unstable library feature 'unstable_default'
//~^ use of deprecated item 'unstable_generic_param::Struct5': test [deprecated]
//~^^ use of deprecated item 'unstable_generic_param::Struct5': test [deprecated]
//~^^^ use of deprecated item 'unstable_generic_param::Struct5::field': test [deprecated]
let _ = STRUCT5;
let _: Struct5 = STRUCT5; //~ use of deprecated item 'unstable_generic_param::Struct5': test [deprecated]
let _: Struct5<usize> = STRUCT5; //~ ERROR use of unstable library feature 'unstable_default'
//~^ use of deprecated item 'unstable_generic_param::Struct5': test [deprecated]
let _: Struct5<isize> = Struct5 { field: 0 }; //~ ERROR use of unstable library feature 'unstable_default'
//~^ use of deprecated item 'unstable_generic_param::Struct5': test [deprecated]
//~^^ use of deprecated item 'unstable_generic_param::Struct5': test [deprecated]
//~^^^ use of deprecated item 'unstable_generic_param::Struct5::field': test [deprecated]
}
124 changes: 123 additions & 1 deletion src/test/ui/stability-attribute/generics-default-stability.stderr
Expand Up @@ -22,6 +22,80 @@ LL | impl Trait2<usize> for S {
|
= help: add `#![feature(unstable_default)]` to the crate attributes to enable

warning: use of deprecated item 'unstable_generic_param::Struct4': test
--> $DIR/generics-default-stability.rs:81:29
|
LL | let _: Struct4<isize> = Struct4 { field: 1 };
| ^^^^^^^
|
= note: `#[warn(deprecated)]` on by default

warning: use of deprecated item 'unstable_generic_param::Struct4': test
--> $DIR/generics-default-stability.rs:81:12
|
LL | let _: Struct4<isize> = Struct4 { field: 1 };
| ^^^^^^^^^^^^^^

warning: use of deprecated item 'unstable_generic_param::Struct4': test
--> $DIR/generics-default-stability.rs:86:12
|
LL | let _: Struct4 = STRUCT4;
| ^^^^^^^

warning: use of deprecated item 'unstable_generic_param::Struct4': test
--> $DIR/generics-default-stability.rs:87:12
|
LL | let _: Struct4<usize> = STRUCT4;
| ^^^^^^^^^^^^^^

warning: use of deprecated item 'unstable_generic_param::Struct4': test
--> $DIR/generics-default-stability.rs:88:29
|
LL | let _: Struct4<isize> = Struct4 { field: 0 };
| ^^^^^^^

warning: use of deprecated item 'unstable_generic_param::Struct4': test
--> $DIR/generics-default-stability.rs:88:12
|
LL | let _: Struct4<isize> = Struct4 { field: 0 };
| ^^^^^^^^^^^^^^

warning: use of deprecated item 'unstable_generic_param::Struct5': test
--> $DIR/generics-default-stability.rs:94:29
|
LL | let _: Struct5<isize> = Struct5 { field: 1 };
| ^^^^^^^

warning: use of deprecated item 'unstable_generic_param::Struct5': test
--> $DIR/generics-default-stability.rs:94:12
|
LL | let _: Struct5<isize> = Struct5 { field: 1 };
| ^^^^^^^^^^^^^^

warning: use of deprecated item 'unstable_generic_param::Struct5': test
--> $DIR/generics-default-stability.rs:99:12
|
LL | let _: Struct5 = STRUCT5;
| ^^^^^^^

warning: use of deprecated item 'unstable_generic_param::Struct5': test
--> $DIR/generics-default-stability.rs:100:12
|
LL | let _: Struct5<usize> = STRUCT5;
| ^^^^^^^^^^^^^^

warning: use of deprecated item 'unstable_generic_param::Struct5': test
--> $DIR/generics-default-stability.rs:102:29
|
LL | let _: Struct5<isize> = Struct5 { field: 0 };
| ^^^^^^^

warning: use of deprecated item 'unstable_generic_param::Struct5': test
--> $DIR/generics-default-stability.rs:102:12
|
LL | let _: Struct5<isize> = Struct5 { field: 0 };
| ^^^^^^^^^^^^^^

error[E0658]: use of unstable library feature 'unstable_default'
--> $DIR/generics-default-stability.rs:35:20
|
Expand Down Expand Up @@ -70,6 +144,54 @@ LL | let _: Struct3<usize, usize> = Struct3 { field1: 0, field2: 0 };
|
= help: add `#![feature(unstable_default)]` to the crate attributes to enable

error: aborting due to 9 previous errors
error[E0658]: use of unstable library feature 'unstable_default'
--> $DIR/generics-default-stability.rs:94:20
|
LL | let _: Struct5<isize> = Struct5 { field: 1 };
| ^^^^^
|
= 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:100:20
|
LL | let _: Struct5<usize> = STRUCT5;
| ^^^^^
|
= 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:102:20
|
LL | let _: Struct5<isize> = Struct5 { field: 0 };
| ^^^^^
|
= help: add `#![feature(unstable_default)]` to the crate attributes to enable

warning: use of deprecated item 'unstable_generic_param::Struct4::field': test
--> $DIR/generics-default-stability.rs:81:39
|
LL | let _: Struct4<isize> = Struct4 { field: 1 };
| ^^^^^^^^

warning: use of deprecated item 'unstable_generic_param::Struct4::field': test
--> $DIR/generics-default-stability.rs:88:39
|
LL | let _: Struct4<isize> = Struct4 { field: 0 };
| ^^^^^^^^

warning: use of deprecated item 'unstable_generic_param::Struct5::field': test
--> $DIR/generics-default-stability.rs:94:39
|
LL | let _: Struct5<isize> = Struct5 { field: 1 };
| ^^^^^^^^

warning: use of deprecated item 'unstable_generic_param::Struct5::field': test
--> $DIR/generics-default-stability.rs:102:39
|
LL | let _: Struct5<isize> = Struct5 { field: 0 };
| ^^^^^^^^

error: aborting due to 12 previous errors; 16 warnings emitted

For more information about this error, try `rustc --explain E0658`.

0 comments on commit a1892f1

Please sign in to comment.