about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/ui/attributes/macro_export_on_decl_macro.rs9
-rw-r--r--tests/ui/attributes/macro_export_on_decl_macro.stderr16
-rw-r--r--tests/ui/for/issue-20605.next.stderr12
-rw-r--r--tests/ui/lazy-type-alias/auxiliary/eager.rs6
-rw-r--r--tests/ui/lazy-type-alias/auxiliary/lazy.rs4
-rw-r--r--tests/ui/lazy-type-alias/coerce-behind-lazy.current.stderr11
-rw-r--r--tests/ui/lazy-type-alias/coerce-behind-lazy.next.stderr11
-rw-r--r--tests/ui/lazy-type-alias/coerce-behind-lazy.rs16
-rw-r--r--tests/ui/lazy-type-alias/extern-crate-has-eager-type-aliases.rs23
-rw-r--r--tests/ui/lazy-type-alias/extern-crate-has-lazy-type-aliases.locally_eager.stderr15
-rw-r--r--tests/ui/lazy-type-alias/extern-crate-has-lazy-type-aliases.locally_lazy.stderr15
-rw-r--r--tests/ui/lazy-type-alias/extern-crate-has-lazy-type-aliases.rs16
-rw-r--r--tests/ui/traits/new-solver/lazy-nested-obligations-2.rs2
-rw-r--r--tests/ui/traits/new-solver/lazy-nested-obligations-2.stderr39
-rw-r--r--tests/ui/traits/new-solver/more-object-bound.stderr4
15 files changed, 151 insertions, 48 deletions
diff --git a/tests/ui/attributes/macro_export_on_decl_macro.rs b/tests/ui/attributes/macro_export_on_decl_macro.rs
new file mode 100644
index 00000000000..e6fe66ac6c3
--- /dev/null
+++ b/tests/ui/attributes/macro_export_on_decl_macro.rs
@@ -0,0 +1,9 @@
+// Using #[macro_export] on a decl macro has no effect and should warn
+
+#![feature(decl_macro)]
+#![deny(unused)]
+
+#[macro_export] //~ ERROR `#[macro_export]` has no effect on declarative macro definitions
+pub macro foo() {}
+
+fn main() {}
diff --git a/tests/ui/attributes/macro_export_on_decl_macro.stderr b/tests/ui/attributes/macro_export_on_decl_macro.stderr
new file mode 100644
index 00000000000..565e07919bc
--- /dev/null
+++ b/tests/ui/attributes/macro_export_on_decl_macro.stderr
@@ -0,0 +1,16 @@
+error: `#[macro_export]` has no effect on declarative macro definitions
+  --> $DIR/macro_export_on_decl_macro.rs:6:1
+   |
+LL | #[macro_export]
+   | ^^^^^^^^^^^^^^^
+   |
+   = note: declarative macros follow the same exporting rules as regular items
+note: the lint level is defined here
+  --> $DIR/macro_export_on_decl_macro.rs:4:9
+   |
+LL | #![deny(unused)]
+   |         ^^^^^^
+   = note: `#[deny(unused_attributes)]` implied by `#[deny(unused)]`
+
+error: aborting due to previous error
+
diff --git a/tests/ui/for/issue-20605.next.stderr b/tests/ui/for/issue-20605.next.stderr
index d55efedfcbe..0955efdbb73 100644
--- a/tests/ui/for/issue-20605.next.stderr
+++ b/tests/ui/for/issue-20605.next.stderr
@@ -34,12 +34,6 @@ error: the type `&mut <dyn Iterator<Item = &'a mut u8> as IntoIterator>::IntoIte
 LL |     for item in *things { *item = 0 }
    |                 ^^^^^^^
 
-error[E0614]: type `<<dyn Iterator<Item = &'a mut u8> as IntoIterator>::IntoIter as Iterator>::Item` cannot be dereferenced
-  --> $DIR/issue-20605.rs:5:27
-   |
-LL |     for item in *things { *item = 0 }
-   |                           ^^^^^
-
 error[E0277]: the size for values of type `<<dyn Iterator<Item = &'a mut u8> as IntoIterator>::IntoIter as Iterator>::Item` cannot be known at compilation time
   --> $DIR/issue-20605.rs:5:9
    |
