Auto merge of #124482 - spastorino:unsafe-extern-blocks, r=oli-obk
Unsafe extern blocks This implements RFC 3484. Tracking issue #123743 and RFC https://github.com/rust-lang/rfcs/pull/3484 This is better reviewed commit by commit.
This commit is contained in:
commit
2d28b6384e
93 changed files with 714 additions and 152 deletions
|
@ -2,6 +2,7 @@ use crate::{ImplTraitContext, Resolver};
|
|||
use rustc_ast::visit::FnKind;
|
||||
use rustc_ast::*;
|
||||
use rustc_expand::expand::AstFragment;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def::{CtorKind, CtorOf, DefKind};
|
||||
use rustc_hir::def_id::LocalDefId;
|
||||
use rustc_span::hygiene::LocalExpnId;
|
||||
|
@ -128,7 +129,11 @@ impl<'a, 'b, 'tcx> visit::Visitor<'a> for DefCollector<'a, 'b, 'tcx> {
|
|||
ItemKind::Union(..) => DefKind::Union,
|
||||
ItemKind::ExternCrate(..) => DefKind::ExternCrate,
|
||||
ItemKind::TyAlias(..) => DefKind::TyAlias,
|
||||
ItemKind::Static(s) => DefKind::Static { mutability: s.mutability, nested: false },
|
||||
ItemKind::Static(s) => DefKind::Static {
|
||||
safety: hir::Safety::Safe,
|
||||
mutability: s.mutability,
|
||||
nested: false,
|
||||
},
|
||||
ItemKind::Const(..) => DefKind::Const,
|
||||
ItemKind::Fn(..) | ItemKind::Delegation(..) => DefKind::Fn,
|
||||
ItemKind::MacroDef(..) => {
|
||||
|
@ -211,8 +216,18 @@ impl<'a, 'b, 'tcx> visit::Visitor<'a> for DefCollector<'a, 'b, 'tcx> {
|
|||
|
||||
fn visit_foreign_item(&mut self, fi: &'a ForeignItem) {
|
||||
let def_kind = match fi.kind {
|
||||
ForeignItemKind::Static(box StaticForeignItem { ty: _, mutability, expr: _ }) => {
|
||||
DefKind::Static { mutability, nested: false }
|
||||
ForeignItemKind::Static(box StaticForeignItem {
|
||||
ty: _,
|
||||
mutability,
|
||||
expr: _,
|
||||
safety,
|
||||
}) => {
|
||||
let safety = match safety {
|
||||
ast::Safety::Unsafe(_) | ast::Safety::Default => hir::Safety::Unsafe,
|
||||
ast::Safety::Safe(_) => hir::Safety::Safe,
|
||||
};
|
||||
|
||||
DefKind::Static { safety, mutability, nested: false }
|
||||
}
|
||||
ForeignItemKind::Fn(_) => DefKind::Fn,
|
||||
ForeignItemKind::TyAlias(_) => DefKind::ForeignTy,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue