Rust 1.100 の never 型安定化で何が壊れる?1.99.1 と比べて確かめた
- Rust 1.100.0(rustc 0ef1bc386 2026-11-09、cargo 3acc79c0c 2026-11-05)
- Rust 1.99.1(rustc 58cf8f9c3 2026-10-13、cargo 5f94df478 2026-08-27)
- Rust 1.98.1(rustc 48a229cea 2026-09-01、一部のケースの比較だけ)
- nightly-2026-11-12(1.102.0-nightly 3ef0c22cd、Miri だけ)
- rustup 1.29.3
- GitHub Actions ubuntu-latest(Ubuntu 26.04.1 LTS、イメージ 20261111.196.1、2 vCPU AMD EPYC 7763、メモリ 7,931 MB)
Rust 1.100.0 が 2026-11-12 に出た。never 型 ! が安定して、edition 2015〜2021 の never type fallback が () から ! に変わっとる。fallback に頼る書き方を 4 つの edition で 1.99.1 と 1.100.0 の両方にかけて、何が壊れるかを確かめてみた。1.100 に上げる前に自分のコードを調べたい人向けの記録やで。
結論: Rust 1.100 never型の変更でビルドが通らなくなるのは 3 か所だった
1.99.1 でビルドが通っとるコードが、1.100.0 でビルドできへんようになったのは次の 3 つやった。
#[allow(dependency_on_unit_never_type_fallback)]で lint を黙らせていたコード- 依存クレートの中のコード
Infallibleが!の別名になって書けなくなったコード(E0432・E0119)
fallback に頼る自分のコードは、1.99.1 の時点でもうビルドが止まる。1.92.0 から lint dependency_on_unit_never_type_fallback が deny になっとるからや。今回の F1〜F6 と serde の D1 では、1.99.1 で lint に止められたものは 1.100.0 でも全部エラーやった。
依存クレートは事情がちゃう。git 依存にした小さなクレートは 1.99.1 で何事もなく動いて、警告が 1 行出るだけ。それが 1.100.0 では E0277 になる。
ビルドは通るのに動きが変わるもんもあった。unsafe の fallback を allow しとった所は、実行時に SIGABRT や SIGILL で落ちるか、処理が黙って消える。クロージャの戻り値の型名を表示するだけのコードは、警告ゼロのまま () が ! に変わってもうた。こっちは事前に機械で見つける方法が、今回試した範囲では見つかってへん。
試した実在のクレート 15 本は両版で cargo check が通って、ビルド時間も変わらんかった。allow も future-incompat の警告も無くて、型名を文字列で使ってへんのやったら、上げて困る所はほとんど無いと見てる。
検証環境
| 項目 | 内容 |
|---|---|
| 実行場所 | GitHub Actions の ubuntu-latest(Ubuntu 26.04.1 LTS、イメージ 20261111.196.1) |
| CPU とメモリ | nproc 2、AMD EPYC 7763、メモリ 7,931 MB |
| Rust | 1.99.1 と 1.100.0。rustup 1.29.3 で入れ、rustc -vV の commit-hash を確かめてから使った |
| 比較用 | 1.98.1(一部のケースだけ)、nightly-2026-11-12(Miri だけ) |
| 実行 | lab-run の実行 43677119136 と 43678157785(2026-11-15、各 4〜5 分) |
ケースはグループに分けた。F は fallback に頼る書き方 10 種、N と I は ! と Infallible、D は依存クレートを使うもの、P は実在のクレート、A は一緒に安定した API やで。
F は元のまま(plain)、先頭に allow を 1 行足したもの(allow)、型を書いて直したもの(fixed)の 3 通りを作った。4 edition × 2 版でビルドして、通ったものは実行してる。結果の表は 462 行になった。
手順: 1.99.1 と 1.100.0 で同じコードをビルドする
ケースのソースは検証リポジトリの labs/rust-1-100-never-type/cases/ に、全手順は labs/rust-1-100-never-type/run.sh に置いてある。fixed 変種は <名前>.fixed.rs や。
| ID | ファイル(cases/ から) |
|---|---|
| F0〜F9 | F/control-todo.rs、F/question-generic-ok.rs、F/closure-panic-bound.rs、F/branch-default.rs、F/generic-return-ignored.rs、F/unsafe-zeroed.rs、F/unsafe-transmute.rs、F/silent-type-change.rs、F/unreachable-more.rs、F/todo-impl-trait.rs |
| N1〜N3 | N/result-never.rs、N/result-infallible.rs、N/never-is-infallible.rs |
| I1〜I7b | I/from-infallible-impl.rs、I/use-infallible-self.rs、I/box-dyn-send.rs、I/method-on-never.rs、I/method-on-never-ref.rs、I/method-on-never-block.rs、I/never-alias-impl.rs、I/never-alias-impl-u8.rs |
| D1〜D5 | D/d1-serde/、D/d2-anyhow/、D/d3-never-say-never/、D/d3b-thiserror/、D/legacy-dep/ と D/d4-app/、D/d5-fix/ |
| A0〜A4 | A/signature-probe.rs、A/drop-guard.rs、A/vec-from-fn.rs、A/trim-prefix.rs(slice-trim-prefix.rs・path-trim-prefix.rs・path-trim-suffix.rs も)、A/clippy-msrv/ |
ツールチェーンを 2 つ入れる
既定のツールチェーンは変えんと、呼ぶときに +1.99.1 みたいに版を付ける。
rustup toolchain install 1.99.1 --profile minimal
rustup toolchain install 1.100.0 --profile minimal --component clippy
rustc +1.99.1 -vV # commit-hash: 58cf8f9c35b355199727627d07ae34a4e2846d67
rustc +1.100.0 -vV # commit-hash: 0ef1bc386059596dada8fb65b50425aab2ea637a
ランナーに最初から入っとった rustc は 1.99.1 やった。計画を立てたときのイメージでは 1.98.1 やったから、ランナーの付属品には頼らんほうが安全やな。
最小のケースを 1 つビルドする
エディションガイドにある 1 つ目の形。f()?; の結果を捨てるから、T は fallback で決まる。
ファイルは question-generic-ok.rs で、先頭のコメントも実物のまま。後で出てくる診断の行番号はこのファイルの行に合うてる。
// F1: エディションガイドの型 1。`f()?;` の結果を捨てると、T が fallback で決まる。
// 狙い: 2015〜2021 は T = ()、2024(と 1.100.0 の全 edition)は T = ! になり、`!: Default` を満たせない。
// 予想: 1.99.1 の 2015〜2021 は deny lint(dependency_on_unit_never_type_fallback)でエラー、allow なら通って T = () と表示。
// 1.99.1 の 2024 と 1.100.0 の全 edition は E0277(`!: Default`)。
fn f<T: Default>() -> Result<T, ()> {
println!("F1 f::<{}>() called", std::any::type_name::<T>());
Ok(T::default())
}
fn outer() -> Result<(), ()> {
f()?;
Ok(())
}
fn main() {
let r = outer();
println!("F1 outer() = {:?}", r);
}
edition を変えながら両方の版でビルドして、通ったら実行する。検証では診断を集めるために --error-format=json も付けた。
for v in 1.99.1 1.100.0; do
for e in 2015 2018 2021 2024; do
rustc +$v --edition $e -C debug-assertions=on -o f1-$v-$e question-generic-ok.rs \
&& ./f1-$v-$e
done
done
このファイルはどの組み合わせでもビルドで止まる。1.99.1 の 2015〜2021 は deny lint、残りは E0277 や。型を書いた question-generic-ok.fixed.rs やったら 8 組とも F1 f::<()>() called と出て終了コード 0 やった。
allow 変種はファイルの先頭に次の 1 行を足しただけ。1 行増えるから、診断の行番号も 1 つずれるで。
#![allow(dependency_on_unit_never_type_fallback, never_type_fallback_flowing_into_unsafe)]
依存クレートの中に同じ書き方がある場合
F1 と同じ形の pub fn check() を持つ edition 2021 のクレート legacy-dep を作って、git リポジトリにした。1.92.0 の PR #146167 によると、依存クレートの中で lint に当たってもエラーにはならんと、future-incompat report で利用側に知らせる。crates.io のクレートでこの状態のもんは用意できへんかったから、git 依存で代わりにしてる。
legacy-dep/Cargo.toml はこれ。
[package]
name = "legacy-dep"
version = "0.1.0"
edition = "2021"
publish = false
[lib]
path = "src/lib.rs"
legacy-dep/src/lib.rs はこう。結果に出る lib.rs:11:5 は、このファイルの f()?; の行や。
//! D4: F1 の書き方(`f()?;` の結果を捨てる)を含む、古い依存クレートの代わり(edition 2021)。
//! 狙い: 依存クレートの中で fallback に頼っている場合、1.99.1 で事前に見つけられるか(future-incompat report)。
//! 予想: git 依存(crates.io と同じく lint が抑えられる)は 1.99.1 でビルドが通り、最後に future-incompat の警告が出る。
//! path 依存は deny lint でエラー。1.100.0 はどちらも依存クレートの中で E0277。
fn f<T: Default>() -> Result<T, ()> {
Ok(T::default())
}
pub fn check() -> Result<(), ()> {
f()?;
Ok(())
}
git リポジトリにする。git の user.name と user.email を設定してへん環境では git commit が失敗するから、検証では -c で渡した。
cd legacy-dep
git -c init.defaultBranch=main init -q
git add -A
git -c user.name=lab -c user.email=lab@localhost commit -q -m "legacy-dep 0.1.0"
利用する側の d4-git/Cargo.toml と d4-git/src/main.rs がこれ。比べるために、依存を { path = "<legacy-dep の絶対パス>" } にした d4-path も作った。
[package]
name = "d4-git"
version = "0.1.0"
edition = "2021"
publish = false
[dependencies]
legacy-dep = { git = "file:///<legacy-dep の絶対パス>" }
[workspace]
// D4 の利用側(edition 2021)。legacy-dep を git 依存または path 依存で使う。
fn main() {
println!("D4 legacy_dep::check() = {:?}", legacy_dep::check());
}
両方の版で同じ依存の解決になるように、Cargo.lock を先に 1 回だけ作ってから --locked でビルドしてる。
cd d4-git
cargo +1.100.0 generate-lockfile
cargo +1.99.1 build --locked
cargo +1.99.1 report future-incompatibilities
cargo +1.100.0 build --locked
結果: 1.99.1 と 1.100.0 の違い
1.99.1 の時点で fallback に頼るコードはもう止まる
F の主な結果。セルは「ビルドの結果 → 実行の結果」で、NG はビルド失敗やで。
| ケース | 1.99.1 2015〜2021 | 1.99.1 2024 | 1.100.0 2015〜2021 | 1.100.0 2024 |
|---|---|---|---|---|
F1 f()?; plain |
NG: dependency_on_unit_never_type_fallback | NG: E0277 | NG: E0277 | NG: E0277 |
| F1 allow | OK → exit 0 | NG: E0277 | NG: E0277 | NG: E0277 |
F1 fixed f::<()>()?; |
OK → exit 0 | OK → exit 0 | OK → exit 0 | OK → exit 0 |
F5 mem::zeroed() plain |
NG: never_type_fallback_flowing_into_unsafe | NG: 同左 | NG: 同左 | NG: 同左 |
| F5 allow | OK → exit 0 | OK → SIGABRT (134) | OK → SIGABRT (134) | OK → SIGABRT (134) |
F6 mem::transmute allow |
OK → exit 0 | OK → SIGILL (132) | OK → SIGILL (132) | OK → SIGILL (132) |
| F7 型名を表示 plain | OK → R = () |
OK → R = ! |
OK → R = ! |
OK → R = ! |
F9 impl Iterator に todo!() |
NG: E0277 () |
NG: E0277 ! |
NG: E0277 ! |
NG: E0277 ! |
F2〜F4 は F1 と同じ並びやった。エディションガイドの残り 2 形と、ジェネリックな戻り値を let _ = match load(k) { ... } で捨てる形や。
1.99.1 の 2021 で出たエラーはこれ。
error: this function depends on never type fallback being `()`
--> question-generic-ok.rs:11:1
|
11 | fn outer() -> Result<(), ()> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: specify the types explicitly
note: in edition 2024, the requirement `!: Default` will fail
--> question-generic-ok.rs:12:5
|
12 | f()?;
| ^^^
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in Rust 2024 and in a future release in all editions!
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/never-type-fallback.html>
= note: `#[deny(dependency_on_unit_never_type_fallback)]` (part of `#[deny(rust_2024_compatibility)]`) on by default
help: use `()` annotations to avoid fallback changes
|
12 | f::<()>()?;
| ++++++
公式ブログの「2015〜2021 も 2024 と同じになった」も数えて確かめてみた。1.100.0 の 2015〜2021 と 1.99.1 の 2024 を比べると、168 組のうち 156 組が同じ結果。違った 12 組は N1・N3・I2・I7 で、fallback やなくて ! が書けるようになったことと Infallible の別名化によるもんやった。
lint の一覧も両版で比べた。1.100.0 で消えた lint は dependency_on_unit_never_type_fallback だけや。never_type_fallback_flowing_into_unsafe は 1.100.0 でも deny のまま残っとる。
allow していたコードは 1.100.0 で E0277 になる
allow 変種の F1〜F4 は 1.99.1 の 2015〜2021 やったら通って動く。1.100.0 では lint が消えたから allow が効かんと、警告とエラーが並んだ。
warning: lint `dependency_on_unit_never_type_fallback` has been removed: the code warned by this lint no longer compiles
--> question-generic-ok.rs:1:10
|
1 | #![allow(dependency_on_unit_never_type_fallback, never_type_fallback_flowing_into_unsafe)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(renamed_and_removed_lints)]` on by default
error[E0277]: the trait bound `!: Default` is not satisfied
--> question-generic-ok.rs:13:5
|
13 | f()?;
| ^^^ the trait `Default` is not implemented for `!`
|
= note: this error might have been caused by changes to Rust's type-inference algorithm (see issue #148922 <https://github.com/rust-lang/rust/issues/148922> for more information)
= help: you might have intended to use the type `()` here instead
serde_json を使った D1 は壊れてよかった例や。serde_json::from_str(body)?; は「JSON として正しいかだけ見る」つもりのコード。allow で 1.99.1 に通すと、中身を () として読んどった。
D1 validate({"a":1}) = Err(invalid type: map, expected unit at line 1 column 0)
D1 validate(null) = Ok
null しか通らん不具合が元からあったわけやな。1.100.0 はここを !: serde::Deserialize<'de> が満たせへんとして止める。壊れて正解やった。from_str::<serde::de::IgnoredAny>(body)? に直したら、両版で {"a":1} が Ok になった。
依存クレートの中は 1.99.1 では警告 1 行だけ
まず 1.99.1 で git 依存のほうをビルドしてみた。
$ cargo +1.99.1 build --locked # d4-git(legacy-dep を git 依存で使う)
Compiling legacy-dep v0.1.0 (file://$RUNNER_TEMP/rust-lab/legacy-dep-git#57c821ad)
Compiling d4-git v0.1.0 ($RUNNER_TEMP/rust-lab/d4-git)
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.11s
warning: the following packages contain code that will be rejected by a future version of Rust: legacy-dep v0.1.0 (file://$RUNNER_TEMP/rust-lab/legacy-dep-git#57c821ad)
note: to see what the problems were, use the option `--future-incompat-report`, or run `cargo report future-incompatibilities --id 1`
exit=0
$ ./target/debug/d4-git
D4 legacy_dep::check() = Ok(())
path 依存やったら 1.99.1 でも deny の lint に止められる。1.100.0 ではどっちの依存も、依存の中で E0277 やった。
error[E0277]: the trait bound `!: Default` is not satisfied
--> ~/.cargo/git/checkouts/legacy-dep-git-2925f67c86325fdb/57c821a/src/lib.rs:11:5
|
11 | f()?;
| ^^^ the trait `Default` is not implemented for `!`
1.99.1 で cargo report future-incompatibilities を打ったら、依存の中で出た警告の全文が出た。直し方の f::<()>()?; まで載っとる。ビルドが通ってまうから、あの 1 行を見落としたら 1.100.0 でいきなり依存が壊れることになるで。
lint が何も言わない変化
F7 はクロージャの戻り値の型名とサイズを返すだけの関数。! も Debug を満たすから、lint の対象にならへん。
use std::fmt::Debug;
fn describe<R: Debug + 'static>(_f: impl FnOnce() -> R) -> (&'static str, usize) {
(std::any::type_name::<R>(), std::mem::size_of::<R>())
}
fn main() {
let (name, size) = describe(|| panic!("F7 closure"));
println!("F7 R = {} (size_of = {})", name, size);
}
1.99.1 の 2021 は F7 R = () (size_of = 0)、1.100.0 は F7 R = ! (size_of = 0) やった。どっちも警告は 0 件。type_name をログやキャッシュのキーに使っとったら、出力が黙って変わる。地味やけど、今回いちばん怖かったんはこれやねん。
Infallible の別名化で通らんようになったコードは 2 つ。どっちも 1.99.1 では 4 edition とも通る。
error[E0432]: unresolved import `std::convert::Infallible`
--> use-infallible-self.rs:5:19
|
5 | use std::convert::Infallible::{self};
| ^^^^^^^^^^ `Infallible` is a type alias, not a module
もう 1 つの I7 では type Never = <fn() -> ! as Ret>::Out; で ! に名前を付けた。安定版で ! を名前で呼ぶクレートの手口を、std だけで書いたもんや。Infallible と Never の両方にトレイトを実装すると、1.98.1 と 1.99.1 は通って、1.100.0 は E0119 やった。
error[E0119]: conflicting implementations of trait `Tr` for type `!`
同じ手口で u8 に名前を付けた対照は 3 つの版とも通った。
unsafe の fallback を allow していると UB になる
F5 は if skip { return } else { unsafe { std::mem::zeroed() } }; で、zeroed の型が fallback で決まる。plain は両版とも never_type_fallback_flowing_into_unsafe で止まった。問題は allow しとった場合や。
1.99.1 の 2021 では zeroed::<()>() になって、F5 after zeroed と出て終わる。1.100.0 では zeroed::<!>() になって、debug でも release でも中断してもうた。
thread 'main' (13627) panicked at /rustc/0ef1bc386059596dada8fb65b50425aab2ea637a/library/core/src/panicking.rs:225:5:
attempted to instantiate uninhabited type `!`
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread caused non-unwinding panic. aborting.
exit=134 (SIGABRT)
F6 の std::mem::transmute::<(), _>(()) はもっと嫌やった。debug は出力なしの SIGILL (132)。release は終了コード 0 やのに、次の行の F6 after transmute が出えへん。落ちんと処理が消えたんや。これはほんまに怖い。
Miri(nightly-2026-11-12)にかけたら F5 も F6 も Undefined Behavior: constructing invalid value of type !: encountered a value of the never type と出た。型を書いた F6 fixed では何も出えへん。SIGABRT や SIGILL、行が消えるといった現れ方は、この環境とこの版で観測した UB の一例や。毎回同じになる保証は無い。
allow で fallback の lint を消しても、1.100.0 では invalid_value の警告が残った。文言は「the type ! does not permit zero-initialization」。ただ warn やからビルドは止まらへん。1.99.1 の 2015〜2021 では出えへんし、上げる前の検出には使えんかった。
cargo fix は今回の 3 か所を自動で直した
エディションガイドには、この変更に自動の修正は無いと書いてある。それでも試してみた。F1・F3・F4 の形を 1 つにまとめた edition 2021 のクレートに、1.99.1 の cargo fix をかけてる。
cargo +1.99.1 fix --allow-no-vcs --broken-code
Fixed src/main.rs (3 fixes) と出て、差分は 6 行やった。
- f()?;
+ f::<()>()?;
...
- let _ = match load(key) {
+ let _: () = match load(key) {
...
- if c { Default::default() } else { return };
+ if c { <() as Default>::default() } else { return };
直したコードは 1.100.0 でそのまま動いた。cargo fix --edition でも同じ 3 か所が直っとる。lint の help に出る提案を当てとるみたいやな。
--broken-code を付けたのは、直す前のコードが deny でビルドに失敗するからや。試したのはこの 3 つの形だけで、クロージャの F2 は入れてへん。
実在のクレート 15 本は両版で通った
| プロジェクト | 1.99.1 | 1.100.0 | future-incompat |
|---|---|---|---|
| 定番 9 本をまとめたもの(anyhow 1.0.104、thiserror 2.0.21、serde 1.0.229、serde_json 1.0.154、tokio 1.54.1、clap 4.6.7、regex 1.13.1、rand 0.10.3、itertools 0.15.0) | OK | OK | 0 件 |
| never-say-never 6.6.666 | OK | OK | 0 件 |
| lending-iterator 0.1.7 | OK | OK | 0 件 |
| generativity 1.2.1 | OK | OK | 0 件 |
| polonius-the-crab 0.5.0 | OK | OK | 0 件 |
| higher-kinded-types 0.3.1 | OK | OK | 0 件 |
| sqlite-tiny 0.7.8 | OK | OK | 0 件 |
never 型まわりの 6 本は、安定版で ! を名前で呼ぶ never-say-never と、それに依存する lending-iterator など。sqlite-tiny 0.7.8 は Infallible = ! の Issue #155924 で名前が出た版や。どれも edition 2021 で cargo check --locked を実行した。
定番 9 本の cargo check は空の target から 3 回ずつ測った。中央値は 1.99.1 が 16.1 秒、1.100.0 が 16.3 秒やで。
! と Infallible は同じ型になった
Result<String, !> と let Ok(v) = parse("x"); は 1.100.0 やったら全 edition で書ける。
N1 size_of::<Result<u32, !>>() = 4
N1 size_of::<Option<!>>() = 0
N1 size_of::<Result<!, !>>() = 0
N3 TypeId::of::<Infallible>() == TypeId::of::<!>() : true
N3 type_name::<Infallible>() = !
N3 type_name::<Result<u8, Infallible>>() = core::result::Result<u8, !>
type_name::<Infallible>() も ! と表示される。F7 と同じで、型名を文字列で扱っとるところに効いてくるで。
一緒に安定した DropGuard・Vec::from_fn・trim_prefix
| API | 1.100.0 で見たこと |
|---|---|
std::mem::DropGuard |
早期 return でも panic でもクロージャが走り、truncate で 4 件に戻った。成功時は DropGuard::dismiss でクロージャを走らせずに済む |
Vec::from_fn |
Vec::from_fn(5, |i| i * i) が [0, 1, 4, 9, 16]。長さ 0 ならクロージャは 0 回。呼ばれる順は 0, 1, 2, 3。添字 3 で panic すると作り済みの 3 個が drop された |
str::trim_prefix |
&str を返す。"1.2.3".trim_prefix("v") はそのまま "1.2.3"。"vv1".trim_prefix('v') は 1 回だけ削って "v1" |
Path::trim_prefix |
Path::new("/srv/app/logs").trim_prefix("/srv") が "app/logs"。Path::trim_suffix は 1.100.0 でも E0599 で、無い |
strip_prefix は一致せえへんと None を返す。trim_prefix は元の文字列を返すから、unwrap_or を書かんで済む。
1.100 に上げる前に自分のコードを調べる手順
今回の結果から、上から順に見ていく手順にまとめた。
- 1.99.1 で
cargo buildが通るか確かめる。落ちたら lint の help どおりに型を書くかcargo +1.99.1 fix --broken-code grep -rn "dependency_on_unit_never_type_fallback\|never_type_fallback_flowing_into_unsafe" --include=*.rs .で allow を探し、型を書いてから allow を外す- 1.99.1 のビルドの最後に「the following packages contain code that will be rejected」が出ていたら
cargo report future-incompatibilities --id <ID>で中身を見る Infallible::{self}の import と、Infallibleと別名の!の両方へのトレイト実装を grep するtype_nameやsize_ofに、型を書いていないクロージャやpanic!()を渡していないか目で見るcargo +1.100.0 checkを一度通し、unreachable_code・method_call_on_diverging_infer_var・renamed_and_removed_lintsの警告が増えていないか 1.99.1 と比べる
図の依存クレートの分岐は git 依存で確かめたもんや。path 依存やったら 1.99.1 の deny で止まるから、最初の分岐に入る。
never_type_fallback_flowing_into_unsafe を allow しとる所は、release で落ちんと行が消えることもあるから、すぐ型を書いたほうがええと思う。2 の grep は個別の lint 名しか拾えんから、rust_2024_compatibility みたいなグループでの allow、Cargo.toml の [lints.rust]、RUSTFLAGS の -A も拾えんはずや。ここは試せてへん。dependency_on_unit_never_type_fallback を名指しで allow しとった所なら、6 で renamed_and_removed_lints が出る。
3 は、自分やったら CI のビルドログをあの 1 行で grep して拾うわ。cargo のドキュメントにある [future-incompat-report] frequency = "always" は、報告を毎回出す設定。今回の検証ではこの設定は試してへん。
ハマりどころ
never-say-never と Infallible の二重実装は 1.98.1 から E0119
never-say-never 6.6.666 の Never と Infallible の両方にトレイトを実装する D3 は、1.100.0 で E0119 になると予想しとった。ところが 1.99.1 でも E0119(for type Infallible)で止まる。1.98.1 も同じやった。
1.100.0 では表示が for type ! に変わっただけ。std だけで同じ手口を書いた I7 は 1.99.1 で通るから、クレート側の何かが効いとるはずや。理由はまだ追えてへん。
.map_err(|e| match e {}) は古い edition で通らない
Infallible のエラーを消すときによう見る回避策や。ところが 1.99.1 の 2015〜2021 では E0277 やった。クロージャの戻り値が () に決まって、anyhow::Error に変換できへんからや。
error[E0277]: `?` couldn't convert the error: `(): std::error::Error` is not satisfied
1.99.1 の 2024 と 1.100.0 では通る。これは 1.100 で通るようになる側の変化やな。両版で通す書き方としては、let Ok(s) = "x".parse::<String>(); で受ける形と、anyhow なら Ok("x".parse::<String>()?) が 8 組すべてで警告 0 件で通った。
.map_err(|e| anyhow!(e)) に新しい警告が出る
1.99.1 では警告 0 件やったのに、1.100.0 では警告 3 件付きで通る。1 つは method_call_on_diverging_infer_var。1.98.1 には無くて 1.99 系で増えた lint で、診断は Issue #156047 を指しとる。将来はエラーになると書かれた警告で、自分のパッケージでも future-incompat の 1 行が出た。残りの 2 件は unreachable_code の unreachable arm と unreachable call や。
clippy の MSRV チェックは ! を見逃す
rust-version = "1.99" のクレートで cargo +1.100.0 clippy を実行してみた。incompatible_msrv の警告は 6 件で、DropGuard が 4 件、Vec::from_fn と trim_prefix が 1 件ずつ。Result<String, !> には何も出えへん。
そのクレートを 1.99.1 で cargo check したら E0658「the ! type is experimental」で失敗した。ライブラリで ! を書くなら MSRV は手で上げる。
Infallible を受け取る関数に 1.100.0 から警告が増える
e: Infallible が ! になって、e を使った先が到達不能と判定されるようになった。下の 3 ケースは 1.99.1 やったら警告 0 件やった。
| ケース | 1.100.0 で出た警告 |
|---|---|
I3 fn to_box(e: Infallible) -> Box<dyn Send> { Box::new(e) } と Box<dyn Error + Send + Sync> 版 |
unreachable_code(unreachable call)2 件 |
I4 let s = { e }.to_string(); |
method_call_on_diverging_infer_var と unreachable_code |
I5 (&e).to_string() と e.clone() |
unreachable_code 1 件 |
どれもビルドは通る。-D warnings を付けた CI なら止まるはずやけど、そこは試してへん。
F8 の 3 つの形では到達不能の警告は増えなかった
公式ブログには、到達不能と判定されるコードが増えることもあるとある。F8 の 3 つの形を試したけど unreachable_code の数は変わらんかった。代わりに、戻らんスレッドの let v = h.join().unwrap(); で unused_variables が 1 件増えとる。
費用: 0 円
GitHub Actions のランナーだけで、クラウドの料金は 0 円。実行は 2 回で、1 回目が 4 分 16 秒、2 回目が 4 分 39 秒やった。プランの無料分数に収まってる。
同じ ubuntu-latest のランナーでは、C# 15 の union types を .NET 11 GA で試した記事 も書いた。こっちも新しい言語機能をコンパイラーの診断で確かめてる。
まとめ
自分のプロジェクトでは、まず allow の grep と 1.100.0 での警告の差分から見るわ。crates.io から取ったクレートの中に fallback 依存がある場合は今回用意できへんかったから、git 依存で代わりに確かめてる。
参考
- https://blog.rust-lang.org/2026/11/12/Rust-1.100.0/
- https://doc.rust-lang.org/stable/releases.html
- https://doc.rust-lang.org/edition-guide/rust-2024/never-type-fallback.html
- https://doc.rust-lang.org/stable/std/primitive.never.html
- https://doc.rust-lang.org/stable/core/mem/struct.DropGuard.html
- https://doc.rust-lang.org/stable/std/vec/struct.Vec.html
- https://doc.rust-lang.org/cargo/reference/future-incompat-report.html
- https://github.com/rust-lang/rust/pull/155499
- https://github.com/rust-lang/rust/issues/155924
- https://github.com/rust-lang/rust/pull/146167
- https://github.com/rust-lang/rust/issues/148922
- https://github.com/rust-lang/rust/issues/143349
- https://github.com/rust-lang/rust/issues/156047