librustc: Remove legacy exports from the language. r=brson
This commit is contained in:
parent
040035cd08
commit
49472ec4c9
14 changed files with 75 additions and 387 deletions
|
@ -331,12 +331,11 @@ fn encode_info_for_mod(ecx: @encode_ctxt, ebml_w: writer::Encoder,
|
||||||
item_impl(*) | item_struct(*) => {
|
item_impl(*) | item_struct(*) => {
|
||||||
let (ident, did) = (item.ident, item.id);
|
let (ident, did) = (item.ident, item.id);
|
||||||
debug!("(encoding info for module) ... encoding impl %s \
|
debug!("(encoding info for module) ... encoding impl %s \
|
||||||
(%?/%?), exported? %?",
|
(%?/%?)",
|
||||||
ecx.tcx.sess.str_of(ident),
|
ecx.tcx.sess.str_of(ident),
|
||||||
did,
|
did,
|
||||||
ast_map::node_id_to_str(ecx.tcx.items, did, ecx.tcx
|
ast_map::node_id_to_str(ecx.tcx.items, did, ecx.tcx
|
||||||
.sess.parse_sess.interner),
|
.sess.parse_sess.interner));
|
||||||
ast_util::is_exported(ident, md));
|
|
||||||
|
|
||||||
ebml_w.start_tag(tag_mod_impl);
|
ebml_w.start_tag(tag_mod_impl);
|
||||||
ebml_w.wr_str(def_to_str(local_def(did)));
|
ebml_w.wr_str(def_to_str(local_def(did)));
|
||||||
|
|
|
@ -29,8 +29,8 @@ use syntax::ast::{provided, required};
|
||||||
use syntax::ast;
|
use syntax::ast;
|
||||||
use syntax::ast_map::{node_item, node_method};
|
use syntax::ast_map::{node_item, node_method};
|
||||||
use syntax::ast_map;
|
use syntax::ast_map;
|
||||||
use syntax::ast_util::{Private, Public, has_legacy_export_attr, is_local};
|
use syntax::ast_util::{Private, Public, is_local};
|
||||||
use syntax::ast_util::{visibility_to_privacy};
|
use syntax::ast_util::{variant_visibility_to_privacy, visibility_to_privacy};
|
||||||
use syntax::codemap::span;
|
use syntax::codemap::span;
|
||||||
use syntax::visit;
|
use syntax::visit;
|
||||||
|
|
||||||
|
@ -38,7 +38,6 @@ pub fn check_crate(tcx: ty::ctxt,
|
||||||
method_map: &method_map,
|
method_map: &method_map,
|
||||||
crate: @ast::crate) {
|
crate: @ast::crate) {
|
||||||
let privileged_items = @DVec();
|
let privileged_items = @DVec();
|
||||||
let legacy_exports = has_legacy_export_attr(crate.node.attrs);
|
|
||||||
|
|
||||||
// Adds structs that are privileged to this scope.
|
// Adds structs that are privileged to this scope.
|
||||||
let add_privileged_items: @fn(&[@ast::item]) -> uint = |items| {
|
let add_privileged_items: @fn(&[@ast::item]) -> uint = |items| {
|
||||||
|
@ -65,20 +64,20 @@ pub fn check_crate(tcx: ty::ctxt,
|
||||||
|it| { it.vis },
|
|it| { it.vis },
|
||||||
~"unbound enum parent when checking \
|
~"unbound enum parent when checking \
|
||||||
dereference of enum type");
|
dereference of enum type");
|
||||||
visibility_to_privacy(parent_vis, legacy_exports)
|
visibility_to_privacy(parent_vis)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// WRONG
|
// WRONG
|
||||||
Public
|
Public
|
||||||
};
|
};
|
||||||
debug!("parental_privacy = %?", parental_privacy);
|
debug!("parental_privacy = %?", parental_privacy);
|
||||||
debug!("vis = %?, priv = %?, legacy_exports = %?",
|
debug!("vis = %?, priv = %?",
|
||||||
variant_info.vis,
|
variant_info.vis,
|
||||||
visibility_to_privacy(variant_info.vis, legacy_exports),
|
visibility_to_privacy(variant_info.vis))
|
||||||
legacy_exports);
|
|
||||||
// inherited => privacy of the enum item
|
// inherited => privacy of the enum item
|
||||||
if visibility_to_privacy(variant_info.vis,
|
if variant_visibility_to_privacy(variant_info.vis,
|
||||||
parental_privacy == Public) == Private {
|
parental_privacy == Public)
|
||||||
|
== Private {
|
||||||
tcx.sess.span_err(span,
|
tcx.sess.span_err(span,
|
||||||
~"can only dereference enums \
|
~"can only dereference enums \
|
||||||
with a single, public variant");
|
with a single, public variant");
|
||||||
|
|
|
@ -54,14 +54,14 @@ use syntax::ast::{ty_bool, ty_char, ty_f, ty_f32, ty_f64, ty_float, ty_i};
|
||||||
use syntax::ast::{ty_i16, ty_i32, ty_i64, ty_i8, ty_int, ty_param, ty_path};
|
use syntax::ast::{ty_i16, ty_i32, ty_i64, ty_i8, ty_int, ty_param, ty_path};
|
||||||
use syntax::ast::{ty_str, ty_u, ty_u16, ty_u32, ty_u64, ty_u8, ty_uint};
|
use syntax::ast::{ty_str, ty_u, ty_u16, ty_u32, ty_u64, ty_u8, ty_uint};
|
||||||
use syntax::ast::{type_value_ns, ty_param_bound, unnamed_field};
|
use syntax::ast::{type_value_ns, ty_param_bound, unnamed_field};
|
||||||
use syntax::ast::{variant, view_item, view_item_export, view_item_import};
|
use syntax::ast::{variant, view_item, view_item_import};
|
||||||
use syntax::ast::{view_item_use, view_path_glob, view_path_list};
|
use syntax::ast::{view_item_use, view_path_glob, view_path_list};
|
||||||
use syntax::ast::{view_path_simple, visibility, anonymous, named, not};
|
use syntax::ast::{view_path_simple, visibility, anonymous, named, not};
|
||||||
use syntax::ast::{unsafe_fn};
|
use syntax::ast::{unsafe_fn};
|
||||||
use syntax::ast_util::{def_id_of_def, dummy_sp, local_def};
|
use syntax::ast_util::{def_id_of_def, dummy_sp, local_def};
|
||||||
use syntax::ast_util::{path_to_ident, walk_pat, trait_method_to_ty_method};
|
use syntax::ast_util::{path_to_ident, walk_pat, trait_method_to_ty_method};
|
||||||
use syntax::ast_util::{Privacy, Public, Private, visibility_to_privacy};
|
use syntax::ast_util::{Privacy, Public, Private};
|
||||||
use syntax::ast_util::has_legacy_export_attr;
|
use syntax::ast_util::{variant_visibility_to_privacy, visibility_to_privacy};
|
||||||
use syntax::attr::{attr_metas, contains_name, attrs_contains_name};
|
use syntax::attr::{attr_metas, contains_name, attrs_contains_name};
|
||||||
use syntax::parse::token::ident_interner;
|
use syntax::parse::token::ident_interner;
|
||||||
use syntax::parse::token::special_idents;
|
use syntax::parse::token::special_idents;
|
||||||
|
@ -469,13 +469,6 @@ pub struct Module {
|
||||||
|
|
||||||
exported_names: HashMap<ident,node_id>,
|
exported_names: HashMap<ident,node_id>,
|
||||||
|
|
||||||
// XXX: This is a transition measure to let us switch export-evaluation
|
|
||||||
// logic when compiling modules that have transitioned to listing their
|
|
||||||
// pub/priv qualifications on items, explicitly, rather than using the
|
|
||||||
// old export rule.
|
|
||||||
|
|
||||||
legacy_exports: bool,
|
|
||||||
|
|
||||||
// The status of resolving each import in this module.
|
// The status of resolving each import in this module.
|
||||||
import_resolutions: HashMap<ident,@ImportResolution>,
|
import_resolutions: HashMap<ident,@ImportResolution>,
|
||||||
|
|
||||||
|
@ -488,8 +481,7 @@ pub struct Module {
|
||||||
|
|
||||||
pub fn Module(parent_link: ParentLink,
|
pub fn Module(parent_link: ParentLink,
|
||||||
def_id: Option<def_id>,
|
def_id: Option<def_id>,
|
||||||
kind: ModuleKind,
|
kind: ModuleKind)
|
||||||
legacy_exports: bool)
|
|
||||||
-> Module {
|
-> Module {
|
||||||
Module {
|
Module {
|
||||||
parent_link: parent_link,
|
parent_link: parent_link,
|
||||||
|
@ -499,7 +491,6 @@ pub fn Module(parent_link: ParentLink,
|
||||||
imports: DVec(),
|
imports: DVec(),
|
||||||
anonymous_children: HashMap(),
|
anonymous_children: HashMap(),
|
||||||
exported_names: HashMap(),
|
exported_names: HashMap(),
|
||||||
legacy_exports: legacy_exports,
|
|
||||||
import_resolutions: HashMap(),
|
import_resolutions: HashMap(),
|
||||||
glob_count: 0,
|
glob_count: 0,
|
||||||
resolved_import_count: 0
|
resolved_import_count: 0
|
||||||
|
@ -553,10 +544,9 @@ pub impl NameBindings {
|
||||||
parent_link: ParentLink,
|
parent_link: ParentLink,
|
||||||
def_id: Option<def_id>,
|
def_id: Option<def_id>,
|
||||||
kind: ModuleKind,
|
kind: ModuleKind,
|
||||||
legacy_exports: bool,
|
|
||||||
sp: span) {
|
sp: span) {
|
||||||
// Merges the module with the existing type def or creates a new one.
|
// Merges the module with the existing type def or creates a new one.
|
||||||
let module_ = @Module(parent_link, def_id, kind, legacy_exports);
|
let module_ = @Module(parent_link, def_id, kind);
|
||||||
match self.type_def {
|
match self.type_def {
|
||||||
None => {
|
None => {
|
||||||
self.type_def = Some(TypeNsDef {
|
self.type_def = Some(TypeNsDef {
|
||||||
|
@ -760,7 +750,6 @@ pub fn Resolver(session: Session,
|
||||||
NoParentLink,
|
NoParentLink,
|
||||||
Some(def_id { crate: 0, node: 0 }),
|
Some(def_id { crate: 0, node: 0 }),
|
||||||
NormalModuleKind,
|
NormalModuleKind,
|
||||||
has_legacy_export_attr(crate.node.attrs),
|
|
||||||
crate.span);
|
crate.span);
|
||||||
|
|
||||||
let current_module = (*graph_root).get_module();
|
let current_module = (*graph_root).get_module();
|
||||||
|
@ -1076,14 +1065,10 @@ pub impl Resolver {
|
||||||
&&visitor: vt<ReducedGraphParent>) {
|
&&visitor: vt<ReducedGraphParent>) {
|
||||||
let ident = item.ident;
|
let ident = item.ident;
|
||||||
let sp = item.span;
|
let sp = item.span;
|
||||||
let legacy = match parent {
|
let privacy = visibility_to_privacy(item.vis);
|
||||||
ModuleReducedGraphParent(m) => m.legacy_exports
|
|
||||||
};
|
|
||||||
let privacy = visibility_to_privacy(item.vis, legacy);
|
|
||||||
|
|
||||||
match /*bad*/copy item.node {
|
match /*bad*/copy item.node {
|
||||||
item_mod(module_) => {
|
item_mod(module_) => {
|
||||||
let legacy = has_legacy_export_attr(item.attrs);
|
|
||||||
let (name_bindings, new_parent) =
|
let (name_bindings, new_parent) =
|
||||||
self.add_child(ident, parent, ForbidDuplicateModules, sp);
|
self.add_child(ident, parent, ForbidDuplicateModules, sp);
|
||||||
|
|
||||||
|
@ -1093,7 +1078,6 @@ pub impl Resolver {
|
||||||
parent_link,
|
parent_link,
|
||||||
Some(def_id),
|
Some(def_id),
|
||||||
NormalModuleKind,
|
NormalModuleKind,
|
||||||
legacy,
|
|
||||||
sp);
|
sp);
|
||||||
|
|
||||||
let new_parent =
|
let new_parent =
|
||||||
|
@ -1103,7 +1087,6 @@ pub impl Resolver {
|
||||||
}
|
}
|
||||||
|
|
||||||
item_foreign_mod(fm) => {
|
item_foreign_mod(fm) => {
|
||||||
let legacy = has_legacy_export_attr(item.attrs);
|
|
||||||
let new_parent = match fm.sort {
|
let new_parent = match fm.sort {
|
||||||
named => {
|
named => {
|
||||||
let (name_bindings, new_parent) =
|
let (name_bindings, new_parent) =
|
||||||
|
@ -1117,7 +1100,6 @@ pub impl Resolver {
|
||||||
parent_link,
|
parent_link,
|
||||||
Some(def_id),
|
Some(def_id),
|
||||||
ExternModuleKind,
|
ExternModuleKind,
|
||||||
legacy,
|
|
||||||
sp);
|
sp);
|
||||||
|
|
||||||
ModuleReducedGraphParent(name_bindings.get_module())
|
ModuleReducedGraphParent(name_bindings.get_module())
|
||||||
|
@ -1168,9 +1150,10 @@ pub impl Resolver {
|
||||||
self.build_reduced_graph_for_variant(*variant,
|
self.build_reduced_graph_for_variant(*variant,
|
||||||
local_def(item.id),
|
local_def(item.id),
|
||||||
// inherited => privacy of the enum item
|
// inherited => privacy of the enum item
|
||||||
visibility_to_privacy(variant.node.vis,
|
variant_visibility_to_privacy(variant.node.vis,
|
||||||
privacy == Public),
|
privacy == Public),
|
||||||
new_parent, visitor);
|
new_parent,
|
||||||
|
visitor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1238,7 +1221,6 @@ pub impl Resolver {
|
||||||
parent_link,
|
parent_link,
|
||||||
Some(def_id),
|
Some(def_id),
|
||||||
TraitModuleKind,
|
TraitModuleKind,
|
||||||
false,
|
|
||||||
sp);
|
sp);
|
||||||
|
|
||||||
let new_parent = ModuleReducedGraphParent(
|
let new_parent = ModuleReducedGraphParent(
|
||||||
|
@ -1301,7 +1283,6 @@ pub impl Resolver {
|
||||||
parent_link,
|
parent_link,
|
||||||
Some(local_def(item.id)),
|
Some(local_def(item.id)),
|
||||||
TraitModuleKind,
|
TraitModuleKind,
|
||||||
false,
|
|
||||||
sp);
|
sp);
|
||||||
module_parent_opt = Some(ModuleReducedGraphParent(
|
module_parent_opt = Some(ModuleReducedGraphParent(
|
||||||
name_bindings.get_module()));
|
name_bindings.get_module()));
|
||||||
|
@ -1408,11 +1389,7 @@ pub impl Resolver {
|
||||||
fn build_reduced_graph_for_view_item(view_item: @view_item,
|
fn build_reduced_graph_for_view_item(view_item: @view_item,
|
||||||
parent: ReducedGraphParent,
|
parent: ReducedGraphParent,
|
||||||
&&_visitor: vt<ReducedGraphParent>) {
|
&&_visitor: vt<ReducedGraphParent>) {
|
||||||
|
let privacy = visibility_to_privacy(view_item.vis);
|
||||||
let legacy = match parent {
|
|
||||||
ModuleReducedGraphParent(m) => m.legacy_exports
|
|
||||||
};
|
|
||||||
let privacy = visibility_to_privacy(view_item.vis, legacy);
|
|
||||||
match /*bad*/copy view_item.node {
|
match /*bad*/copy view_item.node {
|
||||||
view_item_import(view_paths) => {
|
view_item_import(view_paths) => {
|
||||||
for view_paths.each |view_path| {
|
for view_paths.each |view_path| {
|
||||||
|
@ -1484,64 +1461,6 @@ pub impl Resolver {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
view_item_export(view_paths) => {
|
|
||||||
let module_ = self.get_module_from_parent(parent);
|
|
||||||
for view_paths.each |view_path| {
|
|
||||||
match view_path.node {
|
|
||||||
view_path_simple(ident, full_path, _, ident_id) => {
|
|
||||||
let last_ident = full_path.idents.last();
|
|
||||||
if last_ident != ident {
|
|
||||||
self.session.span_err(view_item.span,
|
|
||||||
~"cannot export under \
|
|
||||||
a new name");
|
|
||||||
}
|
|
||||||
if full_path.idents.len() != 1u {
|
|
||||||
self.session.span_err(
|
|
||||||
view_item.span,
|
|
||||||
~"cannot export an item \
|
|
||||||
that is not in this \
|
|
||||||
module");
|
|
||||||
}
|
|
||||||
|
|
||||||
module_.exported_names.insert(ident, ident_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
view_path_glob(*) => {
|
|
||||||
self.session.span_err(view_item.span,
|
|
||||||
~"export globs are \
|
|
||||||
unsupported");
|
|
||||||
}
|
|
||||||
|
|
||||||
view_path_list(path, ref path_list_idents, _) => {
|
|
||||||
if path.idents.len() == 1u &&
|
|
||||||
(*path_list_idents).len() == 0 {
|
|
||||||
|
|
||||||
self.session.span_warn(view_item.span,
|
|
||||||
~"this syntax for \
|
|
||||||
exporting no \
|
|
||||||
variants is \
|
|
||||||
unsupported; export \
|
|
||||||
variants \
|
|
||||||
individually");
|
|
||||||
} else {
|
|
||||||
if path.idents.len() != 0 {
|
|
||||||
self.session.span_err(view_item.span,
|
|
||||||
~"cannot export an \
|
|
||||||
item that is not \
|
|
||||||
in this module");
|
|
||||||
}
|
|
||||||
|
|
||||||
for path_list_idents.each |path_list_ident| {
|
|
||||||
let ident = path_list_ident.node.name;
|
|
||||||
let id = path_list_ident.node.id;
|
|
||||||
module_.exported_names.insert(ident, id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
view_item_use(name, _, node_id) => {
|
view_item_use(name, _, node_id) => {
|
||||||
match find_use_stmt_cnum(self.session.cstore, node_id) {
|
match find_use_stmt_cnum(self.session.cstore, node_id) {
|
||||||
Some(crate_id) => {
|
Some(crate_id) => {
|
||||||
|
@ -1553,12 +1472,11 @@ pub impl Resolver {
|
||||||
let parent_link = ModuleParentLink
|
let parent_link = ModuleParentLink
|
||||||
(self.get_module_from_parent(new_parent), name);
|
(self.get_module_from_parent(new_parent), name);
|
||||||
|
|
||||||
(*child_name_bindings).define_module(privacy,
|
child_name_bindings.define_module(privacy,
|
||||||
parent_link,
|
parent_link,
|
||||||
Some(def_id),
|
Some(def_id),
|
||||||
NormalModuleKind,
|
NormalModuleKind,
|
||||||
false,
|
view_item.span);
|
||||||
view_item.span);
|
|
||||||
self.build_reduced_graph_for_external_crate
|
self.build_reduced_graph_for_external_crate
|
||||||
((*child_name_bindings).get_module());
|
((*child_name_bindings).get_module());
|
||||||
}
|
}
|
||||||
|
@ -1616,8 +1534,7 @@ pub impl Resolver {
|
||||||
let parent_module = self.get_module_from_parent(parent);
|
let parent_module = self.get_module_from_parent(parent);
|
||||||
let new_module = @Module(BlockParentLink(parent_module, block_id),
|
let new_module = @Module(BlockParentLink(parent_module, block_id),
|
||||||
None,
|
None,
|
||||||
AnonymousModuleKind,
|
AnonymousModuleKind);
|
||||||
false);
|
|
||||||
parent_module.anonymous_children.insert(block_id, new_module);
|
parent_module.anonymous_children.insert(block_id, new_module);
|
||||||
new_parent = ModuleReducedGraphParent(new_module);
|
new_parent = ModuleReducedGraphParent(new_module);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1652,7 +1569,6 @@ pub impl Resolver {
|
||||||
parent_link,
|
parent_link,
|
||||||
Some(def_id),
|
Some(def_id),
|
||||||
NormalModuleKind,
|
NormalModuleKind,
|
||||||
false,
|
|
||||||
dummy_sp());
|
dummy_sp());
|
||||||
modules.insert(def_id,
|
modules.insert(def_id,
|
||||||
child_name_bindings.get_module());
|
child_name_bindings.get_module());
|
||||||
|
@ -1779,12 +1695,11 @@ pub impl Resolver {
|
||||||
*ident_str);
|
*ident_str);
|
||||||
let parent_link = self.get_parent_link(new_parent,
|
let parent_link = self.get_parent_link(new_parent,
|
||||||
ident);
|
ident);
|
||||||
(*child_name_bindings).define_module(Public,
|
child_name_bindings.define_module(Public,
|
||||||
parent_link,
|
parent_link,
|
||||||
None,
|
None,
|
||||||
NormalModuleKind,
|
NormalModuleKind,
|
||||||
false,
|
dummy_sp());
|
||||||
dummy_sp());
|
|
||||||
}
|
}
|
||||||
Some(copy type_ns_def)
|
Some(copy type_ns_def)
|
||||||
if type_ns_def.module_def.is_none() => {
|
if type_ns_def.module_def.is_none() => {
|
||||||
|
@ -1793,12 +1708,11 @@ pub impl Resolver {
|
||||||
*ident_str);
|
*ident_str);
|
||||||
let parent_link = self.get_parent_link(new_parent,
|
let parent_link = self.get_parent_link(new_parent,
|
||||||
ident);
|
ident);
|
||||||
(*child_name_bindings).define_module(Public,
|
child_name_bindings.define_module(Public,
|
||||||
parent_link,
|
parent_link,
|
||||||
None,
|
None,
|
||||||
NormalModuleKind,
|
NormalModuleKind,
|
||||||
false,
|
dummy_sp());
|
||||||
dummy_sp());
|
|
||||||
}
|
}
|
||||||
_ => {} // Fall through.
|
_ => {} // Fall through.
|
||||||
}
|
}
|
||||||
|
@ -1865,7 +1779,6 @@ pub impl Resolver {
|
||||||
parent_link,
|
parent_link,
|
||||||
Some(def),
|
Some(def),
|
||||||
NormalModuleKind,
|
NormalModuleKind,
|
||||||
false,
|
|
||||||
dummy_sp());
|
dummy_sp());
|
||||||
type_module =
|
type_module =
|
||||||
child_name_bindings.
|
child_name_bindings.
|
||||||
|
@ -2110,7 +2023,6 @@ pub impl Resolver {
|
||||||
// First, resolve the module path for the directive, if necessary.
|
// First, resolve the module path for the directive, if necessary.
|
||||||
match self.resolve_module_path_for_import(module_,
|
match self.resolve_module_path_for_import(module_,
|
||||||
module_path,
|
module_path,
|
||||||
NoXray,
|
|
||||||
DontUseLexicalScope,
|
DontUseLexicalScope,
|
||||||
import_directive.span) {
|
import_directive.span) {
|
||||||
|
|
||||||
|
@ -2196,12 +2108,6 @@ pub impl Resolver {
|
||||||
self.session.str_of(source),
|
self.session.str_of(source),
|
||||||
self.module_to_str(module_));
|
self.module_to_str(module_));
|
||||||
|
|
||||||
if !self.name_is_exported(containing_module, source) {
|
|
||||||
debug!("(resolving single import) name `%s` is unexported",
|
|
||||||
self.session.str_of(source));
|
|
||||||
return Failed;
|
|
||||||
}
|
|
||||||
|
|
||||||
// We need to resolve both namespaces for this to succeed.
|
// We need to resolve both namespaces for this to succeed.
|
||||||
//
|
//
|
||||||
// XXX: See if there's some way of handling namespaces in a more
|
// XXX: See if there's some way of handling namespaces in a more
|
||||||
|
@ -2392,12 +2298,6 @@ pub impl Resolver {
|
||||||
self.session.str_of(source),
|
self.session.str_of(source),
|
||||||
self.module_to_str(module_));
|
self.module_to_str(module_));
|
||||||
|
|
||||||
if !self.name_is_exported(containing_module, source) {
|
|
||||||
debug!("(resolving single import) name `%s` is unexported",
|
|
||||||
self.session.str_of(source));
|
|
||||||
return Failed;
|
|
||||||
}
|
|
||||||
|
|
||||||
// We need to resolve the module namespace for this to succeed.
|
// We need to resolve the module namespace for this to succeed.
|
||||||
let mut module_result = UnknownResult;
|
let mut module_result = UnknownResult;
|
||||||
|
|
||||||
|
@ -2538,12 +2438,6 @@ pub impl Resolver {
|
||||||
for containing_module.import_resolutions.each
|
for containing_module.import_resolutions.each
|
||||||
|ident, target_import_resolution| {
|
|ident, target_import_resolution| {
|
||||||
|
|
||||||
if !self.name_is_exported(containing_module, ident) {
|
|
||||||
debug!("(resolving glob import) name `%s` is unexported",
|
|
||||||
self.session.str_of(ident));
|
|
||||||
loop;
|
|
||||||
}
|
|
||||||
|
|
||||||
debug!("(resolving glob import) writing module resolution \
|
debug!("(resolving glob import) writing module resolution \
|
||||||
%? into `%s`",
|
%? into `%s`",
|
||||||
is_none(&target_import_resolution.type_target),
|
is_none(&target_import_resolution.type_target),
|
||||||
|
@ -2592,12 +2486,6 @@ pub impl Resolver {
|
||||||
|
|
||||||
// Add all children from the containing module.
|
// Add all children from the containing module.
|
||||||
for containing_module.children.each |ident, name_bindings| {
|
for containing_module.children.each |ident, name_bindings| {
|
||||||
if !self.name_is_exported(containing_module, ident) {
|
|
||||||
debug!("(resolving glob import) name `%s` is unexported",
|
|
||||||
self.session.str_of(ident));
|
|
||||||
loop;
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut dest_import_resolution;
|
let mut dest_import_resolution;
|
||||||
match module_.import_resolutions.find(ident) {
|
match module_.import_resolutions.find(ident) {
|
||||||
None => {
|
None => {
|
||||||
|
@ -2639,7 +2527,6 @@ pub impl Resolver {
|
||||||
fn resolve_module_path_from_root(module_: @Module,
|
fn resolve_module_path_from_root(module_: @Module,
|
||||||
module_path: @DVec<ident>,
|
module_path: @DVec<ident>,
|
||||||
index: uint,
|
index: uint,
|
||||||
xray: XrayFlag,
|
|
||||||
span: span)
|
span: span)
|
||||||
-> ResolveResult<@Module> {
|
-> ResolveResult<@Module> {
|
||||||
let mut search_module = module_;
|
let mut search_module = module_;
|
||||||
|
@ -2655,7 +2542,6 @@ pub impl Resolver {
|
||||||
match self.resolve_name_in_module(search_module,
|
match self.resolve_name_in_module(search_module,
|
||||||
name,
|
name,
|
||||||
TypeNS,
|
TypeNS,
|
||||||
xray,
|
|
||||||
false) {
|
false) {
|
||||||
Failed => {
|
Failed => {
|
||||||
self.session.span_err(span, ~"unresolved name");
|
self.session.span_err(span, ~"unresolved name");
|
||||||
|
@ -2712,7 +2598,6 @@ pub impl Resolver {
|
||||||
*/
|
*/
|
||||||
fn resolve_module_path_for_import(module_: @Module,
|
fn resolve_module_path_for_import(module_: @Module,
|
||||||
module_path: @DVec<ident>,
|
module_path: @DVec<ident>,
|
||||||
xray: XrayFlag,
|
|
||||||
use_lexical_scope: UseLexicalScopeFlag,
|
use_lexical_scope: UseLexicalScopeFlag,
|
||||||
span: span)
|
span: span)
|
||||||
-> ResolveResult<@Module> {
|
-> ResolveResult<@Module> {
|
||||||
|
@ -2787,7 +2672,6 @@ pub impl Resolver {
|
||||||
return self.resolve_module_path_from_root(search_module,
|
return self.resolve_module_path_from_root(search_module,
|
||||||
module_path,
|
module_path,
|
||||||
start_index,
|
start_index,
|
||||||
xray,
|
|
||||||
span);
|
span);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2884,7 +2768,6 @@ pub impl Resolver {
|
||||||
match self.resolve_name_in_module(search_module,
|
match self.resolve_name_in_module(search_module,
|
||||||
name,
|
name,
|
||||||
namespace,
|
namespace,
|
||||||
Xray,
|
|
||||||
false) {
|
false) {
|
||||||
Failed => {
|
Failed => {
|
||||||
// Continue up the search chain.
|
// Continue up the search chain.
|
||||||
|
@ -3030,12 +2913,6 @@ pub impl Resolver {
|
||||||
return Success(PrefixFound(containing_module, i));
|
return Success(PrefixFound(containing_module, i));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn name_is_exported(module_: @Module, name: ident) -> bool {
|
|
||||||
return !module_.legacy_exports ||
|
|
||||||
module_.exported_names.size() == 0 ||
|
|
||||||
module_.exported_names.contains_key(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempts to resolve the supplied name in the given module for the
|
* Attempts to resolve the supplied name in the given module for the
|
||||||
* given namespace. If successful, returns the target corresponding to
|
* given namespace. If successful, returns the target corresponding to
|
||||||
|
@ -3044,19 +2921,12 @@ pub impl Resolver {
|
||||||
fn resolve_name_in_module(module_: @Module,
|
fn resolve_name_in_module(module_: @Module,
|
||||||
name: ident,
|
name: ident,
|
||||||
namespace: Namespace,
|
namespace: Namespace,
|
||||||
xray: XrayFlag,
|
|
||||||
allow_globs: bool)
|
allow_globs: bool)
|
||||||
-> ResolveResult<Target> {
|
-> ResolveResult<Target> {
|
||||||
debug!("(resolving name in module) resolving `%s` in `%s`",
|
debug!("(resolving name in module) resolving `%s` in `%s`",
|
||||||
self.session.str_of(name),
|
self.session.str_of(name),
|
||||||
self.module_to_str(module_));
|
self.module_to_str(module_));
|
||||||
|
|
||||||
if xray == NoXray && !self.name_is_exported(module_, name) {
|
|
||||||
debug!("(resolving name in module) name `%s` is unexported",
|
|
||||||
self.session.str_of(name));
|
|
||||||
return Failed;
|
|
||||||
}
|
|
||||||
|
|
||||||
// First, check the direct children of the module.
|
// First, check the direct children of the module.
|
||||||
match module_.children.find(name) {
|
match module_.children.find(name) {
|
||||||
Some(name_bindings)
|
Some(name_bindings)
|
||||||
|
@ -3358,11 +3228,7 @@ pub impl Resolver {
|
||||||
fn record_exports_for_module(module_: @Module) {
|
fn record_exports_for_module(module_: @Module) {
|
||||||
let mut exports2 = ~[];
|
let mut exports2 = ~[];
|
||||||
|
|
||||||
if module_.legacy_exports {
|
self.add_exports_for_module(&mut exports2, module_);
|
||||||
self.add_exports_for_legacy_module(&mut exports2, module_);
|
|
||||||
} else {
|
|
||||||
self.add_exports_for_module(&mut exports2, module_);
|
|
||||||
}
|
|
||||||
match copy module_.def_id {
|
match copy module_.def_id {
|
||||||
Some(def_id) => {
|
Some(def_id) => {
|
||||||
self.export_map2.insert(def_id.node, move exports2);
|
self.export_map2.insert(def_id.node, move exports2);
|
||||||
|
@ -3440,44 +3306,6 @@ pub impl Resolver {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn add_exports_for_legacy_module(exports2: &mut ~[Export2],
|
|
||||||
module_: @Module) {
|
|
||||||
for module_.exported_names.each |name, _exp_node_id| {
|
|
||||||
for self.namespaces.each |namespace| {
|
|
||||||
match self.resolve_definition_of_name_in_module(module_,
|
|
||||||
name,
|
|
||||||
*namespace,
|
|
||||||
Xray) {
|
|
||||||
NoNameDefinition => {
|
|
||||||
// Nothing to do.
|
|
||||||
}
|
|
||||||
ChildNameDefinition(target_def) => {
|
|
||||||
debug!("(computing exports) legacy export '%s' \
|
|
||||||
for %?",
|
|
||||||
self.session.str_of(name),
|
|
||||||
module_.def_id);
|
|
||||||
exports2.push(Export2 {
|
|
||||||
reexport: false,
|
|
||||||
name: self.session.str_of(name),
|
|
||||||
def_id: def_id_of_def(target_def)
|
|
||||||
});
|
|
||||||
}
|
|
||||||
ImportNameDefinition(target_def) => {
|
|
||||||
debug!("(computing exports) legacy reexport '%s' for \
|
|
||||||
%?",
|
|
||||||
self.session.str_of(name),
|
|
||||||
module_.def_id);
|
|
||||||
exports2.push(Export2 {
|
|
||||||
reexport: true,
|
|
||||||
name: self.session.str_of(name),
|
|
||||||
def_id: def_id_of_def(target_def)
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// AST resolution
|
// AST resolution
|
||||||
//
|
//
|
||||||
// We maintain a list of value ribs and type ribs.
|
// We maintain a list of value ribs and type ribs.
|
||||||
|
@ -4730,13 +4558,6 @@ pub impl Resolver {
|
||||||
xray: XrayFlag)
|
xray: XrayFlag)
|
||||||
-> NameDefinition {
|
-> NameDefinition {
|
||||||
|
|
||||||
if xray == NoXray && !self.name_is_exported(containing_module, name) {
|
|
||||||
debug!("(resolving definition of name in module) name `%s` is \
|
|
||||||
unexported",
|
|
||||||
self.session.str_of(name));
|
|
||||||
return NoNameDefinition;
|
|
||||||
}
|
|
||||||
|
|
||||||
// First, search children.
|
// First, search children.
|
||||||
match containing_module.children.find(name) {
|
match containing_module.children.find(name) {
|
||||||
Some(child_name_bindings) => {
|
Some(child_name_bindings) => {
|
||||||
|
@ -4816,7 +4637,6 @@ pub impl Resolver {
|
||||||
let mut containing_module;
|
let mut containing_module;
|
||||||
match self.resolve_module_path_for_import(self.current_module,
|
match self.resolve_module_path_for_import(self.current_module,
|
||||||
module_path_idents,
|
module_path_idents,
|
||||||
xray,
|
|
||||||
UseLexicalScope,
|
UseLexicalScope,
|
||||||
path.span) {
|
path.span) {
|
||||||
Failed => {
|
Failed => {
|
||||||
|
@ -4864,7 +4684,6 @@ pub impl Resolver {
|
||||||
match self.resolve_module_path_from_root(root_module,
|
match self.resolve_module_path_from_root(root_module,
|
||||||
module_path_idents,
|
module_path_idents,
|
||||||
0,
|
0,
|
||||||
xray,
|
|
||||||
path.span) {
|
path.span) {
|
||||||
|
|
||||||
Failed => {
|
Failed => {
|
||||||
|
|
|
@ -111,9 +111,6 @@ pub fn monomorphic_fn(ccx: @crate_ctxt,
|
||||||
ast_map::node_stmt(*) => {
|
ast_map::node_stmt(*) => {
|
||||||
ccx.tcx.sess.bug(~"Can't monomorphize a stmt")
|
ccx.tcx.sess.bug(~"Can't monomorphize a stmt")
|
||||||
}
|
}
|
||||||
ast_map::node_export(*) => {
|
|
||||||
ccx.tcx.sess.bug(~"Can't monomorphize an export")
|
|
||||||
}
|
|
||||||
ast_map::node_arg(*) => ccx.tcx.sess.bug(~"Can't monomorphize an arg"),
|
ast_map::node_arg(*) => ccx.tcx.sess.bug(~"Can't monomorphize an arg"),
|
||||||
ast_map::node_block(*) => {
|
ast_map::node_block(*) => {
|
||||||
ccx.tcx.sess.bug(~"Can't monomorphize a block")
|
ccx.tcx.sess.bug(~"Can't monomorphize a block")
|
||||||
|
@ -255,7 +252,6 @@ pub fn monomorphic_fn(ccx: @crate_ctxt,
|
||||||
ast_map::node_expr(*) |
|
ast_map::node_expr(*) |
|
||||||
ast_map::node_stmt(*) |
|
ast_map::node_stmt(*) |
|
||||||
ast_map::node_trait_method(*) |
|
ast_map::node_trait_method(*) |
|
||||||
ast_map::node_export(*) |
|
|
||||||
ast_map::node_arg(*) |
|
ast_map::node_arg(*) |
|
||||||
ast_map::node_block(*) |
|
ast_map::node_block(*) |
|
||||||
ast_map::node_local(*) => {
|
ast_map::node_local(*) => {
|
||||||
|
|
|
@ -3756,7 +3756,7 @@ pub fn item_path(cx: ctxt, id: ast::def_id) -> ast_map::path {
|
||||||
|
|
||||||
ast_map::node_stmt(*) | ast_map::node_expr(*) |
|
ast_map::node_stmt(*) | ast_map::node_expr(*) |
|
||||||
ast_map::node_arg(*) | ast_map::node_local(*) |
|
ast_map::node_arg(*) | ast_map::node_local(*) |
|
||||||
ast_map::node_export(*) | ast_map::node_block(*) => {
|
ast_map::node_block(*) => {
|
||||||
cx.sess.bug(fmt!("cannot find item_path for node %?", node));
|
cx.sess.bug(fmt!("cannot find item_path for node %?", node));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,7 +72,6 @@ use std::map;
|
||||||
use std::smallintmap;
|
use std::smallintmap;
|
||||||
use syntax::ast::{provided, required, spanned};
|
use syntax::ast::{provided, required, spanned};
|
||||||
use syntax::ast_map::node_id_to_str;
|
use syntax::ast_map::node_id_to_str;
|
||||||
use syntax::ast_util::{has_legacy_export_attr};
|
|
||||||
use syntax::ast_util::{local_def, respan, split_trait_methods};
|
use syntax::ast_util::{local_def, respan, split_trait_methods};
|
||||||
use syntax::codemap::span;
|
use syntax::codemap::span;
|
||||||
use syntax::print::pprust::*;
|
use syntax::print::pprust::*;
|
||||||
|
|
|
@ -1504,7 +1504,6 @@ pub struct view_item {
|
||||||
pub enum view_item_ {
|
pub enum view_item_ {
|
||||||
view_item_use(ident, ~[@meta_item], node_id),
|
view_item_use(ident, ~[@meta_item], node_id),
|
||||||
view_item_import(~[@view_path]),
|
view_item_import(~[@view_path]),
|
||||||
view_item_export(~[@view_path])
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Meta-data associated with an item
|
// Meta-data associated with an item
|
||||||
|
|
|
@ -96,7 +96,6 @@ pub enum ast_node {
|
||||||
node_variant(variant, @item, @path),
|
node_variant(variant, @item, @path),
|
||||||
node_expr(@expr),
|
node_expr(@expr),
|
||||||
node_stmt(@stmt),
|
node_stmt(@stmt),
|
||||||
node_export(@view_path, @path),
|
|
||||||
// Locals are numbered, because the alias analysis needs to know in which
|
// Locals are numbered, because the alias analysis needs to know in which
|
||||||
// order they are introduced.
|
// order they are introduced.
|
||||||
node_arg(arg, uint),
|
node_arg(arg, uint),
|
||||||
|
@ -128,7 +127,6 @@ pub fn mk_ast_map_visitor() -> vt {
|
||||||
visit_fn: map_fn,
|
visit_fn: map_fn,
|
||||||
visit_local: map_local,
|
visit_local: map_local,
|
||||||
visit_arm: map_arm,
|
visit_arm: map_arm,
|
||||||
visit_view_item: map_view_item,
|
|
||||||
visit_block: map_block,
|
visit_block: map_block,
|
||||||
.. *visit::default_visitor()
|
.. *visit::default_visitor()
|
||||||
});
|
});
|
||||||
|
@ -324,23 +322,6 @@ pub fn map_struct_def(struct_def: @ast::struct_def, parent_node: ast_node,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn map_view_item(vi: @view_item, cx: ctx, _v: vt) {
|
|
||||||
match vi.node {
|
|
||||||
view_item_export(vps) => for vps.each |vp| {
|
|
||||||
let (id, name) = match vp.node {
|
|
||||||
view_path_simple(nm, _, _, id) => {
|
|
||||||
(id, /* FIXME (#2543) */ copy nm)
|
|
||||||
}
|
|
||||||
view_path_glob(pth, id) | view_path_list(pth, _, id) => {
|
|
||||||
(id, path_to_ident(pth))
|
|
||||||
}
|
|
||||||
};
|
|
||||||
cx.map.insert(id, node_export(*vp, extend(cx, name)));
|
|
||||||
},
|
|
||||||
_ => ()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn map_expr(ex: @expr, cx: ctx, v: vt) {
|
pub fn map_expr(ex: @expr, cx: ctx, v: vt) {
|
||||||
cx.map.insert(ex.id, node_expr(ex));
|
cx.map.insert(ex.id, node_expr(ex));
|
||||||
visit::visit_expr(ex, cx, v);
|
visit::visit_expr(ex, cx, v);
|
||||||
|
@ -396,11 +377,6 @@ pub fn node_id_to_str(map: map, id: node_id, itr: @ident_interner) -> ~str {
|
||||||
fmt!("stmt %s (id=%?)",
|
fmt!("stmt %s (id=%?)",
|
||||||
pprust::stmt_to_str(*stmt, itr), id)
|
pprust::stmt_to_str(*stmt, itr), id)
|
||||||
}
|
}
|
||||||
// FIXMEs are as per #2410
|
|
||||||
Some(node_export(_, path)) => {
|
|
||||||
fmt!("export %s (id=%?)", // add more info here
|
|
||||||
path_to_str(*path, itr), id)
|
|
||||||
}
|
|
||||||
Some(node_arg(_, _)) => { // add more info here
|
Some(node_arg(_, _)) => { // add more info here
|
||||||
fmt!("arg (id=%?)", id)
|
fmt!("arg (id=%?)", id)
|
||||||
}
|
}
|
||||||
|
|
|
@ -215,64 +215,6 @@ pub pure fn float_ty_to_str(t: float_ty) -> ~str {
|
||||||
match t { ty_f => ~"f", ty_f32 => ~"f32", ty_f64 => ~"f64" }
|
match t { ty_f => ~"f", ty_f32 => ~"f32", ty_f64 => ~"f64" }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_exported(i: ident, m: _mod) -> bool {
|
|
||||||
let mut local = false;
|
|
||||||
let mut parent_enum : Option<ident> = None;
|
|
||||||
for m.items.each |it| {
|
|
||||||
if it.ident == i { local = true; }
|
|
||||||
match it.node {
|
|
||||||
item_enum(ref enum_definition, _) =>
|
|
||||||
for (*enum_definition).variants.each |v| {
|
|
||||||
if v.node.name == i {
|
|
||||||
local = true;
|
|
||||||
parent_enum = Some(/* FIXME (#2543) */ copy it.ident);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
_ => ()
|
|
||||||
}
|
|
||||||
if local { break; }
|
|
||||||
}
|
|
||||||
let mut has_explicit_exports = false;
|
|
||||||
for m.view_items.each |vi| {
|
|
||||||
match vi.node {
|
|
||||||
view_item_export(vps) => {
|
|
||||||
has_explicit_exports = true;
|
|
||||||
for vps.each |vp| {
|
|
||||||
match vp.node {
|
|
||||||
ast::view_path_simple(id, _, _, _) => {
|
|
||||||
if id == i { return true; }
|
|
||||||
match parent_enum {
|
|
||||||
Some(parent_enum_id) => {
|
|
||||||
if id == parent_enum_id { return true; }
|
|
||||||
}
|
|
||||||
_ => ()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ast::view_path_list(path, ref ids, _) => {
|
|
||||||
if vec::len(path.idents) == 1u {
|
|
||||||
if i == path.idents[0] { return true; }
|
|
||||||
for (*ids).each |id| {
|
|
||||||
if id.node.name == i { return true; }
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
fail ~"export of path-qualified list";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_ => ()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_ => ()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// If there are no declared exports then
|
|
||||||
// everything not imported is exported
|
|
||||||
// even if it's local (since it's explicit)
|
|
||||||
return !has_explicit_exports && local;
|
|
||||||
}
|
|
||||||
|
|
||||||
pub pure fn is_call_expr(e: @expr) -> bool {
|
pub pure fn is_call_expr(e: @expr) -> bool {
|
||||||
match e.node { expr_call(_, _, _) => true, _ => false }
|
match e.node { expr_call(_, _, _) => true, _ => false }
|
||||||
}
|
}
|
||||||
|
@ -476,7 +418,7 @@ pub fn id_visitor(vfn: fn@(node_id)) -> visit::vt<()> {
|
||||||
visit_view_item: fn@(vi: @view_item) {
|
visit_view_item: fn@(vi: @view_item) {
|
||||||
match vi.node {
|
match vi.node {
|
||||||
view_item_use(_, _, id) => vfn(id),
|
view_item_use(_, _, id) => vfn(id),
|
||||||
view_item_import(vps) | view_item_export(vps) => {
|
view_item_import(vps) => {
|
||||||
for vec::each(vps) |vp| {
|
for vec::each(vps) |vp| {
|
||||||
match vp.node {
|
match vp.node {
|
||||||
view_path_simple(_, _, _, id) => vfn(id),
|
view_path_simple(_, _, _, id) => vfn(id),
|
||||||
|
@ -662,46 +604,32 @@ pub fn struct_def_is_tuple_like(struct_def: @ast::struct_def) -> bool {
|
||||||
struct_def.ctor_id.is_some()
|
struct_def.ctor_id.is_some()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn visibility_to_privacy(visibility: visibility) -> Privacy {
|
||||||
|
match visibility {
|
||||||
|
public => Public,
|
||||||
|
inherited | private => Private
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn visibility_to_privacy(visibility: visibility,
|
pub fn variant_visibility_to_privacy(visibility: visibility,
|
||||||
legacy_exports: bool) -> Privacy {
|
enclosing_is_public: bool)
|
||||||
if legacy_exports {
|
-> Privacy {
|
||||||
|
if enclosing_is_public {
|
||||||
match visibility {
|
match visibility {
|
||||||
inherited | public => Public,
|
public | inherited => Public,
|
||||||
private => Private
|
private => Private
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
match visibility {
|
visibility_to_privacy(visibility)
|
||||||
public => Public,
|
|
||||||
inherited | private => Private
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[deriving_eq]
|
||||||
pub enum Privacy {
|
pub enum Privacy {
|
||||||
Private,
|
Private,
|
||||||
Public
|
Public
|
||||||
}
|
}
|
||||||
|
|
||||||
pub impl Privacy : cmp::Eq {
|
|
||||||
pure fn eq(&self, other: &Privacy) -> bool {
|
|
||||||
((*self) as uint) == ((*other) as uint)
|
|
||||||
}
|
|
||||||
pure fn ne(&self, other: &Privacy) -> bool { !(*self).eq(other) }
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn has_legacy_export_attr(attrs: &[attribute]) -> bool {
|
|
||||||
for attrs.each |attribute| {
|
|
||||||
match attribute.node.value.node {
|
|
||||||
meta_word(ref w) if (*w) == ~"legacy_exports" => {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Local Variables:
|
// Local Variables:
|
||||||
// mode: rust
|
// mode: rust
|
||||||
// fill-column: 78;
|
// fill-column: 78;
|
||||||
|
|
|
@ -50,7 +50,7 @@ use ast::{ty_field, ty_fixed_length_vec, ty_fn, ty_infer, ty_mac, ty_method};
|
||||||
use ast::{ty_nil, ty_param, ty_param_bound, ty_path, ty_ptr, ty_rec, ty_rptr};
|
use ast::{ty_nil, ty_param, ty_param_bound, ty_path, ty_ptr, ty_rec, ty_rptr};
|
||||||
use ast::{ty_tup, ty_u32, ty_uniq, ty_vec, type_value_ns, uniq};
|
use ast::{ty_tup, ty_u32, ty_uniq, ty_vec, type_value_ns, uniq};
|
||||||
use ast::{unnamed_field, unsafe_blk, unsafe_fn, variant, view_item};
|
use ast::{unnamed_field, unsafe_blk, unsafe_fn, variant, view_item};
|
||||||
use ast::{view_item_, view_item_export, view_item_import, view_item_use};
|
use ast::{view_item_, view_item_import, view_item_use};
|
||||||
use ast::{view_path, view_path_glob, view_path_list, view_path_simple};
|
use ast::{view_path, view_path_glob, view_path_list, view_path_simple};
|
||||||
use ast::{visibility, vstore, vstore_box, vstore_fixed, vstore_slice};
|
use ast::{visibility, vstore, vstore_box, vstore_fixed, vstore_slice};
|
||||||
use ast::{vstore_uniq};
|
use ast::{vstore_uniq};
|
||||||
|
@ -88,6 +88,7 @@ use core::vec::push;
|
||||||
use core::vec;
|
use core::vec;
|
||||||
use std::map::HashMap;
|
use std::map::HashMap;
|
||||||
|
|
||||||
|
#[deriving_eq]
|
||||||
enum restriction {
|
enum restriction {
|
||||||
UNRESTRICTED,
|
UNRESTRICTED,
|
||||||
RESTRICT_STMT_EXPR,
|
RESTRICT_STMT_EXPR,
|
||||||
|
@ -3735,15 +3736,6 @@ pub impl Parser {
|
||||||
vis: visibility,
|
vis: visibility,
|
||||||
span: mk_sp(lo, self.last_span.hi)
|
span: mk_sp(lo, self.last_span.hi)
|
||||||
});
|
});
|
||||||
} else if self.eat_keyword(~"export") {
|
|
||||||
let view_paths = self.parse_view_paths();
|
|
||||||
self.expect(token::SEMI);
|
|
||||||
return iovi_view_item(@ast::view_item {
|
|
||||||
node: view_item_export(view_paths),
|
|
||||||
attrs: attrs,
|
|
||||||
vis: visibility,
|
|
||||||
span: mk_sp(lo, self.last_span.hi)
|
|
||||||
});
|
|
||||||
} else if macros_allowed && !self.is_any_keyword(copy self.token)
|
} else if macros_allowed && !self.is_any_keyword(copy self.token)
|
||||||
&& self.look_ahead(1) == token::NOT
|
&& self.look_ahead(1) == token::NOT
|
||||||
&& (is_plain_ident(self.look_ahead(2))
|
&& (is_plain_ident(self.look_ahead(2))
|
||||||
|
@ -3916,7 +3908,6 @@ pub impl Parser {
|
||||||
next_tok = self.look_ahead(2);
|
next_tok = self.look_ahead(2);
|
||||||
};
|
};
|
||||||
self.token_is_keyword(~"use", tok)
|
self.token_is_keyword(~"use", tok)
|
||||||
|| self.token_is_keyword(~"export", tok)
|
|
||||||
|| (self.token_is_keyword(~"extern", tok) &&
|
|| (self.token_is_keyword(~"extern", tok) &&
|
||||||
self.token_is_keyword(~"mod", next_tok))
|
self.token_is_keyword(~"mod", next_tok))
|
||||||
}
|
}
|
||||||
|
@ -3925,8 +3916,6 @@ pub impl Parser {
|
||||||
let lo = self.span.lo;
|
let lo = self.span.lo;
|
||||||
let node = if self.eat_keyword(~"use") {
|
let node = if self.eat_keyword(~"use") {
|
||||||
self.parse_use()
|
self.parse_use()
|
||||||
} else if self.eat_keyword(~"export") {
|
|
||||||
view_item_export(self.parse_view_paths())
|
|
||||||
} else if self.eat_keyword(~"extern") {
|
} else if self.eat_keyword(~"extern") {
|
||||||
self.expect_keyword(~"mod");
|
self.expect_keyword(~"mod");
|
||||||
let ident = self.parse_ident();
|
let ident = self.parse_ident();
|
||||||
|
@ -3979,8 +3968,8 @@ pub impl Parser {
|
||||||
if restricted_to_imports {
|
if restricted_to_imports {
|
||||||
match view_item.node {
|
match view_item.node {
|
||||||
view_item_import(_) => {}
|
view_item_import(_) => {}
|
||||||
view_item_export(_) | view_item_use(*) =>
|
view_item_use(*) =>
|
||||||
self.fatal(~"exports and \"extern mod\" \
|
self.fatal(~"\"extern mod\" \
|
||||||
declarations are not \
|
declarations are not \
|
||||||
allowed here")
|
allowed here")
|
||||||
}
|
}
|
||||||
|
@ -4025,13 +4014,6 @@ pub impl Parser {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl restriction : cmp::Eq {
|
|
||||||
pure fn eq(&self, other: &restriction) -> bool {
|
|
||||||
((*self) as uint) == ((*other) as uint)
|
|
||||||
}
|
|
||||||
pure fn ne(&self, other: &restriction) -> bool { !(*self).eq(other) }
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Local Variables:
|
// Local Variables:
|
||||||
// mode: rust
|
// mode: rust
|
||||||
|
|
|
@ -486,7 +486,7 @@ pub fn strict_keyword_table() -> HashMap<~str, ()> {
|
||||||
~"break",
|
~"break",
|
||||||
~"const", ~"copy",
|
~"const", ~"copy",
|
||||||
~"do", ~"drop",
|
~"do", ~"drop",
|
||||||
~"else", ~"enum", ~"export", ~"extern",
|
~"else", ~"enum", ~"extern",
|
||||||
~"fail", ~"false", ~"fn", ~"for",
|
~"fail", ~"false", ~"fn", ~"for",
|
||||||
~"if", ~"impl",
|
~"if", ~"impl",
|
||||||
~"let", ~"log", ~"loop",
|
~"let", ~"log", ~"loop",
|
||||||
|
|
|
@ -1865,25 +1865,20 @@ pub fn print_view_item(s: ps, item: @ast::view_item) {
|
||||||
print_outer_attributes(s, item.attrs);
|
print_outer_attributes(s, item.attrs);
|
||||||
print_visibility(s, item.vis);
|
print_visibility(s, item.vis);
|
||||||
match item.node {
|
match item.node {
|
||||||
ast::view_item_use(id, mta, _) => {
|
ast::view_item_use(id, mta, _) => {
|
||||||
head(s, ~"extern mod");
|
head(s, ~"extern mod");
|
||||||
print_ident(s, id);
|
print_ident(s, id);
|
||||||
if !mta.is_empty() {
|
if !mta.is_empty() {
|
||||||
popen(s);
|
popen(s);
|
||||||
commasep(s, consistent, mta, print_meta_item);
|
commasep(s, consistent, mta, print_meta_item);
|
||||||
pclose(s);
|
pclose(s);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
ast::view_item_import(vps) => {
|
ast::view_item_import(vps) => {
|
||||||
head(s, ~"use");
|
head(s, ~"use");
|
||||||
print_view_paths(s, vps);
|
print_view_paths(s, vps);
|
||||||
}
|
}
|
||||||
|
|
||||||
ast::view_item_export(vps) => {
|
|
||||||
head(s, ~"export");
|
|
||||||
print_view_paths(s, vps);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
word(s.s, ~";");
|
word(s.s, ~";");
|
||||||
end(s); // end inner head-block
|
end(s); // end inner head-block
|
||||||
|
|
|
@ -15,8 +15,6 @@
|
||||||
|
|
||||||
extern mod std;
|
extern mod std;
|
||||||
|
|
||||||
export context;
|
|
||||||
|
|
||||||
struct arc_destruct<T> {
|
struct arc_destruct<T> {
|
||||||
_data: int,
|
_data: int,
|
||||||
}
|
}
|
||||||
|
@ -55,8 +53,8 @@ fn context_res() -> context_res {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type context = arc_destruct<context_res>;
|
pub type context = arc_destruct<context_res>;
|
||||||
|
|
||||||
impl context {
|
pub impl context {
|
||||||
fn socket() { }
|
fn socket() { }
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,22 +8,20 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
export rsrc;
|
|
||||||
|
|
||||||
fn foo(_x: i32) {
|
fn foo(_x: i32) {
|
||||||
}
|
}
|
||||||
|
|
||||||
struct rsrc {
|
pub struct rsrc {
|
||||||
x: i32,
|
x: i32,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl rsrc : Drop {
|
pub impl rsrc : Drop {
|
||||||
fn finalize(&self) {
|
fn finalize(&self) {
|
||||||
foo(self.x);
|
foo(self.x);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn rsrc(x: i32) -> rsrc {
|
pub fn rsrc(x: i32) -> rsrc {
|
||||||
rsrc {
|
rsrc {
|
||||||
x: x
|
x: x
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue