-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-arrayArea: `[T; N]`Area: `[T; N]`A-coercionsArea: implicit and explicit `expr as Type` coercionsArea: implicit and explicit `expr as Type` coercionsC-bugCategory: This is a bug.Category: This is a bug.
Description
The first three coercions here work fine, but the last one fails on both v1.64.0
and v1.66.0-nightly
(playground link):
let vec: Vec<i32> = vec![1, 2, 3];
let _: &[i32] = &vec;
let array: [i32; 3] = [1, 2, 3];
let _: &[i32] = &array;
let vec_rc: Rc<Vec<i32>> = Rc::new(vec![1, 2, 3]);
let _: &[i32] = &vec_rc;
let array_rc: Rc<[i32; 3]> = Rc::new([1, 2, 3]);
let _: &[i32] = &array_rc; // error[E0308]: mismatched types
Is that expected? The Reference mentions that transitive coercions are "not fully supported yet", so maybe this is a known limitation, but I wasn't able to find anything explicit about it. This old unfinished RFC might also be related, but I'm not totally sure. If there's a known limitation like "transitive unsized coercions aren't currently supported", I'd be happy to submit a PR clarifying that in the Reference.
alexhudspith
Metadata
Metadata
Assignees
Labels
A-arrayArea: `[T; N]`Area: `[T; N]`A-coercionsArea: implicit and explicit `expr as Type` coercionsArea: implicit and explicit `expr as Type` coercionsC-bugCategory: This is a bug.Category: This is a bug.