)]}'
{
  "commit": "fb6d93917e59ce3b0acfe01d9fbb37deceda43e8",
  "tree": "f8da3594170bfb3ea1e27b58dd4881cf50a8ce48",
  "parents": [
    "0376d43d443cba463a0b6a6ec9140ea17d7b7130",
    "4f31ff893d4dd6125a445e3bda85c0fae623578c"
  ],
  "author": {
    "name": "Jonathan Brouwer",
    "email": "jonathantbrouwer@gmail.com",
    "time": "Fri Feb 20 22:00:54 2026 +0100"
  },
  "committer": {
    "name": "GitHub",
    "email": "noreply@github.com",
    "time": "Fri Feb 20 22:00:54 2026 +0100"
  },
  "message": "Rollup merge of #146832 - Natural-selection1:not-in-chains, r\u003dpetrochenkov\n\nNot linting irrefutable_let_patterns on let chains\n\n*[View all comments](https://triagebot.infra.rust-lang.org/gh-comments/rust-lang/rust/pull/146832)*\n\n# Description\n\nthis PR makes the lint `irrefutable_let_patterns` not check for `let chains`,\nonly check for single `if let`, `while let`, and `if let guard`.\n\n# Motivation\n\nSince `let chains` were stabilized, the following code has become common:\n\n```rust\nfn max() -\u003e usize { 42 }\n\nfn main() {\n    if let mx \u003d max() \u0026\u0026 mx \u003c usize::MAX { /* */ }\n}\n```\n\nThis code naturally expresses \"please call that function and then do something if the return value satisfies a condition\".\nPutting the let binding outside the if would be bad as then it remains in scope after the if, which is not the intent.\n\nCurrent Output:\n\n```bash\nwarning: leading irrefutable pattern in let chain\n --\u003e src/main.rs:7:8\n  |\n7 |     if let mx \u003d max() \u0026\u0026 mx \u003c usize::MAX {\n  |        ^^^^^^^^^^^^^^\n  |\n  \u003d note: this pattern will always match\n  \u003d help: consider moving it outside of the construct\n  \u003d note: `#[warn(irrefutable_let_patterns)]` on by default\n```\n\nAnother common case is progressively destructuring a struct with enum fields, or an enum with struct variants:\n\n```rust\nstruct NameOfOuterStruct {\n    middle: NameOfMiddleEnum,\n    other: (),\n}\nenum NameOfMiddleEnum {\n    Inner(NameOfInnerStruct),\n    Other(()),\n}\nstruct NameOfInnerStruct {\n    id: u32,\n}\n\nfn test(outer: NameOfOuterStruct) {\n    if let NameOfOuterStruct { middle, .. } \u003d outer\n        \u0026\u0026 let NameOfMiddleEnum::Inner(inner) \u003d middle\n        \u0026\u0026 let NameOfInnerStruct { id } \u003d inner\n    {\n        /* */\n    }\n}\n```\n\nCurrent Output:\n\n```bash\nwarning: leading irrefutable pattern in let chain\n  --\u003e src\\main.rs:17:8\n   |\n17 |     if let NameOfOuterStruct { middle, .. } \u003d outer\n   |        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n   |\n   \u003d note: this pattern will always match\n   \u003d help: consider moving it outside of the construct\n   \u003d note: `#[warn(irrefutable_let_patterns)]` on by default\n\nwarning: trailing irrefutable pattern in let chain\n  --\u003e src\\main.rs:19:12\n   |\n19 |         \u0026\u0026 let NameOfInnerStruct { id } \u003d inner\n   |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n   |\n   \u003d note: this pattern will always match\n   \u003d help: consider moving it into the body\n```\n\nTo avoid the warning, the readability would be much worse:\n\n```rust\nfn test(outer: NameOfOuterStruct) {\n    if let NameOfOuterStruct {\n        middle: NameOfMiddleEnum::Inner(NameOfInnerStruct { id }),\n        ..\n    } \u003d outer\n    {\n        /* */\n    }\n}\n```\n\n# related issue\n\n* rust-lang/rust#139369\n\n# possible questions\n\n1. Moving the irrefutable pattern at the head of the chain out of it would cause a variable that was intended to be temporary to remain in scope, so we remove it.\n   However, should we keep the check for moving the irrefutable pattern at the tail into the body?\n\n2. Should we still lint `entire chain is made up of irrefutable let`?\n\n---\n\nThis is my first time contributing non-documentation code to Rust. If there are any irregularities, please feel free to point them out.\n: )\n",
  "tree_diff": []
}
