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 promoting `!` to a type (RFC 1216) #35121
Comments
nikomatsakis
added
B-RFC-approved
T-lang
B-unstable
labels
Jul 29, 2016
This comment has been minimized.
This comment has been minimized.
|
Huzzah! There's a WIP implementation of this here: https://github.com/canndrew/rust/tree/bang_type_coerced It's current status is: it builds with old-trans and is usable but has a couple of failing tests. Some tests fail due to a bug that causes code like My current roadmap is:
Is there anything that needs to be added to this list? Is it just going to be me working on this? And should this branch be moved onto the main repository? |
chris-morgan
referenced this issue
Aug 1, 2016
Open
Tracking issue for TryFrom/TryInto traits #33417
This comment has been minimized.
This comment has been minimized.
@eddyb, @arielb1, @anyone_else: Thoughts on this approach? I'm pretty much up to this stage (sans a couple of failing tests that I'm (very slowly) trying to fix). |
dns2utf8
added a commit
to dns2utf8/rust
that referenced
this issue
Aug 4, 2016
dns2utf8
added a commit
to dns2utf8/rust
that referenced
this issue
Aug 4, 2016
nikomatsakis
added
the
T-libs
label
Aug 10, 2016
This comment has been minimized.
This comment has been minimized.
Shouldn't This kind of code is fairly common:
I'd expect
But this is only possible if |
This comment has been minimized.
This comment has been minimized.
suhr
commented
Aug 11, 2016
|
@tomaka There's RFC about it: rust-lang/rfcs#1637 The problem is that if |
This comment has been minimized.
This comment has been minimized.
Then special-case |
This comment has been minimized.
This comment has been minimized.
|
@tomaka As for |
This comment has been minimized.
This comment has been minimized.
|
But yes, it might be nice if |
dns2utf8
added a commit
to dns2utf8/rust
that referenced
this issue
Aug 15, 2016
This comment has been minimized.
This comment has been minimized.
|
When exactly do we default diverging type variables to
But the first error I get is " I'd like to have a clear idea of exactly why we have this defaulting behaviour and when it's supposed to get invoked. |
This comment has been minimized.
This comment has been minimized.
That's a very good idea in my opinion. Same for |
dns2utf8
added a commit
to dns2utf8/rust
that referenced
this issue
Aug 20, 2016
This comment has been minimized.
This comment has been minimized.
|
The trait Balls: Default {}
impl Balls for () {}
struct Flah;
impl Flah {
fn flah<T: Balls>(&self) -> T {
Default::default()
}
}
fn doit(cond: bool) {
let _ = if cond {
Flah.flah()
} else {
return
};
}
fn main() {
let _ = doit(true);
}Only the type variable created by |
This comment has been minimized.
This comment has been minimized.
Define "specified". :) The answer is that certain operations, which are not afaik written down anywhere outside the code, require that the type is known at that point. The most common case is field access ( If you make it all the way to the end of the fn, then we run all pending trait selection operations until a steady state is reached. This is the point where defaults (e.g., i32, etc) are applied. This last part is described in the RFC talking about user-specified default type parameters (though that RFC in general needs work). |
nikomatsakis
closed this
Aug 24, 2016
nikomatsakis
reopened this
Aug 24, 2016
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Boy, that's an old bug! But yes I'd say my #36038 is a dupe of that (I thought I'd seen it somewhere before). I don't think |
This comment has been minimized.
This comment has been minimized.
|
Is it planned for #![feature(never_type)]
fn main() {
let result: Result<_, !> = Ok(1);
match result {
// ^^^^^^ pattern `Err(_)` not covered
Ok(i) => println!("{}", i),
}
} |
This comment has been minimized.
This comment has been minimized.
|
@tikue yes, it's one of the bugs listed above. |
This comment has been minimized.
This comment has been minimized.
earthengine
commented
Jul 11, 2018
•
|
So now it looks like denying all unsized rvalues (unless feature "unsized rvalues" turned on) in the wild would be a breaking change, although the effect would be little I think. I then still suggest to have a feature gate to disallow coersion from |
This comment has been minimized.
This comment has been minimized.
|
As long as the The question is, if we stabilize it without coercion to DSTs in order to fix #49593, will we want to restore such coercion later when we add unsized rvalues and would we be able to do so without breaking #49593 again? |
This comment has been minimized.
This comment has been minimized.
earthengine
commented
Jul 11, 2018
|
My previous proposal includes this. #49593 should be a blocking issue for unsized rvalues. My personal suggestion for the final solution, is to let |
This comment has been minimized.
This comment has been minimized.
|
FWIW, // The type `str` is the type of the place being matched. `x` has type `&str`.
let ref x: str = *"foo";
// Fully equivalent to this:
let x: &str = &*"foo"; |
This comment has been minimized.
This comment has been minimized.
earthengine
commented
Jul 13, 2018
•
|
You didn't get my point. My assumsion is that in Rust there is currently no unsized rvalues can appear in code at all. However it turns out that they appear in Your examples instead, is technically fully legal and it is not the point. |
This comment has been minimized.
This comment has been minimized.
There is a similar "ghost" in an expression like |
This comment has been minimized.
This comment has been minimized.
|
@earthengine @SimonSapin No unsized rvalues ("value expression") exist there. Only lvalues ("place expressions") do. The names "lvalue" and "rvalue" are relics and somewhat misleading in C too, but even worse in Rust, because In your examples, |
This comment has been minimized.
This comment has been minimized.
|
In #52420 I hit that let Ok(b): Result<B, !> = ...;
bno longer works. Is that intentional? |
This comment has been minimized.
This comment has been minimized.
|
AFAIK yes -- the infallible pattern story is complicated and has a separate feature gate from |
This comment has been minimized.
This comment has been minimized.
|
@Ericson2314 specifically the feature you would need to add to |
This comment has been minimized.
This comment has been minimized.
|
Thanks!! |
majewsky
referenced this issue
Sep 13, 2018
Closed
primitive type never aka ! not indicated as unstable in the docs #54198
This comment has been minimized.
This comment has been minimized.
|
An interesting conversation on internals:
|
This comment has been minimized.
This comment has been minimized.
|
If you're going to do that, why not treat ! itself as an inference variable? |
This comment has been minimized.
This comment has been minimized.
|
Just make a wrapper around |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
I think rfcbot might support more than one FCP in the same issue. Let’s open a new issue for this round of stabilization? #50121 not only reverted stabilization but also the fallback semantics. Is this something we want to revisit? |
This comment has been minimized.
This comment has been minimized.
|
The remaining unchecked checkbox in the issue description is:
We can add impls later, can’t we? Or is this a blocker? |
This comment has been minimized.
This comment has been minimized.
|
@SimonSapin Opened #57012. I'd expect that the fallback to |
rust-lang
deleted a comment from
rfcbot
Dec 28, 2018
rust-lang
deleted a comment from
rfcbot
Dec 28, 2018
This comment has been minimized.
This comment has been minimized.
|
Cross-referencing: #58184 |
This comment has been minimized.
This comment has been minimized.
|
Apparently there’s bug/hole in having the never type behind a feature gate, and it’s possible to refer to it on Stable: #33417 (comment) |
This comment has been minimized.
This comment has been minimized.
|
Edit: filed #58733. Adding an use of the type in the code example linked above: trait MyTrait {
type Output;
}
impl<T> MyTrait for fn() -> T {
type Output = T;
}
type Void = <fn() -> ! as MyTrait>::Output;
fn main() {
let _a: Void;
}This compiles in Rust 1.12.0 which I think is the first with #35162. In 1.11.0, it errors with: error: the trait bound `fn() -> !: MyTrait` is not satisfied [--explain E0277]
--> a.rs:12:13
|>
12 |> let _a: Void;
|> ^^^^
help: the following implementations were found:
help: <fn() -> T as MyTrait>
error: aborting due to previous error |
nikomatsakis commentedJul 29, 2016
•
edited by cramertj
#Tracking issue for rust-lang/rfcs#1216, which promotes
!to a type.Pending issues to resolve:
!? The initial PR #35162 includesOrdand a few others. This is probably more of a T-libs issue, so I'm adding that tag to the issue.!#35121(): Traitfallback where that behavior might change in the future?!in coercion (#40800)!(#40801)expr_ty*const !- #43061[!; 0]not uninhabitedBox::new(!): Box<Error>does not compile.Related:
!Interesting events: