mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 11:31:15 +00:00
Rollup merge of #137728 - Darksonn:no-tuple-unsize, r=oli-obk
Remove unsizing coercions for tuples See https://github.com/rust-lang/rust/issues/42877#issuecomment-2686010847 and below comments for justification. Tracking issue: #42877 Fixes: #135217
This commit is contained in:
commit
905ddf8cd8
@ -12311,40 +12311,6 @@ fn main() {
|
|||||||
```
|
```
|
||||||
|
|
||||||
will unnecessarily extend the stack frame.
|
will unnecessarily extend the stack frame.
|
||||||
"##,
|
|
||||||
default_severity: Severity::Allow,
|
|
||||||
warn_since: None,
|
|
||||||
deny_since: None,
|
|
||||||
},
|
|
||||||
Lint {
|
|
||||||
label: "unsized_tuple_coercion",
|
|
||||||
description: r##"# `unsized_tuple_coercion`
|
|
||||||
|
|
||||||
The tracking issue for this feature is: [#42877]
|
|
||||||
|
|
||||||
[#42877]: https://github.com/rust-lang/rust/issues/42877
|
|
||||||
|
|
||||||
------------------------
|
|
||||||
|
|
||||||
This is a part of [RFC0401]. According to the RFC, there should be an implementation like this:
|
|
||||||
|
|
||||||
```rust,ignore (partial-example)
|
|
||||||
impl<..., T, U: ?Sized> Unsized<(..., U)> for (..., T) where T: Unsized<U> {}
|
|
||||||
```
|
|
||||||
|
|
||||||
This implementation is currently gated behind `#[feature(unsized_tuple_coercion)]` to avoid insta-stability. Therefore you can use it like this:
|
|
||||||
|
|
||||||
```rust
|
|
||||||
#![feature(unsized_tuple_coercion)]
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
let x : ([i32; 3], [i32; 3]) = ([1, 2, 3], [4, 5, 6]);
|
|
||||||
let y : &([i32; 3], [i32]) = &x;
|
|
||||||
assert_eq!(y.1[0], 4);
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
[RFC0401]: https://github.com/rust-lang/rfcs/blob/master/text/0401-coercions.md
|
|
||||||
"##,
|
"##,
|
||||||
default_severity: Severity::Allow,
|
default_severity: Severity::Allow,
|
||||||
warn_since: None,
|
warn_since: None,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user