crown: Check closure bodies for unrooted types and fix root TransmitBodyPromise* (#39534)

We should also check closure bodies for unrooted expressions. 

Testing: New crown tests
Fixes: #37331
Fixes (partial): #37330

---------

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
This commit is contained in:
Sam 2025-09-29 10:57:23 +02:00 committed by GitHub
parent 6c062bbea8
commit aaa7f83176
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 42 additions and 7 deletions

View file

@ -0,0 +1,14 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
//@rustc-env:RUSTC_BOOTSTRAP=1
#[crown::unrooted_must_root_lint::must_root]
struct Foo(i32);
fn foo2() {
let foo = Foo(0);
//~^ ERROR: Expression of type Foo must be rooted
}
fn main() {}

View file

@ -0,0 +1,16 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
//@rustc-env:RUSTC_BOOTSTRAP=1
#[crown::unrooted_must_root_lint::must_root]
struct Foo(i32);
fn foo2() {
|| {
let foo = Foo(0);
//~^ ERROR: Expression of type Foo must be rooted
};
}
fn main() {}