forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#85607 - LeSeulArtichaut:thir-unsafeck-closure…
…s, r=nikomatsakis Make closures inherit their parent's "safety context" Fixes rust-lang/project-thir-unsafeck#9, ~~blocked on rust-lang#85273~~. r? `@nikomatsakis`
- Loading branch information
Showing
18 changed files
with
173 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
// check-pass | ||
// revisions: mir thir | ||
// [thir]compile-flags: -Zthir-unsafeck | ||
|
||
struct Attr { | ||
name: String, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
src/test/ui/issues/issue-45107-unnecessary-unsafe-in-closure.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
src/test/ui/issues/issue-45107-unnecessary-unsafe-in-closure.thir.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
error: unnecessary `unsafe` block | ||
--> $DIR/issue-45107-unnecessary-unsafe-in-closure.rs:10:13 | ||
| | ||
LL | unsafe { | ||
| ------ because it's nested under this `unsafe` block | ||
LL | let f = |v: &mut Vec<_>| { | ||
LL | unsafe { | ||
| ^^^^^^ unnecessary `unsafe` block | ||
| | ||
note: the lint level is defined here | ||
--> $DIR/issue-45107-unnecessary-unsafe-in-closure.rs:4:8 | ||
| | ||
LL | #[deny(unused_unsafe)] | ||
| ^^^^^^^^^^^^^ | ||
|
||
error: unnecessary `unsafe` block | ||
--> $DIR/issue-45107-unnecessary-unsafe-in-closure.rs:12:38 | ||
| | ||
LL | unsafe { | ||
| ------ because it's nested under this `unsafe` block | ||
... | ||
LL | |w: &mut Vec<u32>| { unsafe { | ||
| ^^^^^^ unnecessary `unsafe` block | ||
|
||
error: unnecessary `unsafe` block | ||
--> $DIR/issue-45107-unnecessary-unsafe-in-closure.rs:16:34 | ||
| | ||
LL | unsafe { | ||
| ------ because it's nested under this `unsafe` block | ||
... | ||
LL | |x: &mut Vec<u32>| { unsafe { | ||
| ^^^^^^ unnecessary `unsafe` block | ||
|
||
error: aborting due to 3 previous errors | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 9 additions & 9 deletions
18
src/test/ui/span/lint-unused-unsafe.stderr → ...est/ui/span/lint-unused-unsafe.mir.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
error: unnecessary `unsafe` block | ||
--> $DIR/lint-unused-unsafe.rs:19:13 | ||
| | ||
LL | fn bad1() { unsafe {} } | ||
| ^^^^^^ unnecessary `unsafe` block | ||
| | ||
note: the lint level is defined here | ||
--> $DIR/lint-unused-unsafe.rs:7:9 | ||
| | ||
LL | #![deny(unused_unsafe)] | ||
| ^^^^^^^^^^^^^ | ||
|
||
error: unnecessary `unsafe` block | ||
--> $DIR/lint-unused-unsafe.rs:20:13 | ||
| | ||
LL | fn bad2() { unsafe { bad1() } } | ||
| ^^^^^^ unnecessary `unsafe` block | ||
|
||
error: unnecessary `unsafe` block | ||
--> $DIR/lint-unused-unsafe.rs:21:20 | ||
| | ||
LL | unsafe fn bad3() { unsafe {} } | ||
| ---------------- ^^^^^^ unnecessary `unsafe` block | ||
| | | ||
| because it's nested under this `unsafe` fn | ||
|
||
error: unnecessary `unsafe` block | ||
--> $DIR/lint-unused-unsafe.rs:22:13 | ||
| | ||
LL | fn bad4() { unsafe { callback(||{}) } } | ||
| ^^^^^^ unnecessary `unsafe` block | ||
|
||
error: unnecessary `unsafe` block | ||
--> $DIR/lint-unused-unsafe.rs:23:20 | ||
| | ||
LL | unsafe fn bad5() { unsafe { unsf() } } | ||
| ---------------- ^^^^^^ unnecessary `unsafe` block | ||
| | | ||
| because it's nested under this `unsafe` fn | ||
|
||
error: unnecessary `unsafe` block | ||
--> $DIR/lint-unused-unsafe.rs:26:9 | ||
| | ||
LL | unsafe { // don't put the warning here | ||
| ------ because it's nested under this `unsafe` block | ||
LL | unsafe { | ||
| ^^^^^^ unnecessary `unsafe` block | ||
|
||
error: unnecessary `unsafe` block | ||
--> $DIR/lint-unused-unsafe.rs:33:9 | ||
| | ||
LL | unsafe { | ||
| ------ because it's nested under this `unsafe` block | ||
LL | unsafe { | ||
| ^^^^^^ unnecessary `unsafe` block | ||
|
||
error: unnecessary `unsafe` block | ||
--> $DIR/lint-unused-unsafe.rs:32:5 | ||
| | ||
LL | unsafe fn bad7() { | ||
| ---------------- because it's nested under this `unsafe` fn | ||
LL | unsafe { | ||
| ^^^^^^ unnecessary `unsafe` block | ||
|
||
error: aborting due to 8 previous errors | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters