diff options
| author | Tyler Mandry <tmandry@gmail.com> | 2020-09-10 12:19:57 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-09-10 12:19:57 -0700 |
| commit | 5aed4957ff893823d353fe3f1d2e4a80ebe35007 (patch) | |
| tree | ffbee7675a39dfad11c9e08610a8b9b9d4c4993d /src/test/codegen/src-hash-algorithm/src-hash-algorithm-md5.rs | |
| parent | 8c35a9279ca50d3e5a6f33d80a7191454fd89cbe (diff) | |
| parent | fd4dd00ddef578aa01744e4146c1dfe3fbca4866 (diff) | |
| download | rust-5aed4957ff893823d353fe3f1d2e4a80ebe35007.tar.gz rust-5aed4957ff893823d353fe3f1d2e4a80ebe35007.zip | |
Rollup merge of #75857 - dtolnay:unsafe, r=nagisa
Syntactically permit unsafety on mods
Similar to https://github.com/rust-lang/rust/pull/66183; we will accept these constructs syntactically but reject with a semantic check after macro expansion if a proc macro hasn't replaced it with something else meaningful to Rust.
```rust
#[mymacro]
unsafe mod m {
...
}
#[mymacro]
unsafe extern "C++" {
...
}
```
The intention is that this might be used as a kind of "item-level unsafe" in attribute macro DSLs -- holding things which are unsafe to declare but potentially safe to use. For example I look forward to using this in https://github.com/dtolnay/cxx.
In the absence of a procedural macro rewriting them to something else, they'll continue to be rejected at compile time though with a better error message than before.
### Before:
```console
error: expected item, found keyword `unsafe`
--> src/main.rs:1:1
|
1 | unsafe mod m {
| ^^^^^^ expected item
```
### After:
```console
error: module cannot be declared unsafe
--> src/main.rs:1:1
|
1 | unsafe mod m {
| ^^^^^^
error: extern block cannot be declared unsafe
--> src/main.rs:4:1
|
4 | unsafe extern "C++" {
| ^^^^^^
```
Closes #68048.
Diffstat (limited to 'src/test/codegen/src-hash-algorithm/src-hash-algorithm-md5.rs')
0 files changed, 0 insertions, 0 deletions
