summaryrefslogtreecommitdiffstats
path: root/tests/ui/associated-inherent-types
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:31 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:31 +0000
commitdc0db358abe19481e475e10c32149b53370f1a1c (patch)
treeab8ce99c4b255ce46f99ef402c27916055b899ee /tests/ui/associated-inherent-types
parentReleasing progress-linux version 1.71.1+dfsg1-2~progress7.99u1. (diff)
downloadrustc-dc0db358abe19481e475e10c32149b53370f1a1c.tar.xz
rustc-dc0db358abe19481e475e10c32149b53370f1a1c.zip
Merging upstream version 1.72.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/associated-inherent-types')
-rw-r--r--tests/ui/associated-inherent-types/assoc-inherent-unstable.rs3
-rw-r--r--tests/ui/associated-inherent-types/assoc-inherent-unstable.stderr2
-rw-r--r--tests/ui/associated-inherent-types/bugs/cycle-iat-inside-of-adt.rs4
-rw-r--r--tests/ui/associated-inherent-types/bugs/cycle-iat-inside-of-adt.stderr40
-rw-r--r--tests/ui/associated-inherent-types/dont-select-if-disabled.rs17
-rw-r--r--tests/ui/associated-inherent-types/dont-select-if-disabled.stderr24
-rw-r--r--tests/ui/associated-inherent-types/issue-109071.no_gate.stderr41
-rw-r--r--tests/ui/associated-inherent-types/issue-109071.rs19
-rw-r--r--tests/ui/associated-inherent-types/issue-109071.with_gate.stderr26
-rw-r--r--tests/ui/associated-inherent-types/issue-109789.stderr4
-rw-r--r--tests/ui/associated-inherent-types/issue-111404-0.rs14
-rw-r--r--tests/ui/associated-inherent-types/issue-111404-1.rs13
-rw-r--r--tests/ui/associated-inherent-types/issue-111404-1.stderr8
-rw-r--r--tests/ui/associated-inherent-types/private-in-public.rs10
-rw-r--r--tests/ui/associated-inherent-types/private-in-public.stderr49
15 files changed, 243 insertions, 31 deletions
diff --git a/tests/ui/associated-inherent-types/assoc-inherent-unstable.rs b/tests/ui/associated-inherent-types/assoc-inherent-unstable.rs
index 34b4e47bf..152bb7a60 100644
--- a/tests/ui/associated-inherent-types/assoc-inherent-unstable.rs
+++ b/tests/ui/associated-inherent-types/assoc-inherent-unstable.rs
@@ -1,6 +1,9 @@
// aux-crate:aux=assoc-inherent-unstable.rs
// edition: 2021
+#![feature(inherent_associated_types)]
+#![allow(incomplete_features)]
+
type Data = aux::Owner::Data; //~ ERROR use of unstable library feature 'data'
fn main() {}
diff --git a/tests/ui/associated-inherent-types/assoc-inherent-unstable.stderr b/tests/ui/associated-inherent-types/assoc-inherent-unstable.stderr
index c0be8bfd7..415ee0193 100644
--- a/tests/ui/associated-inherent-types/assoc-inherent-unstable.stderr
+++ b/tests/ui/associated-inherent-types/assoc-inherent-unstable.stderr
@@ -1,5 +1,5 @@
error[E0658]: use of unstable library feature 'data'
- --> $DIR/assoc-inherent-unstable.rs:4:13
+ --> $DIR/assoc-inherent-unstable.rs:7:13
|
LL | type Data = aux::Owner::Data;
| ^^^^^^^^^^^^^^^^
diff --git a/tests/ui/associated-inherent-types/bugs/cycle-iat-inside-of-adt.rs b/tests/ui/associated-inherent-types/bugs/cycle-iat-inside-of-adt.rs
index f41574403..33c73c3db 100644
--- a/tests/ui/associated-inherent-types/bugs/cycle-iat-inside-of-adt.rs
+++ b/tests/ui/associated-inherent-types/bugs/cycle-iat-inside-of-adt.rs
@@ -1,5 +1,7 @@
// known-bug: #108491
+#![feature(inherent_associated_types)]
+#![allow(incomplete_features)]
// FIXME(inherent_associated_types): This should pass.
struct Foo {
@@ -8,3 +10,5 @@ struct Foo {
impl Foo {
pub type Bar = usize;
}
+
+fn main() {}
diff --git a/tests/ui/associated-inherent-types/bugs/cycle-iat-inside-of-adt.stderr b/tests/ui/associated-inherent-types/bugs/cycle-iat-inside-of-adt.stderr
index f313c4946..23269e1af 100644
--- a/tests/ui/associated-inherent-types/bugs/cycle-iat-inside-of-adt.stderr
+++ b/tests/ui/associated-inherent-types/bugs/cycle-iat-inside-of-adt.stderr
@@ -1,49 +1,43 @@
-error[E0601]: `main` function not found in crate `cycle_iat_inside_of_adt`
- --> $DIR/cycle-iat-inside-of-adt.rs:10:2
- |
-LL | }
- | ^ consider adding a `main` function to `$DIR/cycle-iat-inside-of-adt.rs`
-
error[E0391]: cycle detected when computing predicates of `Foo`
- --> $DIR/cycle-iat-inside-of-adt.rs:5:1
+ --> $DIR/cycle-iat-inside-of-adt.rs:7:1
|
LL | struct Foo {
| ^^^^^^^^^^
|
note: ...which requires computing predicates of `Foo`...
- --> $DIR/cycle-iat-inside-of-adt.rs:5:1
+ --> $DIR/cycle-iat-inside-of-adt.rs:7:1
|
LL | struct Foo {
| ^^^^^^^^^^
note: ...which requires computing inferred outlives predicates of `Foo`...
- --> $DIR/cycle-iat-inside-of-adt.rs:5:1
+ --> $DIR/cycle-iat-inside-of-adt.rs:7:1
|
LL | struct Foo {
| ^^^^^^^^^^
= note: ...which requires computing the inferred outlives predicates for items in this crate...
note: ...which requires computing type of `Foo::bar`...
- --> $DIR/cycle-iat-inside-of-adt.rs:6:5
+ --> $DIR/cycle-iat-inside-of-adt.rs:8:5
|
LL | bar: Self::Bar,
| ^^^^^^^^^^^^^^
note: ...which requires computing normalized predicates of `Foo`...
- --> $DIR/cycle-iat-inside-of-adt.rs:5:1
+ --> $DIR/cycle-iat-inside-of-adt.rs:7:1
|
LL | struct Foo {
| ^^^^^^^^^^
= note: ...which again requires computing predicates of `Foo`, completing the cycle
note: cycle used when collecting item types in top-level module
- --> $DIR/cycle-iat-inside-of-adt.rs:5:1
- |
-LL | / struct Foo {
-LL | | bar: Self::Bar,
-LL | | }
-LL | | impl Foo {
-LL | | pub type Bar = usize;
-LL | | }
- | |_^
+ --> $DIR/cycle-iat-inside-of-adt.rs:3:1
+ |
+LL | / #![feature(inherent_associated_types)]
+LL | | #![allow(incomplete_features)]
+LL | | // FIXME(inherent_associated_types): This should pass.
+LL | |
+... |
+LL | |
+LL | | fn main() {}
+ | |____________^
-error: aborting due to 2 previous errors
+error: aborting due to previous error
-Some errors have detailed explanations: E0391, E0601.
-For more information about an error, try `rustc --explain E0391`.
+For more information about this error, try `rustc --explain E0391`.
diff --git a/tests/ui/associated-inherent-types/dont-select-if-disabled.rs b/tests/ui/associated-inherent-types/dont-select-if-disabled.rs
new file mode 100644
index 000000000..472be4fbf
--- /dev/null
+++ b/tests/ui/associated-inherent-types/dont-select-if-disabled.rs
@@ -0,0 +1,17 @@
+// Regression test for #113265.
+
+// Don't perform selection if the feature is not enabled to prevent cycle errors
+// that exist due to current limitations of the implementation from masking the
+// feature-gate error. See the aforementioned issue.
+// This does lead to rustc not mentioning inherent associated types at usage-sites of
+// IATs that were defined in an external crate but that's acceptable for now.
+
+// FIXME(inherent_associated_types): Revisit this decision once the implementation is smarter.
+
+// The following program would currently lead to a cycle if IATs were enabled.
+
+struct S(S::P); //~ ERROR ambiguous associated type
+
+impl S { type P = (); } //~ ERROR inherent associated types are unstable
+
+fn main() {}
diff --git a/tests/ui/associated-inherent-types/dont-select-if-disabled.stderr b/tests/ui/associated-inherent-types/dont-select-if-disabled.stderr
new file mode 100644
index 000000000..87a3f35c9
--- /dev/null
+++ b/tests/ui/associated-inherent-types/dont-select-if-disabled.stderr
@@ -0,0 +1,24 @@
+error[E0223]: ambiguous associated type
+ --> $DIR/dont-select-if-disabled.rs:13:10
+ |
+LL | struct S(S::P);
+ | ^^^^
+ |
+help: if there were a trait named `Example` with associated type `P` implemented for `S`, you could use the fully-qualified path
+ |
+LL | struct S(<S as Example>::P);
+ | ~~~~~~~~~~~~~~~~~
+
+error[E0658]: inherent associated types are unstable
+ --> $DIR/dont-select-if-disabled.rs:15:10
+ |
+LL | impl S { type P = (); }
+ | ^^^^^^^^^^^^
+ |
+ = note: see issue #8995 <https://github.com/rust-lang/rust/issues/8995> for more information
+ = help: add `#![feature(inherent_associated_types)]` to the crate attributes to enable
+
+error: aborting due to 2 previous errors
+
+Some errors have detailed explanations: E0223, E0658.
+For more information about an error, try `rustc --explain E0223`.
diff --git a/tests/ui/associated-inherent-types/issue-109071.no_gate.stderr b/tests/ui/associated-inherent-types/issue-109071.no_gate.stderr
new file mode 100644
index 000000000..6f206f2b8
--- /dev/null
+++ b/tests/ui/associated-inherent-types/issue-109071.no_gate.stderr
@@ -0,0 +1,41 @@
+error[E0637]: `&` without an explicit lifetime name cannot be used here
+ --> $DIR/issue-109071.rs:8:17
+ |
+LL | type Item = &[T];
+ | ^ explicit lifetime name needed here
+
+error[E0107]: missing generics for struct `Windows`
+ --> $DIR/issue-109071.rs:7:9
+ |
+LL | impl<T> Windows {
+ | ^^^^^^^ expected 1 generic argument
+ |
+note: struct defined here, with 1 generic parameter: `T`
+ --> $DIR/issue-109071.rs:5:8
+ |
+LL | struct Windows<T> {}
+ | ^^^^^^^ -
+help: add missing generic argument
+ |
+LL | impl<T> Windows<T> {
+ | +++
+
+error[E0658]: inherent associated types are unstable
+ --> $DIR/issue-109071.rs:8:5
+ |
+LL | type Item = &[T];
+ | ^^^^^^^^^^^^^^^^^
+ |
+ = note: see issue #8995 <https://github.com/rust-lang/rust/issues/8995> for more information
+ = help: add `#![feature(inherent_associated_types)]` to the crate attributes to enable
+
+error[E0223]: ambiguous associated type
+ --> $DIR/issue-109071.rs:15:22
+ |
+LL | fn T() -> Option<Self::Item> {}
+ | ^^^^^^^^^^ help: use the fully-qualified path: `<Windows<T> as IntoIterator>::Item`
+
+error: aborting due to 4 previous errors
+
+Some errors have detailed explanations: E0107, E0223, E0637, E0658.
+For more information about an error, try `rustc --explain E0107`.
diff --git a/tests/ui/associated-inherent-types/issue-109071.rs b/tests/ui/associated-inherent-types/issue-109071.rs
new file mode 100644
index 000000000..951c708e3
--- /dev/null
+++ b/tests/ui/associated-inherent-types/issue-109071.rs
@@ -0,0 +1,19 @@
+// revisions: with_gate no_gate
+#![cfg_attr(with_gate, feature(inherent_associated_types))]
+#![cfg_attr(with_gate, allow(incomplete_features))]
+
+struct Windows<T> {}
+
+impl<T> Windows { //~ ERROR: missing generics for struct `Windows`
+ type Item = &[T]; //~ ERROR: `&` without an explicit lifetime name cannot be used here
+ //[no_gate]~^ ERROR: inherent associated types are unstable
+
+ fn next() -> Option<Self::Item> {}
+}
+
+impl<T> Windows<T> {
+ fn T() -> Option<Self::Item> {}
+ //[no_gate]~^ ERROR: ambiguous associated type
+}
+
+fn main() {}
diff --git a/tests/ui/associated-inherent-types/issue-109071.with_gate.stderr b/tests/ui/associated-inherent-types/issue-109071.with_gate.stderr
new file mode 100644
index 000000000..a91bb7a51
--- /dev/null
+++ b/tests/ui/associated-inherent-types/issue-109071.with_gate.stderr
@@ -0,0 +1,26 @@
+error[E0637]: `&` without an explicit lifetime name cannot be used here
+ --> $DIR/issue-109071.rs:8:17
+ |
+LL | type Item = &[T];
+ | ^ explicit lifetime name needed here
+
+error[E0107]: missing generics for struct `Windows`
+ --> $DIR/issue-109071.rs:7:9
+ |
+LL | impl<T> Windows {
+ | ^^^^^^^ expected 1 generic argument
+ |
+note: struct defined here, with 1 generic parameter: `T`
+ --> $DIR/issue-109071.rs:5:8
+ |
+LL | struct Windows<T> {}
+ | ^^^^^^^ -
+help: add missing generic argument
+ |
+LL | impl<T> Windows<T> {
+ | +++
+
+error: aborting due to 2 previous errors
+
+Some errors have detailed explanations: E0107, E0637.
+For more information about an error, try `rustc --explain E0107`.
diff --git a/tests/ui/associated-inherent-types/issue-109789.stderr b/tests/ui/associated-inherent-types/issue-109789.stderr
index 7af338274..84fc85cd0 100644
--- a/tests/ui/associated-inherent-types/issue-109789.stderr
+++ b/tests/ui/associated-inherent-types/issue-109789.stderr
@@ -1,8 +1,8 @@
error[E0308]: mismatched types
- --> $DIR/issue-109789.rs:18:1
+ --> $DIR/issue-109789.rs:18:11
|
LL | fn bar(_: Foo<for<'a> fn(&'a ())>::Assoc) {}
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other
|
= note: expected struct `Foo<fn(&'static ())>`
found struct `Foo<for<'a> fn(&'a ())>`
diff --git a/tests/ui/associated-inherent-types/issue-111404-0.rs b/tests/ui/associated-inherent-types/issue-111404-0.rs
new file mode 100644
index 000000000..1180577bd
--- /dev/null
+++ b/tests/ui/associated-inherent-types/issue-111404-0.rs
@@ -0,0 +1,14 @@
+// check-pass
+
+#![feature(inherent_associated_types)]
+#![allow(incomplete_features)]
+
+struct Foo<T>(T);
+
+impl<'a> Foo<fn(&'a ())> {
+ type Assoc = &'a ();
+}
+
+fn bar(_: for<'a> fn(Foo<fn(Foo<fn(&'a ())>::Assoc)>::Assoc)) {}
+
+fn main() {}
diff --git a/tests/ui/associated-inherent-types/issue-111404-1.rs b/tests/ui/associated-inherent-types/issue-111404-1.rs
new file mode 100644
index 000000000..f4ad5d7ff
--- /dev/null
+++ b/tests/ui/associated-inherent-types/issue-111404-1.rs
@@ -0,0 +1,13 @@
+#![feature(inherent_associated_types)]
+#![allow(incomplete_features)]
+
+struct Foo<T>(T);
+
+impl<'a> Foo<fn(&'a ())> {
+ type Assoc = &'a ();
+}
+
+fn bar(_: fn(Foo<for<'b> fn(Foo<fn(&'b ())>::Assoc)>::Assoc)) {}
+//~^ ERROR higher-ranked subtype error
+
+fn main() {}
diff --git a/tests/ui/associated-inherent-types/issue-111404-1.stderr b/tests/ui/associated-inherent-types/issue-111404-1.stderr
new file mode 100644
index 000000000..c55f14323
--- /dev/null
+++ b/tests/ui/associated-inherent-types/issue-111404-1.stderr
@@ -0,0 +1,8 @@
+error: higher-ranked subtype error
+ --> $DIR/issue-111404-1.rs:10:1
+ |
+LL | fn bar(_: fn(Foo<for<'b> fn(Foo<fn(&'b ())>::Assoc)>::Assoc)) {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
diff --git a/tests/ui/associated-inherent-types/private-in-public.rs b/tests/ui/associated-inherent-types/private-in-public.rs
index a4b372537..e9e189f95 100644
--- a/tests/ui/associated-inherent-types/private-in-public.rs
+++ b/tests/ui/associated-inherent-types/private-in-public.rs
@@ -1,18 +1,26 @@
#![feature(inherent_associated_types)]
+#![feature(type_privacy_lints)]
#![allow(incomplete_features)]
#![crate_type = "lib"]
-
#![deny(private_in_public)]
+#![warn(private_interfaces)]
+
+// In this test both old and new private-in-public diagnostic were emitted.
+// Old diagnostic will be deleted soon.
+// See https://rust-lang.github.io/rfcs/2145-type-privacy.html.
pub type PubAlias0 = PubTy::PrivAssocTy;
//~^ ERROR private associated type `PubTy::PrivAssocTy` in public interface (error E0446)
//~| WARNING this was previously accepted
+//~| WARNING associated type `PubTy::PrivAssocTy` is more private than the item `PubAlias0`
pub type PubAlias1 = PrivTy::PubAssocTy;
//~^ ERROR private type `PrivTy` in public interface (error E0446)
//~| WARNING this was previously accepted
+//~| WARNING type `PrivTy` is more private than the item `PubAlias1`
pub type PubAlias2 = PubTy::PubAssocTy<PrivTy>;
//~^ ERROR private type `PrivTy` in public interface (error E0446)
//~| WARNING this was previously accepted
+//~| WARNING type `PrivTy` is more private than the item `PubAlias2`
pub struct PubTy;
impl PubTy {
diff --git a/tests/ui/associated-inherent-types/private-in-public.stderr b/tests/ui/associated-inherent-types/private-in-public.stderr
index f0a64e961..65d187c1b 100644
--- a/tests/ui/associated-inherent-types/private-in-public.stderr
+++ b/tests/ui/associated-inherent-types/private-in-public.stderr
@@ -1,5 +1,5 @@
error: private associated type `PubTy::PrivAssocTy` in public interface (error E0446)
- --> $DIR/private-in-public.rs:7:1
+ --> $DIR/private-in-public.rs:12:1
|
LL | pub type PubAlias0 = PubTy::PrivAssocTy;
| ^^^^^^^^^^^^^^^^^^
@@ -12,8 +12,25 @@ note: the lint level is defined here
LL | #![deny(private_in_public)]
| ^^^^^^^^^^^^^^^^^
+warning: associated type `PubTy::PrivAssocTy` is more private than the item `PubAlias0`
+ --> $DIR/private-in-public.rs:12:1
+ |
+LL | pub type PubAlias0 = PubTy::PrivAssocTy;
+ | ^^^^^^^^^^^^^^^^^^ type alias `PubAlias0` is reachable at visibility `pub`
+ |
+note: but associated type `PubTy::PrivAssocTy` is only usable at visibility `pub(crate)`
+ --> $DIR/private-in-public.rs:27:5
+ |
+LL | type PrivAssocTy = ();
+ | ^^^^^^^^^^^^^^^^
+note: the lint level is defined here
+ --> $DIR/private-in-public.rs:6:9
+ |
+LL | #![warn(private_interfaces)]
+ | ^^^^^^^^^^^^^^^^^^
+
error: private type `PrivTy` in public interface (error E0446)
- --> $DIR/private-in-public.rs:10:1
+ --> $DIR/private-in-public.rs:16:1
|
LL | pub type PubAlias1 = PrivTy::PubAssocTy;
| ^^^^^^^^^^^^^^^^^^
@@ -21,8 +38,20 @@ LL | pub type PubAlias1 = PrivTy::PubAssocTy;
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
+warning: type `PrivTy` is more private than the item `PubAlias1`
+ --> $DIR/private-in-public.rs:16:1
+ |
+LL | pub type PubAlias1 = PrivTy::PubAssocTy;
+ | ^^^^^^^^^^^^^^^^^^ type alias `PubAlias1` is reachable at visibility `pub`
+ |
+note: but type `PrivTy` is only usable at visibility `pub(crate)`
+ --> $DIR/private-in-public.rs:31:1
+ |
+LL | struct PrivTy;
+ | ^^^^^^^^^^^^^
+
error: private type `PrivTy` in public interface (error E0446)
- --> $DIR/private-in-public.rs:13:1
+ --> $DIR/private-in-public.rs:20:1
|
LL | pub type PubAlias2 = PubTy::PubAssocTy<PrivTy>;
| ^^^^^^^^^^^^^^^^^^
@@ -30,5 +59,17 @@ LL | pub type PubAlias2 = PubTy::PubAssocTy<PrivTy>;
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
-error: aborting due to 3 previous errors
+warning: type `PrivTy` is more private than the item `PubAlias2`
+ --> $DIR/private-in-public.rs:20:1
+ |
+LL | pub type PubAlias2 = PubTy::PubAssocTy<PrivTy>;
+ | ^^^^^^^^^^^^^^^^^^ type alias `PubAlias2` is reachable at visibility `pub`
+ |
+note: but type `PrivTy` is only usable at visibility `pub(crate)`
+ --> $DIR/private-in-public.rs:31:1
+ |
+LL | struct PrivTy;
+ | ^^^^^^^^^^^^^
+
+error: aborting due to 3 previous errors; 3 warnings emitted