Change:
I tried compiling this code: which resulted in the following output of rustc: So the compiler says So I tried adding a borrow and recompiling the code: which resulted in: so the compiler says and so I'm stuck in a loop. The compiler can't decide whether I should borrow or not. As a newbie to Rust, this is very frustrating and the opposite of helpful, it just confuses me further. Please fix this indecisiveness :) :
For reference, what you likely want to do is one of the following which means they cannot be the type of a local binding. You can give a binding a slice type (), because that's morally equivalent to a pointer (with sizing info), which has a compile time determined size, as all borrows are .
Current output: After :

Discussion:
ObligationCauseCode::VariableType(hir_id) => { let parent_node = self.tcx.hir().get_parent_node(hir_id); match self.tcx.hir().find(parent_node) { <ins> Some(Node::Local(hir::Local { ty: Some(ty), .. })) => { err.span_suggestion_verbose( ty.span.shrink_to_lo(), "consider borrowing here", "&", Applicability::MachineApplicable, ); err.note("all local variables must have a statically known size"); } </ins> Some(Node::Local(hir::Local { init: Some(hir::Expr { kind: hir::ExprKind::Index(_, _), span, .. }), ..

<ins> fn main() { let x: [u8] = vec!(1, 2, 3)[..]; //~ ERROR E0277 let x: &[u8] = vec!(1, 2, 3)[..]; //~ ERROR E0308 let x: [u8] = &vec!(1, 2, 3)[..]; //~ ERROR E0308 //~^ ERROR E0277 let x: &[u8] = &vec!(1, 2, 3)[..]; } </ins>

<ins> error[E0277]: the size for values of type `[u8]` cannot be known at compilation time --> $DIR/suggest-borrow.rs:2:9 | LL |     let x: [u8] = vec!(1, 2, 3)[..]; |         ^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `[u8]` = note: all local variables must have a statically known size = help: unsized locals are gated as an unstable feature help: consider borrowing here | LL |     let x: &[u8] = vec!(1, 2, 3)[..]; |            + error[E0308]: mismatched types --> $DIR/suggest-borrow.rs:3:20 | LL |     let x: &[u8] = vec!(1, 2, 3)[..]; |            -----   ^^^^^^^^^^^^^^^^^ |            |       | |            |       expected `&[u8]`, found slice `[{integer}]` |            |       help: consider borrowing here: `&vec!(1, 2, 3)[..]` |            expected due to this error[E0308]: mismatched types --> $DIR/suggest-borrow.rs:4:19 | LL |     let x: [u8] = &vec!(1, 2, 3)[..]; |            ----   ^^^^^^^^^^^^^^^^^^ expected slice `[u8]`, found `&[{integer}]` |            | |            expected due to this | help: consider removing the borrow | LL -     let x: [u8] = &vec!(1, 2, 3)[..]; LL +     let x: [u8] = vec!(1, 2, 3)[..]; | help: alternatively, consider changing the type annotation | LL |     let x: &[u8] = &vec!(1, 2, 3)[..]; |            + error[E0277]: the size for values of type `[u8]` cannot be known at compilation time --> $DIR/suggest-borrow.rs:4:9 | LL |     let x: [u8] = &vec!(1, 2, 3)[..]; |         ^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `[u8]` = note: all local variables must have a statically known size = help: unsized locals are gated as an unstable feature help: consider borrowing here | LL |     let x: &[u8] = &vec!(1, 2, 3)[..]; |            + error: aborting due to 4 previous errors Some errors have detailed explanations: E0277, E0308. For more information about an error, try `rustc --explain E0277`. </ins>

= help: the trait `Sized` is not implemented for `[u8]` = note: all local variables must have a statically known size = help: unsized locals are gated as an unstable feature <ins> help: consider borrowing here | LL |     let _foo: &[u8] = *foo; |               + </ins> error: aborting due to 3 previous errors

LL - fn f1<W: ?Sized, X: ?Sized, Y: ?Sized, Z: ?Sized>(x: &X) { LL + fn f1<W: ?Sized, X: ?Sized, Y, Z: ?Sized>(x: &X) { | <ins> help: consider borrowing here | LL |     let y: &Y; |            + </ins> error[E0277]: the size for values of type `X` cannot be known at compilation time --> $DIR/unsized6.rs:7:12

LL - fn f2<X: ?Sized, Y: ?Sized>(x: &X) { LL + fn f2<X, Y: ?Sized>(x: &X) { | <ins> help: consider borrowing here | LL |     let y: &X; |            + </ins> error[E0277]: the size for values of type `Y` cannot be known at compilation time --> $DIR/unsized6.rs:17:12

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>) { | <ins> help: consider borrowing here | LL |     let y: &X = *x1; |            + </ins> error[E0277]: the size for values of type `X` cannot be known at compilation time --> $DIR/unsized6.rs:24:9

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>) { | <ins> help: consider borrowing here | LL |     let y: &X = *x1; |            + </ins> error[E0277]: the size for values of type `X` cannot be known at compilation time --> $DIR/unsized6.rs:32:9