End of error code spanning centralization
This commit is contained in:
parent
f52a87c44e
commit
c5f7c19cf2
3 changed files with 430 additions and 189 deletions
|
@ -208,10 +208,13 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
|
||||||
// Return an error here by looking up the namespace that
|
// Return an error here by looking up the namespace that
|
||||||
// had the duplicate.
|
// had the duplicate.
|
||||||
let ns = ns.unwrap();
|
let ns = ns.unwrap();
|
||||||
resolve_err!(self, sp, E0428,
|
::resolve_error(
|
||||||
"duplicate definition of {} `{}`",
|
&::ResolutionError::DuplicateDefinition(
|
||||||
namespace_error_to_string(duplicate_type),
|
self,
|
||||||
token::get_name(name));
|
sp,
|
||||||
|
namespace_error_to_string(duplicate_type),
|
||||||
|
&*token::get_name(name))
|
||||||
|
);
|
||||||
{
|
{
|
||||||
let r = child.span_for_namespace(ns);
|
let r = child.span_for_namespace(ns);
|
||||||
if let Some(sp) = r {
|
if let Some(sp) = r {
|
||||||
|
@ -304,9 +307,10 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
|
||||||
full_path.segments.last().unwrap().identifier.name;
|
full_path.segments.last().unwrap().identifier.name;
|
||||||
if &token::get_name(source_name)[..] == "mod" ||
|
if &token::get_name(source_name)[..] == "mod" ||
|
||||||
&token::get_name(source_name)[..] == "self" {
|
&token::get_name(source_name)[..] == "self" {
|
||||||
resolve_err!(self, view_path.span, E0429,
|
::resolve_error(&::ResolutionError::SelfImportsOnlyAllowedWithin(
|
||||||
"{}",
|
self,
|
||||||
"`self` imports are only allowed within a { } list");
|
view_path.span)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let subclass = SingleImport(binding.name,
|
let subclass = SingleImport(binding.name,
|
||||||
|
@ -326,9 +330,11 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
|
||||||
_ => None
|
_ => None
|
||||||
}).collect::<Vec<Span>>();
|
}).collect::<Vec<Span>>();
|
||||||
if mod_spans.len() > 1 {
|
if mod_spans.len() > 1 {
|
||||||
resolve_err!(self, mod_spans[0], E0430,
|
::resolve_error(
|
||||||
"{}",
|
&::ResolutionError::SelfImportCanOnlyAppearOnceInTheList(
|
||||||
"`self` import can only appear once in the list");
|
self,
|
||||||
|
mod_spans[0])
|
||||||
|
);
|
||||||
for other_span in mod_spans.iter().skip(1) {
|
for other_span in mod_spans.iter().skip(1) {
|
||||||
self.session.span_note(*other_span,
|
self.session.span_note(*other_span,
|
||||||
"another `self` import appears here");
|
"another `self` import appears here");
|
||||||
|
@ -343,10 +349,12 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
|
||||||
let name = match module_path.last() {
|
let name = match module_path.last() {
|
||||||
Some(name) => *name,
|
Some(name) => *name,
|
||||||
None => {
|
None => {
|
||||||
resolve_err!(self, source_item.span, E0431,
|
::resolve_error(
|
||||||
"{}",
|
&::ResolutionError::
|
||||||
"`self` import can only appear in an import list \
|
SelfImportOnlyInImportListWithNonEmptyPrefix(
|
||||||
with a non-empty prefix");
|
self,
|
||||||
|
source_item.span)
|
||||||
|
);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -117,34 +117,266 @@ mod build_reduced_graph;
|
||||||
mod resolve_imports;
|
mod resolve_imports;
|
||||||
|
|
||||||
pub enum ResolutionError<'b, 'a:'b, 'tcx:'a> {
|
pub enum ResolutionError<'b, 'a:'b, 'tcx:'a> {
|
||||||
/// error: static variables cannot be referenced in a pattern
|
/// error E0401: can't use type parameters from outer function
|
||||||
|
TypeParametersFromOuterFunction(&'b Resolver<'a, 'tcx>, syntax::codemap::Span),
|
||||||
|
/// error E0402: cannot use an outer type parameter in this context
|
||||||
|
OuterTypeParameterContext(&'b Resolver<'a, 'tcx>, syntax::codemap::Span),
|
||||||
|
/// error E0403: the name is already used for a type parameter in this type parameter list
|
||||||
|
NameAlreadyUsedInTypeParameterList(&'b Resolver<'a, 'tcx>, syntax::codemap::Span,
|
||||||
|
syntax::ast::Name),
|
||||||
|
/// error E0404: is not a trait
|
||||||
|
IsNotATrait(&'b Resolver<'a, 'tcx>, syntax::codemap::Span, &'b str),
|
||||||
|
/// error E0405: use of undeclared trait name
|
||||||
|
UndeclaredTraitName(&'b Resolver<'a, 'tcx>, syntax::codemap::Span, &'b str),
|
||||||
|
/// error E0406: undeclared associated type
|
||||||
|
UndeclaredAssociatedType(&'b Resolver<'a, 'tcx>, syntax::codemap::Span),
|
||||||
|
/// error E0407: method is not a member of trait
|
||||||
|
MethodNotMemberOfTrait(&'b Resolver<'a, 'tcx>, syntax::codemap::Span, syntax::ast::Name,
|
||||||
|
&'b str),
|
||||||
|
/// error E0408: variable `{}` from pattern #1 is not bound in pattern
|
||||||
|
VariableNotBoundInPattern(&'b Resolver<'a, 'tcx>, syntax::codemap::Span, syntax::ast::Name,
|
||||||
|
usize),
|
||||||
|
/// error E0409: variable is bound with different mode in pattern #{} than in pattern #1
|
||||||
|
VariableBoundWithDifferentMode(&'b Resolver<'a, 'tcx>, syntax::codemap::Span,
|
||||||
|
syntax::ast::Name, usize),
|
||||||
|
/// error E0410: variable from pattern is not bound in pattern #1
|
||||||
|
VariableNotBoundInParentPattern(&'b Resolver<'a, 'tcx>, syntax::codemap::Span,
|
||||||
|
syntax::ast::Name, usize),
|
||||||
|
/// error E0411: use of `Self` outside of an impl or trait
|
||||||
|
SelfUsedOutsideImplOrTrait(&'b Resolver<'a, 'tcx>, syntax::codemap::Span),
|
||||||
|
/// error E0412: use of undeclared
|
||||||
|
UseOfUndeclared(&'b Resolver<'a, 'tcx>, syntax::codemap::Span, &'b str, &'b str),
|
||||||
|
/// error E0413: declaration shadows an enum variant or unit-like struct in scope
|
||||||
|
DeclarationShadowsEnumVariantOrUnitLikeStruct(&'b Resolver<'a, 'tcx>, syntax::codemap::Span,
|
||||||
|
syntax::ast::Name),
|
||||||
|
/// error E0414: only irrefutable patterns allowed here
|
||||||
|
OnlyIrrefutablePatternsAllowedHere(&'b Resolver<'a, 'tcx>, syntax::codemap::Span),
|
||||||
|
/// error E0415: identifier is bound more than once in this parameter list
|
||||||
|
IdentifierBoundMoreThanOnceInParameterList(&'b Resolver<'a, 'tcx>, syntax::codemap::Span,
|
||||||
|
&'b str),
|
||||||
|
/// error E0416: identifier is bound more than once in the same pattern
|
||||||
|
IdentifierBoundMoreThanOnceInSamePattern(&'b Resolver<'a, 'tcx>, syntax::codemap::Span,
|
||||||
|
&'b str),
|
||||||
|
/// error E0417: static variables cannot be referenced in a pattern
|
||||||
StaticVariableReference(&'b Resolver<'a, 'tcx>, syntax::codemap::Span),
|
StaticVariableReference(&'b Resolver<'a, 'tcx>, syntax::codemap::Span),
|
||||||
/// error: does not name a struct
|
/// error E0418: is not an enum variant, struct or const
|
||||||
DoesNotNameAStruct(&'b Resolver<'a, 'tcx>, syntax::codemap::Span),
|
NotAnEnumVariantStructOrConst(&'b Resolver<'a, 'tcx>, syntax::codemap::Span, &'b str),
|
||||||
/// error: is a struct variant name, but this expression uses it like a function name
|
/// error E0419: unresolved enum variant, struct or const
|
||||||
StructVariantUsedAsFunction(&'a Resolver<'a, 'tcx>, syntax::codemap::Span),
|
UnresolvedEnumVariantStructOrConst(&'b Resolver<'a, 'tcx>, syntax::codemap::Span, &'b str),
|
||||||
/// error: unresolved import
|
/// error E0420: is not an associated const
|
||||||
UnresolvedImport(&'b Resolver<'a, 'tcx>, syntax::codemap::Span),
|
NotAnAssociatedConst(&'b Resolver<'a, 'tcx>, syntax::codemap::Span, &'b str),
|
||||||
/// error: failed to resolve
|
/// error E0421: unresolved associated const
|
||||||
FailedToResolve(&'b Resolver<'a, 'tcx>, syntax::codemap::Span),
|
UnresolvedAssociatedConst(&'b Resolver<'a, 'tcx>, syntax::codemap::Span, &'b str),
|
||||||
|
/// error E0422: does not name a struct
|
||||||
|
DoesNotNameAStruct(&'b Resolver<'a, 'tcx>, syntax::codemap::Span, &'b str),
|
||||||
|
/// error E0423: is a struct variant name, but this expression uses it like a function name
|
||||||
|
StructVariantUsedAsFunction(&'a Resolver<'a, 'tcx>, syntax::codemap::Span, &'b str),
|
||||||
|
/// error E0424: `self` is not available in a static method
|
||||||
|
SelfNotAvailableInStaticMethod(&'a Resolver<'a, 'tcx>, syntax::codemap::Span),
|
||||||
|
/// error E0425: unresolved name
|
||||||
|
UnresolvedName(&'a Resolver<'a, 'tcx>, syntax::codemap::Span, &'b str, &'b str),
|
||||||
|
/// error E0426: use of undeclared label
|
||||||
|
UndeclaredLabel(&'a Resolver<'a, 'tcx>, syntax::codemap::Span, &'b str),
|
||||||
|
/// error E0427: cannot use `ref` binding mode with ...
|
||||||
|
CannotUseRefBindingModeWith(&'a Resolver<'a, 'tcx>, syntax::codemap::Span, &'b str),
|
||||||
|
/// error E0428: duplicate definition
|
||||||
|
DuplicateDefinition(&'a Resolver<'a, 'tcx>, syntax::codemap::Span, &'b str, &'b str),
|
||||||
|
/// error E0429: `self` imports are only allowed within a { } list
|
||||||
|
SelfImportsOnlyAllowedWithin(&'a Resolver<'a, 'tcx>, syntax::codemap::Span),
|
||||||
|
/// error E0430: `self` import can only appear once in the list
|
||||||
|
SelfImportCanOnlyAppearOnceInTheList(&'a Resolver<'a, 'tcx>, syntax::codemap::Span),
|
||||||
|
/// error E0431: `self` import can only appear in an import list with a non-empty prefix
|
||||||
|
SelfImportOnlyInImportListWithNonEmptyPrefix(&'a Resolver<'a, 'tcx>, syntax::codemap::Span),
|
||||||
|
/// error E0432: unresolved import
|
||||||
|
UnresolvedImport(&'b Resolver<'a, 'tcx>, syntax::codemap::Span,
|
||||||
|
Option<(&'b str, Option<&'b str>)>),
|
||||||
|
/// error E0433: failed to resolve
|
||||||
|
FailedToResolve(&'b Resolver<'a, 'tcx>, syntax::codemap::Span, &'b str),
|
||||||
|
/// error E0434: can't capture dynamic environment in a fn item
|
||||||
|
CannotCaptureDynamicEnvironmentInFnItem(&'b Resolver<'a, 'tcx>, syntax::codemap::Span),
|
||||||
|
/// error E0435: attempt to use a non-constant value in a constant
|
||||||
|
AttemptToUseNonConstantValueInConstant(&'b Resolver<'a, 'tcx>, syntax::codemap::Span),
|
||||||
}
|
}
|
||||||
|
|
||||||
fn resolve_error<'b, 'a:'b, 'tcx:'a>(resolution_error: &ResolutionError<'b, 'a, 'tcx>, formatted: &str) {
|
fn resolve_error<'b, 'a:'b, 'tcx:'a>(resolution_error: &ResolutionError<'b, 'a, 'tcx>) {
|
||||||
match resolution_error {
|
match resolution_error {
|
||||||
|
&ResolutionError::TypeParametersFromOuterFunction(resolver, span) => {
|
||||||
|
resolve_err!(resolver, span, E0401, "can't use type parameters from \
|
||||||
|
outer function; try using a local \
|
||||||
|
type parameter instead");
|
||||||
|
},
|
||||||
|
&ResolutionError::OuterTypeParameterContext(resolver, span) => {
|
||||||
|
resolve_err!(resolver, span, E0402,
|
||||||
|
"cannot use an outer type parameter in this context");
|
||||||
|
},
|
||||||
|
&ResolutionError::NameAlreadyUsedInTypeParameterList(resolver, span, name) => {
|
||||||
|
resolve_err!(resolver, span, E0403,
|
||||||
|
"the name `{}` is already used for a type \
|
||||||
|
parameter in this type parameter list", name);
|
||||||
|
},
|
||||||
|
&ResolutionError::IsNotATrait(resolver, span, name) => {
|
||||||
|
resolve_err!(resolver, span, E0404,
|
||||||
|
"`{}` is not a trait",
|
||||||
|
name);
|
||||||
|
},
|
||||||
|
&ResolutionError::UndeclaredTraitName(resolver, span, name) => {
|
||||||
|
resolve_err!(resolver, span, E0405,
|
||||||
|
"use of undeclared trait name `{}`",
|
||||||
|
name);
|
||||||
|
},
|
||||||
|
&ResolutionError::UndeclaredAssociatedType(resolver, span) => {
|
||||||
|
resolve_err!(resolver, span, E0406, "undeclared associated type");
|
||||||
|
},
|
||||||
|
&ResolutionError::MethodNotMemberOfTrait(resolver, span, method, trait_) => {
|
||||||
|
resolve_err!(resolver, span, E0407,
|
||||||
|
"method `{}` is not a member of trait `{}`",
|
||||||
|
method,
|
||||||
|
trait_);
|
||||||
|
},
|
||||||
|
&ResolutionError::VariableNotBoundInPattern(resolver, span, variable_name,
|
||||||
|
pattern_number) => {
|
||||||
|
resolve_err!(resolver, span, E0408,
|
||||||
|
"variable `{}` from pattern #1 is not bound in pattern #{}",
|
||||||
|
variable_name,
|
||||||
|
pattern_number);
|
||||||
|
},
|
||||||
|
&ResolutionError::VariableBoundWithDifferentMode(resolver, span, variable_name,
|
||||||
|
pattern_number) => {
|
||||||
|
resolve_err!(resolver, span, E0409,
|
||||||
|
"variable `{}` is bound with different \
|
||||||
|
mode in pattern #{} than in pattern #1",
|
||||||
|
variable_name,
|
||||||
|
pattern_number);
|
||||||
|
},
|
||||||
|
&ResolutionError::VariableNotBoundInParentPattern(resolver, span, variable_name,
|
||||||
|
pattern_number) => {
|
||||||
|
resolve_err!(resolver, span, E0410,
|
||||||
|
"variable `{}` from pattern #{} is not bound in pattern #1",
|
||||||
|
variable_name,
|
||||||
|
pattern_number);
|
||||||
|
},
|
||||||
|
&ResolutionError::SelfUsedOutsideImplOrTrait(resolver, span) => {
|
||||||
|
resolve_err!(resolver, span, E0411, "use of `Self` outside of an impl or trait");
|
||||||
|
},
|
||||||
|
&ResolutionError::UseOfUndeclared(resolver, span, kind, name) => {
|
||||||
|
resolve_err!(resolver, span, E0412,
|
||||||
|
"use of undeclared {} `{}`",
|
||||||
|
kind,
|
||||||
|
name);
|
||||||
|
},
|
||||||
|
&ResolutionError::DeclarationShadowsEnumVariantOrUnitLikeStruct(resolver, span, name) => {
|
||||||
|
resolve_err!(resolver, span, E0413,
|
||||||
|
"declaration of `{}` shadows an enum variant or unit-like struct in \
|
||||||
|
scope",
|
||||||
|
name);
|
||||||
|
},
|
||||||
|
&ResolutionError::OnlyIrrefutablePatternsAllowedHere(resolver, span) => {
|
||||||
|
resolve_err!(resolver, span, E0414, "only irrefutable patterns allowed here");
|
||||||
|
},
|
||||||
|
&ResolutionError::IdentifierBoundMoreThanOnceInParameterList(resolver, span,
|
||||||
|
identifier) => {
|
||||||
|
resolve_err!(resolver, span, E0415,
|
||||||
|
"identifier `{}` is bound more than once in this parameter list",
|
||||||
|
identifier);
|
||||||
|
},
|
||||||
|
&ResolutionError::IdentifierBoundMoreThanOnceInSamePattern(resolver, span, identifier) => {
|
||||||
|
resolve_err!(resolver, span, E0416,
|
||||||
|
"identifier `{}` is bound more than once in the same pattern",
|
||||||
|
identifier);
|
||||||
|
},
|
||||||
&ResolutionError::StaticVariableReference(resolver, span) => {
|
&ResolutionError::StaticVariableReference(resolver, span) => {
|
||||||
resolve_err!(resolver, span, E0417, "{}", formatted);
|
resolve_err!(resolver, span, E0417, "static variables cannot be \
|
||||||
|
referenced in a pattern, \
|
||||||
|
use a `const` instead");
|
||||||
},
|
},
|
||||||
&ResolutionError::DoesNotNameAStruct(resolver, span) => {
|
&ResolutionError::NotAnEnumVariantStructOrConst(resolver, span, name) => {
|
||||||
resolve_err!(resolver, span, E0422, "{}", formatted);
|
resolve_err!(resolver, span, E0418,
|
||||||
|
"`{}` is not an enum variant, struct or const",
|
||||||
|
name);
|
||||||
},
|
},
|
||||||
&ResolutionError::StructVariantUsedAsFunction(resolver, span) => {
|
&ResolutionError::UnresolvedEnumVariantStructOrConst(resolver, span, name) => {
|
||||||
resolve_err!(resolver, span, E0423, "{}", formatted);
|
resolve_err!(resolver, span, E0419,
|
||||||
|
"unresolved enum variant, struct or const `{}`",
|
||||||
|
name);
|
||||||
},
|
},
|
||||||
&ResolutionError::UnresolvedImport(resolver, span) => {
|
&ResolutionError::NotAnAssociatedConst(resolver, span, name) => {
|
||||||
resolve_err!(resolver, span, E0432, "{}", formatted);
|
resolve_err!(resolver, span, E0420,
|
||||||
|
"`{}` is not an associated const",
|
||||||
|
name);
|
||||||
},
|
},
|
||||||
&ResolutionError::FailedToResolve(resolver, span) => {
|
&ResolutionError::UnresolvedAssociatedConst(resolver, span, name) => {
|
||||||
resolve_err!(resolver, span, E0433, "{}", formatted);
|
resolve_err!(resolver, span, E0421,
|
||||||
|
"unresolved associated const `{}`",
|
||||||
|
name);
|
||||||
|
},
|
||||||
|
&ResolutionError::DoesNotNameAStruct(resolver, span, name) => {
|
||||||
|
resolve_err!(resolver, span, E0422, "`{}` does not name a structure", name);
|
||||||
|
},
|
||||||
|
&ResolutionError::StructVariantUsedAsFunction(resolver, span, path_name) => {
|
||||||
|
resolve_err!(resolver, span, E0423,
|
||||||
|
"`{}` is a struct variant name, but \
|
||||||
|
this expression \
|
||||||
|
uses it like a function name",
|
||||||
|
path_name);
|
||||||
|
},
|
||||||
|
&ResolutionError::SelfNotAvailableInStaticMethod(resolver, span) => {
|
||||||
|
resolve_err!(resolver, span, E0424, "`self` is not available in a static method. \
|
||||||
|
Maybe a `self` argument is missing?");
|
||||||
|
},
|
||||||
|
&ResolutionError::UnresolvedName(resolver, span, path, name) => {
|
||||||
|
resolve_err!(resolver, span, E0425,
|
||||||
|
"unresolved name `{}`{}",
|
||||||
|
path,
|
||||||
|
name);
|
||||||
|
},
|
||||||
|
&ResolutionError::UndeclaredLabel(resolver, span, name) => {
|
||||||
|
resolve_err!(resolver, span, E0426,
|
||||||
|
"use of undeclared label `{}`",
|
||||||
|
name);
|
||||||
|
},
|
||||||
|
&ResolutionError::CannotUseRefBindingModeWith(resolver, span, descr) => {
|
||||||
|
resolve_err!(resolver, span, E0427,
|
||||||
|
"cannot use `ref` binding mode with {}",
|
||||||
|
descr);
|
||||||
|
},
|
||||||
|
&ResolutionError::DuplicateDefinition(resolver, span, namespace, name) => {
|
||||||
|
resolve_err!(resolver, span, E0428,
|
||||||
|
"duplicate definition of {} `{}`",
|
||||||
|
namespace,
|
||||||
|
name);
|
||||||
|
},
|
||||||
|
&ResolutionError::SelfImportsOnlyAllowedWithin(resolver, span) => {
|
||||||
|
resolve_err!(resolver, span, E0429, "{}",
|
||||||
|
"`self` imports are only allowed within a { } list");
|
||||||
|
},
|
||||||
|
&ResolutionError::SelfImportCanOnlyAppearOnceInTheList(resolver, span) => {
|
||||||
|
resolve_err!(resolver, span, E0430,
|
||||||
|
"`self` import can only appear once in the list");
|
||||||
|
},
|
||||||
|
&ResolutionError::SelfImportOnlyInImportListWithNonEmptyPrefix(resolver, span) => {
|
||||||
|
resolve_err!(resolver, span, E0431,
|
||||||
|
"`self` import can only appear in an import list with a \
|
||||||
|
non-empty prefix");
|
||||||
|
}
|
||||||
|
&ResolutionError::UnresolvedImport(resolver, span, name) => {
|
||||||
|
let msg = match name {
|
||||||
|
Some((n, Some(p))) => format!("unresolved import `{}`{}", n, p),
|
||||||
|
Some((n, None)) => format!("unresolved import (maybe you meant `{}::*`?)", n),
|
||||||
|
None => "unresolved import".to_owned()
|
||||||
|
};
|
||||||
|
resolve_err!(resolver, span, E0432, "{}", msg);
|
||||||
|
},
|
||||||
|
&ResolutionError::FailedToResolve(resolver, span, msg) => {
|
||||||
|
resolve_err!(resolver, span, E0433, "failed to resolve. {}", msg);
|
||||||
|
},
|
||||||
|
&ResolutionError::CannotCaptureDynamicEnvironmentInFnItem(resolver, span) => {
|
||||||
|
resolve_err!(resolver, span, E0434, "{}",
|
||||||
|
"can't capture dynamic environment in a fn item; \
|
||||||
|
use the || { ... } closure form instead");
|
||||||
|
},
|
||||||
|
&ResolutionError::AttemptToUseNonConstantValueInConstant(resolver, span) =>{
|
||||||
|
resolve_err!(resolver, span, E0435,
|
||||||
|
"attempt to use a non-constant value in a constant");
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1343,10 +1575,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||||
PathSearch,
|
PathSearch,
|
||||||
true) {
|
true) {
|
||||||
Failed(Some((span, msg))) => {
|
Failed(Some((span, msg))) => {
|
||||||
resolve_error(&ResolutionError::FailedToResolve(self, span),
|
resolve_error(&ResolutionError::FailedToResolve(self, span, &*msg));
|
||||||
&*format!("failed to resolve. {}",
|
|
||||||
msg)
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
Failed(None) => (), // Continue up the search chain.
|
Failed(None) => (), // Continue up the search chain.
|
||||||
Indeterminate => {
|
Indeterminate => {
|
||||||
|
@ -1604,13 +1833,13 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||||
.span_to_snippet((*imports)[index].span)
|
.span_to_snippet((*imports)[index].span)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
if sn.contains("::") {
|
if sn.contains("::") {
|
||||||
resolve_error(&ResolutionError::UnresolvedImport(self, (*imports)[index].span),
|
resolve_error(&ResolutionError::UnresolvedImport(self,
|
||||||
"unresolved import");
|
(*imports)[index].span,
|
||||||
|
None));
|
||||||
} else {
|
} else {
|
||||||
resolve_error(&ResolutionError::UnresolvedImport(self, (*imports)[index].span),
|
resolve_error(&ResolutionError::UnresolvedImport(self,
|
||||||
&*format!("unresolved import (maybe you meant `{}::*`?)",
|
(*imports)[index].span,
|
||||||
sn)
|
Some((&*sn, None))));
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1736,16 +1965,20 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||||
// This was an attempt to access an upvar inside a
|
// This was an attempt to access an upvar inside a
|
||||||
// named function item. This is not allowed, so we
|
// named function item. This is not allowed, so we
|
||||||
// report an error.
|
// report an error.
|
||||||
resolve_err!(self, span, E0434, "{}",
|
resolve_error(
|
||||||
"can't capture dynamic environment in a fn item; \
|
&ResolutionError::CannotCaptureDynamicEnvironmentInFnItem(
|
||||||
use the || { ... } closure form instead");
|
self,
|
||||||
|
span)
|
||||||
|
);
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
ConstantItemRibKind => {
|
ConstantItemRibKind => {
|
||||||
// Still doesn't deal with upvars
|
// Still doesn't deal with upvars
|
||||||
resolve_err!(self, span, E0435, "{}",
|
resolve_error(
|
||||||
"attempt to use a non-constant \
|
&ResolutionError::AttemptToUseNonConstantValueInConstant(
|
||||||
value in a constant");
|
self,
|
||||||
|
span)
|
||||||
|
);
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1761,17 +1994,13 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||||
// This was an attempt to use a type parameter outside
|
// This was an attempt to use a type parameter outside
|
||||||
// its scope.
|
// its scope.
|
||||||
|
|
||||||
resolve_err!(self, span, E0401, "{}",
|
resolve_error(&ResolutionError::TypeParametersFromOuterFunction(self,
|
||||||
"can't use type parameters from \
|
span));
|
||||||
outer function; try using a local \
|
|
||||||
type parameter instead");
|
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
ConstantItemRibKind => {
|
ConstantItemRibKind => {
|
||||||
// see #9186
|
// see #9186
|
||||||
resolve_err!(self, span, E0402, "{}",
|
resolve_error(&ResolutionError::OuterTypeParameterContext(self, span));
|
||||||
"cannot use an outer type \
|
|
||||||
parameter in this context");
|
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1969,12 +2198,10 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||||
debug!("with_type_parameter_rib: {}", type_parameter.id);
|
debug!("with_type_parameter_rib: {}", type_parameter.id);
|
||||||
|
|
||||||
if seen_bindings.contains(&name) {
|
if seen_bindings.contains(&name) {
|
||||||
resolve_err!(self, type_parameter.span, E0403,
|
resolve_error(&ResolutionError::NameAlreadyUsedInTypeParameterList(
|
||||||
"the name `{}` is already \
|
self,
|
||||||
used for a type \
|
type_parameter.span,
|
||||||
parameter in this type \
|
name));
|
||||||
parameter list",
|
|
||||||
name)
|
|
||||||
}
|
}
|
||||||
seen_bindings.insert(name);
|
seen_bindings.insert(name);
|
||||||
|
|
||||||
|
@ -2061,9 +2288,10 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||||
debug!("(resolving trait) found trait def: {:?}", path_res);
|
debug!("(resolving trait) found trait def: {:?}", path_res);
|
||||||
Ok(path_res)
|
Ok(path_res)
|
||||||
} else {
|
} else {
|
||||||
resolve_err!(self, trait_path.span, E0404,
|
resolve_error(&ResolutionError::IsNotATrait(self, trait_path.span,
|
||||||
"`{}` is not a trait",
|
&*path_names_to_string(trait_path,
|
||||||
path_names_to_string(trait_path, path_depth));
|
path_depth))
|
||||||
|
);
|
||||||
|
|
||||||
// If it's a typedef, give a note
|
// If it's a typedef, give a note
|
||||||
if let DefTy(..) = path_res.base_def {
|
if let DefTy(..) = path_res.base_def {
|
||||||
|
@ -2073,9 +2301,10 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||||
Err(())
|
Err(())
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
resolve_err!(self, trait_path.span, E0405,
|
resolve_error(&ResolutionError::UndeclaredTraitName(self,
|
||||||
"use of undeclared trait name `{}`",
|
trait_path.span,
|
||||||
path_names_to_string(trait_path, path_depth));
|
&*path_names_to_string(trait_path,
|
||||||
|
path_depth)));
|
||||||
Err(())
|
Err(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2093,8 +2322,8 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||||
if let Some(PathResolution { base_def: DefTyParam(..), .. }) = path_res {
|
if let Some(PathResolution { base_def: DefTyParam(..), .. }) = path_res {
|
||||||
self.record_def(eq_pred.id, path_res.unwrap());
|
self.record_def(eq_pred.id, path_res.unwrap());
|
||||||
} else {
|
} else {
|
||||||
resolve_err!(self, eq_pred.span, E0406, "{}",
|
resolve_error(&ResolutionError::UndeclaredAssociatedType(self,
|
||||||
"undeclared associated type");
|
eq_pred.span));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2219,8 +2448,10 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||||
if let Some((did, ref trait_ref)) = self.current_trait_ref {
|
if let Some((did, ref trait_ref)) = self.current_trait_ref {
|
||||||
if !self.trait_item_map.contains_key(&(name, did)) {
|
if !self.trait_item_map.contains_key(&(name, did)) {
|
||||||
let path_str = path_names_to_string(&trait_ref.path, 0);
|
let path_str = path_names_to_string(&trait_ref.path, 0);
|
||||||
resolve_err!(self, span, E0407, "method `{}` is not a member of trait `{}`",
|
resolve_error(&ResolutionError::MethodNotMemberOfTrait(self,
|
||||||
name, path_str);
|
span,
|
||||||
|
name,
|
||||||
|
&*path_str));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2267,19 +2498,19 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||||
for (&key, &binding_0) in &map_0 {
|
for (&key, &binding_0) in &map_0 {
|
||||||
match map_i.get(&key) {
|
match map_i.get(&key) {
|
||||||
None => {
|
None => {
|
||||||
resolve_err!(self, p.span, E0408,
|
resolve_error(&ResolutionError::VariableNotBoundInPattern(self,
|
||||||
"variable `{}` from pattern #1 is \
|
p.span,
|
||||||
not bound in pattern #{}",
|
key,
|
||||||
key,
|
i + 1));
|
||||||
i + 1);
|
|
||||||
}
|
}
|
||||||
Some(binding_i) => {
|
Some(binding_i) => {
|
||||||
if binding_0.binding_mode != binding_i.binding_mode {
|
if binding_0.binding_mode != binding_i.binding_mode {
|
||||||
resolve_err!(self, binding_i.span, E0409,
|
resolve_error(&ResolutionError::VariableBoundWithDifferentMode(
|
||||||
"variable `{}` is bound with different \
|
self,
|
||||||
mode in pattern #{} than in pattern #1",
|
binding_i.span,
|
||||||
key,
|
key,
|
||||||
i + 1);
|
i + 1)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2287,11 +2518,10 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||||
|
|
||||||
for (&key, &binding) in &map_i {
|
for (&key, &binding) in &map_i {
|
||||||
if !map_0.contains_key(&key) {
|
if !map_0.contains_key(&key) {
|
||||||
resolve_err!(self, binding.span, E0410,
|
resolve_error(&ResolutionError::VariableNotBoundInParentPattern(self,
|
||||||
"variable `{}` from pattern #{} is \
|
binding.span,
|
||||||
not bound in pattern #1",
|
key,
|
||||||
key,
|
i + 1));
|
||||||
i + 1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2405,13 +2635,16 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||||
maybe_qself.is_none() &&
|
maybe_qself.is_none() &&
|
||||||
path.segments[0].identifier.name == self_type_name;
|
path.segments[0].identifier.name == self_type_name;
|
||||||
if is_invalid_self_type_name {
|
if is_invalid_self_type_name {
|
||||||
resolve_err!(self, ty.span, E0411,
|
resolve_error(&ResolutionError::SelfUsedOutsideImplOrTrait(self,
|
||||||
"use of `Self` outside of an impl or trait");
|
ty.span));
|
||||||
} else {
|
} else {
|
||||||
resolve_err!(self, ty.span, E0412,
|
resolve_error(&ResolutionError::UseOfUndeclared(
|
||||||
"use of undeclared {} `{}`",
|
self,
|
||||||
kind,
|
ty.span,
|
||||||
path_names_to_string(path, 0));
|
kind,
|
||||||
|
&*path_names_to_string(path,
|
||||||
|
0))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2463,11 +2696,12 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
FoundStructOrEnumVariant(..) => {
|
FoundStructOrEnumVariant(..) => {
|
||||||
resolve_err!(self, pattern.span, E0413,
|
resolve_error(
|
||||||
"declaration of `{}` shadows an enum \
|
&ResolutionError::DeclarationShadowsEnumVariantOrUnitLikeStruct(
|
||||||
variant or unit-like struct in \
|
self,
|
||||||
scope",
|
pattern.span,
|
||||||
renamed);
|
renamed)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
FoundConst(def, lp) if mode == RefutableMode => {
|
FoundConst(def, lp) if mode == RefutableMode => {
|
||||||
debug!("(resolving pattern) resolving `{}` to \
|
debug!("(resolving pattern) resolving `{}` to \
|
||||||
|
@ -2485,10 +2719,11 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
FoundConst(..) => {
|
FoundConst(..) => {
|
||||||
resolve_err!(self, pattern.span, E0414,
|
resolve_error(
|
||||||
"{}",
|
&ResolutionError::OnlyIrrefutablePatternsAllowedHere(
|
||||||
"only irrefutable patterns \
|
self,
|
||||||
allowed here");
|
pattern.span)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
BareIdentifierPatternUnresolved => {
|
BareIdentifierPatternUnresolved => {
|
||||||
debug!("(resolving pattern) binding `{}`",
|
debug!("(resolving pattern) binding `{}`",
|
||||||
|
@ -2520,22 +2755,22 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||||
bindings_list.contains_key(&renamed) {
|
bindings_list.contains_key(&renamed) {
|
||||||
// Forbid duplicate bindings in the same
|
// Forbid duplicate bindings in the same
|
||||||
// parameter list.
|
// parameter list.
|
||||||
resolve_err!(self, pattern.span, E0415,
|
resolve_error(
|
||||||
"identifier `{}` \
|
&ResolutionError::IdentifierBoundMoreThanOnceInParameterList(
|
||||||
is bound more \
|
self,
|
||||||
than once in \
|
pattern.span,
|
||||||
this parameter \
|
&*token::get_ident(ident))
|
||||||
list",
|
);
|
||||||
token::get_ident(ident));
|
|
||||||
} else if bindings_list.get(&renamed) ==
|
} else if bindings_list.get(&renamed) ==
|
||||||
Some(&pat_id) {
|
Some(&pat_id) {
|
||||||
// Then this is a duplicate variable in the
|
// Then this is a duplicate variable in the
|
||||||
// same disjunction, which is an error.
|
// same disjunction, which is an error.
|
||||||
resolve_err!(self, pattern.span, E0416,
|
resolve_error(
|
||||||
"identifier `{}` is bound \
|
&ResolutionError::IdentifierBoundMoreThanOnceInSamePattern(
|
||||||
more than once in the same \
|
self,
|
||||||
pattern",
|
pattern.span,
|
||||||
token::get_ident(ident));
|
&*token::get_ident(ident))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
// Else, not bound in the same pattern: do
|
// Else, not bound in the same pattern: do
|
||||||
// nothing.
|
// nothing.
|
||||||
|
@ -2566,10 +2801,8 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||||
self.record_def(pattern.id, path_res);
|
self.record_def(pattern.id, path_res);
|
||||||
}
|
}
|
||||||
DefStatic(..) => {
|
DefStatic(..) => {
|
||||||
resolve_error(&ResolutionError::StaticVariableReference(&self, path.span),
|
resolve_error(&ResolutionError::StaticVariableReference(&self,
|
||||||
"static variables cannot be \
|
path.span));
|
||||||
referenced in a pattern, \
|
|
||||||
use a `const` instead");
|
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
// If anything ends up here entirely resolved,
|
// If anything ends up here entirely resolved,
|
||||||
|
@ -2577,10 +2810,14 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||||
// partially resolved, that's OK, because it may
|
// partially resolved, that's OK, because it may
|
||||||
// be a `T::CONST` that typeck will resolve.
|
// be a `T::CONST` that typeck will resolve.
|
||||||
if path_res.depth == 0 {
|
if path_res.depth == 0 {
|
||||||
resolve_err!(self, path.span, E0418,
|
resolve_error(
|
||||||
"`{}` is not an enum variant, struct or const",
|
&ResolutionError::NotAnEnumVariantStructOrConst(
|
||||||
token::get_ident(
|
self,
|
||||||
path.segments.last().unwrap().identifier));
|
path.span,
|
||||||
|
&*token::get_ident(
|
||||||
|
path.segments.last().unwrap().identifier)
|
||||||
|
)
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
let const_name = path.segments.last().unwrap()
|
let const_name = path.segments.last().unwrap()
|
||||||
.identifier.name;
|
.identifier.name;
|
||||||
|
@ -2591,9 +2828,12 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
resolve_err!(self, path.span, E0419,
|
resolve_error(
|
||||||
"unresolved enum variant, struct or const `{}`",
|
&ResolutionError::UnresolvedEnumVariantStructOrConst(
|
||||||
token::get_ident(path.segments.last().unwrap().identifier));
|
self,
|
||||||
|
path.span,
|
||||||
|
&*token::get_ident(path.segments.last().unwrap().identifier))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
visit::walk_path(self, path);
|
visit::walk_path(self, path);
|
||||||
}
|
}
|
||||||
|
@ -2625,16 +2865,24 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||||
self.record_def(pattern.id, path_res);
|
self.record_def(pattern.id, path_res);
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
resolve_err!(self, path.span, E0420,
|
resolve_error(
|
||||||
"`{}` is not an associated const",
|
&ResolutionError::NotAnAssociatedConst(
|
||||||
token::get_ident(
|
self,
|
||||||
path.segments.last().unwrap().identifier));
|
path.span,
|
||||||
|
&*token::get_ident(
|
||||||
|
path.segments.last().unwrap().identifier)
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
resolve_err!(self, path.span, E0421,
|
resolve_error(
|
||||||
"unresolved associated const `{}`",
|
&ResolutionError::UnresolvedAssociatedConst(
|
||||||
token::get_ident(path.segments.last().unwrap().identifier));
|
self,
|
||||||
|
path.span,
|
||||||
|
&*token::get_ident(path.segments.last().unwrap().identifier)
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
visit::walk_pat(self, pattern);
|
visit::walk_pat(self, pattern);
|
||||||
}
|
}
|
||||||
|
@ -2647,9 +2895,11 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||||
result => {
|
result => {
|
||||||
debug!("(resolving pattern) didn't find struct \
|
debug!("(resolving pattern) didn't find struct \
|
||||||
def: {:?}", result);
|
def: {:?}", result);
|
||||||
resolve_error(&ResolutionError::DoesNotNameAStruct(self, path.span),
|
resolve_error(&ResolutionError::DoesNotNameAStruct(
|
||||||
&*format!("`{}` does not name a structure",
|
self,
|
||||||
path_names_to_string(path, 0)));
|
path.span,
|
||||||
|
&*path_names_to_string(path, 0))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
visit::walk_path(self, path);
|
visit::walk_path(self, path);
|
||||||
|
@ -2695,10 +2945,8 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||||
return FoundConst(def, LastMod(AllPublic));
|
return FoundConst(def, LastMod(AllPublic));
|
||||||
}
|
}
|
||||||
DefStatic(..) => {
|
DefStatic(..) => {
|
||||||
resolve_error(&ResolutionError::StaticVariableReference(self, span),
|
resolve_error(&ResolutionError::StaticVariableReference(self,
|
||||||
"static variables cannot be \
|
span));
|
||||||
referenced in a pattern, \
|
|
||||||
use a `const` instead");
|
|
||||||
return BareIdentifierPatternUnresolved;
|
return BareIdentifierPatternUnresolved;
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
|
@ -2715,10 +2963,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||||
Failed(err) => {
|
Failed(err) => {
|
||||||
match err {
|
match err {
|
||||||
Some((span, msg)) => {
|
Some((span, msg)) => {
|
||||||
resolve_error(&ResolutionError::FailedToResolve(self, span),
|
resolve_error(&ResolutionError::FailedToResolve(self, span, &*msg));
|
||||||
&*format!("failed to resolve. {}",
|
|
||||||
msg)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
None => ()
|
None => ()
|
||||||
}
|
}
|
||||||
|
@ -2947,10 +3192,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
resolve_error(&ResolutionError::FailedToResolve(self, span),
|
resolve_error(&ResolutionError::FailedToResolve(self, span, &*msg));
|
||||||
&*format!("failed to resolve. {}",
|
|
||||||
msg)
|
|
||||||
);
|
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
Indeterminate => panic!("indeterminate unexpected"),
|
Indeterminate => panic!("indeterminate unexpected"),
|
||||||
|
@ -3009,10 +3251,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
resolve_error(&ResolutionError::FailedToResolve(self, span),
|
resolve_error(&ResolutionError::FailedToResolve(self, span, &*msg));
|
||||||
&*format!("failed to resolve. {}",
|
|
||||||
msg)
|
|
||||||
);
|
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3108,10 +3347,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||||
failed to resolve {}", name);
|
failed to resolve {}", name);
|
||||||
|
|
||||||
if let Some((span, msg)) = err {
|
if let Some((span, msg)) = err {
|
||||||
resolve_error(&ResolutionError::FailedToResolve(self, span),
|
resolve_error(&ResolutionError::FailedToResolve(self, span, &*msg))
|
||||||
&*format!("failed to resolve. {}",
|
|
||||||
msg)
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return None;
|
return None;
|
||||||
|
@ -3314,11 +3550,9 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||||
if let DefVariant(_, _, true) = path_res.base_def {
|
if let DefVariant(_, _, true) = path_res.base_def {
|
||||||
let path_name = path_names_to_string(path, 0);
|
let path_name = path_names_to_string(path, 0);
|
||||||
|
|
||||||
resolve_error(&ResolutionError::StructVariantUsedAsFunction(self, expr.span),
|
resolve_error(&ResolutionError::StructVariantUsedAsFunction(self,
|
||||||
&*format!("`{}` is a struct variant name, but \
|
expr.span,
|
||||||
this expression \
|
&*path_name));
|
||||||
uses it like a function name",
|
|
||||||
path_name));
|
|
||||||
|
|
||||||
let msg = format!("did you mean to write: \
|
let msg = format!("did you mean to write: \
|
||||||
`{} {{ /* fields */ }}`?",
|
`{} {{ /* fields */ }}`?",
|
||||||
|
@ -3355,11 +3589,9 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||||
match type_res.map(|r| r.base_def) {
|
match type_res.map(|r| r.base_def) {
|
||||||
Some(DefTy(struct_id, _))
|
Some(DefTy(struct_id, _))
|
||||||
if self.structs.contains_key(&struct_id) => {
|
if self.structs.contains_key(&struct_id) => {
|
||||||
resolve_error(&ResolutionError::StructVariantUsedAsFunction(self, expr.span),
|
resolve_error(&ResolutionError::StructVariantUsedAsFunction(self,
|
||||||
&*format!("`{}` is a struct variant name, but \
|
expr.span,
|
||||||
this expression \
|
&*path_name));
|
||||||
uses it like a function name",
|
|
||||||
path_name));
|
|
||||||
|
|
||||||
let msg = format!("did you mean to write: \
|
let msg = format!("did you mean to write: \
|
||||||
`{} {{ /* fields */ }}`?",
|
`{} {{ /* fields */ }}`?",
|
||||||
|
@ -3386,11 +3618,11 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||||
|
|
||||||
if method_scope &&
|
if method_scope &&
|
||||||
&token::get_name(special_names::self_)[..] == path_name {
|
&token::get_name(special_names::self_)[..] == path_name {
|
||||||
resolve_err!(self, expr.span, E0424,
|
resolve_error(
|
||||||
"{}",
|
&ResolutionError::SelfNotAvailableInStaticMethod(
|
||||||
"`self` is not available \
|
self,
|
||||||
in a static method. Maybe a \
|
expr.span)
|
||||||
`self` argument is missing?");
|
);
|
||||||
} else {
|
} else {
|
||||||
let last_name = path.segments.last().unwrap().identifier.name;
|
let last_name = path.segments.last().unwrap().identifier.name;
|
||||||
let mut msg = match self.find_fallback_in_self_type(last_name) {
|
let mut msg = match self.find_fallback_in_self_type(last_name) {
|
||||||
|
@ -3414,10 +3646,10 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||||
msg = format!(". Did you mean {}?", msg)
|
msg = format!(". Did you mean {}?", msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
resolve_err!(self, expr.span, E0425,
|
resolve_error(&ResolutionError::UnresolvedName(self,
|
||||||
"unresolved name `{}`{}",
|
expr.span,
|
||||||
path_name,
|
&*path_name,
|
||||||
msg);
|
&*msg));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3435,9 +3667,11 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||||
None => {
|
None => {
|
||||||
debug!("(resolving expression) didn't find struct def",);
|
debug!("(resolving expression) didn't find struct def",);
|
||||||
|
|
||||||
resolve_error(&ResolutionError::DoesNotNameAStruct(self, path.span),
|
resolve_error(&ResolutionError::DoesNotNameAStruct(
|
||||||
&*format!("`{}` does not name a structure",
|
self,
|
||||||
path_names_to_string(path, 0)));
|
path.span,
|
||||||
|
&*path_names_to_string(path, 0))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3462,9 +3696,9 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||||
let renamed = mtwt::resolve(label);
|
let renamed = mtwt::resolve(label);
|
||||||
match self.search_label(renamed) {
|
match self.search_label(renamed) {
|
||||||
None => {
|
None => {
|
||||||
resolve_err!(self, expr.span, E0426,
|
resolve_error(&ResolutionError::UndeclaredLabel(self,
|
||||||
"use of undeclared label `{}`",
|
expr.span,
|
||||||
token::get_ident(label))
|
&*token::get_ident(label)))
|
||||||
}
|
}
|
||||||
Some(DlDef(def @ DefLabel(_))) => {
|
Some(DlDef(def @ DefLabel(_))) => {
|
||||||
// Since this def is a label, it is never read.
|
// Since this def is a label, it is never read.
|
||||||
|
@ -3610,9 +3844,9 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||||
match pat_binding_mode {
|
match pat_binding_mode {
|
||||||
BindByValue(_) => {}
|
BindByValue(_) => {}
|
||||||
BindByRef(..) => {
|
BindByRef(..) => {
|
||||||
resolve_err!(self, pat.span, E0427,
|
resolve_error(&ResolutionError::CannotUseRefBindingModeWith(self,
|
||||||
"cannot use `ref` binding mode with {}",
|
pat.span,
|
||||||
descr);
|
descr));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -272,12 +272,11 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
|
||||||
Some((span, msg)) => (span, format!(". {}", msg)),
|
Some((span, msg)) => (span, format!(". {}", msg)),
|
||||||
None => (import_directive.span, String::new())
|
None => (import_directive.span, String::new())
|
||||||
};
|
};
|
||||||
::resolve_error(&::ResolutionError::UnresolvedImport(self.resolver, span),
|
::resolve_error(&::ResolutionError::UnresolvedImport(self.resolver, span,
|
||||||
&*format!("unresolved import `{}`{}",
|
Some((&*import_path_to_string(
|
||||||
import_path_to_string(
|
&import_directive.module_path,
|
||||||
&import_directive.module_path,
|
import_directive.subclass),
|
||||||
import_directive.subclass),
|
Some(&*help))))
|
||||||
help)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
ResolveResult::Indeterminate => break, // Bail out. We'll come around next time.
|
ResolveResult::Indeterminate => break, // Bail out. We'll come around next time.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue