Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upTracking issue for RFC #1909: Unsized Rvalues #48055
Comments
aturon
added
B-RFC-approved
T-lang
C-tracking-issue
labels
Feb 7, 2018
This comment has been minimized.
This comment has been minimized.
@aturon: Are you referring to |
This comment has been minimized.
This comment has been minimized.
|
@Aaron1011 that was copied straight from the RFC. But yes, I presume that's what it's referring to. |
This comment has been minimized.
This comment has been minimized.
|
Why would unsized temporaries ever be necessary? The only way it would make sense to pass them as arguments would be by fat pointer, and I cannot think of a situation that would require the memory to be copied/moved. They cannot be assigned or returned from functions under the RFC. Unsized local variables could also be treated as pointers. In other words, is there any reason why unsized temporary elision shouldn't be always guaranteed? |
This was referenced Apr 11, 2018
This comment has been minimized.
This comment has been minimized.
|
Is there any progress on this issue? enum RepeatSyntax { Dyn, None }
syntax::ast::ExprKind::Repeat(P<Expr>, P<Expr>, RepeatSyntax)
enum RepeatExprCount {
Const(BodyId),
Dyn(P<Expr>),
}
hir::Expr_::ExprRepeat(P<Expr>, RepeatExprCount)But for the MIR part, I have no idea how to construct a correct MIR. Should I update the structure of Thanks in advance if someone would like to write a simple mentoring instruction. |
This comment has been minimized.
This comment has been minimized.
|
I'm trying to remove the |
This was referenced May 27, 2018
RalfJung
referenced this issue
Jul 10, 2018
Open
Tracking issue for promoting `!` to a type (RFC 1216) #35121
This comment has been minimized.
This comment has been minimized.
|
An alternative that would solve both of the unresolved questions would be explicit If I remember correctly, the main reason for this RFC was to get cc @arielb1 (RFC author) @qnighy (currently implementing this RFC in #51131) @eddyb (knows a lot about this stuff) |
This comment has been minimized.
This comment has been minimized.
|
@mikeyhew There's not really much of a problem with making by-value |
This comment has been minimized.
This comment has been minimized.
|
I guess I can see why people think it's more ergonomic: in order to opt into it, you just have to add If we're going to go ahead with this implicit syntax, then there are a few details that would be good to nail down:
|
This comment has been minimized.
This comment has been minimized.
|
@eddyb have you seen @alercah's RFC for DerefMove? rust-lang/rfcs#2439 |
bors
added a commit
that referenced
this issue
Aug 19, 2018
This comment has been minimized.
This comment has been minimized.
|
As a next step, I'll be working on trait object safety. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
@alexreg I would definitely appreciate your help, if I end up writing an RFC for The idea I have so far is to treat unsized rvalues as a sort of sugar for |
This comment has been minimized.
This comment has been minimized.
|
@mikeyhew That sounds like a reasonable approach to me. Has anyone specified the supposed semantics of |
This comment has been minimized.
This comment has been minimized.
|
Not sure if this is the right place to document this, but I found a way to make a subset of unsized returns (technically, all of them, given a
// Rust definitions
trait CloneAs<T: ?Sized> {
fn clone_as(&self) -> T;
}
impl<T: Trait + Clone> CloneAs<dyn Trait> for T {
fn clone_as(&self) -> dyn Trait { self.clone() }
}
trait Trait: CloneAs<dyn Trait> {}// Call ABI signature for `<dyn Trait as CloneAs<dyn Trait>>::clone_as`
fn(
// opaque pointer passed to `ret` as the first argument
ret_opaque: *(),
// called to return the unsized value
ret: fn(
// `ret_opaque` from above
opaque: *(),
// the `dyn Trait` return value's components
ptr: *(), vtable: *(),
) -> (),
// `self: &dyn Trait`'s components
self_ptr: *(), self_vtable: *(),
) -> ()
y = call f(x); // returns an unsized value
z = call g(y); // takes the unsized value and returns a sized one// by compiling it into:
f(&mut z, |z, y| { *z = call g(y); }, x)
|
This comment has been minimized.
This comment has been minimized.
I don't think it's been formally specified. Informally,
Don't think that bikeshed has been painted yet. I guess |
qnighy
referenced this issue
Oct 28, 2018
Closed
Unsized rvalues: implement boxed closure impls. #55431
This comment has been minimized.
This comment has been minimized.
|
Calling #![feature(unsized_locals)]
fn a(f: Box<FnOnce()>) { f() } |
This comment has been minimized.
This comment has been minimized.
|
Indeed, stability attributes do not work on However |
This comment has been minimized.
This comment has been minimized.
This sounds like a full-on MIR local reuse optimization, which may seem deceptively simple at first, but requires quite the complex analysis of all possible interactions in time, including across loop iterations. |
This comment has been minimized.
This comment has been minimized.
|
Since unsized values can be used in more circumstances, should we add pub enum Option<T: ?Sized>{}
pub enum Result<T: ?Sized, E> {}
pub struct AssertUnwindSafe<T: ?Sized>(T); |
This comment has been minimized.
This comment has been minimized.
|
@F001 Unsized enums are disallowed today and part of it has to do with the fact that all enum layout optimizations would have to either be disabled or reified into the vtable. |
This comment has been minimized.
This comment has been minimized.
|
While playing with the What's the plan for allowing |
This comment has been minimized.
This comment has been minimized.
|
@stjepang |
kennytm
referenced this issue
Nov 8, 2018
Closed
[Stabilization] Stablize using some arbitrary self types defined in std #55786
This comment has been minimized.
This comment has been minimized.
|
@eddyb shouldn't we wait until |
This comment has been minimized.
This comment has been minimized.
|
@Centril It seems unlikely that we'd see anyone relying on them accepting |
This comment has been minimized.
This comment has been minimized.
|
@cramertj I don't see how, moves |
This comment has been minimized.
This comment has been minimized.
|
@eddyb You can observe that the function can be constructed with those type params, just not apply them: #![feature(unsized_locals)] // for the fn declaration
fn my_drop<T>(_: T) {}
fn my_unsized_drop<T: ?Sized>(_: T) {}
trait Trait {}
fn main() {
let _ = my_drop::<()>;
// let _ = my_drop::<dyn Trait>; // This one won't compile
let _ = my_unsized_drop::<()>;
let _ = my_unsized_drop::<dyn Trait>; // This will compile
} |
This comment has been minimized.
This comment has been minimized.
|
As I said in #51131 (comment), I've once attempted to add pub trait Pattern<'a> {
type Searcher;
}
fn clone<'a, P: Pattern<'a>>(this: &MatchesInternal<'a, P>) -> MatchesInternal<'a, P> where P::Searcher: Clone {
MatchesInternal(this.0.clone())
}
pub struct MatchesInternal<'a, P: Pattern<'a>>(P::Searcher);
fn main() {}Here Therefore, I'm thinking of adding an independent pass (or adding a check to an existing pass) after typeck to ensure |
pietroalbini
added a commit
to pietroalbini/rust
that referenced
this issue
Nov 25, 2018
This comment has been minimized.
This comment has been minimized.
earthengine
commented
Jan 15, 2019
•
|
(moved from internals) I recently make a lot of mistakes by missing For myself, I would turn on I think this could happen to others as well, so I guess unless we prohibited raw Trait appear in function sigtures, stablizing |
This comment has been minimized.
This comment has been minimized.
|
@earthengine I agree. I wish we had implemented this and made |
This comment has been minimized.
This comment has been minimized.
|
Could it be made deny-by-default only in those places where it was previously disallowed, so that no currently-invalid code becomes accepted? |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Maybe make it two separate lints? |
This comment has been minimized.
This comment has been minimized.
|
Yes, that's the obvious solution... seems kind of ugly though? |
This comment has been minimized.
This comment has been minimized.
|
Could they be pseudonamespaced like clippy lints? |
This comment has been minimized.
This comment has been minimized.
|
That's an interesting idea. I don't know, but @arielb1 probably does. |
This comment has been minimized.
This comment has been minimized.
|
It's possible to have lint groups such that |
bors
added a commit
that referenced
this issue
Feb 11, 2019
bors
added a commit
that referenced
this issue
Feb 12, 2019
bors
added a commit
that referenced
this issue
Feb 12, 2019
This comment has been minimized.
This comment has been minimized.
earthengine
commented
Feb 14, 2019
•
|
Just found that the |
aturon commentedFeb 7, 2018
•
edited by Centril
This is a tracking issue for the RFC "Unsized Rvalues " (rust-lang/rfcs#1909).
Steps:
Unresolved questions:
How can we mitigate the risk of unintended unsized or large allocas? Note that the problem already exists today with large structs/arrays. A MIR lint against large/variable stack sizes would probably help users avoid these stack overflows. Do we want it in Clippy? rustc?
How do we handle truely-unsized DSTs when we get them? They can theoretically be passed to functions, but they can never be put in temporaries.
Decide on a concrete syntax for VLAs.