@@ -66,6 +60,12 @@ LL |     for item in *things { *item = 0 }
 note: required by a bound in `None`
   --> $SRC_DIR/core/src/option.rs:LL:COL
 
+error[E0614]: type `<<dyn Iterator<Item = &'a mut u8> as IntoIterator>::IntoIter as Iterator>::Item` cannot be dereferenced
+  --> $DIR/issue-20605.rs:5:27
+   |
+LL |     for item in *things { *item = 0 }
+   |                           ^^^^^
+
 error: aborting due to 9 previous errors
 
 Some errors have detailed explanations: E0277, E0614.
diff --git a/tests/ui/lazy-type-alias/auxiliary/eager.rs b/tests/ui/lazy-type-alias/auxiliary/eager.rs
new file mode 100644
index 00000000000..8793a1701ec
--- /dev/null
+++ b/tests/ui/lazy-type-alias/auxiliary/eager.rs
@@ -0,0 +1,6 @@
+// This crate does *not* have lazy type aliases enabled.
+
+#![allow(type_alias_bounds)]
+
+// The `Copy` bound is ignored both locally and externally for backward compatibility.
+pub type Alias<T: Copy> = Option<T>;
diff --git a/tests/ui/lazy-type-alias/auxiliary/lazy.rs b/tests/ui/lazy-type-alias/auxiliary/lazy.rs
new file mode 100644
index 00000000000..caa7999b4f7
--- /dev/null
+++ b/tests/ui/lazy-type-alias/auxiliary/lazy.rs
@@ -0,0 +1,4 @@
+#![feature(lazy_type_alias)]
+#![allow(incomplete_features)]
+
+pub type Alias<T: Copy> = Option<T>;
diff --git a/tests/ui/lazy-type-alias/coerce-behind-lazy.current.stderr b/tests/ui/lazy-type-alias/coerce-behind-lazy.current.stderr
new file mode 100644
index 00000000000..98b3921dec4
--- /dev/null
+++ b/tests/ui/lazy-type-alias/coerce-behind-lazy.current.stderr
@@ -0,0 +1,11 @@
+warning: the feature `lazy_type_alias` is incomplete and may not be safe to use and/or cause compiler crashes
+  --> $DIR/coerce-behind-lazy.rs:5:12
+   |
+LL | #![feature(lazy_type_alias)]
+   |            ^^^^^^^^^^^^^^^
+   |
+   = note: see issue #112792 <https://github.com/rust-lang/rust/issues/112792> for more information
+   = note: `#[warn(incomplete_features)]` on by default
+
+warning: 1 warning emitted
+
diff --git a/tests/ui/lazy-type-alias/coerce-behind-lazy.next.stderr b/tests/ui/lazy-type-alias/coerce-behind-lazy.next.stderr
new file mode 100644
index 00000000000..98b3921dec4
--- /dev/null
+++ b/tests/ui/lazy-type-alias/coerce-behind-lazy.next.stderr
@@ -0,0 +1,11 @@
+warning: the feature `lazy_type_alias` is incomplete and may not be safe to use and/or cause compiler crashes
+  --> $DIR/coerce-behind-lazy.rs:5:12
+   |
+LL | #![feature(lazy_type_alias)]
+   |            ^^^^^^^^^^^^^^^
+   |
+   = note: see issue #112792 <https://github.com/rust-lang/rust/issues/112792> for more information
+   = note: `#[warn(incomplete_features)]` on by default
+
+warning: 1 warning emitted
+
diff --git a/tests/ui/lazy-type-alias/coerce-behind-lazy.rs b/tests/ui/lazy-type-alias/coerce-behind-lazy.rs
new file mode 100644
index 00000000000..745eadb9625
--- /dev/null
+++ b/tests/ui/lazy-type-alias/coerce-behind-lazy.rs
@@ -0,0 +1,16 @@
+// check-pass
+// revisions: current next
+//[next] compile-flags: -Ztrait-solver=next
+
+#![feature(lazy_type_alias)]
+//~^ WARN the feature `lazy_type_alias` is incomplete
+
+use std::any::Any;
+
+type Coerce = Box<dyn Any>;
+
+fn test() -> Coerce {
+    Box::new(1)
+}
+
+fn main() {}
diff --git a/tests/ui/lazy-type-alias/extern-crate-has-eager-type-aliases.rs b/tests/ui/lazy-type-alias/extern-crate-has-eager-type-aliases.rs
new file mode 100644
index 00000000000..07389961c4c
--- /dev/null
+++ b/tests/ui/lazy-type-alias/extern-crate-has-eager-type-aliases.rs
@@ -0,0 +1,23 @@
+// This test serves as a regression test for issue #114468 and it also ensures that we consider
+// type aliases from external crates that don't have `lazy_type_alias` enabled to be eager.
+
+// aux-crate:eager=eager.rs
+// edition: 2021
+// check-pass
+
+#![feature(lazy_type_alias)]
+#![allow(incomplete_features)]
+
+// This used to crash when we were computing the variances of `Struct` since we would convert
+// `eager::Alias<T>` to a weak projection due to the presence of `#![feature(lazy_type_alias)]` in
+// this (!) crate and subsequently attempt to obtain the variances of the type alias associated with
+// the weak projection which would panic because we don't compute this information for eager type
+// aliases at all.
+struct Struct<T>(eager::Alias<T>);
+
+fn main() {
+    // We want to ignore (or rather “end up ignoring”) the bound `T: Copy` since `Alias` should be
+    // treated as an eager type alias not just inside the crate it is defined in but also in
+    // dependent crates (like this one).
+    let _: eager::Alias<String>;
+}
diff --git a/tests/ui/lazy-type-alias/extern-crate-has-lazy-type-aliases.locally_eager.stderr b/tests/ui/lazy-type-alias/extern-crate-has-lazy-type-aliases.locally_eager.stderr
new file mode 100644
index 00000000000..9e0e2bfa872
--- /dev/null
+++ b/tests/ui/lazy-type-alias/extern-crate-has-lazy-type-aliases.locally_eager.stderr
@@ -0,0 +1,15 @@
+error[E0277]: the trait bound `String: Copy` is not satisfied
+  --> $DIR/extern-crate-has-lazy-type-aliases.rs:15:12
+   |
+LL |     let _: lazy::Alias<String>;
+   |            ^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `String`
+   |
+note: required by a bound on the type alias `Alias`
+  --> $DIR/auxiliary/lazy.rs:4:19
+   |
+LL | pub type Alias<T: Copy> = Option<T>;
+   |                   ^^^^ required by this bound
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/lazy-type-alias/extern-crate-has-lazy-type-aliases.locally_lazy.stderr b/tests/ui/lazy-type-alias/extern-crate-has-lazy-type-aliases.locally_lazy.stderr
new file mode 100644
index 00000000000..9e0e2bfa872
--- /dev/null
+++ b/tests/ui/lazy-type-alias/extern-crate-has-lazy-type-aliases.locally_lazy.stderr
@@ -0,0 +1,15 @@
+error[E0277]: the trait bound `String: Copy` is not satisfied
+  --> $DIR/extern-crate-has-lazy-type-aliases.rs:15:12
+   |
+LL |     let _: lazy::Alias<String>;
+   |            ^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `String`
+   |
+note: required by a bound on the type alias `Alias`
+  --> $DIR/auxiliary/lazy.rs:4:19
+   |
+LL | pub type Alias<T: Copy> = Option<T>;
+   |                   ^^^^ required by this bound
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/lazy-type-alias/extern-crate-has-lazy-type-aliases.rs b/tests/ui/lazy-type-alias/extern-crate-has-lazy-type-aliases.rs
new file mode 100644
index 00000000000..31a19161b6c
--- /dev/null
+++ b/tests/ui/lazy-type-alias/extern-crate-has-lazy-type-aliases.rs
@@ -0,0 +1,16 @@
+// revisions: locally_eager locally_lazy
+// aux-crate:lazy=lazy.rs
+// edition: 2021
+
+// Test that we treat lazy type aliases from external crates as lazy independently of whether the
+// local crate enables `lazy_type_alias` or not.
+
+#![cfg_attr(
+    locally_lazy,
+    feature(lazy_type_alias),
+    allow(incomplete_features)
+)]
+
+fn main() {
+    let _: lazy::Alias<String>; //~ ERROR the trait bound `String: Copy` is not satisfied
+}
diff --git a/tests/ui/traits/new-solver/lazy-nested-obligations-2.rs b/tests/ui/traits/new-solver/lazy-nested-obligations-2.rs
index fd91d81cdf0..20f504928c7 100644
--- a/tests/ui/traits/new-solver/lazy-nested-obligations-2.rs
+++ b/tests/ui/traits/new-solver/lazy-nested-obligations-2.rs
@@ -1,5 +1,5 @@
 // compile-flags: -Ztrait-solver=next
