about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/crashes/123629.rs10
-rw-r--r--tests/crashes/127033.rs18
-rw-r--r--tests/crashes/129372.rs52
-rw-r--r--tests/rustdoc-js-std/parser-errors.js9
-rw-r--r--tests/rustdoc-js-std/parser-returned.js68
-rw-r--r--tests/rustdoc-js/never-search.js7
-rw-r--r--tests/ui/async-await/async-closures/tainted-body-2.rs18
-rw-r--r--tests/ui/async-await/async-closures/tainted-body-2.stderr9
-rw-r--r--tests/ui/async-await/async-closures/validate-synthetic-body.rs19
-rw-r--r--tests/ui/consts/const-float-bits-conv.rs5
-rw-r--r--tests/ui/consts/const-float-classify.rs1
-rw-r--r--tests/ui/consts/const-float-classify.stderr2
-rw-r--r--tests/ui/lexer/prefixed-lifetime.rs10
-rw-r--r--tests/ui/lexer/prefixed-lifetime.stderr14
-rw-r--r--tests/ui/lifetimes/raw/gen-lt.e2024.stderr8
-rw-r--r--tests/ui/lifetimes/raw/gen-lt.rs14
-rw-r--r--tests/ui/lifetimes/raw/lifetimes-eq.rs8
-rw-r--r--tests/ui/lifetimes/raw/macro-lt.rs12
-rw-r--r--tests/ui/lifetimes/raw/multiple-prefixes.rs6
-rw-r--r--tests/ui/lifetimes/raw/multiple-prefixes.stderr8
-rw-r--r--tests/ui/lifetimes/raw/prim-lt.rs8
-rw-r--r--tests/ui/lifetimes/raw/simple.rs21
-rw-r--r--tests/ui/lifetimes/raw/static-lt.rs8
-rw-r--r--tests/ui/lifetimes/raw/three-tokens.rs12
-rw-r--r--tests/ui/rust-2024/gen-kw.e2015.stderr11
-rw-r--r--tests/ui/rust-2024/gen-kw.e2018.stderr11
-rw-r--r--tests/ui/rust-2024/gen-kw.rs5
27 files changed, 358 insertions, 16 deletions
diff --git a/tests/crashes/123629.rs b/tests/crashes/123629.rs
new file mode 100644
index 00000000000..61532321806
--- /dev/null
+++ b/tests/crashes/123629.rs
@@ -0,0 +1,10 @@
+//@ known-bug: #123629
+#![feature(generic_assert)]
+
+fn foo()
+where
+    for<const N: usize = { assert!(u) }> ():,
+{
+}
+
+fn main() {}
diff --git a/tests/crashes/127033.rs b/tests/crashes/127033.rs
new file mode 100644
index 00000000000..919c9dfd30e
--- /dev/null
+++ b/tests/crashes/127033.rs
@@ -0,0 +1,18 @@
+//@ known-bug: #127033
+//@ compile-flags: --edition=2021
+
+pub trait RaftLogStorage {
+    fn save_vote(vote: ()) -> impl std::future::Future + Send;
+}
+
+struct X;
+impl RaftLogStorage for X {
+    fn save_vote(vote: ()) -> impl std::future::Future {
+        loop {}
+        async {
+            vote
+        }
+    }
+}
+
+fn main() {}
diff --git a/tests/crashes/129372.rs b/tests/crashes/129372.rs
new file mode 100644
index 00000000000..43be01b35df
--- /dev/null
+++ b/tests/crashes/129372.rs
@@ -0,0 +1,52 @@
+//@ known-bug: #129372
+//@ compile-flags: -Cdebuginfo=2 -Copt-level=0
+
+pub struct Wrapper<T>(T);
+struct Struct;
+
+pub trait TraitA {
+    type AssocA<'t>;
+}
+pub trait TraitB {
+    type AssocB;
+}
+
+pub fn helper(v: impl MethodTrait) {
+    let _local_that_causes_ice = v.method();
+}
+
+pub fn main() {
+    helper(Wrapper(Struct));
+}
+
+pub trait MethodTrait {
+    type Assoc<'a>;
+
+    fn method(self) -> impl for<'a> FnMut(&'a ()) -> Self::Assoc<'a>;
+}
+
+impl<T: TraitB> MethodTrait for T
+where
+    <T as TraitB>::AssocB: TraitA,
+{
+    type Assoc<'a> = <T::AssocB as TraitA>::AssocA<'a>;
+
+    fn method(self) -> impl for<'a> FnMut(&'a ()) -> Self::Assoc<'a> {
+        move |_| loop {}
+    }
+}
+
+impl<T, B> TraitB for Wrapper<B>
+where
+    B: TraitB<AssocB = T>,
+{
+    type AssocB = T;
+}
+
+impl TraitB for Struct {
+    type AssocB = Struct;
+}
+
+impl TraitA for Struct {
+    type AssocA<'t> = Self;
+}
diff --git a/tests/rustdoc-js-std/parser-errors.js b/tests/rustdoc-js-std/parser-errors.js
index c4d7c2b0b85..5ce35bf511d 100644
--- a/tests/rustdoc-js-std/parser-errors.js
+++ b/tests/rustdoc-js-std/parser-errors.js
@@ -252,15 +252,6 @@ const PARSED = [
         error: "Unexpected `'` after `b` (not a valid identifier)",
     },
     {
-        query: "a->",
-        elems: [],
-        foundElems: 0,
-        original: "a->",
-        returned: [],
-        userQuery: "a->",
-        error: "Expected at least one item after `->`",
-    },
-    {
         query: '"p" <a>',
         elems: [],
         foundElems: 0,
diff --git a/tests/rustdoc-js-std/parser-returned.js b/tests/rustdoc-js-std/parser-returned.js
index 44e517c49b5..8f68209bb96 100644
--- a/tests/rustdoc-js-std/parser-returned.js
+++ b/tests/rustdoc-js-std/parser-returned.js
@@ -94,4 +94,72 @@ const PARSED = [
         userQuery: "-> !",
         error: null,
     },
+    {
+        query: "a->",
+        elems: [{
+            name: "a",
+            fullPath: ["a"],
+            pathWithoutLast: [],
+            pathLast: "a",
+            generics: [],
+            typeFilter: -1,
+        }],
+        foundElems: 1,
+        original: "a->",
+        returned: [],
+        userQuery: "a->",
+        hasReturnArrow: true,
+        error: null,
+    },
+    {
+        query: "!->",
+        elems: [{
+            name: "never",
+            fullPath: ["never"],
+            pathWithoutLast: [],
+            pathLast: "never",
+            generics: [],
+            typeFilter: 1,
+        }],
+        foundElems: 1,
+        original: "!->",
+        returned: [],
+        userQuery: "!->",
+        hasReturnArrow: true,
+        error: null,
+    },
+    {
+        query: "! ->",
+        elems: [{
+            name: "never",
+            fullPath: ["never"],
+            pathWithoutLast: [],
+            pathLast: "never",
+            generics: [],
+            typeFilter: 1,
+        }],
+        foundElems: 1,
+        original: "! ->",
+        returned: [],
+        userQuery: "! ->",
+        hasReturnArrow: true,
+        error: null,
+    },
+    {
+        query: "primitive:!->",
+        elems: [{
+            name: "never",
+            fullPath: ["never"],
+            pathWithoutLast: [],
+            pathLast: "never",
+            generics: [],
+            typeFilter: 1,
+        }],
+        foundElems: 1,
+        original: "primitive:!->",
+        returned: [],
+        userQuery: "primitive:!->",
+        hasReturnArrow: true,
+        error: null,
+    },
 ];
diff --git a/tests/rustdoc-js/never-search.js b/tests/rustdoc-js/never-search.js
index 9f18370c2f5..9cc62a5ed04 100644
--- a/tests/rustdoc-js/never-search.js
+++ b/tests/rustdoc-js/never-search.js
@@ -2,6 +2,13 @@
 
 const EXPECTED = [
     {
+        'query': '! ->',
+        'others': [
+            { 'path': 'never_search', 'name': 'impossible' },
+            { 'path': 'never_search', 'name': 'box_impossible' },
+        ],
+    },
+    {
         'query': '-> !',
         'others': [
             { 'path': 'never_search', 'name': 'loops' },
diff --git a/tests/ui/async-await/async-closures/tainted-body-2.rs b/tests/ui/async-await/async-closures/tainted-body-2.rs
new file mode 100644
index 00000000000..73c6bdc30a0
--- /dev/null
+++ b/tests/ui/async-await/async-closures/tainted-body-2.rs
@@ -0,0 +1,18 @@
+//@ edition: 2021
+
+#![feature(async_closure)]
+
+// Ensure that building a by-ref async closure body doesn't ICE when the parent
+// body is tainted.
+
+fn main() {
+    missing;
+    //~^ ERROR cannot find value `missing` in this scope
+
+    // We don't do numerical inference fallback when the body is tainted.
+    // This leads to writeback folding the type of the coroutine-closure
+    // into an error type, since its signature contains that numerical
+    // infer var.
+    let c = async |_| {};
+    c(1);
+}
diff --git a/tests/ui/async-await/async-closures/tainted-body-2.stderr b/tests/ui/async-await/async-closures/tainted-body-2.stderr
new file mode 100644
index 00000000000..798d47064d9
--- /dev/null
+++ b/tests/ui/async-await/async-closures/tainted-body-2.stderr
@@ -0,0 +1,9 @@
+error[E0425]: cannot find value `missing` in this scope
+  --> $DIR/tainted-body-2.rs:9:5
+   |
+LL |     missing;
+   |     ^^^^^^^ not found in this scope
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0425`.
diff --git a/tests/ui/async-await/async-closures/validate-synthetic-body.rs b/tests/ui/async-await/async-closures/validate-synthetic-body.rs
new file mode 100644
index 00000000000..67e683ac08a
--- /dev/null
+++ b/tests/ui/async-await/async-closures/validate-synthetic-body.rs
@@ -0,0 +1,19 @@
+//@ check-pass
+//@ edition: 2021
+
+#![feature(async_closure)]
+
+// Make sure that we don't hit a query cycle when validating
+// the by-move coroutine body for an async closure.
+
+use std::future::Future;
+
+async fn test<Fut: Future>(operation: impl Fn() -> Fut) {
+    operation().await;
+}
+
+pub async fn orchestrate_simple_crud() {
+    test(async || async {}.await).await;
+}
+
+fn main() {}
diff --git a/tests/ui/consts/const-float-bits-conv.rs b/tests/ui/consts/const-float-bits-conv.rs
index 3a526c54dc3..869498d1076 100644
--- a/tests/ui/consts/const-float-bits-conv.rs
+++ b/tests/ui/consts/const-float-bits-conv.rs
@@ -1,10 +1,9 @@
 //@ compile-flags: -Zmir-opt-level=0
 //@ run-pass
 
-#![feature(const_float_bits_conv)]
 #![feature(const_float_classify)]
-#![feature(f16)]
-#![feature(f128)]
+#![feature(f16, f16_const)]
+#![feature(f128, f128_const)]
 #![allow(unused_macro_rules)]
 // Don't promote
 const fn nop<T>(x: T) -> T { x }
diff --git a/tests/ui/consts/const-float-classify.rs b/tests/ui/consts/const-float-classify.rs
index c64d31a5c60..6e5097f7f2b 100644
--- a/tests/ui/consts/const-float-classify.rs
+++ b/tests/ui/consts/const-float-classify.rs
@@ -2,7 +2,6 @@
 //@ known-bug: #110395
 // FIXME(effects) run-pass
 
-#![feature(const_float_bits_conv)]
 #![feature(const_float_classify)]
 #![feature(const_trait_impl, effects)]
 #![allow(incomplete_features)]
diff --git a/tests/ui/consts/const-float-classify.stderr b/tests/ui/consts/const-float-classify.stderr
index 38acb8a2281..a35de8ad0ea 100644
--- a/tests/ui/consts/const-float-classify.stderr
+++ b/tests/ui/consts/const-float-classify.stderr
@@ -1,5 +1,5 @@
 error: const `impl` for trait `PartialEq` which is not marked with `#[const_trait]`
-  --> $DIR/const-float-classify.rs:13:12
+  --> $DIR/const-float-classify.rs:12:12
    |
 LL | impl const PartialEq<NonDet> for bool {
    |            ^^^^^^^^^^^^^^^^^
diff --git a/tests/ui/lexer/prefixed-lifetime.rs b/tests/ui/lexer/prefixed-lifetime.rs
new file mode 100644
index 00000000000..6191b97d576
--- /dev/null
+++ b/tests/ui/lexer/prefixed-lifetime.rs
@@ -0,0 +1,10 @@
+//@ edition: 2021
+
+macro_rules! w {
+    ($($tt:tt)*) => {};
+}
+
+w!('foo#lifetime);
+//~^ ERROR prefix `'foo` is unknown
+
+fn main() {}
diff --git a/tests/ui/lexer/prefixed-lifetime.stderr b/tests/ui/lexer/prefixed-lifetime.stderr
new file mode 100644
index 00000000000..39e8b5a2a57
--- /dev/null
+++ b/tests/ui/lexer/prefixed-lifetime.stderr
@@ -0,0 +1,14 @@
+error: prefix `'foo` is unknown
+  --> $DIR/prefixed-lifetime.rs:7:4
+   |
+LL | w!('foo#lifetime);
+   |    ^^^^ unknown prefix
+   |
+   = note: prefixed identifiers and literals are reserved since Rust 2021
+help: consider inserting whitespace here
+   |
+LL | w!('foo #lifetime);
+   |        +
+
+error: aborting due to 1 previous error
+
diff --git a/tests/ui/lifetimes/raw/gen-lt.e2024.stderr b/tests/ui/lifetimes/raw/gen-lt.e2024.stderr
new file mode 100644
index 00000000000..232453df8ef
--- /dev/null
+++ b/tests/ui/lifetimes/raw/gen-lt.e2024.stderr
@@ -0,0 +1,8 @@
+error: lifetimes cannot use keyword names
+  --> $DIR/gen-lt.rs:11:11
+   |
+LL | fn gen_lt<'gen>() {}
+   |           ^^^^
+
+error: aborting due to 1 previous error
+
diff --git a/tests/ui/lifetimes/raw/gen-lt.rs b/tests/ui/lifetimes/raw/gen-lt.rs
new file mode 100644
index 00000000000..4f3ede5b4a2
--- /dev/null
+++ b/tests/ui/lifetimes/raw/gen-lt.rs
@@ -0,0 +1,14 @@
+//@ revisions: e2021 e2024
+
+//@[e2021] edition:2021
+//@[e2024] edition:2024
+//@[e2024] compile-flags: -Zunstable-options
+
+//@[e2021] check-pass
+
+fn raw_gen_lt<'r#gen>() {}
+
+fn gen_lt<'gen>() {}
+//[e2024]~^ ERROR lifetimes cannot use keyword names
+
+fn main() {}
diff --git a/tests/ui/lifetimes/raw/lifetimes-eq.rs b/tests/ui/lifetimes/raw/lifetimes-eq.rs
new file mode 100644
index 00000000000..dddafb829ba
--- /dev/null
+++ b/tests/ui/lifetimes/raw/lifetimes-eq.rs
@@ -0,0 +1,8 @@
+//@ edition: 2021
+//@ check-pass
+
+// Test that `'r#a` is `'a`.
+
+fn test<'r#a>(x: &'a ()) {}
+
+fn main() {}
diff --git a/tests/ui/lifetimes/raw/macro-lt.rs b/tests/ui/lifetimes/raw/macro-lt.rs
new file mode 100644
index 00000000000..d1167b00467
--- /dev/null
+++ b/tests/ui/lifetimes/raw/macro-lt.rs
@@ -0,0 +1,12 @@
+//@ check-pass
+//@ edition: 2021
+
+macro_rules! lifetime {
+    ($lt:lifetime) => {
+        fn hello<$lt>() {}
+    }
+}
+
+lifetime!('r#struct);
+
+fn main() {}
diff --git a/tests/ui/lifetimes/raw/multiple-prefixes.rs b/tests/ui/lifetimes/raw/multiple-prefixes.rs
new file mode 100644
index 00000000000..f335373d8a7
--- /dev/null
+++ b/tests/ui/lifetimes/raw/multiple-prefixes.rs
@@ -0,0 +1,6 @@
+//@ edition: 2021
+
+fn test(x: &'r#r#r ()) {}
+//~^ ERROR expected type, found `#`
+
+fn main() {}
diff --git a/tests/ui/lifetimes/raw/multiple-prefixes.stderr b/tests/ui/lifetimes/raw/multiple-prefixes.stderr
new file mode 100644
index 00000000000..8d5479e0a4f
--- /dev/null
+++ b/tests/ui/lifetimes/raw/multiple-prefixes.stderr
@@ -0,0 +1,8 @@
+error: expected type, found `#`
+  --> $DIR/multiple-prefixes.rs:3:17
+   |
+LL | fn test(x: &'r#r#r ()) {}
+   |                 ^ expected type
+
+error: aborting due to 1 previous error
+
diff --git a/tests/ui/lifetimes/raw/prim-lt.rs b/tests/ui/lifetimes/raw/prim-lt.rs
new file mode 100644
index 00000000000..ca45efb65fd
--- /dev/null
+++ b/tests/ui/lifetimes/raw/prim-lt.rs
@@ -0,0 +1,8 @@
+//@ check-pass
+//@ edition: 2021
+
+// Checks a primitive name can be defined as a lifetime.
+
+fn foo<'r#i32>() {}
+
+fn main() {}
diff --git a/tests/ui/lifetimes/raw/simple.rs b/tests/ui/lifetimes/raw/simple.rs
new file mode 100644
index 00000000000..6f70a272203
--- /dev/null
+++ b/tests/ui/lifetimes/raw/simple.rs
@@ -0,0 +1,21 @@
+//@ check-pass
+//@ edition: 2021
+
+fn foo<'r#struct>() {}
+
+fn hr<T>() where for<'r#struct> T: Into<&'r#struct ()> {}
+
+trait Foo<'r#struct> {}
+
+trait Bar<'r#struct> {
+    fn method(&'r#struct self) {}
+    fn method2(self: &'r#struct Self) {}
+}
+
+fn labeled() {
+    'r#struct: loop {
+        break 'r#struct;
+    }
+}
+
+fn main() {}
diff --git a/tests/ui/lifetimes/raw/static-lt.rs b/tests/ui/lifetimes/raw/static-lt.rs
new file mode 100644
index 00000000000..1fec7097dab
--- /dev/null
+++ b/tests/ui/lifetimes/raw/static-lt.rs
@@ -0,0 +1,8 @@
+//@ check-pass
+//@ edition: 2021
+
+// Makes sure that `'r#static` is `'static`
+
+const FOO: &'r#static str = "hello, world";
+
+fn main() {}
diff --git a/tests/ui/lifetimes/raw/three-tokens.rs b/tests/ui/lifetimes/raw/three-tokens.rs
new file mode 100644
index 00000000000..2ae54ebbcb5
--- /dev/null
+++ b/tests/ui/lifetimes/raw/three-tokens.rs
@@ -0,0 +1,12 @@
+//@ edition: 2015
+//@ check-pass
+// Ensure that we parse `'r#lt` as three tokens in edition 2015.
+
+macro_rules! ed2015 {
+    ('r # lt) => {};
+    ($lt:lifetime) => { compile_error!() };
+}
+
+ed2015!('r#lt);
+
+fn main() {}
diff --git a/tests/ui/rust-2024/gen-kw.e2015.stderr b/tests/ui/rust-2024/gen-kw.e2015.stderr
index b1074f77e00..ff552f663c7 100644
--- a/tests/ui/rust-2024/gen-kw.e2015.stderr
+++ b/tests/ui/rust-2024/gen-kw.e2015.stderr
@@ -31,5 +31,14 @@ LL |     () => { mod test { fn gen() {} } }
    = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2024!
    = note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
 
-error: aborting due to 3 previous errors
+error: `gen` is a keyword in the 2024 edition
+  --> $DIR/gen-kw.rs:25:9
+   |
+LL | fn test<'gen>() {}
+   |         ^^^^ help: you can use a raw identifier to stay compatible: `'r#gen`
+   |
+   = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2024!
+   = note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
+
+error: aborting due to 4 previous errors
 
diff --git a/tests/ui/rust-2024/gen-kw.e2018.stderr b/tests/ui/rust-2024/gen-kw.e2018.stderr
index b902cff7fdb..efa812069c3 100644
--- a/tests/ui/rust-2024/gen-kw.e2018.stderr
+++ b/tests/ui/rust-2024/gen-kw.e2018.stderr
@@ -31,5 +31,14 @@ LL |     () => { mod test { fn gen() {} } }
    = warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2024!
    = note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
 
-error: aborting due to 3 previous errors
+error: `gen` is a keyword in the 2024 edition
+  --> $DIR/gen-kw.rs:25:9
+   |
+LL | fn test<'gen>() {}
+   |         ^^^^ help: you can use a raw identifier to stay compatible: `'r#gen`
+   |
+   = warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2024!
+   = note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
+
+error: aborting due to 4 previous errors
 
diff --git a/tests/ui/rust-2024/gen-kw.rs b/tests/ui/rust-2024/gen-kw.rs
index 04251cbcac4..5a658470c0a 100644
--- a/tests/ui/rust-2024/gen-kw.rs
+++ b/tests/ui/rust-2024/gen-kw.rs
@@ -22,4 +22,9 @@ macro_rules! t {
     //[e2018]~| WARNING this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2024!
 }
 
+fn test<'gen>() {}
+//~^ ERROR `gen` is a keyword in the 2024 edition
+//[e2015]~| WARNING this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2024!
+//[e2018]~| WARNING this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2024!
+
 t!();