News for hackers. Stuff that matters.
Re:Rust 1.100.0 by ustad on Thursday November 12, 2026 @02:23PM (#50472771)
“Never type” - Feel like I’m stupid for not having a clue what that means.
Re:Rust 1.100.0 by pkulak on Thursday November 12, 2026 @02:26PM (#50472814)
A few other langs have it too. It's just something to return when no return is actually possible. And then it can propagate, so it makes some nice things possible that weren't before.
Re:Rust 1.100.0 by igravious on Thursday November 12, 2026 @02:59PM (#50473307)
Without looking up the Rust implementation I would hazard a guess that it is loose language to say "something to return when no return is actually possible" because if it is anything like the Bottom Type then there is no something that is being returned which is what this function signature indicates. Generally used for exception handling or intentional infinite loops (in both cases the function does not return from whence it came) … please correct me if I'm wrong here …
Re:Rust 1.100.0 by kibwen on Thursday November 12, 2026 @04:11PM (#50474336)
Basic use cases like that have always been possible in Rust, either via defining your own enum with zero variants (`enum Foo {}`), or by using a function return type of `!` which was hardcoded to work for certain things, e.g. infinite loops. What this release does is generalizes it so that `!` can participate in types in general, and the coolest part is that pattern matching is aware of this, so for example if you have a `Result<u8, !>` where the error variant is impossible, a `match` over this would allow you to omit the impossible error arm, and furthermore because this enum now effectively only has a single variant, it would allow you to use the pleasant irrefutable destructuring assignment syntax `let Ok(foo) = blah();`.
Re:Rust 1.100.0 by afdbcreid on Thursday November 12, 2026 @04:21PM (#50474464)
It has existed as a real type for a very long time (I believe in the beginning it really wasn't a real type but that's a long time ago), you just weren't allowed to name it. There was also an (unsupported) hack that allowed you to use it on stable.
Re:Rust 1.100.0 by anamexis on Thursday November 12, 2026 @02:26PM (#50472818)
Re:Rust 1.100.0 by LoganDark on Thursday November 12, 2026 @02:49PM (#50473171)
It's the type called "!", or the return value of diverging control flow, such as infinite loops, returns or function calls that panic or abort. It's an uninhabited type, meaning no values can actually exist, and that any code that would encounter such a value is unreachable.
Re:Rust 1.100.0 by Xirdus on Thursday November 12, 2026 @03:04PM (#50473385)
Mathematically, types are sets of possible values.

Any type (like in TypeScript; Rust doesn't have one) is a set of every possible value; a supertype of all types. Every expression regardless of type can be assigned to a variable of type any.

The opposite is the never type, which is an empty set; no value is of type never. Per set theory, an empty set is a subset of every set, which makes the never type a subtype of all types. An expression of type never can be assigned to every variable regardless of type.

If never type has no values, then how can an expression have never type? Easy: it must never evaluate. Infinite loops, unconditional panics/exceptions, process exit/abort, etc. Also, generics - you can have Vec<!> that's always empty, Result<T,!> that can never be an error, etc.

Re:Rust 1.100.0 by boston_clone on Thursday November 12, 2026 @03:29PM (#50473739)
[delayed]
Re:Rust 1.100.0 by rcxdude on Thursday November 12, 2026 @04:15PM (#50474393)
Rust does have https://doc.rust-lang.org/std/any/trait.Any.html but it's not quite the same thing (for one thing, it's not actually all types).
Re:Rust 1.100.0 by afdbcreid on Thursday November 12, 2026 @04:19PM (#50474437)
Also called top and bottom types, for this reason.
Re:Rust 1.100.0 by steveklabnik on Thursday November 12, 2026 @04:31PM (#50474591)
Any is not a top type and ! is not a bottom type, actually. They are sort of similar from a lay perspective if you squint, though.
Re:Rust 1.100.0 by afdbcreid on Thursday November 12, 2026 @05:00PM (#50474931)
Why not? I mean if you refer to Rust specifically, yes, because there is no subtyping except for lifetimes, only coercion (and `Any` also cannot contain any type). But in general, why not?
Re:Rust 1.100.0 by steveklabnik on Thursday November 12, 2026 @05:14PM (#50475106)
I am speaking about Rust specifically, yes.
Re:Rust 1.100.0 by NooneAtAll5 on Thursday November 12, 2026 @03:26PM (#50473700)
noreturn, basically
Re:Rust 1.100.0 by sixthDot on Friday November 13, 2026 @07:03AM (#50482311)
yeah aka the bottom type , but "never return" is inisde the type system (a bit like D handles that) while "noreturn" is an attribute. That's basically the two known possible ways of expressing that a call will never return.
Re:Rust 1.100.0 by yccs27 on Thursday November 12, 2026 @04:07PM (#50474283)
As in, values of this type can never actually exist.
Re:Rust 1.100.0 by saghm on Thursday November 12, 2026 @09:56PM (#50477553)
It's the type of what you get back from a `panic!` (a value you never actually get back).