diff options
| author | Yuki Okushi <jtitor@2k36.org> | 2021-06-22 20:01:05 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-06-22 20:01:05 +0900 |
| commit | 8ec4e7dfdd5b90aa8867bf07e4d68f57908b080e (patch) | |
| tree | 5e8e26643667d41959435fd8212835c4c33ba366 /compiler/rustc_middle | |
| parent | 8af9339e49304f504d6c1c6c2210c44bbed45fc4 (diff) | |
| parent | b07bb6d698d842f05b1664b8824671080274d53d (diff) | |
| download | rust-8ec4e7dfdd5b90aa8867bf07e4d68f57908b080e.tar.gz rust-8ec4e7dfdd5b90aa8867bf07e4d68f57908b080e.zip | |
Rollup merge of #86517 - camsteffen:unused-unsafe-async, r=LeSeulArtichaut
Fix `unused_unsafe` around `await`
Enables `unused_unsafe` lint for `unsafe { future.await }`.
The existing test for this is `unsafe { println!() }`, so I assume that `println!` used to contain compiler-generated unsafe but this is no longer true, and so the existing test is broken. I replaced the test with `unsafe { ...await }`. I believe `await` is currently the only instance of compiler-generated unsafe.
Reverts some parts of #85421, but the issue predates that PR.
Diffstat (limited to 'compiler/rustc_middle')
| -rw-r--r-- | compiler/rustc_middle/src/mir/mod.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/thir.rs | 1 |
2 files changed, 3 insertions, 0 deletions
diff --git a/compiler/rustc_middle/src/mir/mod.rs b/compiler/rustc_middle/src/mir/mod.rs index 0daaec272fd..672686410f9 100644 --- a/compiler/rustc_middle/src/mir/mod.rs +++ b/compiler/rustc_middle/src/mir/mod.rs @@ -494,6 +494,8 @@ impl<'tcx> Body<'tcx> { #[derive(Copy, Clone, PartialEq, Eq, Debug, TyEncodable, TyDecodable, HashStable)] pub enum Safety { Safe, + /// Unsafe because of compiler-generated unsafe code, like `await` desugaring + BuiltinUnsafe, /// Unsafe because of an unsafe fn FnUnsafe, /// Unsafe because of an `unsafe` block diff --git a/compiler/rustc_middle/src/thir.rs b/compiler/rustc_middle/src/thir.rs index 2f107e7b96c..6b2e542ee70 100644 --- a/compiler/rustc_middle/src/thir.rs +++ b/compiler/rustc_middle/src/thir.rs @@ -114,6 +114,7 @@ pub struct Adt<'tcx> { #[derive(Copy, Clone, Debug, HashStable)] pub enum BlockSafety { Safe, + BuiltinUnsafe, ExplicitUnsafe(hir::HirId), } |
