about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/test/ui/const-generics/issues/issue-88119.rs35
-rw-r--r--src/test/ui/error-codes/E0604.stderr9
-rw-r--r--src/test/ui/error-festival.stderr9
-rw-r--r--src/test/ui/mismatched_types/cast-rfc0401.stderr9
4 files changed, 44 insertions, 18 deletions
diff --git a/src/test/ui/const-generics/issues/issue-88119.rs b/src/test/ui/const-generics/issues/issue-88119.rs
new file mode 100644
index 00000000000..70dfa7f708b
--- /dev/null
+++ b/src/test/ui/const-generics/issues/issue-88119.rs
@@ -0,0 +1,35 @@
+// check-pass
+
+#![allow(incomplete_features)]
+#![feature(const_trait_impl, generic_const_exprs)]
+
+trait ConstName {
+    const NAME_BYTES: &'static [u8];
+}
+
+impl const ConstName for u8 {
+    const NAME_BYTES: &'static [u8] = b"u8";
+}
+
+const fn name_len<T: ?Sized + ConstName>() -> usize {
+    T::NAME_BYTES.len()
+}
+
+impl<T: ?Sized + ConstName> const ConstName for &T
+where
+    [(); name_len::<T>()]:,
+{
+    const NAME_BYTES: &'static [u8] = b"&T";
+}
+
+impl<T: ?Sized + ConstName> const ConstName for &mut T
+where
+    [(); name_len::<T>()]:,
+{
+    const NAME_BYTES: &'static [u8] = b"&mut T";
+}
+
+pub const ICE_1: &'static [u8] = <&&mut u8 as ConstName>::NAME_BYTES;
+pub const ICE_2: &'static [u8] = <&mut &u8 as ConstName>::NAME_BYTES;
+
+fn main() {}
diff --git a/src/test/ui/error-codes/E0604.stderr b/src/test/ui/error-codes/E0604.stderr
index d715d28b73c..68da03928b7 100644
--- a/src/test/ui/error-codes/E0604.stderr
+++ b/src/test/ui/error-codes/E0604.stderr
@@ -2,13 +2,10 @@ error[E0604]: only `u8` can be cast as `char`, not `u32`
   --> $DIR/E0604.rs:2:5
    |
 LL |     1u32 as char;
-   |     ^^^^^^^^^^^^ invalid cast
-   |
-help: try `char::from_u32` instead
-  --> $DIR/E0604.rs:2:5
-   |
-LL |     1u32 as char;
    |     ^^^^^^^^^^^^
+   |     |
+   |     invalid cast
+   |     help: try `char::from_u32` instead: `char::from_u32(1u32)`
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/error-festival.stderr b/src/test/ui/error-festival.stderr
index 0ddb6fc99b0..81aa268cacc 100644
--- a/src/test/ui/error-festival.stderr
+++ b/src/test/ui/error-festival.stderr
@@ -57,13 +57,10 @@ error[E0604]: only `u8` can be cast as `char`, not `u32`
   --> $DIR/error-festival.rs:25:5
    |
 LL |     0u32 as char;
-   |     ^^^^^^^^^^^^ invalid cast
-   |
-help: try `char::from_u32` instead
-  --> $DIR/error-festival.rs:25:5
-   |
-LL |     0u32 as char;
    |     ^^^^^^^^^^^^
+   |     |
+   |     invalid cast
+   |     help: try `char::from_u32` instead: `char::from_u32(0u32)`
 
 error[E0605]: non-primitive cast: `u8` as `Vec<u8>`
   --> $DIR/error-festival.rs:29:5
diff --git a/src/test/ui/mismatched_types/cast-rfc0401.stderr b/src/test/ui/mismatched_types/cast-rfc0401.stderr
index 84220ea172a..3a508459cc0 100644
--- a/src/test/ui/mismatched_types/cast-rfc0401.stderr
+++ b/src/test/ui/mismatched_types/cast-rfc0401.stderr
@@ -98,13 +98,10 @@ error[E0604]: only `u8` can be cast as `char`, not `u32`
   --> $DIR/cast-rfc0401.rs:41:13
    |
 LL |     let _ = 0x61u32 as char;
-   |             ^^^^^^^^^^^^^^^ invalid cast
-   |
-help: try `char::from_u32` instead
-  --> $DIR/cast-rfc0401.rs:41:13
-   |
-LL |     let _ = 0x61u32 as char;
    |             ^^^^^^^^^^^^^^^
+   |             |
+   |             invalid cast
+   |             help: try `char::from_u32` instead: `char::from_u32(0x61u32)`
 
 error[E0606]: casting `bool` as `f32` is invalid
   --> $DIR/cast-rfc0401.rs:43:13