Allow unsafe extern on all editions
This commit is contained in:
parent
68b0b86c5b
commit
6d670b74e5
7 changed files with 11 additions and 36 deletions
|
@ -1016,15 +1016,12 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
|
|||
walk_list!(self, visit_attribute, &item.attrs);
|
||||
return; // Avoid visiting again.
|
||||
}
|
||||
ItemKind::ForeignMod(ForeignMod { abi, safety, .. }) => {
|
||||
ItemKind::ForeignMod(ForeignMod { abi, .. }) => {
|
||||
let old_item = mem::replace(&mut self.extern_mod, Some(item));
|
||||
self.visibility_not_permitted(
|
||||
&item.vis,
|
||||
errors::VisibilityNotPermittedNote::IndividualForeignItems,
|
||||
);
|
||||
if let &Safety::Unsafe(span) = safety {
|
||||
self.dcx().emit_err(errors::UnsafeItem { span, kind: "extern block" });
|
||||
}
|
||||
if abi.is_none() {
|
||||
self.maybe_lint_missing_abi(item.span, item.id);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
extern "C" unsafe {
|
||||
//~^ ERROR expected `{`, found keyword `unsafe`
|
||||
//~| ERROR extern block cannot be declared unsafe
|
||||
unsafe fn foo();
|
||||
//~^ ERROR functions in `extern` blocks cannot have qualifiers
|
||||
}
|
||||
|
|
|
@ -4,20 +4,14 @@ error: expected `{`, found keyword `unsafe`
|
|||
LL | extern "C" unsafe {
|
||||
| ^^^^^^ expected `{`
|
||||
|
||||
error: extern block cannot be declared unsafe
|
||||
--> $DIR/unsafe-foreign-mod-2.rs:1:12
|
||||
|
|
||||
LL | extern "C" unsafe {
|
||||
| ^^^^^^
|
||||
|
||||
error: functions in `extern` blocks cannot have qualifiers
|
||||
--> $DIR/unsafe-foreign-mod-2.rs:4:5
|
||||
--> $DIR/unsafe-foreign-mod-2.rs:3:5
|
||||
|
|
||||
LL | extern "C" unsafe {
|
||||
| ----------------- in this `extern` block
|
||||
...
|
||||
LL |
|
||||
LL | unsafe fn foo();
|
||||
| ^^^^^^ help: remove this qualifier
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
unsafe extern "C" {
|
||||
//~^ ERROR extern block cannot be declared unsafe
|
||||
}
|
||||
//@ build-pass
|
||||
|
||||
unsafe extern "C" {}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
error: extern block cannot be declared unsafe
|
||||
--> $DIR/unsafe-foreign-mod.rs:1:1
|
||||
|
|
||||
LL | unsafe extern "C" {
|
||||
| ^^^^^^
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
|
@ -1,10 +1,11 @@
|
|||
//@ build-pass
|
||||
|
||||
extern "C" {
|
||||
static TEST1: i32;
|
||||
fn test1(i: i32);
|
||||
}
|
||||
|
||||
unsafe extern "C" {
|
||||
//~^ ERROR: extern block cannot be declared unsafe
|
||||
static TEST2: i32;
|
||||
fn test2(i: i32);
|
||||
}
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
error: extern block cannot be declared unsafe
|
||||
--> $DIR/extern-items.rs:6:1
|
||||
|
|
||||
LL | unsafe extern "C" {
|
||||
| ^^^^^^
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
Loading…
Add table
Reference in a new issue