Revert "rustc: Switch to the new resolution pass"
This reverts commit c4af6e92fbae171c56a4e68666025725555fc9d8. Branch was burning...many, many unresolved imports.
This commit is contained in:
parent
f9cb04f6fa
commit
a856bccdc6
@ -63,12 +63,6 @@ export local_data_get;
|
||||
export local_data_set;
|
||||
export local_data_modify;
|
||||
|
||||
export single_threaded;
|
||||
export thread_per_core;
|
||||
export thread_per_task;
|
||||
export manual_threads;
|
||||
export osmain;
|
||||
|
||||
/* Data types */
|
||||
|
||||
/// A handle to a task
|
||||
|
@ -25,7 +25,6 @@ export ip_addr, parse_addr_err;
|
||||
export format_addr;
|
||||
export v4, v6;
|
||||
export get_addr;
|
||||
export ipv4, ipv6;
|
||||
|
||||
/// An IP address
|
||||
enum ip_addr {
|
||||
@ -390,4 +389,4 @@ mod test {
|
||||
let ga_result = get_addr(localhost_name, iotask);
|
||||
assert result::is_err(ga_result);
|
||||
}
|
||||
}
|
||||
}
|
@ -16,8 +16,10 @@ export parse_from_source_str;
|
||||
// unresolved import errors. Maybe resolve3 will fix it.
|
||||
import common::*;
|
||||
import parser::parser;
|
||||
import attr::parser_attr;
|
||||
import common::parser_common;
|
||||
//import attr::parser_attr;
|
||||
import attr::*; //resolve bug?
|
||||
//import common::parser_common;
|
||||
import common::*; //resolve bug?
|
||||
import ast::node_id;
|
||||
import util::interner;
|
||||
// FIXME (#1935): resolve badness
|
||||
|
@ -9,7 +9,6 @@ export lit;
|
||||
export cmnt_style;
|
||||
export gather_comments_and_literals;
|
||||
export is_doc_comment, doc_comment_style, strip_doc_comment_decoration;
|
||||
export isolated, trailing, mixed, blank_line;
|
||||
|
||||
enum cmnt_style {
|
||||
isolated, // No code on either side of each line of the comment
|
||||
|
@ -12,47 +12,7 @@ import common::{seq_sep_trailing_disallowed, seq_sep_trailing_allowed,
|
||||
seq_sep_none, token_to_str};
|
||||
import dvec::{dvec, extensions};
|
||||
import vec::{push};
|
||||
import ast::{_mod, add, alt_check, alt_exhaustive, arg, arm, attribute,
|
||||
bitand, bitor, bitxor, blk, blk_check_mode, bound_const,
|
||||
bound_copy, bound_send, bound_trait, box, by_copy, by_move,
|
||||
by_mutbl_ref, by_ref, by_val, capture_clause, capture_item,
|
||||
carg_base, carg_ident, cdir_dir_mod, cdir_src_mod,
|
||||
cdir_view_item, checked_expr, claimed_expr, class_immutable,
|
||||
class_member, class_method, class_mutable, constr, constr_arg,
|
||||
constr_general, crate, crate_cfg, crate_directive, decl,
|
||||
decl_item, decl_local, default_blk, deref, div, expl, expr,
|
||||
expr_, expr_addr_of, expr_alt, expr_assert, expr_assign,
|
||||
expr_assign_op, expr_binary, expr_block, expr_break, expr_call,
|
||||
expr_cast, expr_check, expr_cont, expr_copy, expr_do_body,
|
||||
expr_fail, expr_field, expr_fn, expr_fn_block, expr_if,
|
||||
expr_if_check, expr_index, expr_lit, expr_log, expr_loop,
|
||||
expr_loop_body, expr_mac, expr_move, expr_new, expr_path,
|
||||
expr_rec, expr_ret, expr_swap, expr_tup, expr_unary, expr_vec,
|
||||
expr_vstore, expr_while, extern_fn, field, fn_decl, foreign_item,
|
||||
foreign_item_fn, foreign_mod, ident, impure_fn, infer,
|
||||
init_assign, init_move, initializer, instance_var, item, item_,
|
||||
item_class, item_const, item_enum, item_fn, item_foreign_mod,
|
||||
item_impl, item_mod, item_trait, item_ty, lit, lit_, lit_bool,
|
||||
lit_float, lit_int, lit_int_unsuffixed, lit_nil, lit_str,
|
||||
lit_uint, local, m_const, m_imm, m_mutbl, mac_, mac_aq,
|
||||
mac_ellipsis, mac_embed_block, mac_embed_type, mac_invoc,
|
||||
mac_invoc_tt, mac_var, matcher, method, mode, mt, mtc_bb,
|
||||
mtc_rep, mtc_tok, mul, mutability, neg, noreturn, not, pat,
|
||||
pat_box, pat_enum, pat_ident, pat_lit, pat_range, pat_rec,
|
||||
pat_tup, pat_uniq, pat_wild, path, private, proto, proto_any,
|
||||
proto_bare, proto_block, proto_box, proto_uniq, public, pure_fn,
|
||||
purity, re_anon, re_named, region, region_param, rem, ret_style,
|
||||
return_val, rp_none, rp_self, shl, shr, stmt, stmt_decl,
|
||||
stmt_expr, stmt_semi, subtract, token_tree, trait_ref, tt_delim,
|
||||
tt_dotdotdot, tt_flat, tt_interpolate, ty, ty_, ty_bot, ty_box,
|
||||
ty_constr, ty_constr_, ty_constr_arg, ty_field, ty_fn, ty_infer,
|
||||
ty_mac, ty_method, ty_nil, ty_param, ty_path, ty_ptr, ty_rec,
|
||||
ty_rptr, ty_tup, ty_u32, ty_uniq, ty_vec, ty_vstore,
|
||||
unchecked_blk, uniq, unsafe_blk, unsafe_fn, variant, view_item,
|
||||
view_item_, view_item_export, view_item_import, view_item_use,
|
||||
view_path, view_path_glob, view_path_list, view_path_simple,
|
||||
visibility, vstore, vstore_box, vstore_fixed, vstore_slice,
|
||||
vstore_uniq};
|
||||
import ast::*;
|
||||
|
||||
export file_type;
|
||||
export parser;
|
||||
|
@ -168,9 +168,26 @@ fn compile_upto(sess: session, cfg: ast::crate_cfg,
|
||||
session::sess_os_to_meta_os(sess.targ_cfg.os),
|
||||
sess.opts.static));
|
||||
|
||||
let { def_map: def_map, exp_map: exp_map, impl_map: impl_map } =
|
||||
time(time_passes, "fast resolution", ||
|
||||
middle::resolve3::resolve_crate(sess, ast_map, crate));
|
||||
let mut def_map;
|
||||
let mut impl_map;
|
||||
let mut exp_map;
|
||||
if sess.fast_resolve() {
|
||||
let { def_map: fast_dm, exp_map: fast_em, impl_map: fast_im } =
|
||||
time(time_passes, "fast resolution", ||
|
||||
middle::resolve3::resolve_crate(sess, ast_map, crate));
|
||||
|
||||
def_map = fast_dm;
|
||||
impl_map = fast_im;
|
||||
exp_map = fast_em;
|
||||
} else {
|
||||
let { def_map: normal_dm, exp_map: normal_em, impl_map: normal_im } =
|
||||
time(time_passes, "resolution", ||
|
||||
resolve::resolve_crate(sess, ast_map, crate));
|
||||
|
||||
def_map = normal_dm;
|
||||
impl_map = normal_im;
|
||||
exp_map = normal_em;
|
||||
}
|
||||
|
||||
let freevars = time(time_passes, "freevar finding", ||
|
||||
freevars::annotate_freevars(def_map, crate));
|
||||
|
@ -9,7 +9,6 @@ import filesearch::filesearch;
|
||||
import io::writer_util;
|
||||
|
||||
export os;
|
||||
export os_macos, os_win32, os_linux, os_freebsd;
|
||||
export ctxt;
|
||||
export load_library_crate;
|
||||
export list_file_metadata;
|
||||
|
@ -2,7 +2,6 @@ import driver::session::session;
|
||||
import metadata::csearch::{each_path, get_impls_for_mod, lookup_defs};
|
||||
import metadata::cstore::find_use_stmt_cnum;
|
||||
import metadata::decoder::{def_like, dl_def, dl_field, dl_impl};
|
||||
import middle::lint::{error, ignore, level, unused_imports, warn};
|
||||
import syntax::ast::{_mod, arm, blk, bound_const, bound_copy, bound_trait};
|
||||
import syntax::ast::{bound_send, capture_clause, class_ctor, class_dtor};
|
||||
import syntax::ast::{class_member, class_method, crate, crate_num, decl_item};
|
||||
@ -144,10 +143,7 @@ enum TypeParameters/& {
|
||||
// The index at the method site will be 1, because the
|
||||
// outer T had index 0.
|
||||
|
||||
uint,
|
||||
|
||||
// The kind of the rib used for type parameters.
|
||||
RibKind)
|
||||
uint)
|
||||
}
|
||||
|
||||
// The rib kind controls the translation of argument or local definitions
|
||||
@ -156,13 +152,9 @@ enum TypeParameters/& {
|
||||
enum RibKind {
|
||||
// No translation needs to be applied.
|
||||
NormalRibKind,
|
||||
|
||||
// We passed through a function scope at the given node ID. Translate
|
||||
// upvars as appropriate.
|
||||
FunctionRibKind(node_id),
|
||||
|
||||
// We passed through a function *item* scope. Disallow upvars.
|
||||
OpaqueFunctionRibKind
|
||||
FunctionRibKind(node_id)
|
||||
}
|
||||
|
||||
// The X-ray flag indicates that a context has the X-ray privilege, which
|
||||
@ -177,17 +169,6 @@ enum XrayFlag {
|
||||
Xray //< Private items can be accessed.
|
||||
}
|
||||
|
||||
enum AllowCapturingSelfFlag {
|
||||
AllowCapturingSelf, //< The "self" definition can be captured.
|
||||
DontAllowCapturingSelf, //< The "self" definition cannot be captured.
|
||||
}
|
||||
|
||||
enum EnumVariantOrConstResolution {
|
||||
FoundEnumVariant(def),
|
||||
FoundConst,
|
||||
EnumVariantOrConstNotFound
|
||||
}
|
||||
|
||||
// FIXME (issue #2550): Should be a class but then it becomes not implicitly
|
||||
// copyable due to a kind bug.
|
||||
|
||||
@ -277,15 +258,10 @@ class Rib {
|
||||
class ImportDirective {
|
||||
let module_path: @dvec<Atom>;
|
||||
let subclass: @ImportDirectiveSubclass;
|
||||
let span: span;
|
||||
|
||||
new(module_path: @dvec<Atom>,
|
||||
subclass: @ImportDirectiveSubclass,
|
||||
span: span) {
|
||||
|
||||
new(module_path: @dvec<Atom>, subclass: @ImportDirectiveSubclass) {
|
||||
self.module_path = module_path;
|
||||
self.subclass = subclass;
|
||||
self.span = span;
|
||||
}
|
||||
}
|
||||
|
||||
@ -301,8 +277,6 @@ class Target {
|
||||
}
|
||||
|
||||
class ImportResolution {
|
||||
let span: span;
|
||||
|
||||
// The number of outstanding references to this name. When this reaches
|
||||
// zero, outside modules can count on the targets being correct. Before
|
||||
// then, all bets are off; future imports could override this name.
|
||||
@ -314,19 +288,13 @@ class ImportResolution {
|
||||
let mut type_target: option<Target>;
|
||||
let mut impl_target: @dvec<@Target>;
|
||||
|
||||
let mut used: bool;
|
||||
|
||||
new(span: span) {
|
||||
self.span = span;
|
||||
|
||||
new() {
|
||||
self.outstanding_references = 0u;
|
||||
|
||||
self.module_target = none;
|
||||
self.value_target = none;
|
||||
self.type_target = none;
|
||||
self.impl_target = @dvec();
|
||||
|
||||
self.used = false;
|
||||
}
|
||||
|
||||
fn target_for_namespace(namespace: Namespace) -> option<Target> {
|
||||
@ -430,18 +398,10 @@ pure fn is_none<T>(x: option<T>) -> bool {
|
||||
}
|
||||
}
|
||||
|
||||
fn unused_import_lint_level(session: session) -> level {
|
||||
for session.opts.lint_opts.each |lint_option_pair| {
|
||||
let (lint_type, lint_level) = lint_option_pair;
|
||||
if lint_type == unused_imports {
|
||||
ret lint_level;
|
||||
}
|
||||
}
|
||||
ret ignore;
|
||||
}
|
||||
|
||||
// Records the definitions (at most one for each namespace) that a name is
|
||||
// bound to.
|
||||
/**
|
||||
* Records the definitions (at most one for each namespace) that a name is
|
||||
* bound to.
|
||||
*/
|
||||
class NameBindings {
|
||||
let mut module_def: ModuleDef; //< Meaning in the module namespace.
|
||||
let mut type_def: option<def>; //< Meaning in the type namespace.
|
||||
@ -589,8 +549,6 @@ class Resolver {
|
||||
|
||||
let graph_root: @NameBindings;
|
||||
|
||||
let unused_import_lint_level: level;
|
||||
|
||||
// The number of imports that are currently unresolved.
|
||||
let mut unresolved_imports: uint;
|
||||
|
||||
@ -636,8 +594,6 @@ class Resolver {
|
||||
(*self.graph_root).define_module(NoParentLink,
|
||||
some({ crate: 0, node: 0 }));
|
||||
|
||||
self.unused_import_lint_level = unused_import_lint_level(session);
|
||||
|
||||
self.unresolved_imports = 0u;
|
||||
|
||||
self.current_module = (*self.graph_root).get_module();
|
||||
@ -658,21 +614,10 @@ class Resolver {
|
||||
/// The main name resolution procedure.
|
||||
fn resolve(this: @Resolver) {
|
||||
self.build_reduced_graph(this);
|
||||
self.session.abort_if_errors();
|
||||
|
||||
self.resolve_imports();
|
||||
self.session.abort_if_errors();
|
||||
|
||||
self.record_exports();
|
||||
self.session.abort_if_errors();
|
||||
|
||||
self.build_impl_scopes();
|
||||
self.session.abort_if_errors();
|
||||
|
||||
self.resolve_crate();
|
||||
self.session.abort_if_errors();
|
||||
|
||||
self.check_for_unused_imports_if_necessary();
|
||||
}
|
||||
|
||||
//
|
||||
@ -1000,8 +945,7 @@ class Resolver {
|
||||
source_atom);
|
||||
self.build_import_directive(module,
|
||||
module_path,
|
||||
subclass,
|
||||
view_path.span);
|
||||
subclass);
|
||||
}
|
||||
view_path_list(_, source_idents, _) {
|
||||
for source_idents.each |source_ident| {
|
||||
@ -1010,15 +954,13 @@ class Resolver {
|
||||
let subclass = @SingleImport(atom, atom);
|
||||
self.build_import_directive(module,
|
||||
module_path,
|
||||
subclass,
|
||||
view_path.span);
|
||||
subclass);
|
||||
}
|
||||
}
|
||||
view_path_glob(_, _) {
|
||||
self.build_import_directive(module,
|
||||
module_path,
|
||||
@GlobImport,
|
||||
view_path.span);
|
||||
@GlobImport);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1124,8 +1066,7 @@ class Resolver {
|
||||
do self.with_type_parameter_rib
|
||||
(HasTypeParameters(&type_parameters,
|
||||
foreign_item.id,
|
||||
0u,
|
||||
NormalRibKind)) || {
|
||||
0u)) || {
|
||||
|
||||
visit_foreign_item(foreign_item, new_parent, visitor);
|
||||
}
|
||||
@ -1351,10 +1292,9 @@ class Resolver {
|
||||
/// Creates and adds an import directive to the given module.
|
||||
fn build_import_directive(module: @Module,
|
||||
module_path: @dvec<Atom>,
|
||||
subclass: @ImportDirectiveSubclass,
|
||||
span: span) {
|
||||
subclass: @ImportDirectiveSubclass) {
|
||||
|
||||
let directive = @ImportDirective(module_path, subclass, span);
|
||||
let directive = @ImportDirective(module_path, subclass);
|
||||
module.imports.push(directive);
|
||||
|
||||
// Bump the reference count on the name. Or, if this is a glob, set
|
||||
@ -1367,7 +1307,7 @@ class Resolver {
|
||||
resolution.outstanding_references += 1u;
|
||||
}
|
||||
none {
|
||||
let resolution = @ImportResolution(span);
|
||||
let resolution = @ImportResolution();
|
||||
resolution.outstanding_references = 1u;
|
||||
module.import_resolutions.insert(target, resolution);
|
||||
}
|
||||
@ -1463,8 +1403,9 @@ class Resolver {
|
||||
alt self.resolve_import_for_module(module, import_directive) {
|
||||
Failed {
|
||||
// We presumably emitted an error. Continue.
|
||||
self.session.span_err(import_directive.span,
|
||||
"failed to resolve import");
|
||||
// XXX: span_err
|
||||
self.session.err(#fmt("failed to resolve import in: %s",
|
||||
self.module_to_str(module)));
|
||||
}
|
||||
Indeterminate {
|
||||
// Bail out. We'll come around next time.
|
||||
@ -1509,8 +1450,7 @@ class Resolver {
|
||||
// First, resolve the module path for the directive, if necessary.
|
||||
alt self.resolve_module_path_for_import(module,
|
||||
module_path,
|
||||
NoXray,
|
||||
import_directive.span) {
|
||||
NoXray) {
|
||||
|
||||
Failed {
|
||||
resolution_result = Failed;
|
||||
@ -1531,11 +1471,9 @@ class Resolver {
|
||||
source);
|
||||
}
|
||||
GlobImport {
|
||||
let span = import_directive.span;
|
||||
resolution_result =
|
||||
self.resolve_glob_import(module,
|
||||
containing_module,
|
||||
span);
|
||||
containing_module);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1672,7 +1610,6 @@ class Resolver {
|
||||
some(import_resolution)
|
||||
if import_resolution.outstanding_references
|
||||
== 0u {
|
||||
|
||||
fn get_binding(import_resolution: @ImportResolution,
|
||||
namespace: Namespace)
|
||||
-> NamespaceResult {
|
||||
@ -1683,7 +1620,6 @@ class Resolver {
|
||||
ret UnboundResult;
|
||||
}
|
||||
some(target) {
|
||||
import_resolution.used = true;
|
||||
ret BoundResult(target.target_module,
|
||||
target.bindings);
|
||||
}
|
||||
@ -1794,9 +1730,7 @@ class Resolver {
|
||||
* succeeds or bails out (as importing * from an empty module or a module
|
||||
* that exports nothing is valid).
|
||||
*/
|
||||
fn resolve_glob_import(module: @Module,
|
||||
containing_module: @Module,
|
||||
span: span)
|
||||
fn resolve_glob_import(module: @Module, containing_module: @Module)
|
||||
-> ResolveResult<()> {
|
||||
|
||||
// This function works in a highly imperative manner; it eagerly adds
|
||||
@ -1833,8 +1767,7 @@ class Resolver {
|
||||
alt module.import_resolutions.find(atom) {
|
||||
none {
|
||||
// Simple: just copy the old import resolution.
|
||||
let new_import_resolution =
|
||||
@ImportResolution(target_import_resolution.span);
|
||||
let new_import_resolution = @ImportResolution();
|
||||
new_import_resolution.module_target =
|
||||
copy target_import_resolution.module_target;
|
||||
new_import_resolution.value_target =
|
||||
@ -1895,17 +1828,12 @@ class Resolver {
|
||||
|
||||
// Add all children from the containing module.
|
||||
for containing_module.children.each |atom, name_bindings| {
|
||||
if !self.name_is_exported(containing_module, atom) {
|
||||
#debug("(resolving glob import) name '%s' is unexported",
|
||||
*(*self.atom_table).atom_to_str(atom));
|
||||
cont;
|
||||
}
|
||||
|
||||
let mut dest_import_resolution;
|
||||
alt module.import_resolutions.find(atom) {
|
||||
none {
|
||||
// Create a new import resolution from this child.
|
||||
dest_import_resolution = @ImportResolution(span);
|
||||
dest_import_resolution = @ImportResolution();
|
||||
module.import_resolutions.insert
|
||||
(atom, dest_import_resolution);
|
||||
}
|
||||
@ -1951,8 +1879,7 @@ class Resolver {
|
||||
fn resolve_module_path_from_root(module: @Module,
|
||||
module_path: @dvec<Atom>,
|
||||
index: uint,
|
||||
xray: XrayFlag,
|
||||
span: span)
|
||||
xray: XrayFlag)
|
||||
-> ResolveResult<@Module> {
|
||||
|
||||
let mut search_module = module;
|
||||
@ -1969,7 +1896,10 @@ class Resolver {
|
||||
xray) {
|
||||
|
||||
Failed {
|
||||
self.session.span_err(span, "unresolved name");
|
||||
// XXX: span_err
|
||||
self.session.err(#fmt("module resolution failed: %s",
|
||||
*(*self.atom_table)
|
||||
.atom_to_str(name)));
|
||||
ret Failed;
|
||||
}
|
||||
Indeterminate {
|
||||
@ -1982,10 +1912,10 @@ class Resolver {
|
||||
alt target.bindings.module_def {
|
||||
NoModuleDef {
|
||||
// Not a module.
|
||||
self.session.span_err(span,
|
||||
#fmt("not a module: %s",
|
||||
*(*self.atom_table).
|
||||
atom_to_str(name)));
|
||||
// XXX: span_err
|
||||
self.session.err(#fmt("not a module: %s",
|
||||
*(*self.atom_table).
|
||||
atom_to_str(name)));
|
||||
ret Failed;
|
||||
}
|
||||
ModuleDef(module) {
|
||||
@ -2007,8 +1937,7 @@ class Resolver {
|
||||
*/
|
||||
fn resolve_module_path_for_import(module: @Module,
|
||||
module_path: @dvec<Atom>,
|
||||
xray: XrayFlag,
|
||||
span: span)
|
||||
xray: XrayFlag)
|
||||
-> ResolveResult<@Module> {
|
||||
|
||||
let module_path_len = (*module_path).len();
|
||||
@ -2026,7 +1955,10 @@ class Resolver {
|
||||
let mut search_module;
|
||||
alt self.resolve_module_in_lexical_scope(module, first_element) {
|
||||
Failed {
|
||||
self.session.span_err(span, "unresolved name");
|
||||
// XXX: span_err
|
||||
self.session.err(#fmt("unresolved name: %s",
|
||||
*(*self.atom_table).
|
||||
atom_to_str(first_element)));
|
||||
ret Failed;
|
||||
}
|
||||
Indeterminate {
|
||||
@ -2042,8 +1974,7 @@ class Resolver {
|
||||
ret self.resolve_module_path_from_root(search_module,
|
||||
module_path,
|
||||
1u,
|
||||
xray,
|
||||
span);
|
||||
xray);
|
||||
}
|
||||
|
||||
fn resolve_item_in_lexical_scope(module: @Module,
|
||||
@ -2087,7 +2018,6 @@ class Resolver {
|
||||
namespace);
|
||||
}
|
||||
some(target) {
|
||||
import_resolution.used = true;
|
||||
ret Success(copy target);
|
||||
}
|
||||
}
|
||||
@ -2227,7 +2157,6 @@ class Resolver {
|
||||
some(target) {
|
||||
#debug("(resolving name in module) resolved to \
|
||||
import");
|
||||
import_resolution.used = true;
|
||||
ret Success(copy target);
|
||||
}
|
||||
}
|
||||
@ -2387,7 +2316,8 @@ class Resolver {
|
||||
if is_none(module_result) && is_none(value_result) &&
|
||||
is_none(type_result) && is_none(impl_result) {
|
||||
|
||||
self.session.span_err(import_directive.span, "unresolved import");
|
||||
// XXX: span_err, better error
|
||||
self.session.err("couldn't find anything with that name");
|
||||
ret Failed;
|
||||
}
|
||||
|
||||
@ -2431,8 +2361,13 @@ class Resolver {
|
||||
let index = module.resolved_import_count;
|
||||
let import_count = module.imports.len();
|
||||
if index != import_count {
|
||||
self.session.span_err(module.imports.get_elt(index).span,
|
||||
"unresolved import");
|
||||
let module_path = module.imports.get_elt(index).module_path;
|
||||
|
||||
// XXX: span_err
|
||||
self.session.err(#fmt("unresolved import in %s: %s",
|
||||
self.module_to_str(module),
|
||||
*(*self.atom_table)
|
||||
.atoms_to_str((*module_path).get())));
|
||||
}
|
||||
|
||||
// Descend into children and anonymous children.
|
||||
@ -2517,8 +2452,7 @@ class Resolver {
|
||||
|
||||
alt self.resolve_definition_of_name_in_module(module,
|
||||
name,
|
||||
namespace,
|
||||
Xray) {
|
||||
namespace) {
|
||||
NoNameDefinition {
|
||||
// Nothing to do.
|
||||
}
|
||||
@ -2577,7 +2511,7 @@ class Resolver {
|
||||
for module.children.each |_atom, child_name_bindings| {
|
||||
alt (*child_name_bindings).get_module_if_available() {
|
||||
none {
|
||||
// Nothing to do.
|
||||
/* Nothing to do. */
|
||||
}
|
||||
some(child_module) {
|
||||
self.build_impl_scopes_for_module_subtree(child_module);
|
||||
@ -2643,7 +2577,10 @@ class Resolver {
|
||||
|
||||
// AST resolution
|
||||
//
|
||||
// We maintain a list of value ribs and type ribs.
|
||||
// We maintain a list of value ribs and type ribs. Since ribs are
|
||||
// somewhat expensive to allocate, we try to avoid creating ribs unless
|
||||
// we know we need to. For instance, we don't allocate a type rib for
|
||||
// a function with no type parameters.
|
||||
//
|
||||
// Simultaneously, we keep track of the current position in the module
|
||||
// graph in the `current_module` pointer. When we go to resolve a name in
|
||||
@ -2697,30 +2634,18 @@ class Resolver {
|
||||
// Wraps the given definition in the appropriate number of `def_upvar`
|
||||
// wrappers.
|
||||
|
||||
fn upvarify(ribs: @dvec<@Rib>, rib_index: uint, def_like: def_like,
|
||||
span: span, allow_capturing_self: AllowCapturingSelfFlag)
|
||||
-> option<def_like> {
|
||||
fn upvarify(ribs: @dvec<@Rib>, rib_index: uint, def_like: def_like)
|
||||
-> def_like {
|
||||
|
||||
let mut def;
|
||||
let mut is_ty_param;
|
||||
|
||||
alt def_like {
|
||||
dl_def(d @ def_local(*)) | dl_def(d @ def_upvar(*)) |
|
||||
dl_def(d @ def_arg(*)) | dl_def(d @ def_binding(*)) {
|
||||
dl_def(d @ def_arg(*)) | dl_def(d @ def_self(*)) |
|
||||
dl_def(d @ def_binding(*)) {
|
||||
def = d;
|
||||
is_ty_param = false;
|
||||
}
|
||||
dl_def(d @ def_ty_param(*)) {
|
||||
def = d;
|
||||
is_ty_param = true;
|
||||
}
|
||||
dl_def(d @ def_self(*))
|
||||
if allow_capturing_self == DontAllowCapturingSelf {
|
||||
def = d;
|
||||
is_ty_param = false;
|
||||
}
|
||||
_ {
|
||||
ret some(def_like);
|
||||
ret def_like;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2732,43 +2657,19 @@ class Resolver {
|
||||
// Nothing to do. Continue.
|
||||
}
|
||||
FunctionRibKind(function_id) {
|
||||
if !is_ty_param {
|
||||
def = def_upvar(def_id_of_def(def).node,
|
||||
@def,
|
||||
function_id);
|
||||
}
|
||||
}
|
||||
OpaqueFunctionRibKind {
|
||||
if !is_ty_param {
|
||||
// This was an attempt to access an upvar inside a
|
||||
// named function item. This is not allowed, so we
|
||||
// report an error.
|
||||
|
||||
self.session.span_err(span,
|
||||
"attempted dynamic environment-\
|
||||
capture");
|
||||
} else {
|
||||
// This was an attempt to use a type parameter outside
|
||||
// its scope.
|
||||
|
||||
self.session.span_err(span,
|
||||
"attempt to use a type \
|
||||
argument out of scope");
|
||||
}
|
||||
|
||||
ret none;
|
||||
def = def_upvar(def_id_of_def(def).node,
|
||||
@def,
|
||||
function_id);
|
||||
}
|
||||
}
|
||||
|
||||
rib_index += 1u;
|
||||
}
|
||||
|
||||
ret some(dl_def(def));
|
||||
ret dl_def(def);
|
||||
}
|
||||
|
||||
fn search_ribs(ribs: @dvec<@Rib>, name: Atom, span: span,
|
||||
allow_capturing_self: AllowCapturingSelfFlag)
|
||||
-> option<def_like> {
|
||||
fn search_ribs(ribs: @dvec<@Rib>, name: Atom) -> option<def_like> {
|
||||
|
||||
// XXX: This should not use a while loop.
|
||||
// XXX: Try caching?
|
||||
@ -2779,8 +2680,7 @@ class Resolver {
|
||||
let rib = (*ribs).get_elt(i);
|
||||
alt rib.bindings.find(name) {
|
||||
some(def_like) {
|
||||
ret self.upvarify(ribs, i, def_like, span,
|
||||
allow_capturing_self);
|
||||
ret some(self.upvarify(ribs, i, def_like));
|
||||
}
|
||||
none {
|
||||
// Continue.
|
||||
@ -2833,8 +2733,7 @@ class Resolver {
|
||||
item_enum(_, type_parameters, _) |
|
||||
item_ty(_, type_parameters, _) {
|
||||
do self.with_type_parameter_rib
|
||||
(HasTypeParameters(&type_parameters, item.id, 0u,
|
||||
NormalRibKind))
|
||||
(HasTypeParameters(&type_parameters, item.id, 0u))
|
||||
|| {
|
||||
|
||||
visit_item(item, (), visitor);
|
||||
@ -2861,8 +2760,7 @@ class Resolver {
|
||||
|
||||
// Create a new rib for the interface-wide type parameters.
|
||||
do self.with_type_parameter_rib
|
||||
(HasTypeParameters(&type_parameters, item.id, 0u,
|
||||
NormalRibKind))
|
||||
(HasTypeParameters(&type_parameters, item.id, 0u))
|
||||
|| {
|
||||
|
||||
for methods.each |method| {
|
||||
@ -2874,8 +2772,7 @@ class Resolver {
|
||||
do self.with_type_parameter_rib
|
||||
(HasTypeParameters(&method.tps,
|
||||
item.id,
|
||||
type_parameters.len(),
|
||||
NormalRibKind))
|
||||
type_parameters.len()))
|
||||
|| {
|
||||
|
||||
// Resolve the method-specific type parameters.
|
||||
@ -2922,9 +2819,7 @@ class Resolver {
|
||||
do self.with_type_parameter_rib
|
||||
(HasTypeParameters(&type_parameters,
|
||||
foreign_item.id,
|
||||
0u,
|
||||
OpaqueFunctionRibKind))
|
||||
|| {
|
||||
0u)) || {
|
||||
|
||||
visit_foreign_item(foreign_item, (),
|
||||
visitor);
|
||||
@ -2949,13 +2844,11 @@ class Resolver {
|
||||
self.session.main_fn = some((item.id, item.span));
|
||||
}
|
||||
|
||||
self.resolve_function(OpaqueFunctionRibKind,
|
||||
self.resolve_function(NormalRibKind,
|
||||
some(@fn_decl),
|
||||
HasTypeParameters
|
||||
(&ty_params,
|
||||
item.id,
|
||||
0u,
|
||||
OpaqueFunctionRibKind),
|
||||
HasTypeParameters(&ty_params,
|
||||
item.id,
|
||||
0u),
|
||||
block,
|
||||
NoSelfBinding,
|
||||
NoCaptureClause,
|
||||
@ -2976,10 +2869,10 @@ class Resolver {
|
||||
|
||||
fn with_type_parameter_rib(type_parameters: TypeParameters, f: fn()) {
|
||||
alt type_parameters {
|
||||
HasTypeParameters(type_parameters, node_id, initial_index,
|
||||
rib_kind) {
|
||||
HasTypeParameters(type_parameters, node_id, initial_index)
|
||||
if (*type_parameters).len() >= 1u {
|
||||
|
||||
let function_type_rib = @Rib(rib_kind);
|
||||
let function_type_rib = @Rib(NormalRibKind);
|
||||
(*self.type_ribs).push(function_type_rib);
|
||||
|
||||
for (*type_parameters).eachi |index, type_parameter| {
|
||||
@ -2992,7 +2885,7 @@ class Resolver {
|
||||
}
|
||||
}
|
||||
|
||||
NoTypeParameters {
|
||||
HasTypeParameters(*) | NoTypeParameters {
|
||||
// Nothing to do.
|
||||
}
|
||||
}
|
||||
@ -3000,11 +2893,13 @@ class Resolver {
|
||||
f();
|
||||
|
||||
alt type_parameters {
|
||||
HasTypeParameters(type_parameters, _, _, _) {
|
||||
HasTypeParameters(type_parameters, _, _)
|
||||
if (*type_parameters).len() >= 1u {
|
||||
|
||||
(*self.type_ribs).pop();
|
||||
}
|
||||
|
||||
NoTypeParameters {
|
||||
HasTypeParameters(*) | NoTypeParameters {
|
||||
// Nothing to do.
|
||||
}
|
||||
}
|
||||
@ -3028,11 +2923,11 @@ class Resolver {
|
||||
for (*capture_clause).each |capture_item| {
|
||||
alt self.resolve_identifier(capture_item.name,
|
||||
ValueNS,
|
||||
true,
|
||||
capture_item.span) {
|
||||
true) {
|
||||
none {
|
||||
self.session.span_err(capture_item.span,
|
||||
"unresolved name in \
|
||||
"use of undeclared \
|
||||
identifier in \
|
||||
capture clause");
|
||||
}
|
||||
some(def) {
|
||||
@ -3054,7 +2949,7 @@ class Resolver {
|
||||
NoTypeParameters {
|
||||
// Continue.
|
||||
}
|
||||
HasTypeParameters(type_parameters, _, _, _) {
|
||||
HasTypeParameters(type_parameters, _, _) {
|
||||
self.resolve_type_parameters(*type_parameters, visitor);
|
||||
}
|
||||
}
|
||||
@ -3097,8 +2992,8 @@ class Resolver {
|
||||
false, visitor) {
|
||||
none {
|
||||
self.session.span_err(constraint.span,
|
||||
#fmt("unresolved name: %s",
|
||||
*constraint.node.path.idents.last()));
|
||||
"use of undeclared \
|
||||
constraint");
|
||||
}
|
||||
some(def) {
|
||||
self.record_def(constraint.node.id, def);
|
||||
@ -3149,8 +3044,7 @@ class Resolver {
|
||||
let outer_type_parameter_count = (*type_parameters).len();
|
||||
let borrowed_type_parameters: &~[ty_param] = &*type_parameters;
|
||||
do self.with_type_parameter_rib(HasTypeParameters
|
||||
(borrowed_type_parameters, id, 0u,
|
||||
NormalRibKind))
|
||||
(borrowed_type_parameters, id, 0u))
|
||||
|| {
|
||||
|
||||
// Resolve the type parameters.
|
||||
@ -3161,8 +3055,8 @@ class Resolver {
|
||||
alt self.resolve_path(interface.path, TypeNS, true, visitor) {
|
||||
none {
|
||||
self.session.span_err(interface.path.span,
|
||||
"attempt to implement a \
|
||||
nonexistent interface");
|
||||
"attempt to implement an \
|
||||
unknown interface");
|
||||
}
|
||||
some(def) {
|
||||
// Write a mapping from the interface ID to the
|
||||
@ -3189,8 +3083,7 @@ class Resolver {
|
||||
let type_parameters =
|
||||
HasTypeParameters(borrowed_method_type_parameters,
|
||||
method.id,
|
||||
outer_type_parameter_count,
|
||||
NormalRibKind);
|
||||
outer_type_parameter_count);
|
||||
self.resolve_function(NormalRibKind,
|
||||
some(@method.decl),
|
||||
type_parameters,
|
||||
@ -3246,8 +3139,7 @@ class Resolver {
|
||||
let outer_type_parameter_count = type_parameters.len();
|
||||
let borrowed_type_parameters: &~[ty_param] = &type_parameters;
|
||||
do self.with_type_parameter_rib(HasTypeParameters
|
||||
(borrowed_type_parameters, id, 0u,
|
||||
NormalRibKind))
|
||||
(borrowed_type_parameters, id, 0u))
|
||||
|| {
|
||||
|
||||
// Resolve the type parameters.
|
||||
@ -3286,8 +3178,7 @@ class Resolver {
|
||||
HasTypeParameters
|
||||
(borrowed_type_parameters,
|
||||
method.id,
|
||||
outer_type_parameter_count,
|
||||
NormalRibKind),
|
||||
outer_type_parameter_count),
|
||||
method.body,
|
||||
HasSelfBinding(method.self_id),
|
||||
NoCaptureClause,
|
||||
@ -3482,32 +3373,19 @@ class Resolver {
|
||||
// such a variant is simply disallowed (since it's rarely
|
||||
// what you want).
|
||||
|
||||
// XXX: This restriction is not yet implemented.
|
||||
|
||||
let atom = (*self.atom_table).intern(path.idents[0]);
|
||||
|
||||
alt self.resolve_enum_variant_or_const(atom) {
|
||||
FoundEnumVariant(def) if mode == RefutableMode {
|
||||
alt self.resolve_enum_variant(atom) {
|
||||
some(def) {
|
||||
#debug("(resolving pattern) resolving '%s' to \
|
||||
enum variant",
|
||||
*path.idents[0]);
|
||||
|
||||
self.record_def(pattern.id, def);
|
||||
}
|
||||
FoundEnumVariant(_) {
|
||||
self.session.span_err(pattern.span,
|
||||
#fmt("declaration of `%s` \
|
||||
shadows an enum \
|
||||
that's in scope",
|
||||
*(*self.atom_table).
|
||||
atom_to_str
|
||||
(atom)));
|
||||
}
|
||||
FoundConst {
|
||||
self.session.span_err(pattern.span,
|
||||
"pattern variable \
|
||||
conflicts with a constant \
|
||||
in scope");
|
||||
}
|
||||
EnumVariantOrConstNotFound {
|
||||
none {
|
||||
#debug("(resolving pattern) binding '%s'",
|
||||
*path.idents[0]);
|
||||
|
||||
@ -3579,7 +3457,7 @@ class Resolver {
|
||||
}
|
||||
none {
|
||||
self.session.span_err(path.span,
|
||||
"unresolved enum variant");
|
||||
"undeclared enum variant");
|
||||
}
|
||||
}
|
||||
|
||||
@ -3596,9 +3474,7 @@ class Resolver {
|
||||
}
|
||||
}
|
||||
|
||||
fn resolve_enum_variant_or_const(name: Atom)
|
||||
-> EnumVariantOrConstResolution {
|
||||
|
||||
fn resolve_enum_variant(name: Atom) -> option<def> {
|
||||
alt self.resolve_item_in_lexical_scope(self.current_module,
|
||||
name,
|
||||
ValueNS) {
|
||||
@ -3610,13 +3486,10 @@ class Resolver {
|
||||
of name bindings with no def?!";
|
||||
}
|
||||
some(def @ def_variant(*)) {
|
||||
ret FoundEnumVariant(def);
|
||||
}
|
||||
some(def_const(*)) {
|
||||
ret FoundConst;
|
||||
ret some(def);
|
||||
}
|
||||
some(_) {
|
||||
ret EnumVariantOrConstNotFound;
|
||||
ret none;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3626,7 +3499,7 @@ class Resolver {
|
||||
}
|
||||
|
||||
Failed {
|
||||
ret EnumVariantOrConstNotFound;
|
||||
ret none;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3658,20 +3531,16 @@ class Resolver {
|
||||
|
||||
ret self.resolve_identifier(path.idents.last(),
|
||||
namespace,
|
||||
check_ribs,
|
||||
path.span);
|
||||
check_ribs);
|
||||
}
|
||||
|
||||
fn resolve_identifier(identifier: ident,
|
||||
namespace: Namespace,
|
||||
check_ribs: bool,
|
||||
span: span)
|
||||
check_ribs: bool)
|
||||
-> option<def> {
|
||||
|
||||
if check_ribs {
|
||||
alt self.resolve_identifier_in_local_ribs(identifier,
|
||||
namespace,
|
||||
span) {
|
||||
alt self.resolve_identifier_in_local_ribs(identifier, namespace) {
|
||||
some(def) {
|
||||
ret some(def);
|
||||
}
|
||||
@ -3688,17 +3557,9 @@ class Resolver {
|
||||
// XXX: Merge me with resolve_name_in_module?
|
||||
fn resolve_definition_of_name_in_module(containing_module: @Module,
|
||||
name: Atom,
|
||||
namespace: Namespace,
|
||||
xray: XrayFlag)
|
||||
namespace: Namespace)
|
||||
-> NameDefinition {
|
||||
|
||||
if xray == NoXray && !self.name_is_exported(containing_module, name) {
|
||||
#debug("(resolving definition of name in module) name '%s' is \
|
||||
unexported",
|
||||
*(*self.atom_table).atom_to_str(name));
|
||||
ret NoNameDefinition;
|
||||
}
|
||||
|
||||
// First, search children.
|
||||
alt containing_module.children.find(name) {
|
||||
some(child_name_bindings) {
|
||||
@ -3725,7 +3586,6 @@ class Resolver {
|
||||
alt (*target.bindings).def_for_namespace(namespace) {
|
||||
some(def) {
|
||||
// Found it.
|
||||
import_resolution.used = true;
|
||||
ret ImportNameDefinition(def);
|
||||
}
|
||||
none {
|
||||
@ -3769,8 +3629,7 @@ class Resolver {
|
||||
let mut containing_module;
|
||||
alt self.resolve_module_path_for_import(self.current_module,
|
||||
module_path_atoms,
|
||||
xray,
|
||||
path.span) {
|
||||
xray) {
|
||||
|
||||
Failed {
|
||||
self.session.span_err(path.span,
|
||||
@ -3792,8 +3651,7 @@ class Resolver {
|
||||
let name = (*self.atom_table).intern(path.idents.last());
|
||||
alt self.resolve_definition_of_name_in_module(containing_module,
|
||||
name,
|
||||
namespace,
|
||||
xray) {
|
||||
namespace) {
|
||||
NoNameDefinition {
|
||||
// We failed to resolve the name. Report an error.
|
||||
self.session.span_err(path.span,
|
||||
@ -3823,8 +3681,7 @@ class Resolver {
|
||||
alt self.resolve_module_path_from_root(root_module,
|
||||
module_path_atoms,
|
||||
0u,
|
||||
xray,
|
||||
path.span) {
|
||||
xray) {
|
||||
|
||||
Failed {
|
||||
self.session.span_err(path.span,
|
||||
@ -3846,8 +3703,7 @@ class Resolver {
|
||||
let name = (*self.atom_table).intern(path.idents.last());
|
||||
alt self.resolve_definition_of_name_in_module(containing_module,
|
||||
name,
|
||||
namespace,
|
||||
xray) {
|
||||
namespace) {
|
||||
NoNameDefinition {
|
||||
// We failed to resolve the name. Report an error.
|
||||
self.session.span_err(path.span,
|
||||
@ -3865,8 +3721,7 @@ class Resolver {
|
||||
}
|
||||
|
||||
fn resolve_identifier_in_local_ribs(identifier: ident,
|
||||
namespace: Namespace,
|
||||
span: span)
|
||||
namespace: Namespace)
|
||||
-> option<def> {
|
||||
|
||||
let name = (*self.atom_table).intern(identifier);
|
||||
@ -3875,12 +3730,10 @@ class Resolver {
|
||||
let mut search_result;
|
||||
alt namespace {
|
||||
ValueNS {
|
||||
search_result = self.search_ribs(self.value_ribs, name, span,
|
||||
DontAllowCapturingSelf);
|
||||
search_result = self.search_ribs(self.value_ribs, name);
|
||||
}
|
||||
TypeNS {
|
||||
search_result = self.search_ribs(self.type_ribs, name, span,
|
||||
AllowCapturingSelf);
|
||||
search_result = self.search_ribs(self.type_ribs, name);
|
||||
}
|
||||
ModuleNS | ImplNS {
|
||||
fail "module or impl namespaces do not have local ribs";
|
||||
@ -4007,83 +3860,6 @@ class Resolver {
|
||||
self.def_map.insert(node_id, def);
|
||||
}
|
||||
|
||||
//
|
||||
// Unused import checking
|
||||
//
|
||||
// Although this is a lint pass, it lives in here because it depends on
|
||||
// resolve data structures.
|
||||
//
|
||||
|
||||
fn check_for_unused_imports_if_necessary() {
|
||||
if self.unused_import_lint_level == ignore {
|
||||
ret;
|
||||
}
|
||||
|
||||
let root_module = (*self.graph_root).get_module();
|
||||
self.check_for_unused_imports_in_module_subtree(root_module);
|
||||
}
|
||||
|
||||
fn check_for_unused_imports_in_module_subtree(module: @Module) {
|
||||
// If this isn't a local crate, then bail out. We don't need to check
|
||||
// for unused imports in external crates.
|
||||
|
||||
alt module.def_id {
|
||||
some(def_id) if def_id.crate == local_crate {
|
||||
// OK. Continue.
|
||||
}
|
||||
none {
|
||||
// Check for unused imports in the root module.
|
||||
}
|
||||
some(_) {
|
||||
// Bail out.
|
||||
#debug("(checking for unused imports in module subtree) not \
|
||||
checking for unused imports for '%s'",
|
||||
self.module_to_str(module));
|
||||
ret;
|
||||
}
|
||||
}
|
||||
|
||||
self.check_for_unused_imports_in_module(module);
|
||||
|
||||
for module.children.each |_atom, child_name_bindings| {
|
||||
alt (*child_name_bindings).get_module_if_available() {
|
||||
none {
|
||||
// Nothing to do.
|
||||
}
|
||||
some(child_module) {
|
||||
self.check_for_unused_imports_in_module_subtree
|
||||
(child_module);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for module.anonymous_children.each |_node_id, child_module| {
|
||||
self.check_for_unused_imports_in_module_subtree(child_module);
|
||||
}
|
||||
}
|
||||
|
||||
fn check_for_unused_imports_in_module(module: @Module) {
|
||||
for module.import_resolutions.each |_impl_name, import_resolution| {
|
||||
if !import_resolution.used {
|
||||
alt self.unused_import_lint_level {
|
||||
warn {
|
||||
self.session.span_warn(import_resolution.span,
|
||||
"unused import");
|
||||
}
|
||||
error {
|
||||
self.session.span_err(import_resolution.span,
|
||||
"unused import");
|
||||
}
|
||||
ignore {
|
||||
self.session.span_bug(import_resolution.span,
|
||||
"shouldn't be here if lint \
|
||||
pass is ignored");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Diagnostics
|
||||
//
|
||||
|
@ -166,13 +166,6 @@ export ty_sort_str;
|
||||
export normalize_ty;
|
||||
export to_str;
|
||||
export borrow, serialize_borrow, deserialize_borrow;
|
||||
export bound_const;
|
||||
export terr_no_integral_type, terr_ty_param_size, terr_self_substs;
|
||||
export terr_in_field, terr_record_fields, terr_vstores_differ, terr_arg_count;
|
||||
export terr_sorts, terr_vec, terr_str, terr_record_size, terr_tuple_size;
|
||||
export terr_regions_differ, terr_mutability, terr_purity_mismatch;
|
||||
export terr_constr_mismatch, terr_constr_len, terr_proto_mismatch;
|
||||
export terr_ret_style_mismatch;
|
||||
|
||||
// Data types
|
||||
|
||||
|
@ -75,8 +75,6 @@ export deserialize_method_map_entry;
|
||||
export vtable_map;
|
||||
export vtable_res;
|
||||
export vtable_origin;
|
||||
export method_static, method_param, method_trait;
|
||||
export vtable_static, vtable_param, vtable_trait;
|
||||
|
||||
#[auto_serialize]
|
||||
enum method_origin {
|
||||
|
@ -7,8 +7,6 @@ export config;
|
||||
export default_config;
|
||||
export parse_config;
|
||||
export usage;
|
||||
export markdown, pandoc_html;
|
||||
export doc_per_crate, doc_per_mod;
|
||||
|
||||
/// The type of document to output
|
||||
enum output_format {
|
||||
|
@ -2,6 +2,6 @@
|
||||
// aux-build:ambig_impl_2_lib.rs
|
||||
use ambig_impl_2_lib;
|
||||
import ambig_impl_2_lib::methods1;
|
||||
impl methods2 for uint { fn me() -> uint { self } } //~ NOTE is `methods2::me`
|
||||
impl methods2 for uint { fn me() -> uint { self } } //~ NOTE candidate #2 is `methods2::me`
|
||||
fn main() { 1u.me(); } //~ ERROR multiple applicable methods in scope
|
||||
//~^ NOTE is `ambig_impl_2_lib::methods1::me`
|
||||
//~^ NOTE candidate #1 is `ambig_impl_2_lib::methods1::me`
|
||||
|
11
src/test/compile-fail/bad-tag-export-2.rs
Normal file
11
src/test/compile-fail/bad-tag-export-2.rs
Normal file
@ -0,0 +1,11 @@
|
||||
// error-pattern:b does not refer to an enumeration
|
||||
import bad::*;
|
||||
|
||||
mod bad {
|
||||
export b::{};
|
||||
|
||||
fn b() { fail; }
|
||||
}
|
||||
|
||||
fn main() {
|
||||
}
|
13
src/test/compile-fail/bad-tag-export-3.rs
Normal file
13
src/test/compile-fail/bad-tag-export-3.rs
Normal file
@ -0,0 +1,13 @@
|
||||
// error-pattern:b does not refer to an enumeration
|
||||
import bad::*;
|
||||
|
||||
mod bad {
|
||||
export b::{f, z};
|
||||
|
||||
fn b() { fail; }
|
||||
fn f() { fail; }
|
||||
fn z() { fail; }
|
||||
}
|
||||
|
||||
fn main() {
|
||||
}
|
12
src/test/compile-fail/bad-tag-export-4.rs
Normal file
12
src/test/compile-fail/bad-tag-export-4.rs
Normal file
@ -0,0 +1,12 @@
|
||||
// error-pattern:f is not a variant
|
||||
import bad::*;
|
||||
|
||||
mod bad {
|
||||
export b::{f, z};
|
||||
|
||||
enum b { z, k }
|
||||
fn f() { fail; }
|
||||
}
|
||||
|
||||
fn main() {
|
||||
}
|
14
src/test/compile-fail/bad-tag-export.rs
Normal file
14
src/test/compile-fail/bad-tag-export.rs
Normal file
@ -0,0 +1,14 @@
|
||||
// error-pattern:variant e doesn't belong to enum floop
|
||||
import bad::*;
|
||||
|
||||
mod bad {
|
||||
|
||||
export floop::{a, e};
|
||||
|
||||
enum floop {a, b, c}
|
||||
enum bloop {d, e, f}
|
||||
|
||||
}
|
||||
|
||||
fn main() {
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
// error-pattern:unresolved name
|
||||
// error-pattern:unresolved name: z
|
||||
fn main() {
|
||||
let x = 5;
|
||||
let y = fn~(copy z, copy x) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
// error-pattern:unresolved name
|
||||
// error-pattern:unresolved name: z
|
||||
fn main() {
|
||||
let x = 5;
|
||||
let y = fn~(move z, move x) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
// error-pattern:nonexistent
|
||||
// error-pattern:unresolved typename: nonexistent
|
||||
class cat : nonexistent {
|
||||
let meows: uint;
|
||||
new(in_x : uint) { self.meows = in_x; }
|
||||
@ -6,4 +6,4 @@ class cat : nonexistent {
|
||||
|
||||
fn main() {
|
||||
let nyan = cat(0u);
|
||||
}
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
class cat : int { //~ ERROR interface
|
||||
class cat : int { //~ ERROR can only implement interface types
|
||||
let meows: uint;
|
||||
new(in_x : uint) { self.meows = in_x; }
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let nyan = cat(0u);
|
||||
}
|
||||
}
|
13
src/test/compile-fail/cross-crate-glob-collision.rs
Normal file
13
src/test/compile-fail/cross-crate-glob-collision.rs
Normal file
@ -0,0 +1,13 @@
|
||||
// error-pattern: is glob-imported from multiple different modules
|
||||
// issue #482
|
||||
|
||||
use std;
|
||||
// expecting swap to be defined in vec
|
||||
import vec::*;
|
||||
import alternate_supplier::*;
|
||||
|
||||
mod alternate_supplier {
|
||||
fn contains() { }
|
||||
}
|
||||
|
||||
fn main() { contains() }
|
@ -1,4 +1,4 @@
|
||||
// error-pattern: import
|
||||
// error-pattern: unresolved import
|
||||
|
||||
import m::unexported;
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
iface foo { fn foo(); }
|
||||
|
||||
impl of foo for uint {}
|
||||
impl of foo for uint {} //~ ERROR missing method `foo`
|
||||
|
||||
impl of foo for uint { fn foo() -> int {} }
|
||||
impl of foo for uint { fn foo() -> int {} } //~ ERROR incompatible type
|
||||
|
||||
impl of int for uint { fn foo() {} } //~ ERROR interface
|
||||
impl of int for uint { fn foo() {} } //~ ERROR can only implement interface
|
||||
|
||||
fn main() {}
|
||||
|
14
src/test/compile-fail/import-from-dup.rs
Normal file
14
src/test/compile-fail/import-from-dup.rs
Normal file
@ -0,0 +1,14 @@
|
||||
// error-pattern:duplicate definition of f
|
||||
|
||||
import m1::{f};
|
||||
import m2::{f};
|
||||
|
||||
mod m1 {
|
||||
fn f() { }
|
||||
}
|
||||
|
||||
mod m2 {
|
||||
fn f() { }
|
||||
}
|
||||
|
||||
fn main() { }
|
@ -1,4 +1,4 @@
|
||||
// error-pattern:unresolved
|
||||
// error-pattern:unresolved import
|
||||
import spam::{ham, eggs};
|
||||
|
||||
mod spam {
|
||||
|
@ -1,5 +1,5 @@
|
||||
// error-pattern: unresolved
|
||||
|
||||
// error-pattern: unresolved name
|
||||
mod circ1 {
|
||||
import circ1::*;
|
||||
export f1;
|
||||
|
20
src/test/compile-fail/import-glob-multiple.rs
Normal file
20
src/test/compile-fail/import-glob-multiple.rs
Normal file
@ -0,0 +1,20 @@
|
||||
// error-pattern:common2
|
||||
|
||||
import mod1::*;
|
||||
import mod2::*;
|
||||
|
||||
mod mod1 {
|
||||
fn f1() { #debug("f1"); }
|
||||
fn common1() { #debug("common") }
|
||||
fn common2() { #debug("common") }
|
||||
}
|
||||
|
||||
mod mod2 {
|
||||
fn f2() { #debug("f1"); }
|
||||
fn common1() { #debug("common") }
|
||||
fn common2() { #debug("common") }
|
||||
}
|
||||
|
||||
|
||||
|
||||
fn main() { common2(); }
|
@ -1,4 +1,4 @@
|
||||
// error-pattern:import
|
||||
// error-pattern:cyclic import
|
||||
|
||||
mod a {
|
||||
import b::x;
|
||||
|
@ -1,4 +1,4 @@
|
||||
// error-pattern:import
|
||||
// error-pattern: cyclic import
|
||||
|
||||
import y::x;
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
// xfail-test
|
||||
// error-pattern: unresolved
|
||||
// error-pattern: unresolved import
|
||||
import zed::bar;
|
||||
import zed::baz;
|
||||
mod zed {
|
||||
|
@ -1,4 +1,4 @@
|
||||
// error-pattern: unresolved
|
||||
// error-pattern: unresolved modulename
|
||||
import baz::zed::bar;
|
||||
mod baz { }
|
||||
mod zed {
|
||||
|
@ -1,4 +1,4 @@
|
||||
// error-pattern: unresolved
|
||||
// error-pattern: unresolved modulename
|
||||
import main::bar;
|
||||
|
||||
fn main(args: ~[str]) { #debug("foo"); }
|
||||
|
@ -1,4 +1,4 @@
|
||||
// error-pattern: import
|
||||
// error-pattern: cyclic import
|
||||
|
||||
mod a { import foo = b::foo; export foo; }
|
||||
mod b { import foo = a::foo; export foo; }
|
||||
|
15
src/test/compile-fail/import5.rs
Normal file
15
src/test/compile-fail/import5.rs
Normal file
@ -0,0 +1,15 @@
|
||||
// error-pattern:unresolved import
|
||||
|
||||
mod m1 {
|
||||
fn foo() { #debug("foo"); }
|
||||
}
|
||||
|
||||
mod m2 {
|
||||
import m1::foo;
|
||||
}
|
||||
|
||||
mod m3 {
|
||||
import m2::foo;
|
||||
}
|
||||
|
||||
fn main() { }
|
@ -1,8 +1,7 @@
|
||||
// xfail-test
|
||||
// Testing that we don't fail abnormally after hitting the errors
|
||||
|
||||
import unresolved::*; //~ ERROR unresolved modulename
|
||||
//~^ ERROR unresolved does not name a module
|
||||
|
||||
fn main() {
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
// -*- rust -*-
|
||||
// error-pattern: lt
|
||||
// error-pattern: lt is not declared pure
|
||||
|
||||
fn f(a: int, b: int) : lt(a, b) { }
|
||||
|
||||
|
18
src/test/compile-fail/tag-exports-2.rs
Normal file
18
src/test/compile-fail/tag-exports-2.rs
Normal file
@ -0,0 +1,18 @@
|
||||
// error-pattern:unresolved name: lovejoy
|
||||
import alder::*;
|
||||
|
||||
mod alder {
|
||||
export burnside;
|
||||
export everett::{flanders};
|
||||
export irving::{johnson, kearney};
|
||||
export marshall::{};
|
||||
|
||||
enum burnside { couch, davis }
|
||||
enum everett { flanders, glisan, hoyt }
|
||||
enum irving { johnson, kearney, lovejoy }
|
||||
enum marshall { northrup, overton }
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let raleigh: irving = lovejoy;
|
||||
}
|
18
src/test/compile-fail/tag-exports-3.rs
Normal file
18
src/test/compile-fail/tag-exports-3.rs
Normal file
@ -0,0 +1,18 @@
|
||||
// error-pattern:unresolved name: northrup
|
||||
import alder::*;
|
||||
|
||||
mod alder {
|
||||
export burnside;
|
||||
export everett::{flanders};
|
||||
export irving::{johnson, kearney};
|
||||
export marshall::{};
|
||||
|
||||
enum burnside { couch, davis }
|
||||
enum everett { flanders, glisan, hoyt }
|
||||
enum irving { johnson, kearney, lovejoy }
|
||||
enum marshall { northrup, overton }
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let savier: marshall = northrup;
|
||||
}
|
18
src/test/compile-fail/tag-exports.rs
Normal file
18
src/test/compile-fail/tag-exports.rs
Normal file
@ -0,0 +1,18 @@
|
||||
// error-pattern:unresolved name: glisan
|
||||
import alder::*;
|
||||
|
||||
mod alder {
|
||||
export burnside;
|
||||
export everett::{flanders};
|
||||
export irving::{johnson, kearney};
|
||||
export marshall::{};
|
||||
|
||||
enum burnside { couch, davis }
|
||||
enum everett { flanders, glisan, hoyt }
|
||||
enum irving { johnson, kearney, lovejoy }
|
||||
enum marshall { northrup, overton }
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let quimby: everett = glisan;
|
||||
}
|
@ -3,5 +3,5 @@
|
||||
use issue2170lib;
|
||||
|
||||
fn main() {
|
||||
// let _ = issue2170lib::rsrc(2i32);
|
||||
let _ = issue2170lib::rsrc(2i32);
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ import alder::*;
|
||||
|
||||
mod alder {
|
||||
export burnside;
|
||||
export couch;
|
||||
export everett;
|
||||
export flanders;
|
||||
export irving;
|
||||
|
Loading…
x
Reference in New Issue
Block a user