-// known-bug: #95863
+// check-pass
 
 pub trait With {
     type F;
diff --git a/tests/ui/traits/new-solver/lazy-nested-obligations-2.stderr b/tests/ui/traits/new-solver/lazy-nested-obligations-2.stderr
deleted file mode 100644
index d0a4cd661b3..00000000000
--- a/tests/ui/traits/new-solver/lazy-nested-obligations-2.stderr
+++ /dev/null
@@ -1,39 +0,0 @@
-error[E0308]: mismatched types
-  --> $DIR/lazy-nested-obligations-2.rs:15:23
-   |
-LL |     let _: V<i32> = V(f);
-   |                     - ^ types differ
-   |                     |
-   |                     arguments to this struct are incorrect
-   |
-   = note: expected associated type `<i32 as With>::F`
-                      found fn item `for<'a> fn(&'a str) {f}`
-   = help: consider constraining the associated type `<i32 as With>::F` to `for<'a> fn(&'a str) {f}` or calling a method that returns `<i32 as With>::F`
-   = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
-note: tuple struct defined here
-  --> $DIR/lazy-nested-obligations-2.rs:16:16
-   |
-LL |     pub struct V<T: With>(<T as With>::F);
-   |                ^
-
-error[E0308]: mismatched types
-  --> $DIR/lazy-nested-obligations-2.rs:21:30
-   |
-LL |     let _: E3<i32> = E3::Var(f);
-   |                      ------- ^ types differ
-   |                      |
-   |                      arguments to this enum variant are incorrect
-   |
-   = note: expected associated type `<i32 as With>::F`
-                      found fn item `for<'a> fn(&'a str) {f}`
-   = help: consider constraining the associated type `<i32 as With>::F` to `for<'a> fn(&'a str) {f}` or calling a method that returns `<i32 as With>::F`
-   = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
-note: tuple variant defined here
-  --> $DIR/lazy-nested-obligations-2.rs:19:9
-   |
-LL |         Var(<T as With>::F),
-   |         ^^^
-
-error: aborting due to 2 previous errors
-
-For more information about this error, try `rustc --explain E0308`.
diff --git a/tests/ui/traits/new-solver/more-object-bound.stderr b/tests/ui/traits/new-solver/more-object-bound.stderr
index 4554b8c7473..54965dee184 100644
--- a/tests/ui/traits/new-solver/more-object-bound.stderr
+++ b/tests/ui/traits/new-solver/more-object-bound.stderr
@@ -1,8 +1,8 @@
 error[E0277]: the trait bound `dyn Trait<A = A, B = B>: Trait` is not satisfied
-  --> $DIR/more-object-bound.rs:12:17
+  --> $DIR/more-object-bound.rs:12:5
    |
 LL |     foo::<A, B, dyn Trait<A = A, B = B>>(x)
-   |                 ^^^^^^^^^^^^^^^^^^^^^^^ the trait `Trait` is not implemented for `dyn Trait<A = A, B = B>`
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Trait` is not implemented for `dyn Trait<A = A, B = B>`
    |
 note: required by a bound in `foo`
   --> $DIR/more-object-bound.rs:18:8