From cf7a03612592b83de388cb9ea575e88955866fa8 Mon Sep 17 00:00:00 2001 From: Gurinder Singh Date: Mon, 4 Mar 2024 17:18:19 +0530 Subject: [PATCH] Fix tuple element tys returned from sized_conditions() Instead of returning the type of only the last element we return the types of all elements. Without it in some situations we were allowing typeck to succeed for tuples which have an unsized element at a non-last position. --- .../src/traits/select/mod.rs | 4 +- tests/ui/dst/dst-bad-deep-2.rs | 2 +- tests/ui/layout/issue-84108.rs | 1 + tests/ui/layout/issue-84108.stderr | 12 +- .../ice-unsized-tuple-const-issue-121443.rs | 16 +++ ...ce-unsized-tuple-const-issue-121443.stderr | 46 ++++++++ tests/ui/trait-bounds/unsized-bound.stderr | 106 ++++++++++++------ tests/ui/unsized/unsized3.rs | 1 + tests/ui/unsized/unsized3.stderr | 44 +++++++- tests/ui/unsized/unsized6.rs | 2 + tests/ui/unsized/unsized6.stderr | 46 +++++++- 11 files changed, 228 insertions(+), 52 deletions(-) create mode 100644 tests/ui/trait-bounds/ice-unsized-tuple-const-issue-121443.rs create mode 100644 tests/ui/trait-bounds/ice-unsized-tuple-const-issue-121443.stderr diff --git a/compiler/rustc_trait_selection/src/traits/select/mod.rs b/compiler/rustc_trait_selection/src/traits/select/mod.rs index a4499d438c1b5..bbcc6e1eebdc8 100644 --- a/compiler/rustc_trait_selection/src/traits/select/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/select/mod.rs @@ -2116,9 +2116,7 @@ impl<'tcx> SelectionContext<'_, 'tcx> { ty::Str | ty::Slice(_) | ty::Dynamic(..) | ty::Foreign(..) => None, - ty::Tuple(tys) => Where( - obligation.predicate.rebind(tys.last().map_or_else(Vec::new, |&last| vec![last])), - ), + ty::Tuple(tys) => Where(obligation.predicate.rebind(tys.to_vec())), ty::Adt(def, args) => { let sized_crit = def.sized_constraint(self.tcx()); diff --git a/tests/ui/dst/dst-bad-deep-2.rs b/tests/ui/dst/dst-bad-deep-2.rs index e587399135d32..85275aecc61f3 100644 --- a/tests/ui/dst/dst-bad-deep-2.rs +++ b/tests/ui/dst/dst-bad-deep-2.rs @@ -9,5 +9,5 @@ pub fn main() { let f: ([isize; 3],) = ([5, 6, 7],); let g: &([isize],) = &f; let h: &(([isize],),) = &(*g,); - //~^ ERROR the size for values of type + //~^ ERROR the size for values of type `[isize]` cannot be known at compilation time } diff --git a/tests/ui/layout/issue-84108.rs b/tests/ui/layout/issue-84108.rs index 44d6ac8db72f0..425da65b9905a 100644 --- a/tests/ui/layout/issue-84108.rs +++ b/tests/ui/layout/issue-84108.rs @@ -11,4 +11,5 @@ const BAR: (&Path, [u8], usize) = ("hello", [], 42); static BAZ: ([u8], usize) = ([], 0); //~^ ERROR the size for values of type `[u8]` cannot be known at compilation time +//~| ERROR the size for values of type `[u8]` cannot be known at compilation time //~| ERROR mismatched types diff --git a/tests/ui/layout/issue-84108.stderr b/tests/ui/layout/issue-84108.stderr index 58bddb069fc7d..6889f16664784 100644 --- a/tests/ui/layout/issue-84108.stderr +++ b/tests/ui/layout/issue-84108.stderr @@ -29,6 +29,16 @@ LL | static BAZ: ([u8], usize) = ([], 0); = help: the trait `Sized` is not implemented for `[u8]` = note: only the last element of a tuple may have a dynamically sized type +error[E0277]: the size for values of type `[u8]` cannot be known at compilation time + --> $DIR/issue-84108.rs:12:29 + | +LL | static BAZ: ([u8], usize) = ([], 0); + | ^^^^^^^ doesn't have a size known at compile-time + | + = help: within `([u8], usize)`, the trait `Sized` is not implemented for `[u8]`, which is required by `([u8], usize): Sized` + = note: required because it appears within the type `([u8], usize)` + = note: constant expressions must have a statically known size + error[E0308]: mismatched types --> $DIR/issue-84108.rs:12:30 | @@ -38,7 +48,7 @@ LL | static BAZ: ([u8], usize) = ([], 0); = note: expected slice `[u8]` found array `[_; 0]` -error: aborting due to 4 previous errors +error: aborting due to 5 previous errors Some errors have detailed explanations: E0277, E0308, E0412. For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/trait-bounds/ice-unsized-tuple-const-issue-121443.rs b/tests/ui/trait-bounds/ice-unsized-tuple-const-issue-121443.rs new file mode 100644 index 0000000000000..c3a2ab82adc6a --- /dev/null +++ b/tests/ui/trait-bounds/ice-unsized-tuple-const-issue-121443.rs @@ -0,0 +1,16 @@ +// Regression test for #121443 +// Checks that no ICE occurs upon encountering +// a tuple with unsized element that is not +// the last element + +type Fn = dyn FnOnce() -> u8; + +const TEST: Fn = some_fn; +//~^ ERROR cannot find value `some_fn` in this scope +//~| ERROR the size for values of type `(dyn FnOnce() -> u8 + 'static)` cannot be known at compilation time +//~| ERROR the size for values of type `(dyn FnOnce() -> u8 + 'static)` cannot be known at compilation time +const TEST2: (Fn, u8) = (TEST, 0); +//~^ ERROR the size for values of type `(dyn FnOnce() -> u8 + 'static)` cannot be known at compilation time +//~| ERROR the size for values of type `(dyn FnOnce() -> u8 + 'static)` cannot be known at compilation time + +fn main() {} diff --git a/tests/ui/trait-bounds/ice-unsized-tuple-const-issue-121443.stderr b/tests/ui/trait-bounds/ice-unsized-tuple-const-issue-121443.stderr new file mode 100644 index 0000000000000..4cd30c8a5d421 --- /dev/null +++ b/tests/ui/trait-bounds/ice-unsized-tuple-const-issue-121443.stderr @@ -0,0 +1,46 @@ +error[E0425]: cannot find value `some_fn` in this scope + --> $DIR/ice-unsized-tuple-const-issue-121443.rs:8:18 + | +LL | const TEST: Fn = some_fn; + | ^^^^^^^ not found in this scope + +error[E0277]: the size for values of type `(dyn FnOnce() -> u8 + 'static)` cannot be known at compilation time + --> $DIR/ice-unsized-tuple-const-issue-121443.rs:8:13 + | +LL | const TEST: Fn = some_fn; + | ^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `(dyn FnOnce() -> u8 + 'static)` + +error[E0277]: the size for values of type `(dyn FnOnce() -> u8 + 'static)` cannot be known at compilation time + --> $DIR/ice-unsized-tuple-const-issue-121443.rs:8:18 + | +LL | const TEST: Fn = some_fn; + | ^^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `(dyn FnOnce() -> u8 + 'static)` + = note: constant expressions must have a statically known size + +error[E0277]: the size for values of type `(dyn FnOnce() -> u8 + 'static)` cannot be known at compilation time + --> $DIR/ice-unsized-tuple-const-issue-121443.rs:12:14 + | +LL | const TEST2: (Fn, u8) = (TEST, 0); + | ^^^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `(dyn FnOnce() -> u8 + 'static)` + = note: only the last element of a tuple may have a dynamically sized type + +error[E0277]: the size for values of type `(dyn FnOnce() -> u8 + 'static)` cannot be known at compilation time + --> $DIR/ice-unsized-tuple-const-issue-121443.rs:12:25 + | +LL | const TEST2: (Fn, u8) = (TEST, 0); + | ^^^^^^^^^ doesn't have a size known at compile-time + | + = help: within `((dyn FnOnce() -> u8 + 'static), u8)`, the trait `Sized` is not implemented for `(dyn FnOnce() -> u8 + 'static)`, which is required by `((dyn FnOnce() -> u8 + 'static), u8): Sized` + = note: required because it appears within the type `((dyn FnOnce() -> u8 + 'static), u8)` + = note: constant expressions must have a statically known size + +error: aborting due to 5 previous errors + +Some errors have detailed explanations: E0277, E0425. +For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/trait-bounds/unsized-bound.stderr b/tests/ui/trait-bounds/unsized-bound.stderr index c8049ebee1173..470d1d946923f 100644 --- a/tests/ui/trait-bounds/unsized-bound.stderr +++ b/tests/ui/trait-bounds/unsized-bound.stderr @@ -1,10 +1,10 @@ -error[E0277]: the size for values of type `B` cannot be known at compilation time +error[E0277]: the size for values of type `A` cannot be known at compilation time --> $DIR/unsized-bound.rs:2:30 | LL | impl Trait<(A, B)> for (A, B) where A: ?Sized, B: ?Sized, {} - | - ^^^^^^ doesn't have a size known at compile-time - | | - | this type parameter needs to be `Sized` + | - ^^^^^^ doesn't have a size known at compile-time + | | + | this type parameter needs to be `Sized` | = note: required because it appears within the type `(A, B)` note: required by an implicit `Sized` bound in `Trait` @@ -15,35 +15,42 @@ LL | trait Trait {} help: consider removing the `?Sized` bound to make the type parameter `Sized` | LL - impl Trait<(A, B)> for (A, B) where A: ?Sized, B: ?Sized, {} -LL + impl Trait<(A, B)> for (A, B) where A: ?Sized, {} +LL + impl Trait<(A, B)> for (A, B) where B: ?Sized, {} | help: consider relaxing the implicit `Sized` restriction | LL | trait Trait {} | ++++++++ -error[E0277]: the size for values of type `A` cannot be known at compilation time +error[E0277]: the size for values of type `B` cannot be known at compilation time --> $DIR/unsized-bound.rs:2:30 | LL | impl Trait<(A, B)> for (A, B) where A: ?Sized, B: ?Sized, {} - | - ^^^^^^ doesn't have a size known at compile-time - | | - | this type parameter needs to be `Sized` + | - ^^^^^^ doesn't have a size known at compile-time + | | + | this type parameter needs to be `Sized` | - = note: only the last element of a tuple may have a dynamically sized type + = note: required because it appears within the type `(A, B)` +note: required by an implicit `Sized` bound in `Trait` + --> $DIR/unsized-bound.rs:1:13 + | +LL | trait Trait {} + | ^ required by the implicit `Sized` requirement on this type parameter in `Trait` help: consider removing the `?Sized` bound to make the type parameter `Sized` | LL - impl Trait<(A, B)> for (A, B) where A: ?Sized, B: ?Sized, {} -LL + impl Trait<(A, B)> for (A, B) where B: ?Sized, {} +LL + impl Trait<(A, B)> for (A, B) where A: ?Sized, {} | +help: consider relaxing the implicit `Sized` restriction + | +LL | trait Trait {} + | ++++++++ -error[E0277]: the size for values of type `C` cannot be known at compilation time +error[E0277]: the size for values of type `A` cannot be known at compilation time --> $DIR/unsized-bound.rs:5:52 | LL | impl Trait<(A, B, C)> for (A, B, C) where A: ?Sized, {} - | - ^^^^^^^^^ doesn't have a size known at compile-time - | | - | this type parameter needs to be `Sized` + | - this type parameter needs to be `Sized` ^^^^^^^^^ doesn't have a size known at compile-time | = note: required because it appears within the type `(A, B, C)` note: required by an implicit `Sized` bound in `Trait` @@ -54,46 +61,66 @@ LL | trait Trait {} help: consider removing the `?Sized` bound to make the type parameter `Sized` | LL - impl Trait<(A, B, C)> for (A, B, C) where A: ?Sized, {} -LL + impl Trait<(A, B, C)> for (A, B, C) where A: ?Sized, {} +LL + impl Trait<(A, B, C)> for (A, B, C) {} | help: consider relaxing the implicit `Sized` restriction | LL | trait Trait {} | ++++++++ -error[E0277]: the size for values of type `A` cannot be known at compilation time +error[E0277]: the size for values of type `B` cannot be known at compilation time --> $DIR/unsized-bound.rs:5:52 | LL | impl Trait<(A, B, C)> for (A, B, C) where A: ?Sized, {} - | - this type parameter needs to be `Sized` ^^^^^^^^^ doesn't have a size known at compile-time + | - this type parameter needs to be `Sized` ^^^^^^^^^ doesn't have a size known at compile-time + | + = note: required because it appears within the type `(A, B, C)` +note: required by an implicit `Sized` bound in `Trait` + --> $DIR/unsized-bound.rs:1:13 | - = note: only the last element of a tuple may have a dynamically sized type +LL | trait Trait {} + | ^ required by the implicit `Sized` requirement on this type parameter in `Trait` help: consider removing the `?Sized` bound to make the type parameter `Sized` | LL - impl Trait<(A, B, C)> for (A, B, C) where A: ?Sized, {} -LL + impl Trait<(A, B, C)> for (A, B, C) {} +LL + impl Trait<(A, B, C)> for (A, B, C) where A: ?Sized, {} + | +help: consider relaxing the implicit `Sized` restriction | +LL | trait Trait {} + | ++++++++ -error[E0277]: the size for values of type `B` cannot be known at compilation time +error[E0277]: the size for values of type `C` cannot be known at compilation time --> $DIR/unsized-bound.rs:5:52 | LL | impl Trait<(A, B, C)> for (A, B, C) where A: ?Sized, {} - | - this type parameter needs to be `Sized` ^^^^^^^^^ doesn't have a size known at compile-time + | - ^^^^^^^^^ doesn't have a size known at compile-time + | | + | this type parameter needs to be `Sized` + | + = note: required because it appears within the type `(A, B, C)` +note: required by an implicit `Sized` bound in `Trait` + --> $DIR/unsized-bound.rs:1:13 | - = note: only the last element of a tuple may have a dynamically sized type +LL | trait Trait {} + | ^ required by the implicit `Sized` requirement on this type parameter in `Trait` help: consider removing the `?Sized` bound to make the type parameter `Sized` | LL - impl Trait<(A, B, C)> for (A, B, C) where A: ?Sized, {} -LL + impl Trait<(A, B, C)> for (A, B, C) where A: ?Sized, {} +LL + impl Trait<(A, B, C)> for (A, B, C) where A: ?Sized, {} | +help: consider relaxing the implicit `Sized` restriction + | +LL | trait Trait {} + | ++++++++ -error[E0277]: the size for values of type `B` cannot be known at compilation time +error[E0277]: the size for values of type `A` cannot be known at compilation time --> $DIR/unsized-bound.rs:10:47 | LL | impl Trait2<(A, B)> for (A, B) {} - | - ^^^^^^ doesn't have a size known at compile-time - | | - | this type parameter needs to be `Sized` + | - ^^^^^^ doesn't have a size known at compile-time + | | + | this type parameter needs to be `Sized` | = note: required because it appears within the type `(A, B)` note: required by an implicit `Sized` bound in `Trait2` @@ -104,27 +131,36 @@ LL | trait Trait2 {} help: consider removing the `?Sized` bound to make the type parameter `Sized` | LL - impl Trait2<(A, B)> for (A, B) {} -LL + impl Trait2<(A, B)> for (A, B) {} +LL + impl Trait2<(A, B)> for (A, B) {} | help: consider relaxing the implicit `Sized` restriction | LL | trait Trait2 {} | ++++++++ -error[E0277]: the size for values of type `A` cannot be known at compilation time +error[E0277]: the size for values of type `B` cannot be known at compilation time --> $DIR/unsized-bound.rs:10:47 | LL | impl Trait2<(A, B)> for (A, B) {} - | - ^^^^^^ doesn't have a size known at compile-time - | | - | this type parameter needs to be `Sized` + | - ^^^^^^ doesn't have a size known at compile-time + | | + | this type parameter needs to be `Sized` | - = note: only the last element of a tuple may have a dynamically sized type + = note: required because it appears within the type `(A, B)` +note: required by an implicit `Sized` bound in `Trait2` + --> $DIR/unsized-bound.rs:9:14 + | +LL | trait Trait2 {} + | ^ required by the implicit `Sized` requirement on this type parameter in `Trait2` help: consider removing the `?Sized` bound to make the type parameter `Sized` | LL - impl Trait2<(A, B)> for (A, B) {} -LL + impl Trait2<(A, B)> for (A, B) {} +LL + impl Trait2<(A, B)> for (A, B) {} + | +help: consider relaxing the implicit `Sized` restriction | +LL | trait Trait2 {} + | ++++++++ error[E0277]: the size for values of type `A` cannot be known at compilation time --> $DIR/unsized-bound.rs:14:23 diff --git a/tests/ui/unsized/unsized3.rs b/tests/ui/unsized/unsized3.rs index af76aca2c2958..99e4109446e17 100644 --- a/tests/ui/unsized/unsized3.rs +++ b/tests/ui/unsized/unsized3.rs @@ -39,6 +39,7 @@ fn f8(x1: &S, x2: &S) { fn f9(x1: Box>) { f5(&(*x1, 34)); //~^ ERROR the size for values of type + //~| ERROR the size for values of type } fn f10(x1: Box>) { diff --git a/tests/ui/unsized/unsized3.stderr b/tests/ui/unsized/unsized3.stderr index c7a145b1c5171..92513e595a562 100644 --- a/tests/ui/unsized/unsized3.stderr +++ b/tests/ui/unsized/unsized3.stderr @@ -75,19 +75,20 @@ LL | fn f5(x: &Y) {} | ++++++++ error[E0277]: the size for values of type `X` cannot be known at compilation time - --> $DIR/unsized3.rs:40:5 + --> $DIR/unsized3.rs:40:9 | LL | fn f9(x1: Box>) { | - this type parameter needs to be `Sized` LL | f5(&(*x1, 34)); - | ^^ doesn't have a size known at compile-time + | ^^^^^^^^^ doesn't have a size known at compile-time | note: required because it appears within the type `S` --> $DIR/unsized3.rs:28:8 | LL | struct S { | ^ - = note: only the last element of a tuple may have a dynamically sized type + = note: required because it appears within the type `(S, {integer})` + = note: tuples must have a statically known size to be initialized help: consider removing the `?Sized` bound to make the type parameter `Sized` | LL - fn f9(x1: Box>) { @@ -95,7 +96,38 @@ LL + fn f9(x1: Box>) { | error[E0277]: the size for values of type `X` cannot be known at compilation time - --> $DIR/unsized3.rs:45:9 + --> $DIR/unsized3.rs:40:8 + | +LL | fn f9(x1: Box>) { + | - this type parameter needs to be `Sized` +LL | f5(&(*x1, 34)); + | -- ^^^^^^^^^^ doesn't have a size known at compile-time + | | + | required by a bound introduced by this call + | +note: required because it appears within the type `S` + --> $DIR/unsized3.rs:28:8 + | +LL | struct S { + | ^ + = note: required because it appears within the type `(S, {integer})` +note: required by an implicit `Sized` bound in `f5` + --> $DIR/unsized3.rs:24:7 + | +LL | fn f5(x: &Y) {} + | ^ required by the implicit `Sized` requirement on this type parameter in `f5` +help: consider removing the `?Sized` bound to make the type parameter `Sized` + | +LL - fn f9(x1: Box>) { +LL + fn f9(x1: Box>) { + | +help: consider relaxing the implicit `Sized` restriction + | +LL | fn f5(x: &Y) {} + | ++++++++ + +error[E0277]: the size for values of type `X` cannot be known at compilation time + --> $DIR/unsized3.rs:46:9 | LL | fn f10(x1: Box>) { | - this type parameter needs to be `Sized` @@ -116,7 +148,7 @@ LL + fn f10(x1: Box>) { | error[E0277]: the size for values of type `X` cannot be known at compilation time - --> $DIR/unsized3.rs:45:8 + --> $DIR/unsized3.rs:46:8 | LL | fn f10(x1: Box>) { | - this type parameter needs to be `Sized` @@ -146,6 +178,6 @@ help: consider relaxing the implicit `Sized` restriction LL | fn f5(x: &Y) {} | ++++++++ -error: aborting due to 6 previous errors +error: aborting due to 7 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/unsized/unsized6.rs b/tests/ui/unsized/unsized6.rs index 79133554d5472..fc772f50b1ae1 100644 --- a/tests/ui/unsized/unsized6.rs +++ b/tests/ui/unsized/unsized6.rs @@ -25,6 +25,7 @@ fn f3(x1: Box, x2: Box, x3: Box) { //~^ ERROR the size for values of type let (y, z) = (*x3, 4); //~^ ERROR the size for values of type + //~| ERROR the size for values of type } fn f4(x1: Box, x2: Box, x3: Box) { let y: X = *x1; @@ -33,6 +34,7 @@ fn f4(x1: Box, x2: Box, x3: Box) { //~^ ERROR the size for values of type let (y, z) = (*x3, 4); //~^ ERROR the size for values of type + //~| ERROR the size for values of type } fn g1(x: X) {} diff --git a/tests/ui/unsized/unsized6.stderr b/tests/ui/unsized/unsized6.stderr index 56e7f60f9ff08..dbea064595e57 100644 --- a/tests/ui/unsized/unsized6.stderr +++ b/tests/ui/unsized/unsized6.stderr @@ -124,6 +124,23 @@ LL - fn f3(x1: Box, x2: Box, x3: Box) { LL + fn f3(x1: Box, x2: Box, x3: Box) { | +error[E0277]: the size for values of type `X` cannot be known at compilation time + --> $DIR/unsized6.rs:26:18 + | +LL | fn f3(x1: Box, x2: Box, x3: Box) { + | - this type parameter needs to be `Sized` +... +LL | let (y, z) = (*x3, 4); + | ^^^^^^^^ doesn't have a size known at compile-time + | + = note: required because it appears within the type `(X, {integer})` + = note: tuples must have a statically known size to be initialized +help: consider removing the `?Sized` bound to make the type parameter `Sized` + | +LL - fn f3(x1: Box, x2: Box, x3: Box) { +LL + fn f3(x1: Box, x2: Box, x3: Box) { + | + error[E0277]: the size for values of type `X` cannot be known at compilation time --> $DIR/unsized6.rs:26:10 | @@ -142,7 +159,7 @@ LL + fn f3(x1: Box, x2: Box, x3: Box) { | error[E0277]: the size for values of type `X` cannot be known at compilation time - --> $DIR/unsized6.rs:30:9 + --> $DIR/unsized6.rs:31:9 | LL | fn f4(x1: Box, x2: Box, x3: Box) { | - this type parameter needs to be `Sized` @@ -162,7 +179,7 @@ LL | let y: &X = *x1; | + error[E0277]: the size for values of type `X` cannot be known at compilation time - --> $DIR/unsized6.rs:32:9 + --> $DIR/unsized6.rs:33:9 | LL | fn f4(x1: Box, x2: Box, x3: Box) { | - this type parameter needs to be `Sized` @@ -179,7 +196,24 @@ LL + fn f4(x1: Box, x2: Box, x3: Box) { | error[E0277]: the size for values of type `X` cannot be known at compilation time - --> $DIR/unsized6.rs:34:10 + --> $DIR/unsized6.rs:35:18 + | +LL | fn f4(x1: Box, x2: Box, x3: Box) { + | - this type parameter needs to be `Sized` +... +LL | let (y, z) = (*x3, 4); + | ^^^^^^^^ doesn't have a size known at compile-time + | + = note: required because it appears within the type `(X, {integer})` + = note: tuples must have a statically known size to be initialized +help: consider removing the `?Sized` bound to make the type parameter `Sized` + | +LL - fn f4(x1: Box, x2: Box, x3: Box) { +LL + fn f4(x1: Box, x2: Box, x3: Box) { + | + +error[E0277]: the size for values of type `X` cannot be known at compilation time + --> $DIR/unsized6.rs:35:10 | LL | fn f4(x1: Box, x2: Box, x3: Box) { | - this type parameter needs to be `Sized` @@ -196,7 +230,7 @@ LL + fn f4(x1: Box, x2: Box, x3: Box) { | error[E0277]: the size for values of type `X` cannot be known at compilation time - --> $DIR/unsized6.rs:38:18 + --> $DIR/unsized6.rs:40:18 | LL | fn g1(x: X) {} | - ^ doesn't have a size known at compile-time @@ -215,7 +249,7 @@ LL | fn g1(x: &X) {} | + error[E0277]: the size for values of type `X` cannot be known at compilation time - --> $DIR/unsized6.rs:40:22 + --> $DIR/unsized6.rs:42:22 | LL | fn g2(x: X) {} | - ^ doesn't have a size known at compile-time @@ -233,6 +267,6 @@ help: function arguments must have a statically known size, borrowed types alway LL | fn g2(x: &X) {} | + -error: aborting due to 13 previous errors +error: aborting due to 15 previous errors For more information about this error, try `rustc --explain E0277`.