-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement the !
type
#35162
Implement the !
type
#35162
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @pnkfelix (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
How much effort is it worth going to to get this working without MIR? It works currently except for one weirdly failing test. But if we're going to be launching MIR soon is it worth keeping old trans working at all? |
@@ -699,6 +699,39 @@ mod impls { | |||
|
|||
ord_impl! { char usize u8 u16 u32 u64 isize i8 i16 i32 i64 } | |||
|
|||
// Note: This macro is a temporary hack that can be remove once we are building with a compiler | |||
// that supports `!` | |||
macro_rules! argh { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be a bit more formal, e.g. "Remove this in the next snapshot." and not_stage0
instead of args
.
cc @alexcrichton Does "SNAP" work anymore?
f57d48f
to
143ba6e
Compare
} | ||
|
||
#[cfg(not(stage0))] | ||
not_stage0!(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nikomatsakis What do you think about these impls?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm pretty sure I added these out of necessity to make a test pass. Also !
is trivially totally ordered so it should impl Ord
.
f9c44b3
to
54b7243
Compare
☔ The latest upstream changes (presumably #35174) made this pull request unmergeable. Please resolve the merge conflicts. |
54b7243
to
2c62c30
Compare
@@ -930,11 +933,15 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> { | |||
} | |||
} | |||
|
|||
pub fn is_empty(&self, _cx: TyCtxt) -> bool { | |||
pub fn is_empty(&self, cx: TyCtxt) -> bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that this function should be renamed -- it sounds very much like it is checking for TyEmpty
, when in fact it does more (not sure if this happens in a later commit)
OK so @eddyb and I chatted a bunch on IRC. In general, I'm feeling nervous about how the "never-to-any" adjustment is different from other adjustments. For one thing, it's applied eagerly, in I can see various ways to go forward:
Honestly without trying to work through either of those latter two options, I'm not quite sure how easy/hard they would be, but it seems like option 3 probably leaves us with a cleaner setup than we started with overall (presuming it works), so maybe worth a try. |
☔ The latest upstream changes (presumably #35116) made this pull request unmergeable. Please resolve the merge conflicts. |
💔 Test failed - auto-linux-64-opt-no-mir |
@bors retry |
Old trans apparently sometimes drops rvalue datums from other branches. You should use an lvalue datum instead. fix: diff --git a/src/librustc_trans/expr.rs b/src/librustc_trans/expr.rs
index 0ea5715..18bafdb 100644
--- a/src/librustc_trans/expr.rs
+++ b/src/librustc_trans/expr.rs
@@ -385,7 +385,7 @@ fn apply_adjustments<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
let mono_target = bcx.monomorphize(target);
let llty = type_of::type_of(bcx.ccx(), mono_target);
let dummy = C_undef(llty.ptr_to());
- datum = Datum::new(dummy, mono_target, Rvalue::new(ByRef)).to_expr_datum();
+ datum = Datum::new(dummy, mono_target, Lvalue::new("never")).to_expr_datum();
}
AdjustReifyFnPointer => {
match datum.ty.sty { test case (sans assertions): pub struct Receiver(u32);
impl Drop for Receiver {
fn drop(&mut self) {}
}
pub fn recv(f1: bool, f2: bool) -> Receiver {
match f1 {
false => Receiver(0),
true => {
match f2 {
true => return Receiver(0),
false => return Receiver(0),
}
}
}
}
fn main() {} |
@bors r=nikomatsakis |
📌 Commit f59f1f0 has been approved by |
@eddyb Thanks! |
Also @arielb1 thanks! |
⌛ Testing commit f59f1f0 with merge 1f58506... |
💔 Test failed - auto-win-msvc-64-opt-no-mir |
@bors retry |
Anyone know what happened here? Has the problem with msvc wanting libm been fixed? |
I really doubt msvc wants libm. If that legitimately happened I'd be quite worried. It is probably just some other bug causing a random "m" to appear in the command to the linker. |
Implement the `!` type This implements the never type (`!`) and hides it behind the feature gate `#[feature(never_type)]`. With the feature gate off, things should build as normal (although some error messages may be different). With the gate on, `!` is usable as a type and diverging type variables (ie. types that are unconstrained by anything in the code) will default to `!` instead of `()`.
For the record this indirectly introduced some issues (see #35883 (comment)) and parts of it will need to be semi-reverted (old |
This implements the never type (
!
) and hides it behind the feature gate#[feature(never_type)]
. With the feature gate off, things should build as normal (although some error messages may be different). With the gate on,!
is usable as a type and diverging type variables (ie. types that are unconstrained by anything in the code) will default to!
instead of()
.(tracking issue #35121 )