about summary refs log tree commit diff
path: root/tests/ui/unsized
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2024-07-31 22:39:40 +0000
committerEsteban Küber <esteban@kuber.com.ar>2024-08-08 17:35:40 +0000
commitf6767f7a68f42101e6820171c033565e0f3a807a (patch)
tree4a665d914a01652bf6d8df250aaa062bd0ce2042 /tests/ui/unsized
parentd3a393932eeafa4638ae22f5ecbc38bf38760d0e (diff)
downloadrust-f6767f7a68f42101e6820171c033565e0f3a807a.tar.gz
rust-f6767f7a68f42101e6820171c033565e0f3a807a.zip
Detect `*` operator on `!Sized` expression
```
error[E0277]: the size for values of type `str` cannot be known at compilation time
  --> $DIR/unsized-str-in-return-expr-arg-and-local.rs:15:9
   |
LL |     let x = *"";
   |         ^ doesn't have a size known at compile-time
   |
   = help: the trait `Sized` is not implemented for `str`
   = note: all local variables must have a statically known size
   = help: unsized locals are gated as an unstable feature
help: references are always `Sized`, even if they point to unsized data; consider not dereferencing the expression
   |
LL -     let x = *"";
LL +     let x = "";
   |
```
Diffstat (limited to 'tests/ui/unsized')
-rw-r--r--tests/ui/unsized/unsized6.stderr10
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/ui/unsized/unsized6.stderr b/tests/ui/unsized/unsized6.stderr
index 56e7f60f9ff..d406120efc5 100644
--- a/tests/ui/unsized/unsized6.stderr
+++ b/tests/ui/unsized/unsized6.stderr
@@ -123,6 +123,11 @@ help: consider removing the `?Sized` bound to make the type parameter `Sized`
 LL - fn f3<X: ?Sized>(x1: Box<X>, x2: Box<X>, x3: Box<X>) {
 LL + fn f3<X>(x1: Box<X>, x2: Box<X>, x3: Box<X>) {
    |
+help: references are always `Sized`, even if they point to unsized data; consider not dereferencing the expression
+   |
+LL -     let y = *x2;
+LL +     let y = x2;
+   |
 
 error[E0277]: the size for values of type `X` cannot be known at compilation time
   --> $DIR/unsized6.rs:26:10
@@ -177,6 +182,11 @@ help: consider removing the `?Sized` bound to make the type parameter `Sized`
 LL - fn f4<X: ?Sized + T>(x1: Box<X>, x2: Box<X>, x3: Box<X>) {
 LL + fn f4<X: T>(x1: Box<X>, x2: Box<X>, x3: Box<X>) {
    |
+help: references are always `Sized`, even if they point to unsized data; consider not dereferencing the expression
+   |
+LL -     let y = *x2;
+LL +     let y = x2;
+   |
 
 error[E0277]: the size for values of type `X` cannot be known at compilation time
   --> $DIR/unsized6.rs:34:10