• Rust
  • types
  • programming

Rust 1.100 stabilizes ! and lets Result express an impossible error

The never type now works inside Result and other type positions on stable Rust, with one inference change to watch when upgrading and the Iterator regression fixed in 1.100.1.

Rust 1.100.0 shipped on November 12 and stabilized the never type, written !. Rust already used it for expressions such as return and for function signatures ending in -> !. The new part is that developers can name it in other type positions, including the error parameter of Result. Rust 1.100.0 announcement

Result<T, E> describes the outcome of an operation. On success, Ok holds a value of type T. On failure, Err holds a value of type E. For example, Result<String, std::io::Error> can hold the text read from a file or an error encountered while reading it. Using ! for E tells the compiler that only Ok can hold a value.

The never type in plain words

A type describes which values something can hold: bool holds true or false, u8 holds 0 to 255. The never type ! holds no values at all. The Rust team calls it “the canonical uninhabited type”, meaning a type nobody can ever create a value of.

That sounds useless until you look at code that never finishes normally. return leaves the function. std::process::exit ends the program. panic! unwinds. The blog post calls these “diverging computations”: code after them is unreachable, and their type is !.

Because a value of type ! can never exist, Rust lets ! stand in for any other type. This is called the never-to-any coercion. It is why one match arm can return while another produces a number:

fn first_or_stop(option: Option<u32>) {
    let value = match option {
        Some(x) => x,       // u32
        None => return,     // `return` has type !, coerced to u32
    };
    println!("{value}");
}

What changed in 1.100 is that you can now write ! in places like Result<T, !>, not only get it from expressions like return. Rust 1.100.0: never type

When the error branch has no possible value

Imagine an import library that runs files and in-memory data through the same pipeline. Reading a file can return an I/O error. Constructing a single default row in memory can use the pipeline’s existing Result shape with ! as the error type.

fn default_row() -> Result<&'static str, !> {
    Ok("untitled")
}

fn main() {
    let Ok(row) = default_row();
    println!("{row}");
}

There is no value of type ! to put inside Err. The pattern let Ok(row) therefore covers every value the function can return. This is useful when a generic API needs one result shape for fallible and infallible operations. For a standalone function as small as this one, returning the string directly is simpler. The Rust team’s explanation of the never type

The difference shows up in let Ok(row) = default_row();. Change the return type to Result<&'static str, std::io::Error> and the compiler will require the caller to handle a possible Err, even if the function body currently returns only Ok. With !, the signature itself gives the compiler enough information to accept the binding.

What to look for when upgrading

Rust 1.100 also makes std::convert::Infallible an alias for !. The release changes never-type inference fallback from () to ! in editions before 2024, following the change already in the 2024 edition. The Rust team notes that this can affect rare cases such as ignoring the result of a call with a generic return type. Compatibility notes from the Rust team

The note also says the change “might also make the compiler detect more code as unreachable”, so expect new unreachable_code warnings in places where an expression is now typed as ! instead of ().

What “fallback” means

Rust uses type inference: the compiler works out types you did not write. Sometimes a ! expression gets coerced into a type that nothing else in the code pins down. The compiler then needs a default, called the fallback type. In editions 2015, 2018 and 2021 (an edition is the language version a crate opts into in Cargo.toml), that default used to be (), the empty “unit” type. Edition 2024 already used !. Rust 1.100 uses ! in every edition.

Most code never notices. Code that relied on the old () without saying so can stop compiling.

A fallback-sensitive call and its fix

The Rust edition guide shows the typical case. f is generic over the success type, and the caller uses ? without using the value:

fn f<T: Default>() -> Result<T, ()> {
    Ok(T::default())
}

fn outer() -> Result<(), ()> {
    f()?; // before 1.100 (editions 2015–2021): T falls back to ()
          // on 1.100: T falls back to !, and ! does not implement Default
    Ok(())
}

Nothing at the call site says what T is. Older compilers quietly picked (); Rust 1.100 picks !, and the T: Default bound fails. The fix is to name the type the code always relied on:

f::<()>()?;
// or
() = f()?;

Either form removes the need for fallback, so the result no longer depends on the compiler version. The same applies to an if or match where one branch is return and the other is an unannotated Default::default(). Edition guide: never type fallback change These snippets follow the edition guide. None of the Rust examples in this article were compiled, because no Rust toolchain was available on the machine used to write it.

If the error is inside a dependency rather than your own code, the Rust team suggests updating that dependency first, since fixes were released to public crates that the change broke. A library that supports older compilers can still express “cannot fail” with Infallible and keep its existing minimum Rust version.

Common mistakes when upgrading

  • Adding a random trait bound to make the error go away. Name the type the code meant instead, as above.
  • Debugging a dependency’s error yourself first. Run cargo update -p <crate> for the crate that fails; the Rust team says fixes were released for public crates broken by this change.
  • Treating new unreachable_code warnings as noise. Read each one. It may point at code that really cannot run, such as a statement after a call that never returns.
  • Switching a library’s public API from Infallible to ! without need. Since Infallible is now an alias, existing APIs already work with !. Writing ! yourself requires Rust 1.100, which raises your minimum supported version.

Update (November 27, 2026): Rust 1.100.1

Rust 1.100.1 fixes a separate regression in 1.100.0, unrelated to the never type: some types with valid Iterator implementations were no longer recognized as iterators. The cause was a change to the unstable const version of Iterator; stable code could not use it, but it still affected trait checking, and 1.100.1 reverts it. Rust 1.100.1 announcement

The reported pattern is a wrapper whose Iterator impl is bounded on <Self as Deref>::Target: Iterator and overrides nth (or DoubleEndedIterator::nth_back). On 1.100.0 those overrides fail with an E0277 error saying the target “is not an iterator”, while next and next_back still compile. The report names objc2 0.4.1, which winit 0.29 pulls in on Apple targets; the issue was closed on November 28 after the fix shipped. Regression report

If a macOS build broke on 1.100.0 with this error, check whether objc2 is in the graph and then update the toolchain:

cargo tree -i objc2
rustup update stable
rustc --version   # expect 1.100.1 or later
cargo check --all-targets

Do not add extra trait bounds to silence this E0277 before ruling out the compiler regression.

Conclusion

Use Result<T, !> when an API must share a result shape with fallible operations even though this particular operation cannot fail. For a small standalone function, return T directly. When upgrading, use 1.100.1 or later, and make a generic type explicit wherever the new fallback changes what the compiler infers.

Written by Duy Pham Independent developer. I build the apps on this site and write about how they work.

More about me