diff options
Diffstat (limited to 'tests')
33 files changed, 398 insertions, 43 deletions
diff --git a/tests/rustdoc-gui/search-result-color.goml b/tests/rustdoc-gui/search-result-color.goml index e3c628b366f..7a7785fd9ac 100644 --- a/tests/rustdoc-gui/search-result-color.goml +++ b/tests/rustdoc-gui/search-result-color.goml @@ -61,7 +61,7 @@ assert-css: ( {"color": "#c5c5c5"}, ) assert-css: ( - "//*[@class='result-name']/*[text()='test_docs::']", + "//*[@class='result-name']//*[text()='test_docs::']", {"color": "#0096cf"}, ) @@ -138,7 +138,7 @@ call-function: ( move-cursor-to: ".search-input" focus: ".search-input" // To ensure the `<a>` container isnt focus or hover. assert-css: ( - "//*[@class='result-name']/*[text()='test_docs::']/ancestor::a", + "//*[@class='result-name']//*[text()='test_docs::']/ancestor::a", {"color": "#0096cf", "background-color": "transparent"}, ALL, ) @@ -146,11 +146,11 @@ assert-css: ( // Checking color and background on hover. move-cursor-to: "//*[@class='desc'][text()='Just a normal struct.']" assert-css: ( - "//*[@class='result-name']/*[text()='test_docs::']", + "//*[@class='result-name']//*[text()='test_docs::']", {"color": "#fff"}, ) assert-css: ( - "//*[@class='result-name']/*[text()='test_docs::']/ancestor::a", + "//*[@class='result-name']//*[text()='test_docs::']/ancestor::a", {"color": "#fff", "background-color": "rgb(60, 60, 60)"}, ) @@ -173,7 +173,7 @@ assert-css: ( {"color": "#ddd"}, ) assert-css: ( - "//*[@class='result-name']/*[text()='test_docs::']", + "//*[@class='result-name']//*[text()='test_docs::']", {"color": "#ddd"}, ) @@ -250,7 +250,7 @@ call-function: ( move-cursor-to: ".search-input" focus: ".search-input" // To ensure the `<a>` container isnt focus or hover. assert-css: ( - "//*[@class='result-name']/*[text()='test_docs::']/ancestor::a", + "//*[@class='result-name']//*[text()='test_docs::']/ancestor::a", {"color": "#ddd", "background-color": "transparent"}, ) @@ -270,7 +270,7 @@ assert-css: ( {"color": "#000"}, ) assert-css: ( - "//*[@class='result-name']/*[text()='test_docs::']", + "//*[@class='result-name']//*[text()='test_docs::']", {"color": "#000"}, ) @@ -347,7 +347,7 @@ call-function: ( move-cursor-to: ".search-input" focus: ".search-input" // To ensure the `<a>` container isnt focus or hover. assert-css: ( - "//*[@class='result-name']/*[text()='test_docs::']/ancestor::a", + "//*[@class='result-name']//*[text()='test_docs::']/ancestor::a", {"color": "#000", "background-color": "transparent"}, ) diff --git a/tests/rustdoc-gui/search-result-display.goml b/tests/rustdoc-gui/search-result-display.goml index 6593c1a9c45..f4c0e3eb047 100644 --- a/tests/rustdoc-gui/search-result-display.goml +++ b/tests/rustdoc-gui/search-result-display.goml @@ -1,3 +1,4 @@ +// ignore-tidy-linelength // Checks that the search results have the expected width. go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" set-window-size: (900, 1000) @@ -7,15 +8,40 @@ press-key: 'Enter' wait-for: "#crate-search" // The width is returned by "getComputedStyle" which returns the exact number instead of the // CSS rule which is "50%"... -assert-size: (".search-results div.desc", {"width": 310}) +assert-size: (".search-results div.desc", {"width": 248}) +store-size: (".search-results .result-name .typename", {"width": width}) set-window-size: (600, 100) // As counter-intuitive as it may seem, in this width, the width is "100%", which is why // when computed it's larger. assert-size: (".search-results div.desc", {"width": 566}) // The result set is all on one line. -assert-css: (".search-results .result-name > span:not(.typename)", {"display": "inline"}) -assert-css: (".search-results .result-name > span.typename", {"display": "inline-block"}) +compare-elements-position-near: ( + ".search-results .result-name .typename", + ".search-results .result-name .path", + {"y": 2}, +) +compare-elements-position-near-false: ( + ".search-results .result-name .typename", + ".search-results .result-name .path", + {"x": 5}, +) +// The width of the "typename" isn't fixed anymore in this display mode. +store-size: (".search-results .result-name .typename", {"width": new_width}) +assert: |new_width| < |width| - 10 + +// Check that if the search is too long on mobile, it'll go under the "typename". +go-to: "file://" + |DOC_PATH| + "/test_docs/index.html?search=SuperIncrediblyLongLongLongLongLongLongLongGigaGigaGigaMegaLongLongLongStructName" +wait-for: "#crate-search" +compare-elements-position-near: ( + ".search-results .result-name .typename", + ".search-results .result-name .path", + {"y": 2, "x": 0}, +) +store-size: (".search-results .result-name", {"width": width, "height": height}) +store-size: (".search-results .result-name .path", {"width": sub_width, "height": sub_height}) +assert: |width| < |sub_width| + 8 && |width| > |sub_width| - 8 +assert: |height| < |sub_height| + 8 && |height| > |sub_height| - 8 // Check that the crate filter `<select>` is correctly handled when it goes to next line. // To do so we need to update the length of one of its `<option>`. diff --git a/tests/ui/associated-inherent-types/private-in-public.rs b/tests/ui/associated-inherent-types/private-in-public.rs index 44a20a79ad6..33b84fc9506 100644 --- a/tests/ui/associated-inherent-types/private-in-public.rs +++ b/tests/ui/associated-inherent-types/private-in-public.rs @@ -1,7 +1,7 @@ #![feature(inherent_associated_types)] +#![feature(type_privacy_lints)] #![allow(incomplete_features)] #![crate_type = "lib"] - #![deny(private_in_public)] #![warn(private_interfaces)] diff --git a/tests/ui/closures/issue-113087.rs b/tests/ui/closures/issue-113087.rs new file mode 100644 index 00000000000..a4edc2f2f0b --- /dev/null +++ b/tests/ui/closures/issue-113087.rs @@ -0,0 +1,11 @@ +fn some_fn<'a>(_: &'a i32, _: impl FnOnce(&'a i32)) {} + +fn main() { + let some_closure = |_| {}; + + for a in [1] { + some_fn(&a, |c| { //~ ERROR does not live long enough + some_closure(c); + }); + } +} diff --git a/tests/ui/closures/issue-113087.stderr b/tests/ui/closures/issue-113087.stderr new file mode 100644 index 00000000000..8ccef4a54f5 --- /dev/null +++ b/tests/ui/closures/issue-113087.stderr @@ -0,0 +1,16 @@ +error[E0597]: `a` does not live long enough + --> $DIR/issue-113087.rs:7:17 + | +LL | for a in [1] { + | - binding `a` declared here +LL | some_fn(&a, |c| { + | ^^ borrowed value does not live long enough +LL | some_closure(c); + | ------------ borrow later captured here by closure +LL | }); +LL | } + | - `a` dropped here while still borrowed + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0597`. diff --git a/tests/ui/const-generics/generic_const_exprs/eval-privacy.rs b/tests/ui/const-generics/generic_const_exprs/eval-privacy.rs index 96b769699cc..5c43213e898 100644 --- a/tests/ui/const-generics/generic_const_exprs/eval-privacy.rs +++ b/tests/ui/const-generics/generic_const_exprs/eval-privacy.rs @@ -1,7 +1,7 @@ #![crate_type = "lib"] #![feature(generic_const_exprs)] +#![feature(type_privacy_lints)] #![allow(incomplete_features)] - #![warn(private_interfaces)] // In this test both old and new private-in-public diagnostic were emitted. diff --git a/tests/ui/error-codes/E0445.rs b/tests/ui/error-codes/E0445.rs index f5f35fb8a4d..30c222ae6f2 100644 --- a/tests/ui/error-codes/E0445.rs +++ b/tests/ui/error-codes/E0445.rs @@ -1,3 +1,4 @@ +#![feature(type_privacy_lints)] #[warn(private_bounds)] #[warn(private_interfaces)] diff --git a/tests/ui/error-codes/E0445.stderr b/tests/ui/error-codes/E0445.stderr index ac3637a8218..ba2c21485ef 100644 --- a/tests/ui/error-codes/E0445.stderr +++ b/tests/ui/error-codes/E0445.stderr @@ -1,5 +1,5 @@ error[E0445]: private trait `Foo` in public interface - --> $DIR/E0445.rs:12:1 + --> $DIR/E0445.rs:13:1 | LL | trait Foo { | --------- `Foo` declared as private @@ -10,23 +10,23 @@ LL | pub trait Bar : Foo {} warning: trait `Foo` is more private than the item `Bar` | note: trait `Bar` is reachable at visibility `pub` - --> $DIR/E0445.rs:12:1 + --> $DIR/E0445.rs:13:1 | LL | pub trait Bar : Foo {} | ^^^^^^^^^^^^^^^^^^^ note: but trait `Foo` is only usable at visibility `pub(crate)` - --> $DIR/E0445.rs:8:1 + --> $DIR/E0445.rs:9:1 | LL | trait Foo { | ^^^^^^^^^ note: the lint level is defined here - --> $DIR/E0445.rs:1:8 + --> $DIR/E0445.rs:2:8 | LL | #[warn(private_bounds)] | ^^^^^^^^^^^^^^ error[E0445]: private trait `Foo` in public interface - --> $DIR/E0445.rs:14:1 + --> $DIR/E0445.rs:15:1 | LL | trait Foo { | --------- `Foo` declared as private @@ -37,18 +37,18 @@ LL | pub struct Bar2<T: Foo>(pub T); warning: trait `Foo` is more private than the item `Bar2` | note: struct `Bar2` is reachable at visibility `pub` - --> $DIR/E0445.rs:14:1 + --> $DIR/E0445.rs:15:1 | LL | pub struct Bar2<T: Foo>(pub T); | ^^^^^^^^^^^^^^^^^^^^^^^ note: but trait `Foo` is only usable at visibility `pub(crate)` - --> $DIR/E0445.rs:8:1 + --> $DIR/E0445.rs:9:1 | LL | trait Foo { | ^^^^^^^^^ error[E0445]: private trait `Foo` in public interface - --> $DIR/E0445.rs:16:1 + --> $DIR/E0445.rs:17:1 | LL | trait Foo { | --------- `Foo` declared as private @@ -59,12 +59,12 @@ LL | pub fn foo<T: Foo> (t: T) {} warning: trait `Foo` is more private than the item `foo` | note: function `foo` is reachable at visibility `pub` - --> $DIR/E0445.rs:16:1 + --> $DIR/E0445.rs:17:1 | LL | pub fn foo<T: Foo> (t: T) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ note: but trait `Foo` is only usable at visibility `pub(crate)` - --> $DIR/E0445.rs:8:1 + --> $DIR/E0445.rs:9:1 | LL | trait Foo { | ^^^^^^^^^ diff --git a/tests/ui/feature-gates/feature-gate-type_privacy_lints.rs b/tests/ui/feature-gates/feature-gate-type_privacy_lints.rs new file mode 100644 index 00000000000..aad64c9d073 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-type_privacy_lints.rs @@ -0,0 +1,12 @@ +// check-pass + +#![warn(private_interfaces)] //~ WARN unknown lint + //~| WARN unknown lint + //~| WARN unknown lint +#![warn(private_bounds)] //~ WARN unknown lint + //~| WARN unknown lint + //~| WARN unknown lint +#![warn(unnameable_types)] //~ WARN unknown lint + //~| WARN unknown lint + //~| WARN unknown lint +fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-type_privacy_lints.stderr b/tests/ui/feature-gates/feature-gate-type_privacy_lints.stderr new file mode 100644 index 00000000000..79cc974cca1 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-type_privacy_lints.stderr @@ -0,0 +1,93 @@ +warning: unknown lint: `private_interfaces` + --> $DIR/feature-gate-type_privacy_lints.rs:3:1 + | +LL | #![warn(private_interfaces)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: the `private_interfaces` lint is unstable + = note: see issue #48054 <https://github.com/rust-lang/rust/issues/48054> for more information + = help: add `#![feature(type_privacy_lints)]` to the crate attributes to enable + = note: `#[warn(unknown_lints)]` on by default + +warning: unknown lint: `private_bounds` + --> $DIR/feature-gate-type_privacy_lints.rs:6:1 + | +LL | #![warn(private_bounds)] + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: the `private_bounds` lint is unstable + = note: see issue #48054 <https://github.com/rust-lang/rust/issues/48054> for more information + = help: add `#![feature(type_privacy_lints)]` to the crate attributes to enable + +warning: unknown lint: `unnameable_types` + --> $DIR/feature-gate-type_privacy_lints.rs:9:1 + | +LL | #![warn(unnameable_types)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: the `unnameable_types` lint is unstable + = note: see issue #48054 <https://github.com/rust-lang/rust/issues/48054> for more information + = help: add `#![feature(type_privacy_lints)]` to the crate attributes to enable + +warning: unknown lint: `private_interfaces` + --> $DIR/feature-gate-type_privacy_lints.rs:3:1 + | +LL | #![warn(private_interfaces)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: the `private_interfaces` lint is unstable + = note: see issue #48054 <https://github.com/rust-lang/rust/issues/48054> for more information + = help: add `#![feature(type_privacy_lints)]` to the crate attributes to enable + +warning: unknown lint: `private_bounds` + --> $DIR/feature-gate-type_privacy_lints.rs:6:1 + | +LL | #![warn(private_bounds)] + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: the `private_bounds` lint is unstable + = note: see issue #48054 <https://github.com/rust-lang/rust/issues/48054> for more information + = help: add `#![feature(type_privacy_lints)]` to the crate attributes to enable + +warning: unknown lint: `unnameable_types` + --> $DIR/feature-gate-type_privacy_lints.rs:9:1 + | +LL | #![warn(unnameable_types)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: the `unnameable_types` lint is unstable + = note: see issue #48054 <https://github.com/rust-lang/rust/issues/48054> for more information + = help: add `#![feature(type_privacy_lints)]` to the crate attributes to enable + +warning: unknown lint: `private_interfaces` + --> $DIR/feature-gate-type_privacy_lints.rs:3:1 + | +LL | #![warn(private_interfaces)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: the `private_interfaces` lint is unstable + = note: see issue #48054 <https://github.com/rust-lang/rust/issues/48054> for more information + = help: add `#![feature(type_privacy_lints)]` to the crate attributes to enable + +warning: unknown lint: `private_bounds` + --> $DIR/feature-gate-type_privacy_lints.rs:6:1 + | +LL | #![warn(private_bounds)] + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: the `private_bounds` lint is unstable + = note: see issue #48054 <https://github.com/rust-lang/rust/issues/48054> for more information + = help: add `#![feature(type_privacy_lints)]` to the crate attributes to enable + +warning: unknown lint: `unnameable_types` + --> $DIR/feature-gate-type_privacy_lints.rs:9:1 + | +LL | #![warn(unnameable_types)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: the `unnameable_types` lint is unstable + = note: see issue #48054 <https://github.com/rust-lang/rust/issues/48054> for more information + = help: add `#![feature(type_privacy_lints)]` to the crate attributes to enable + +warning: 9 warnings emitted + diff --git a/tests/ui/issues/issue-18389.rs b/tests/ui/issues/issue-18389.rs index 3686afc48af..0af693c4e0f 100644 --- a/tests/ui/issues/issue-18389.rs +++ b/tests/ui/issues/issue-18389.rs @@ -1,3 +1,4 @@ +#![feature(type_privacy_lints)] #![warn(private_bounds)] // In this test both old and new private-in-public diagnostic were emitted. diff --git a/tests/ui/issues/issue-18389.stderr b/tests/ui/issues/issue-18389.stderr index f9ebde48a45..6b78151c606 100644 --- a/tests/ui/issues/issue-18389.stderr +++ b/tests/ui/issues/issue-18389.stderr @@ -1,5 +1,5 @@ error[E0445]: private trait `Private<<Self as Public>::P, <Self as Public>::R>` in public interface - --> $DIR/issue-18389.rs:13:1 + --> $DIR/issue-18389.rs:14:1 | LL | trait Private<P, R> { | ------------------- `Private<<Self as Public>::P, <Self as Public>::R>` declared as private @@ -14,7 +14,7 @@ LL | | > { warning: trait `Private<<Self as Public>::P, <Self as Public>::R>` is more private than the item `Public` | note: trait `Public` is reachable at visibility `pub` - --> $DIR/issue-18389.rs:13:1 + --> $DIR/issue-18389.rs:14:1 | LL | / pub trait Public: Private< LL | | @@ -23,12 +23,12 @@ LL | | <Self as Public>::R LL | | > { | |_^ note: but trait `Private<<Self as Public>::P, <Self as Public>::R>` is only usable at visibility `pub(crate)` - --> $DIR/issue-18389.rs:10:1 + --> $DIR/issue-18389.rs:11:1 | LL | trait Private<P, R> { | ^^^^^^^^^^^^^^^^^^^ note: the lint level is defined here - --> $DIR/issue-18389.rs:1:9 + --> $DIR/issue-18389.rs:2:9 | LL | #![warn(private_bounds)] | ^^^^^^^^^^^^^^ diff --git a/tests/ui/match/issue-113012.rs b/tests/ui/match/issue-113012.rs new file mode 100644 index 00000000000..da7a8b65b97 --- /dev/null +++ b/tests/ui/match/issue-113012.rs @@ -0,0 +1,12 @@ +// run-pass + +#![allow(dead_code)] +struct Foo(()); + +const FOO: Foo = Foo(match 0 { + 0.. => (), + _ => (), +}); + +fn main() { +} diff --git a/tests/ui/privacy/effective_visibilities_full_priv.rs b/tests/ui/privacy/effective_visibilities_full_priv.rs index cc708917586..a26ae3bd122 100644 --- a/tests/ui/privacy/effective_visibilities_full_priv.rs +++ b/tests/ui/privacy/effective_visibilities_full_priv.rs @@ -6,7 +6,7 @@ struct SemiPriv; mod m { #[rustc_effective_visibility] struct Priv; - //~^ ERROR Direct: pub(self), Reexported: pub(self), Reachable: pub(crate), ReachableThroughImplTrait: pub(crate) + //~^ ERROR not in the table //~| ERROR not in the table #[rustc_effective_visibility] diff --git a/tests/ui/privacy/effective_visibilities_full_priv.stderr b/tests/ui/privacy/effective_visibilities_full_priv.stderr index a856aa20d92..29d82e2ee01 100644 --- a/tests/ui/privacy/effective_visibilities_full_priv.stderr +++ b/tests/ui/privacy/effective_visibilities_full_priv.stderr @@ -1,4 +1,4 @@ -error: Direct: pub(self), Reexported: pub(self), Reachable: pub(crate), ReachableThroughImplTrait: pub(crate) +error: not in the table --> $DIR/effective_visibilities_full_priv.rs:8:5 | LL | struct Priv; diff --git a/tests/ui/privacy/private-in-public-non-principal.rs b/tests/ui/privacy/private-in-public-non-principal.rs index a80c1541463..9ae7512c509 100644 --- a/tests/ui/privacy/private-in-public-non-principal.rs +++ b/tests/ui/privacy/private-in-public-non-principal.rs @@ -1,6 +1,6 @@ #![feature(auto_traits)] #![feature(negative_impls)] - +#![feature(type_privacy_lints)] #![deny(private_interfaces)] // In this test both old and new private-in-public diagnostic were emitted. diff --git a/tests/ui/privacy/unnameable_types.rs b/tests/ui/privacy/unnameable_types.rs index 8b53f372fc9..eae20dd9df3 100644 --- a/tests/ui/privacy/unnameable_types.rs +++ b/tests/ui/privacy/unnameable_types.rs @@ -1,4 +1,4 @@ -#![allow(unused)] +#![feature(type_privacy_lints)] #![allow(private_in_public)] #![deny(unnameable_types)] diff --git a/tests/ui/privacy/where-priv-type.rs b/tests/ui/privacy/where-priv-type.rs index 9899902dd88..468d6e98a74 100644 --- a/tests/ui/privacy/where-priv-type.rs +++ b/tests/ui/privacy/where-priv-type.rs @@ -3,8 +3,8 @@ #![crate_type = "lib"] #![feature(generic_const_exprs)] +#![feature(type_privacy_lints)] #![allow(incomplete_features)] - #![warn(private_bounds)] #![warn(private_interfaces)] diff --git a/tests/ui/privacy/where-pub-type-impls-priv-trait.rs b/tests/ui/privacy/where-pub-type-impls-priv-trait.rs index 3aad893eae2..35e33bcb3b7 100644 --- a/tests/ui/privacy/where-pub-type-impls-priv-trait.rs +++ b/tests/ui/privacy/where-pub-type-impls-priv-trait.rs @@ -2,8 +2,8 @@ #![crate_type = "lib"] #![feature(generic_const_exprs)] +#![feature(type_privacy_lints)] #![allow(incomplete_features)] - #![warn(private_bounds)] // In this test both old and new private-in-public diagnostic were emitted. diff --git a/tests/ui/pub/issue-33174-restricted-type-in-public-interface.rs b/tests/ui/pub/issue-33174-restricted-type-in-public-interface.rs index 9e4ba80a784..bd8f6585f48 100644 --- a/tests/ui/pub/issue-33174-restricted-type-in-public-interface.rs +++ b/tests/ui/pub/issue-33174-restricted-type-in-public-interface.rs @@ -1,3 +1,4 @@ +#![feature(type_privacy_lints)] #![allow(non_camel_case_types)] // genus is always capitalized #![warn(private_interfaces)] //~^ NOTE the lint level is defined here diff --git a/tests/ui/pub/issue-33174-restricted-type-in-public-interface.stderr b/tests/ui/pub/issue-33174-restricted-type-in-public-interface.stderr index 52f67d4cdd5..5ebda47558c 100644 --- a/tests/ui/pub/issue-33174-restricted-type-in-public-interface.stderr +++ b/tests/ui/pub/issue-33174-restricted-type-in-public-interface.stderr @@ -1,5 +1,5 @@ error[E0446]: private type `Snail` in public interface - --> $DIR/issue-33174-restricted-type-in-public-interface.rs:27:1 + --> $DIR/issue-33174-restricted-type-in-public-interface.rs:28:1 | LL | pub(crate) struct Snail; | ----------------------- `Snail` declared as private @@ -10,23 +10,23 @@ LL | pub type Helix_pomatia = Shell<Snail>; warning: type `Snail` is more private than the item `Helix_pomatia` | note: type alias `Helix_pomatia` is reachable at visibility `pub` - --> $DIR/issue-33174-restricted-type-in-public-interface.rs:27:1 + --> $DIR/issue-33174-restricted-type-in-public-interface.rs:28:1 | LL | pub type Helix_pomatia = Shell<Snail>; | ^^^^^^^^^^^^^^^^^^^^^^ note: but type `Snail` is only usable at visibility `pub(crate)` - --> $DIR/issue-33174-restricted-type-in-public-interface.rs:9:1 + --> $DIR/issue-33174-restricted-type-in-public-interface.rs:10:1 | LL | pub(crate) struct Snail; | ^^^^^^^^^^^^^^^^^^^^^^^ note: the lint level is defined here - --> $DIR/issue-33174-restricted-type-in-public-interface.rs:2:9 + --> $DIR/issue-33174-restricted-type-in-public-interface.rs:3:9 | LL | #![warn(private_interfaces)] | ^^^^^^^^^^^^^^^^^^ error[E0446]: crate-private type `Turtle` in public interface - --> $DIR/issue-33174-restricted-type-in-public-interface.rs:31:1 + --> $DIR/issue-33174-restricted-type-in-public-interface.rs:32:1 | LL | pub(super) struct Turtle; | ------------------------ `Turtle` declared as crate-private @@ -37,18 +37,18 @@ LL | pub type Dermochelys_coriacea = Shell<sea::Turtle>; warning: type `Turtle` is more private than the item `Dermochelys_coriacea` | note: type alias `Dermochelys_coriacea` is reachable at visibility `pub` - --> $DIR/issue-33174-restricted-type-in-public-interface.rs:31:1 + --> $DIR/issue-33174-restricted-type-in-public-interface.rs:32:1 | LL | pub type Dermochelys_coriacea = Shell<sea::Turtle>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: but type `Turtle` is only usable at visibility `pub(crate)` - --> $DIR/issue-33174-restricted-type-in-public-interface.rs:14:5 + --> $DIR/issue-33174-restricted-type-in-public-interface.rs:15:5 | LL | pub(super) struct Turtle; | ^^^^^^^^^^^^^^^^^^^^^^^^ error[E0446]: private type `Tortoise` in public interface - --> $DIR/issue-33174-restricted-type-in-public-interface.rs:35:1 + --> $DIR/issue-33174-restricted-type-in-public-interface.rs:36:1 | LL | struct Tortoise; | --------------- `Tortoise` declared as private @@ -59,12 +59,12 @@ LL | pub type Testudo_graeca = Shell<Tortoise>; warning: type `Tortoise` is more private than the item `Testudo_graeca` | note: type alias `Testudo_graeca` is reachable at visibility `pub` - --> $DIR/issue-33174-restricted-type-in-public-interface.rs:35:1 + --> $DIR/issue-33174-restricted-type-in-public-interface.rs:36:1 | LL | pub type Testudo_graeca = Shell<Tortoise>; | ^^^^^^^^^^^^^^^^^^^^^^^ note: but type `Tortoise` is only usable at visibility `pub(crate)` - --> $DIR/issue-33174-restricted-type-in-public-interface.rs:19:1 + --> $DIR/issue-33174-restricted-type-in-public-interface.rs:20:1 | LL | struct Tortoise; | ^^^^^^^^^^^^^^^ diff --git a/tests/ui/traits/auxiliary/trivial3.rs b/tests/ui/traits/auxiliary/trivial3.rs new file mode 100644 index 00000000000..0a47fdc74d7 --- /dev/null +++ b/tests/ui/traits/auxiliary/trivial3.rs @@ -0,0 +1 @@ +pub trait Trait {} diff --git a/tests/ui/traits/auxiliary/trivial4.rs b/tests/ui/traits/auxiliary/trivial4.rs new file mode 100644 index 00000000000..a527d1a9526 --- /dev/null +++ b/tests/ui/traits/auxiliary/trivial4.rs @@ -0,0 +1,3 @@ +pub trait Trait {} + +impl Trait for () {} diff --git a/tests/ui/traits/trivial_impl.rs b/tests/ui/traits/trivial_impl.rs new file mode 100644 index 00000000000..6ac8c744bc4 --- /dev/null +++ b/tests/ui/traits/trivial_impl.rs @@ -0,0 +1,18 @@ +//! This test checks that we do need to implement +//! all members, even if their where bounds only hold +//! due to other impls. + +trait Foo<T> { + fn foo() + where + Self: Foo<()>; +} + +impl Foo<()> for () { + fn foo() {} +} + +impl Foo<u32> for () {} +//~^ ERROR: not all trait items implemented, missing: `foo` + +fn main() {} diff --git a/tests/ui/traits/trivial_impl.stderr b/tests/ui/traits/trivial_impl.stderr new file mode 100644 index 00000000000..4b29b55bea1 --- /dev/null +++ b/tests/ui/traits/trivial_impl.stderr @@ -0,0 +1,14 @@ +error[E0046]: not all trait items implemented, missing: `foo` + --> $DIR/trivial_impl.rs:15:1 + | +LL | / fn foo() +LL | | where +LL | | Self: Foo<()>; + | |______________________- `foo` from trait +... +LL | impl Foo<u32> for () {} + | ^^^^^^^^^^^^^^^^^^^^ missing `foo` in implementation + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0046`. diff --git a/tests/ui/traits/trivial_impl2.rs b/tests/ui/traits/trivial_impl2.rs new file mode 100644 index 00000000000..be58096007f --- /dev/null +++ b/tests/ui/traits/trivial_impl2.rs @@ -0,0 +1,13 @@ +//! This test checks that we currently need to implement +//! members, even if their where bounds don't hold for the impl type. + +trait Foo<T> { + fn foo() + where + Self: Foo<()>; +} + +impl Foo<u32> for () {} +//~^ ERROR: not all trait items implemented, missing: `foo` + +fn main() {} diff --git a/tests/ui/traits/trivial_impl2.stderr b/tests/ui/traits/trivial_impl2.stderr new file mode 100644 index 00000000000..04c05df0616 --- /dev/null +++ b/tests/ui/traits/trivial_impl2.stderr @@ -0,0 +1,14 @@ +error[E0046]: not all trait items implemented, missing: `foo` + --> $DIR/trivial_impl2.rs:10:1 + | +LL | / fn foo() +LL | | where +LL | | Self: Foo<()>; + | |______________________- `foo` from trait +... +LL | impl Foo<u32> for () {} + | ^^^^^^^^^^^^^^^^^^^^ missing `foo` in implementation + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0046`. diff --git a/tests/ui/traits/trivial_impl3.rs b/tests/ui/traits/trivial_impl3.rs new file mode 100644 index 00000000000..714f643bc99 --- /dev/null +++ b/tests/ui/traits/trivial_impl3.rs @@ -0,0 +1,19 @@ +//! Check that we don't break orphan rules. +//! The dependency may add an impl for `u8` later, +//! which would break this crate. We want to avoid adding +//! more ways in which adding an impl can be a breaking change. + +// aux-build:trivial3.rs + +extern crate trivial3; + +pub trait Foo { + fn foo() + where + Self: trivial3::Trait; +} + +impl Foo for u8 {} +//~^ ERROR not all trait items implemented, missing: `foo` + +fn main() {} diff --git a/tests/ui/traits/trivial_impl3.stderr b/tests/ui/traits/trivial_impl3.stderr new file mode 100644 index 00000000000..dfb39d6ce15 --- /dev/null +++ b/tests/ui/traits/trivial_impl3.stderr @@ -0,0 +1,14 @@ +error[E0046]: not all trait items implemented, missing: `foo` + --> $DIR/trivial_impl3.rs:16:1 + | +LL | / fn foo() +LL | | where +LL | | Self: trivial3::Trait; + | |______________________________- `foo` from trait +... +LL | impl Foo for u8 {} + | ^^^^^^^^^^^^^^^ missing `foo` in implementation + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0046`. diff --git a/tests/ui/traits/trivial_impl4.rs b/tests/ui/traits/trivial_impl4.rs new file mode 100644 index 00000000000..518f159c1fb --- /dev/null +++ b/tests/ui/traits/trivial_impl4.rs @@ -0,0 +1,21 @@ +//! Check that we don't break orphan rules. +//! The dependency may add an impl for `u8` later, +//! which would break this crate. We want to avoid adding +//! more ways in which adding an impl can be a breaking change. +//! This test differs from `trivial_impl3` because there actually +//! exists any impl for `Trait`, which has an effect on coherence. + +// aux-build:trivial4.rs + +extern crate trivial4; + +pub trait Foo { + fn foo() + where + Self: trivial4::Trait; +} + +impl Foo for u8 {} +//~^ ERROR not all trait items implemented, missing: `foo` + +fn main() {} diff --git a/tests/ui/traits/trivial_impl4.stderr b/tests/ui/traits/trivial_impl4.stderr new file mode 100644 index 00000000000..04b29ed7734 --- /dev/null +++ b/tests/ui/traits/trivial_impl4.stderr @@ -0,0 +1,14 @@ +error[E0046]: not all trait items implemented, missing: `foo` + --> $DIR/trivial_impl4.rs:18:1 + | +LL | / fn foo() +LL | | where +LL | | Self: trivial4::Trait; + | |______________________________- `foo` from trait +... +LL | impl Foo for u8 {} + | ^^^^^^^^^^^^^^^ missing `foo` in implementation + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0046`. diff --git a/tests/ui/traits/trivial_impl_sized.rs b/tests/ui/traits/trivial_impl_sized.rs new file mode 100644 index 00000000000..501a3405090 --- /dev/null +++ b/tests/ui/traits/trivial_impl_sized.rs @@ -0,0 +1,26 @@ +//! This test checks that we currently need to implement +//! members, even if their where bounds don't hold for the impl type. + +trait Foo { + fn foo() + where + Self: Sized; +} + +impl Foo for () { + fn foo() {} +} + +// Must not be allowed +impl Foo for i32 {} +//~^ ERROR: not all trait items implemented, missing: `foo` + +// Should be allowed +impl Foo for dyn std::fmt::Debug {} +//~^ ERROR: not all trait items implemented, missing: `foo` + +impl Foo for dyn std::fmt::Display { + fn foo() {} +} + +fn main() {} diff --git a/tests/ui/traits/trivial_impl_sized.stderr b/tests/ui/traits/trivial_impl_sized.stderr new file mode 100644 index 00000000000..ebf6dfc9dd2 --- /dev/null +++ b/tests/ui/traits/trivial_impl_sized.stderr @@ -0,0 +1,25 @@ +error[E0046]: not all trait items implemented, missing: `foo` + --> $DIR/trivial_impl_sized.rs:15:1 + | +LL | / fn foo() +LL | | where +LL | | Self: Sized; + | |____________________- `foo` from trait +... +LL | impl Foo for i32 {} + | ^^^^^^^^^^^^^^^^ missing `foo` in implementation + +error[E0046]: not all trait items implemented, missing: `foo` + --> $DIR/trivial_impl_sized.rs:19:1 + | +LL | / fn foo() +LL | | where +LL | | Self: Sized; + | |____________________- `foo` from trait +... +LL | impl Foo for dyn std::fmt::Debug {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `foo` in implementation + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0046`. |
