Auto merge of #38154 - petrochenkov:altname, r=jseyfried
More systematic error reporting in path resolution Path resolution for types, expressions and patterns used various heuristics to give more helpful messages on unresolved or incorrectly resolved paths. This PR combines these heuristics and applies them to all non-import paths. First a path is resolved in all namespaces, starting from its primary namespace (to give messages like "expected function, found macro, you probably forgot `!`"). If this resolution doesn't give a desired result we create a base error - either "path is not resolved" or "path is resolved, but the resolution is not acceptable in this context". Other helps and notes are applied to this base error using heuristics. Here's the list of heuristics for a path with a last segment `name` in order. First we issue special messages for unresolved `Self` and `self`. Second we try to find free items named `name` in other modules and suggest to import them. Then we try to find fields and associated items named `name` and suggest `self.name` or `Self::name`. After that we try several deterministic context dependent heuristics like "expected value, found struct, you probably forgot `{}`". If nothing of the above works we try to find candidates with other names using Levenshtein distance. --- Some alternatives/notes/unresolved questions: - ~~I had a strong desire to migrate all affected tests to `test/ui`, diagnostics comparison becomes much more meaningful, but I did this only for few tests so far.~~ (Done) - ~~Labels for "unresolved path" errors are mostly useless now, it may make sense to move some help/notes to these labels, help becomes closer to the error this way.~~ (Done) - ~~Currently only the first successful heuristic results in additional message shown to the user, it may make sense to print them all, they are rarely compatible, so the diagnostics bloat is unlikely.~~ (Done) - Now when https://github.com/rust-lang/rust/pull/38014 landed `resolve_path` can potentially be replaced with `smart_resolve_path` in couple more places - e.g. ~~visibilities~~ (done), ~~import prefixes~~ (done), HIR paths. --- Some additional fixes: - Associated suggestions and typo suggestions are filtered with a context specific predicate to avoid inapplicable suggestions. - `adjust_local_def` works properly in speculative resolution. - I also fixed a recently introduced ICE in partially resolved UFCS paths (see test `ufcs-partially-resolved.rs`). Minimal reproduction: ``` enum E {} fn main() { <u8 as E>::A; } ``` Fixes https://github.com/rust-lang/rust/issues/38409, fixes https://github.com/rust-lang/rust/issues/38504 (duplicates). - Some bugs in resolution of visibilities are fixed - `pub(Enum)`, `pub(Trait)`, `pub(non::local::path)`. - Fixes https://github.com/rust-lang/rust/issues/38012. --- r? @jseyfried for technical details + @jonathandturner for diagnostics changes How to read the patch: `smart_resolve_path(_fragment)/resolve_qpath_anywhere` are written anew and replace `resolve_trait_reference`/`resolve_type`/`resolve_pattern_path`/`resolve_struct_path`/`resolve_expr` for `ExprKind::Path`, everything else can be read as a diff.
This commit is contained in:
commit
65c043fdd2
164 changed files with 2288 additions and 1332 deletions
|
@ -298,8 +298,7 @@ pub trait CrateStore<'tcx> {
|
|||
|
||||
// trait/impl-item info
|
||||
fn trait_of_item(&self, def_id: DefId) -> Option<DefId>;
|
||||
fn associated_item<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)
|
||||
-> Option<ty::AssociatedItem>;
|
||||
fn associated_item(&self, def: DefId) -> Option<ty::AssociatedItem>;
|
||||
|
||||
// flags
|
||||
fn is_const_fn(&self, did: DefId) -> bool;
|
||||
|
@ -456,8 +455,7 @@ impl<'tcx> CrateStore<'tcx> for DummyCrateStore {
|
|||
|
||||
// trait/impl-item info
|
||||
fn trait_of_item(&self, def_id: DefId) -> Option<DefId> { bug!("trait_of_item") }
|
||||
fn associated_item<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)
|
||||
-> Option<ty::AssociatedItem> { bug!("associated_item") }
|
||||
fn associated_item(&self, def: DefId) -> Option<ty::AssociatedItem> { bug!("associated_item") }
|
||||
|
||||
// flags
|
||||
fn is_const_fn(&self, did: DefId) -> bool { bug!("is_const_fn") }
|
||||
|
|
|
@ -2071,7 +2071,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
|||
pub fn associated_item(self, def_id: DefId) -> AssociatedItem {
|
||||
self.associated_items.memoize(def_id, || {
|
||||
if !def_id.is_local() {
|
||||
return self.sess.cstore.associated_item(self.global_tcx(), def_id)
|
||||
return self.sess.cstore.associated_item(def_id)
|
||||
.expect("missing AssociatedItem in metadata");
|
||||
}
|
||||
|
||||
|
@ -2526,8 +2526,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
|||
/// ID of the impl that the method belongs to. Otherwise, return `None`.
|
||||
pub fn impl_of_method(self, def_id: DefId) -> Option<DefId> {
|
||||
if def_id.krate != LOCAL_CRATE {
|
||||
return self.sess.cstore.associated_item(self.global_tcx(), def_id)
|
||||
.and_then(|item| {
|
||||
return self.sess.cstore.associated_item(def_id).and_then(|item| {
|
||||
match item.container {
|
||||
TraitContainer(_) => None,
|
||||
ImplContainer(def_id) => Some(def_id),
|
||||
|
|
|
@ -188,8 +188,7 @@ impl<'tcx> CrateStore<'tcx> for cstore::CStore {
|
|||
self.get_crate_data(def_id.krate).get_trait_of_item(def_id.index)
|
||||
}
|
||||
|
||||
fn associated_item<'a>(&self, _tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)
|
||||
-> Option<ty::AssociatedItem>
|
||||
fn associated_item(&self, def: DefId) -> Option<ty::AssociatedItem>
|
||||
{
|
||||
self.dep_graph.read(DepNode::MetaData(def));
|
||||
self.get_crate_data(def.krate).get_associated_item(def.index)
|
||||
|
|
|
@ -417,28 +417,18 @@ impl<'a> Resolver<'a> {
|
|||
let ident = Ident::with_empty_ctxt(child.name);
|
||||
let def = child.def;
|
||||
let def_id = def.def_id();
|
||||
let vis = match def {
|
||||
Def::Macro(..) => ty::Visibility::Public,
|
||||
_ if parent.is_trait() => ty::Visibility::Public,
|
||||
_ => self.session.cstore.visibility(def_id),
|
||||
};
|
||||
let vis = self.session.cstore.visibility(def_id);
|
||||
|
||||
match def {
|
||||
Def::Mod(..) | Def::Enum(..) => {
|
||||
let module = self.new_module(parent, ModuleKind::Def(def, ident.name), def_id);
|
||||
self.define(parent, ident, TypeNS, (module, vis, DUMMY_SP, Mark::root()));
|
||||
}
|
||||
Def::Variant(..) => {
|
||||
Def::Variant(..) | Def::TyAlias(..) => {
|
||||
self.define(parent, ident, TypeNS, (def, vis, DUMMY_SP, Mark::root()));
|
||||
}
|
||||
Def::VariantCtor(..) => {
|
||||
self.define(parent, ident, ValueNS, (def, vis, DUMMY_SP, Mark::root()));
|
||||
}
|
||||
Def::Fn(..) |
|
||||
Def::Static(..) |
|
||||
Def::Const(..) |
|
||||
Def::AssociatedConst(..) |
|
||||
Def::Method(..) => {
|
||||
Def::Fn(..) | Def::Static(..) | Def::Const(..) |
|
||||
Def::VariantCtor(..) | Def::StructCtor(..) => {
|
||||
self.define(parent, ident, ValueNS, (def, vis, DUMMY_SP, Mark::root()));
|
||||
}
|
||||
Def::Trait(..) => {
|
||||
|
@ -446,29 +436,19 @@ impl<'a> Resolver<'a> {
|
|||
let module = self.new_module(parent, module_kind, parent.normal_ancestor_id);
|
||||
self.define(parent, ident, TypeNS, (module, vis, DUMMY_SP, Mark::root()));
|
||||
|
||||
// If this is a trait, add all the trait item names to the trait info.
|
||||
let trait_item_def_ids = self.session.cstore.associated_item_def_ids(def_id);
|
||||
for trait_item_def_id in trait_item_def_ids {
|
||||
let trait_item_name = self.session.cstore.def_key(trait_item_def_id)
|
||||
.disambiguated_data.data.get_opt_name()
|
||||
.expect("opt_item_name returned None for trait");
|
||||
self.trait_item_map.insert((trait_item_name, def_id), false);
|
||||
}
|
||||
}
|
||||
Def::TyAlias(..) | Def::AssociatedTy(..) => {
|
||||
self.define(parent, ident, TypeNS, (def, vis, DUMMY_SP, Mark::root()));
|
||||
}
|
||||
Def::Struct(..) => {
|
||||
self.define(parent, ident, TypeNS, (def, vis, DUMMY_SP, Mark::root()));
|
||||
for child in self.session.cstore.item_children(def_id) {
|
||||
let ns = if let Def::AssociatedTy(..) = child.def { TypeNS } else { ValueNS };
|
||||
let ident = Ident::with_empty_ctxt(child.name);
|
||||
self.define(module, ident, ns, (child.def, ty::Visibility::Public,
|
||||
DUMMY_SP, Mark::root()));
|
||||
|
||||
// Record field names for error reporting.
|
||||
let field_names = self.session.cstore.struct_field_names(def_id);
|
||||
self.insert_field_names(def_id, field_names);
|
||||
let has_self = self.session.cstore.associated_item(child.def.def_id())
|
||||
.map_or(false, |item| item.method_has_self_argument);
|
||||
self.trait_item_map.insert((def_id, child.name, ns), (child.def, has_self));
|
||||
}
|
||||
module.populated.set(true);
|
||||
}
|
||||
Def::StructCtor(..) => {
|
||||
self.define(parent, ident, ValueNS, (def, vis, DUMMY_SP, Mark::root()));
|
||||
}
|
||||
Def::Union(..) => {
|
||||
Def::Struct(..) | Def::Union(..) => {
|
||||
self.define(parent, ident, TypeNS, (def, vis, DUMMY_SP, Mark::root()));
|
||||
|
||||
// Record field names for error reporting.
|
||||
|
@ -478,15 +458,7 @@ impl<'a> Resolver<'a> {
|
|||
Def::Macro(..) => {
|
||||
self.define(parent, ident, MacroNS, (def, vis, DUMMY_SP, Mark::root()));
|
||||
}
|
||||
Def::Local(..) |
|
||||
Def::PrimTy(..) |
|
||||
Def::TyParam(..) |
|
||||
Def::Upvar(..) |
|
||||
Def::Label(..) |
|
||||
Def::SelfTy(..) |
|
||||
Def::Err => {
|
||||
bug!("unexpected definition: {:?}", def);
|
||||
}
|
||||
_ => bug!("unexpected definition: {:?}", def)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -751,18 +723,15 @@ impl<'a, 'b> Visitor<'a> for BuildReducedGraphVisitor<'a, 'b> {
|
|||
|
||||
// Add the item to the trait info.
|
||||
let item_def_id = self.resolver.definitions.local_def_id(item.id);
|
||||
let mut is_static_method = false;
|
||||
let (def, ns) = match item.node {
|
||||
TraitItemKind::Const(..) => (Def::AssociatedConst(item_def_id), ValueNS),
|
||||
TraitItemKind::Method(ref sig, _) => {
|
||||
is_static_method = !sig.decl.has_self();
|
||||
(Def::Method(item_def_id), ValueNS)
|
||||
}
|
||||
TraitItemKind::Type(..) => (Def::AssociatedTy(item_def_id), TypeNS),
|
||||
let (def, ns, has_self) = match item.node {
|
||||
TraitItemKind::Const(..) => (Def::AssociatedConst(item_def_id), ValueNS, false),
|
||||
TraitItemKind::Method(ref sig, _) =>
|
||||
(Def::Method(item_def_id), ValueNS, sig.decl.has_self()),
|
||||
TraitItemKind::Type(..) => (Def::AssociatedTy(item_def_id), TypeNS, false),
|
||||
TraitItemKind::Macro(_) => bug!(), // handled above
|
||||
};
|
||||
|
||||
self.resolver.trait_item_map.insert((item.ident.name, def_id), is_static_method);
|
||||
self.resolver.trait_item_map.insert((def_id, item.ident.name, ns), (def, has_self));
|
||||
|
||||
let vis = ty::Visibility::Public;
|
||||
self.resolver.define(parent, item.ident, ns, (def, vis, item.span, self.expansion));
|
||||
|
|
|
@ -860,6 +860,26 @@ match (A, B, C) {
|
|||
```
|
||||
"##,
|
||||
|
||||
E0422: r##"
|
||||
You are trying to use an identifier that is either undefined or not a struct.
|
||||
Erroneous code example:
|
||||
``` compile_fail,E0422
|
||||
fn main () {
|
||||
let x = Foo { x: 1, y: 2 };
|
||||
}
|
||||
```
|
||||
In this case, `Foo` is undefined, so it inherently isn't anything, and
|
||||
definitely not a struct.
|
||||
```compile_fail
|
||||
fn main () {
|
||||
let foo = 1;
|
||||
let x = foo { x: 1, y: 2 };
|
||||
}
|
||||
```
|
||||
In this case, `foo` is defined, but is not a struct, so Rust can't use it as
|
||||
one.
|
||||
"##,
|
||||
|
||||
E0423: r##"
|
||||
A `struct` variant name was used like a function name.
|
||||
|
||||
|
@ -1519,7 +1539,12 @@ register_diagnostics! {
|
|||
// E0419, merged into 531
|
||||
// E0420, merged into 532
|
||||
// E0421, merged into 531
|
||||
// E0422, merged into 531/532
|
||||
E0531, // unresolved pattern path kind `name`
|
||||
// E0427, merged into 530
|
||||
E0573,
|
||||
E0574,
|
||||
E0575,
|
||||
E0576,
|
||||
E0577,
|
||||
E0578,
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -717,7 +717,7 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> {
|
|||
}
|
||||
|
||||
// Record the destination of this import
|
||||
self.def_map.insert(directive.id, PathResolution::new(module.def().unwrap()));
|
||||
self.record_def(directive.id, PathResolution::new(module.def().unwrap()));
|
||||
}
|
||||
|
||||
// Miscellaneous post-processing, including recording reexports, reporting conflicts,
|
||||
|
|
|
@ -1519,14 +1519,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
|
|||
self.set_tainted_by_errors();
|
||||
return self.tcx().types.err;
|
||||
}
|
||||
_ => {
|
||||
struct_span_err!(tcx.sess, span, E0248,
|
||||
"found value `{}` used as a type",
|
||||
tcx.item_path_str(path.def.def_id()))
|
||||
.span_label(span, &format!("value used as a type"))
|
||||
.emit();
|
||||
return self.tcx().types.err;
|
||||
}
|
||||
_ => span_bug!(span, "unexpected definition: {:?}", path.def)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2861,25 +2861,6 @@ struct Bar<S, T> { x: Foo<S, T> }
|
|||
```
|
||||
"##,
|
||||
|
||||
E0248: r##"
|
||||
This error indicates an attempt to use a value where a type is expected. For
|
||||
example:
|
||||
|
||||
```compile_fail,E0248
|
||||
enum Foo {
|
||||
Bar(u32)
|
||||
}
|
||||
|
||||
fn do_something(x: Foo::Bar) { }
|
||||
```
|
||||
|
||||
In this example, we're attempting to take a type of `Foo::Bar` in the
|
||||
do_something function. This is not legal: `Foo::Bar` is a value of type `Foo`,
|
||||
not a distinct static type. Likewise, it's not legal to attempt to
|
||||
`impl Foo::Bar`: instead, you must `impl Foo` and then pattern match to specify
|
||||
behavior for specific enum variants.
|
||||
"##,
|
||||
|
||||
E0569: r##"
|
||||
If an impl has a generic parameter with the `#[may_dangle]` attribute, then
|
||||
that impl must be declared as an `unsafe impl. For example:
|
||||
|
@ -4247,6 +4228,7 @@ register_diagnostics! {
|
|||
E0245, // not a trait
|
||||
// E0246, // invalid recursive type
|
||||
// E0247,
|
||||
// E0248, // value used as a type, now reported earlier during resolution as E0412
|
||||
// E0249,
|
||||
// E0319, // trait impls for defaulted traits allowed just for structs/enums
|
||||
E0320, // recursive overflow during dropck
|
||||
|
|
|
@ -14,5 +14,5 @@
|
|||
extern crate macro_crate_test;
|
||||
|
||||
fn main() {
|
||||
macro_crate_test::foo(); //~ ERROR unresolved name
|
||||
macro_crate_test::foo(); //~ ERROR unresolved function `macro_crate_test::foo`
|
||||
}
|
||||
|
|
|
@ -39,6 +39,6 @@ fn main() {
|
|||
|
||||
assert_eq!(pprust::expr_to_string(&*quote_expr!(&cx, 23)), "23");
|
||||
|
||||
let expr = quote_expr!(&cx, 2 - $abcd + 7); //~ ERROR unresolved name `abcd`
|
||||
let expr = quote_expr!(&cx, 2 - $abcd + 7); //~ ERROR unresolved value `abcd`
|
||||
assert_eq!(pprust::expr_to_string(&*expr), "2 - $abcd + 7");
|
||||
}
|
||||
|
|
|
@ -14,8 +14,8 @@ trait SomeTrait {
|
|||
|
||||
fn main() {
|
||||
let trait_obj: &SomeTrait = SomeTrait;
|
||||
//~^ ERROR E0425
|
||||
//~| NOTE unresolved name
|
||||
//~^ ERROR expected value, found trait `SomeTrait`
|
||||
//~| NOTE not a value
|
||||
//~| ERROR E0038
|
||||
//~| method `foo` has no receiver
|
||||
//~| NOTE the trait `SomeTrait` cannot be made into an object
|
||||
|
|
|
@ -12,5 +12,4 @@ fn main () {
|
|||
struct Foo { a: bool };
|
||||
|
||||
let f = Foo(); //~ ERROR E0423
|
||||
//~^ struct called like a function
|
||||
}
|
||||
|
|
|
@ -14,10 +14,7 @@ impl Foo {
|
|||
fn bar(self) {}
|
||||
|
||||
fn foo() {
|
||||
self.bar();
|
||||
//~^ ERROR `self` is not available in a static method [E0424]
|
||||
//~| NOTE not available in static method
|
||||
//~| NOTE maybe a `self` argument is missing?
|
||||
self.bar(); //~ ERROR E0424
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
trait Foo {
|
||||
fn bar() {
|
||||
Self; //~ ERROR E0425
|
||||
elf; //~ ERROR E0425
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -11,10 +11,10 @@
|
|||
// Check that associated paths starting with `<<` are successfully parsed.
|
||||
|
||||
fn main() {
|
||||
let _: <<A>::B>::C; //~ ERROR type name `A` is undefined or not in scope
|
||||
let _ = <<A>::B>::C; //~ ERROR type name `A` is undefined or not in scope
|
||||
let <<A>::B>::C; //~ ERROR type name `A` is undefined or not in scope
|
||||
let 0 ... <<A>::B>::C; //~ ERROR type name `A` is undefined or not in scope
|
||||
let _: <<A>::B>::C; //~ ERROR unresolved type `A`
|
||||
let _ = <<A>::B>::C; //~ ERROR unresolved type `A`
|
||||
let <<A>::B>::C; //~ ERROR unresolved type `A`
|
||||
let 0 ... <<A>::B>::C; //~ ERROR unresolved type `A`
|
||||
//~^ ERROR only char and numeric types are allowed in range patterns
|
||||
<<A>::B>::C; //~ ERROR type name `A` is undefined or not in scope
|
||||
<<A>::B>::C; //~ ERROR unresolved type `A`
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ pub trait Foo {
|
|||
}
|
||||
|
||||
fn foo2<I: Foo>(x: I) {
|
||||
let _: A = x.boo(); //~ERROR undefined or not in scope
|
||||
let _: A = x.boo(); //~ ERROR unresolved type `A`
|
||||
}
|
||||
|
||||
pub fn main() {}
|
||||
|
|
|
@ -132,6 +132,10 @@ pub struct UnstableStruct {
|
|||
pub struct StableStruct {
|
||||
#[stable(feature = "test_feature", since = "1.0.0")] pub i: isize
|
||||
}
|
||||
#[unstable(feature = "test_feature", issue = "0")]
|
||||
pub enum UnstableEnum {}
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub enum StableEnum {}
|
||||
|
||||
#[stable(feature = "test_feature", since = "1.0.0")]
|
||||
#[rustc_deprecated(since = "1.0.0", reason = "text")]
|
||||
|
|
|
@ -8,8 +8,11 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// error-pattern: unresolved name `m1::arguments`
|
||||
|
||||
mod m1 {}
|
||||
|
||||
fn main(arguments: Vec<String>) { log(debug, m1::arguments); }
|
||||
fn main(arguments: Vec<String>) { //~ ERROR main function has wrong type
|
||||
log(debug, m1::arguments);
|
||||
//~^ ERROR unresolved function `log`
|
||||
//~| ERROR unresolved value `debug`
|
||||
//~| ERROR unresolved value `m1::arguments`
|
||||
}
|
||||
|
|
|
@ -8,12 +8,13 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// error-pattern: unresolved name `m1::arguments`
|
||||
|
||||
mod m1 {
|
||||
pub mod arguments {}
|
||||
}
|
||||
|
||||
fn main(arguments: Vec<String>) {
|
||||
fn main(arguments: Vec<String>) { //~ ERROR main function has wrong type
|
||||
log(debug, m1::arguments);
|
||||
//~^ ERROR unresolved function `log`
|
||||
//~| ERROR unresolved value `debug`
|
||||
//~| ERROR expected value, found module `m1::arguments`
|
||||
}
|
||||
|
|
|
@ -16,8 +16,8 @@ impl cat {
|
|||
fn sleep(&self) { loop{} }
|
||||
fn meow(&self) {
|
||||
println!("Meow");
|
||||
meows += 1; //~ ERROR unresolved name
|
||||
sleep(); //~ ERROR unresolved name
|
||||
meows += 1; //~ ERROR unresolved value `meows`
|
||||
sleep(); //~ ERROR unresolved function `sleep`
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ impl Foo for i8 {}
|
|||
impl Foo for i16 {}
|
||||
impl Foo for i32 {}
|
||||
impl Foo for i64 {}
|
||||
impl Foo for DoesNotExist {} //~ ERROR `DoesNotExist` is undefined
|
||||
impl Foo for DoesNotExist {} //~ ERROR unresolved type `DoesNotExist`
|
||||
impl Foo for u8 {}
|
||||
impl Foo for u16 {}
|
||||
impl Foo for u32 {}
|
||||
|
|
|
@ -20,7 +20,7 @@ fn closure<F, T>(x: F) -> Result<T, ()>
|
|||
}
|
||||
|
||||
fn foo() -> Result<(), ()> {
|
||||
try!(closure(|| bar(0 as *mut _))); //~ ERROR unresolved name `bar`
|
||||
try!(closure(|| bar(0 as *mut _))); //~ ERROR unresolved function `bar`
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
@ -8,5 +8,5 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// error-pattern: unresolved name `this_does_nothing_what_the`
|
||||
fn main() { println!("doing"); this_does_nothing_what_the; println!("boing"); }
|
||||
//~^ ERROR unresolved value `this_does_nothing_what_the`
|
||||
|
|
|
@ -22,13 +22,13 @@ enum E {
|
|||
}
|
||||
|
||||
fn main() {
|
||||
let e1 = Empty1; //~ ERROR `Empty1` is the name of a struct or struct variant
|
||||
let e1 = Empty1(); //~ ERROR `Empty1` is the name of a struct or struct variant
|
||||
let e3 = E::Empty3; //~ ERROR `E::Empty3` is the name of a struct or struct variant
|
||||
let e3 = E::Empty3(); //~ ERROR `E::Empty3` is the name of a struct or struct variant
|
||||
let e1 = Empty1; //~ ERROR expected value, found struct `Empty1`
|
||||
let e1 = Empty1(); //~ ERROR expected function, found struct `Empty1`
|
||||
let e3 = E::Empty3; //~ ERROR expected value, found struct variant `E::Empty3`
|
||||
let e3 = E::Empty3(); //~ ERROR expected function, found struct variant `E::Empty3`
|
||||
|
||||
let xe1 = XEmpty1; //~ ERROR `XEmpty1` is the name of a struct or struct variant
|
||||
let xe1 = XEmpty1(); //~ ERROR `XEmpty1` is the name of a struct or struct variant
|
||||
let xe1 = XEmpty1; //~ ERROR expected value, found struct `XEmpty1`
|
||||
let xe1 = XEmpty1(); //~ ERROR expected function, found struct `XEmpty1`
|
||||
let xe3 = XE::Empty3; //~ ERROR no associated item named `Empty3` found for type
|
||||
let xe3 = XE::Empty3(); //~ ERROR no associated item named `Empty3` found for type
|
||||
}
|
||||
|
|
|
@ -22,15 +22,15 @@ fn main() {
|
|||
let xe1 = XEmpty1 {};
|
||||
|
||||
match e1 {
|
||||
Empty1() => () //~ ERROR unresolved tuple struct/variant `Empty1`
|
||||
Empty1() => () //~ ERROR expected tuple struct/variant, found struct `Empty1`
|
||||
}
|
||||
match xe1 {
|
||||
XEmpty1() => () //~ ERROR unresolved tuple struct/variant `XEmpty1`
|
||||
XEmpty1() => () //~ ERROR expected tuple struct/variant, found struct `XEmpty1`
|
||||
}
|
||||
match e1 {
|
||||
Empty1(..) => () //~ ERROR unresolved tuple struct/variant `Empty1`
|
||||
Empty1(..) => () //~ ERROR expected tuple struct/variant, found struct `Empty1`
|
||||
}
|
||||
match xe1 {
|
||||
XEmpty1(..) => () //~ ERROR unresolved tuple struct/variant `XEmpty1`
|
||||
XEmpty1(..) => () //~ ERROR expected tuple struct/variant, found struct `XEmpty1`
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,6 @@ enum Foo {
|
|||
Bar
|
||||
}
|
||||
|
||||
fn foo(x: Foo::Bar) {} //~ERROR found value `Foo::Bar` used as a type
|
||||
fn foo(x: Foo::Bar) {} //~ ERROR expected type, found variant `Foo::Bar`
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -8,14 +8,12 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// error-pattern: failed to resolve. Use of undeclared type or module `foo`
|
||||
|
||||
// In this test baz isn't resolved when called as foo.baz even though
|
||||
// it's called from inside foo. This is somewhat surprising and may
|
||||
// want to change eventually.
|
||||
|
||||
mod foo {
|
||||
pub fn bar() { foo::baz(); }
|
||||
pub fn bar() { foo::baz(); } //~ ERROR failed to resolve. Use of undeclared type or module `foo`
|
||||
|
||||
fn baz() { }
|
||||
}
|
||||
|
|
|
@ -8,10 +8,13 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// error-pattern: unresolved name
|
||||
mod foo {
|
||||
pub fn x(y: isize) { log(debug, y); }
|
||||
//~^ ERROR unresolved function `log`
|
||||
//~| ERROR unresolved value `debug`
|
||||
fn z(y: isize) { log(debug, y); }
|
||||
//~^ ERROR unresolved function `log`
|
||||
//~| ERROR unresolved value `debug`
|
||||
}
|
||||
|
||||
fn main() { foo::z(10); }
|
||||
fn main() { foo::z(10); } //~ ERROR function `z` is private
|
||||
|
|
|
@ -8,10 +8,8 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// error-pattern: failed to resolve. Use of undeclared type or module `bar`
|
||||
|
||||
mod foo {
|
||||
pub fn x() { bar::x(); }
|
||||
pub fn x() { bar::x(); } //~ ERROR failed to resolve. Use of undeclared type or module `bar`
|
||||
}
|
||||
|
||||
mod bar {
|
||||
|
|
|
@ -24,7 +24,7 @@ extern "rust-intrinsic" {
|
|||
|
||||
// Unresolved bounds should still error.
|
||||
fn align_of<T: NoSuchTrait>() -> usize;
|
||||
//~^ ERROR trait `NoSuchTrait` is not in scope
|
||||
//~^ ERROR unresolved trait `NoSuchTrait`
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
fn main() {
|
||||
// Odd formatting to make sure we get the right span.
|
||||
for t in &
|
||||
foo //~ ERROR unresolved name `foo`
|
||||
foo //~ ERROR unresolved value `foo`
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,6 +13,6 @@
|
|||
|
||||
fn main() {
|
||||
for _ in 0..10 {
|
||||
iter.next(); //~ error: unresolved name `iter`
|
||||
iter.next(); //~ ERROR unresolved value `iter`
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,13 +29,13 @@ mod bar {
|
|||
fn foo<T>() {}
|
||||
|
||||
fn main() {
|
||||
fpriv(); //~ ERROR: unresolved
|
||||
epriv(); //~ ERROR: unresolved
|
||||
B; //~ ERROR: unresolved
|
||||
C; //~ ERROR: unresolved
|
||||
import(); //~ ERROR: unresolved
|
||||
fpriv(); //~ ERROR unresolved function `fpriv`
|
||||
epriv(); //~ ERROR unresolved function `epriv`
|
||||
B; //~ ERROR expected value, found enum `B`
|
||||
C; //~ ERROR unresolved value `C`
|
||||
import(); //~ ERROR: unresolved function `import`
|
||||
|
||||
foo::<A>(); //~ ERROR: not in scope
|
||||
foo::<C>(); //~ ERROR: not in scope
|
||||
foo::<D>(); //~ ERROR: not in scope
|
||||
foo::<A>(); //~ ERROR: unresolved type `A`
|
||||
foo::<C>(); //~ ERROR: unresolved type `C`
|
||||
foo::<D>(); //~ ERROR: unresolved type `D`
|
||||
}
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// error-pattern: unresolved name
|
||||
|
||||
use module_of_many_things::*;
|
||||
|
||||
mod module_of_many_things {
|
||||
|
@ -23,6 +21,6 @@ mod module_of_many_things {
|
|||
fn main() {
|
||||
f1();
|
||||
f2();
|
||||
f999(); // 'export' currently doesn't work?
|
||||
f999(); //~ ERROR unresolved function `f999`
|
||||
f4();
|
||||
}
|
||||
|
|
|
@ -1,137 +0,0 @@
|
|||
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
trait Foo {
|
||||
fn bar(&self);
|
||||
fn baz(&self) { }
|
||||
fn bah(_: Option<&Self>) { }
|
||||
}
|
||||
|
||||
struct BarTy {
|
||||
x : isize,
|
||||
y : f64,
|
||||
}
|
||||
|
||||
impl BarTy {
|
||||
fn a() {}
|
||||
fn b(&self) {}
|
||||
}
|
||||
|
||||
impl Foo for *const BarTy {
|
||||
fn bar(&self) {
|
||||
baz();
|
||||
//~^ ERROR: unresolved name `baz`
|
||||
//~| NOTE did you mean to call `self.baz`?
|
||||
a;
|
||||
//~^ ERROR: unresolved name `a`
|
||||
//~| NOTE unresolved name
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Foo for &'a BarTy {
|
||||
fn bar(&self) {
|
||||
baz();
|
||||
//~^ ERROR: unresolved name `baz`
|
||||
//~| NOTE did you mean to call `self.baz`?
|
||||
x;
|
||||
//~^ ERROR: unresolved name `x`
|
||||
//~| NOTE did you mean `self.x`?
|
||||
y;
|
||||
//~^ ERROR: unresolved name `y`
|
||||
//~| NOTE did you mean `self.y`?
|
||||
a;
|
||||
//~^ ERROR: unresolved name `a`
|
||||
//~| NOTE unresolved name
|
||||
bah;
|
||||
//~^ ERROR: unresolved name `bah`
|
||||
//~| NOTE did you mean to call `Foo::bah`?
|
||||
b;
|
||||
//~^ ERROR: unresolved name `b`
|
||||
//~| NOTE unresolved name
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Foo for &'a mut BarTy {
|
||||
fn bar(&self) {
|
||||
baz();
|
||||
//~^ ERROR: unresolved name `baz`
|
||||
//~| NOTE did you mean to call `self.baz`?
|
||||
x;
|
||||
//~^ ERROR: unresolved name `x`
|
||||
//~| NOTE did you mean `self.x`?
|
||||
y;
|
||||
//~^ ERROR: unresolved name `y`
|
||||
//~| NOTE did you mean `self.y`?
|
||||
a;
|
||||
//~^ ERROR: unresolved name `a`
|
||||
//~| NOTE unresolved name
|
||||
bah;
|
||||
//~^ ERROR: unresolved name `bah`
|
||||
//~| NOTE did you mean to call `Foo::bah`?
|
||||
b;
|
||||
//~^ ERROR: unresolved name `b`
|
||||
//~| NOTE unresolved name
|
||||
}
|
||||
}
|
||||
|
||||
impl Foo for Box<BarTy> {
|
||||
fn bar(&self) {
|
||||
baz();
|
||||
//~^ ERROR: unresolved name `baz`
|
||||
//~| NOTE did you mean to call `self.baz`?
|
||||
bah;
|
||||
//~^ ERROR: unresolved name `bah`
|
||||
//~| NOTE did you mean to call `Foo::bah`?
|
||||
}
|
||||
}
|
||||
|
||||
impl Foo for *const isize {
|
||||
fn bar(&self) {
|
||||
baz();
|
||||
//~^ ERROR: unresolved name `baz`
|
||||
//~| NOTE did you mean to call `self.baz`?
|
||||
bah;
|
||||
//~^ ERROR: unresolved name `bah`
|
||||
//~| NOTE did you mean to call `Foo::bah`?
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Foo for &'a isize {
|
||||
fn bar(&self) {
|
||||
baz();
|
||||
//~^ ERROR: unresolved name `baz`
|
||||
//~| NOTE did you mean to call `self.baz`?
|
||||
bah;
|
||||
//~^ ERROR: unresolved name `bah`
|
||||
//~| NOTE did you mean to call `Foo::bah`?
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Foo for &'a mut isize {
|
||||
fn bar(&self) {
|
||||
baz();
|
||||
//~^ ERROR: unresolved name `baz`
|
||||
//~| NOTE did you mean to call `self.baz`?
|
||||
bah;
|
||||
//~^ ERROR: unresolved name `bah`
|
||||
//~| NOTE did you mean to call `Foo::bah`?
|
||||
}
|
||||
}
|
||||
|
||||
impl Foo for Box<isize> {
|
||||
fn bar(&self) {
|
||||
baz();
|
||||
//~^ ERROR: unresolved name `baz`
|
||||
//~| NOTE did you mean to call `self.baz`?
|
||||
bah;
|
||||
//~^ ERROR: unresolved name `bah`
|
||||
//~| NOTE did you mean to call `Foo::bah`?
|
||||
}
|
||||
}
|
|
@ -9,5 +9,5 @@
|
|||
// except according to those terms.
|
||||
|
||||
fn main() {
|
||||
println!("{}", x); //~ ERROR unresolved name `x`
|
||||
println!("{}", x); //~ ERROR unresolved value `x`
|
||||
}
|
||||
|
|
|
@ -11,10 +11,10 @@
|
|||
// macro f should not be able to inject a reference to 'n'.
|
||||
|
||||
macro_rules! f { () => (n) }
|
||||
//~^ ERROR unresolved name `n`
|
||||
//~| ERROR unresolved name `n`
|
||||
//~| ERROR unresolved name `n`
|
||||
//~| ERROR unresolved name `n`
|
||||
//~^ ERROR unresolved value `n`
|
||||
//~| ERROR unresolved value `n`
|
||||
//~| ERROR unresolved value `n`
|
||||
//~| ERROR unresolved value `n`
|
||||
|
||||
fn main() -> (){
|
||||
for n in 0..1 {
|
||||
|
|
|
@ -20,7 +20,7 @@ mod foo {
|
|||
}
|
||||
|
||||
fn new() -> NoResult<MyEnum, String> {
|
||||
//~^ ERROR: found value `foo::MyEnum::NoResult` used as a type
|
||||
//~^ ERROR expected type, found variant `NoResult`
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
|
@ -30,18 +30,18 @@ mod bar {
|
|||
use foo;
|
||||
|
||||
fn new() -> Result<foo::MyEnum, String> {
|
||||
//~^ ERROR: found value `foo::MyEnum::Result` used as a type
|
||||
//~^ ERROR expected type, found variant `Result`
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
|
||||
fn new() -> Result<foo::MyEnum, String> {
|
||||
//~^ ERROR: found value `foo::MyEnum::Result` used as a type
|
||||
//~^ ERROR expected type, found variant `Result`
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn newer() -> NoResult<foo::MyEnum, String> {
|
||||
//~^ ERROR: found value `foo::MyEnum::NoResult` used as a type
|
||||
//~^ ERROR expected type, found variant `NoResult`
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,6 @@
|
|||
// except according to those terms.
|
||||
|
||||
impl Undefined {}
|
||||
//~^ ERROR type name `Undefined` is undefined or not in scope
|
||||
//~^ ERROR unresolved type `Undefined`
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -13,10 +13,10 @@ static Y: u8 = 1;
|
|||
fn foo() {}
|
||||
|
||||
impl X {}
|
||||
//~^ ERROR type name `X` is undefined or not in scope
|
||||
//~^ ERROR expected type, found constant `X`
|
||||
impl Y {}
|
||||
//~^ ERROR type name `Y` is undefined or not in scope
|
||||
//~^ ERROR expected type, found static `Y`
|
||||
impl foo {}
|
||||
//~^ ERROR type name `foo` is undefined or not in scope
|
||||
//~^ ERROR expected type, found function `foo`
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -17,7 +17,7 @@ trait From<Src> {
|
|||
trait To: Sized {
|
||||
fn to<Dst: From<Self>>(self) ->
|
||||
<Dst as From<Self>>::Dst
|
||||
//~^ ERROR associated type `From::Dst` is undefined or not in scope
|
||||
//~^ ERROR unresolved associated type `From::Dst`
|
||||
{
|
||||
From::from(self)
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
trait A {
|
||||
type Output;
|
||||
fn a(&self) -> <Self as A>::X;
|
||||
//~^ ERROR: associated type `A::X` is undefined or not in scope
|
||||
//~^ ERROR unresolved associated type `A::X`
|
||||
}
|
||||
|
||||
impl A for u32 {
|
||||
|
|
|
@ -14,5 +14,5 @@ trait Trait {
|
|||
|
||||
fn main() {
|
||||
<<i32 as Copy>::foobar as Trait>::foo();
|
||||
//~^ ERROR associated type `Copy::foobar` is undefined or not in scope
|
||||
//~^ ERROR unresolved associated type `Copy::foobar`
|
||||
}
|
||||
|
|
|
@ -8,6 +8,4 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// error-pattern: unresolved name `foobar`
|
||||
|
||||
fn main() { println!("{}", foobar); }
|
||||
fn main() { println!("{}", foobar); } //~ ERROR unresolved value `foobar`
|
||||
|
|
|
@ -15,7 +15,7 @@ trait channel<T> {
|
|||
}
|
||||
|
||||
// `chan` is not a trait, it's an enum
|
||||
impl chan for isize { //~ ERROR `chan` is not a trait
|
||||
impl chan for isize { //~ ERROR expected trait, found enum `chan`
|
||||
fn send(&self, v: isize) { panic!() }
|
||||
}
|
||||
|
||||
|
|
|
@ -1,109 +0,0 @@
|
|||
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
trait Groom {
|
||||
fn shave(other: usize);
|
||||
}
|
||||
|
||||
pub struct cat {
|
||||
whiskers: isize,
|
||||
}
|
||||
|
||||
pub enum MaybeDog {
|
||||
Dog,
|
||||
NoDog
|
||||
}
|
||||
|
||||
impl MaybeDog {
|
||||
fn bark() {
|
||||
// If this provides a suggestion, it's a bug as MaybeDog doesn't impl Groom
|
||||
shave();
|
||||
//~^ ERROR: unresolved name `shave`
|
||||
//~| NOTE unresolved name
|
||||
}
|
||||
}
|
||||
|
||||
impl Groom for cat {
|
||||
fn shave(other: usize) {
|
||||
whiskers -= other;
|
||||
//~^ ERROR: unresolved name `whiskers`
|
||||
//~| NOTE unresolved name
|
||||
//~| HELP this is an associated function
|
||||
shave(4);
|
||||
//~^ ERROR: unresolved name `shave`
|
||||
//~| NOTE did you mean to call `Groom::shave`?
|
||||
purr();
|
||||
//~^ ERROR: unresolved name `purr`
|
||||
//~| NOTE unresolved name
|
||||
}
|
||||
}
|
||||
|
||||
impl cat {
|
||||
fn static_method() {}
|
||||
|
||||
fn purr_louder() {
|
||||
static_method();
|
||||
//~^ ERROR: unresolved name `static_method`
|
||||
//~| NOTE unresolved name
|
||||
purr();
|
||||
//~^ ERROR: unresolved name `purr`
|
||||
//~| NOTE unresolved name
|
||||
purr();
|
||||
//~^ ERROR: unresolved name `purr`
|
||||
//~| NOTE unresolved name
|
||||
purr();
|
||||
//~^ ERROR: unresolved name `purr`
|
||||
//~| NOTE unresolved name
|
||||
}
|
||||
}
|
||||
|
||||
impl cat {
|
||||
fn meow() {
|
||||
if self.whiskers > 3 {
|
||||
//~^ ERROR `self` is not available in a static method [E0424]
|
||||
//~| NOTE not available in static method
|
||||
//~| NOTE maybe a `self` argument is missing?
|
||||
println!("MEOW");
|
||||
}
|
||||
}
|
||||
|
||||
fn purr(&self) {
|
||||
grow_older();
|
||||
//~^ ERROR: unresolved name `grow_older`
|
||||
//~| NOTE unresolved name
|
||||
shave();
|
||||
//~^ ERROR: unresolved name `shave`
|
||||
//~| NOTE unresolved name
|
||||
}
|
||||
|
||||
fn burn_whiskers(&mut self) {
|
||||
whiskers = 0;
|
||||
//~^ ERROR: unresolved name `whiskers`
|
||||
//~| NOTE did you mean `self.whiskers`?
|
||||
}
|
||||
|
||||
pub fn grow_older(other:usize) {
|
||||
whiskers = 4;
|
||||
//~^ ERROR: unresolved name `whiskers`
|
||||
//~| NOTE unresolved name
|
||||
//~| HELP this is an associated function
|
||||
purr_louder();
|
||||
//~^ ERROR: unresolved name `purr_louder`
|
||||
//~| NOTE unresolved name
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
self += 1;
|
||||
//~^ ERROR: unresolved name `self`
|
||||
//~| NOTE unresolved name
|
||||
//~| HELP: module `self`
|
||||
// it's a bug if this suggests a missing `self` as we're not in a method
|
||||
}
|
|
@ -10,8 +10,6 @@
|
|||
|
||||
// Prefix in imports with empty braces should be resolved and checked privacy, stability, etc.
|
||||
|
||||
use foo::{};
|
||||
//~^ ERROR failed to resolve. Maybe a missing `extern crate foo;`?
|
||||
//~| NOTE foo
|
||||
use foo::{}; //~ ERROR unresolved module or enum `foo`
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -14,8 +14,7 @@
|
|||
|
||||
extern crate lint_stability;
|
||||
|
||||
use lint_stability::UnstableStruct::{};
|
||||
//~^ ERROR use of unstable library feature 'test_feature'
|
||||
use lint_stability::StableStruct::{}; // OK
|
||||
use lint_stability::UnstableEnum::{}; //~ ERROR use of unstable library feature 'test_feature'
|
||||
use lint_stability::StableEnum::{}; // OK
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
extern crate issue_30535 as foo;
|
||||
|
||||
fn bar(
|
||||
_: foo::Foo::FooV //~ ERROR value `foo::Foo::FooV` used as a type
|
||||
_: foo::Foo::FooV //~ ERROR expected type, found variant `foo::Foo::FooV`
|
||||
) {}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
use std::fmt;
|
||||
|
||||
impl fmt::Display for DecoderError { //~ ERROR E0412
|
||||
impl fmt::Display for DecoderError { //~ ERROR unresolved type `DecoderError`
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "Missing data: {}", self.0)
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ fn f() {
|
|||
fn g() {}
|
||||
mod foo {
|
||||
fn h() {
|
||||
g(); //~ ERROR unresolved name
|
||||
g(); //~ ERROR unresolved function `g`
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,5 +11,5 @@
|
|||
fn main () {
|
||||
let sr: Vec<(u32, _, _) = vec![]; //~ ERROR expected one of `+`, `,`, or `>`, found `=`
|
||||
let sr2: Vec<(u32, _, _)> = sr.iter().map(|(faction, th_sender, th_receiver)| {}).collect();
|
||||
//~^ ERROR unresolved name `sr`
|
||||
//~^ ERROR unresolved value `sr`
|
||||
}
|
||||
|
|
|
@ -9,11 +9,11 @@
|
|||
// except according to those terms.
|
||||
|
||||
struct Bar<T> {
|
||||
inner: Foo<T> //~ ERROR type name `Foo` is undefined or not in scope
|
||||
inner: Foo<T> //~ ERROR unresolved type `Foo`
|
||||
}
|
||||
|
||||
enum Baz<T> {
|
||||
Foo(Foo<T>) //~ ERROR type name `Foo` is undefined or not in scope
|
||||
Foo(Foo<T>) //~ ERROR unresolved type `Foo`
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -9,8 +9,8 @@
|
|||
// except according to those terms.
|
||||
|
||||
struct Foo<T: ?Hash> { }
|
||||
//~^ ERROR trait `Hash` is not in scope [E0405]
|
||||
//~^^ ERROR parameter `T` is never used [E0392]
|
||||
//~^ ERROR unresolved trait `Hash`
|
||||
//~^^ ERROR parameter `T` is never used
|
||||
//~^^^ WARN default bound relaxed for a type parameter, but this does nothing
|
||||
|
||||
fn main() { }
|
||||
|
|
|
@ -23,7 +23,7 @@ mod a {
|
|||
pub mod sub {
|
||||
use a::b::*;
|
||||
fn sub() -> bar { 1 }
|
||||
//~^ ERROR: type name `bar` is undefined or not in scope
|
||||
//~^ ERROR unresolved type `bar`
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -32,5 +32,5 @@ mod m1 {
|
|||
}
|
||||
|
||||
fn main() {
|
||||
foo(); //~ ERROR: unresolved name
|
||||
foo(); //~ ERROR expected function, found module `foo`
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ mod a {
|
|||
}
|
||||
pub mod sub {
|
||||
use a::b::*;
|
||||
fn sub() -> isize { foo(); 1 } //~ ERROR: unresolved name `foo`
|
||||
fn sub() -> isize { foo(); 1 } //~ ERROR unresolved function `foo`
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,6 @@
|
|||
// except according to those terms.
|
||||
|
||||
|
||||
trait B < A > { fn a() -> A { this.a } } //~ ERROR unresolved name
|
||||
trait B < A > { fn a() -> A { this.a } } //~ ERROR unresolved value `this`
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
fn main() {
|
||||
let z = match 3 {
|
||||
x(1) => x(1) //~ ERROR unresolved tuple struct/variant `x`
|
||||
//~^ ERROR unresolved name `x`
|
||||
//~^ ERROR unresolved function `x`
|
||||
};
|
||||
assert!(z == 3);
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ struct Foo {
|
|||
x: isize
|
||||
}
|
||||
|
||||
impl Fo { //~ ERROR type name `Fo` is undefined or not in scope
|
||||
impl Fo { //~ ERROR unresolved type `Fo`
|
||||
fn foo() {}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
impl B { //~ ERROR type name `B` is undefined or not in scope
|
||||
impl B { //~ ERROR unresolved type `B`
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
|
|
@ -9,5 +9,5 @@
|
|||
// except according to those terms.
|
||||
|
||||
fn main() {
|
||||
let super = "foo"; //~ ERROR unresolved unit struct/variant or constant `super`
|
||||
let super = "foo"; //~ ERROR failed to resolve. There are too many initial `super`s
|
||||
}
|
||||
|
|
|
@ -9,5 +9,5 @@
|
|||
// except according to those terms.
|
||||
|
||||
fn main() {
|
||||
let super: isize; //~ ERROR unresolved unit struct/variant or constant `super`
|
||||
let super: isize; //~ ERROR failed to resolve. There are too many initial `super`s
|
||||
}
|
||||
|
|
|
@ -25,6 +25,6 @@ test!(b,
|
|||
// test1!(#[bar])
|
||||
#[qux]
|
||||
fn main() {
|
||||
a::bar(); //~ ERROR unresolved name `a::bar`
|
||||
a::bar(); //~ ERROR unresolved function `a::bar`
|
||||
b::bar();
|
||||
}
|
||||
|
|
|
@ -18,6 +18,6 @@ macro_rules! foo {
|
|||
// not to the macro variable '$id'
|
||||
fn main() {
|
||||
foo!(
|
||||
x //~ ERROR unresolved name `x`
|
||||
x //~ ERROR unresolved value `x`
|
||||
);
|
||||
}
|
||||
|
|
|
@ -16,6 +16,6 @@ fn my_panic() -> ! { panic!(); }
|
|||
fn main() {
|
||||
match true { false => { my_panic(); } true => { } }
|
||||
|
||||
println!("{}", x); //~ ERROR unresolved name `x`
|
||||
println!("{}", x); //~ ERROR unresolved value `x`
|
||||
let x: isize;
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ fn main() {
|
|||
[0, 1, 2, 3, x..] => {} //~ ERROR pattern requires
|
||||
};
|
||||
|
||||
match does_not_exist { //~ ERROR unresolved name
|
||||
match does_not_exist { //~ ERROR unresolved value `does_not_exist`
|
||||
[] => {}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -13,5 +13,5 @@
|
|||
mod mod_file_aux;
|
||||
|
||||
fn main() {
|
||||
assert!(mod_file_aux::bar() == 10); //~ ERROR unresolved name
|
||||
assert!(mod_file_aux::bar() == 10); //~ ERROR unresolved function `mod_file_aux::bar`
|
||||
}
|
||||
|
|
|
@ -13,6 +13,6 @@ use std::option::*;
|
|||
fn main() {
|
||||
let None: isize = 42; //~ ERROR let bindings cannot shadow unit variants
|
||||
log(debug, None);
|
||||
//~^ ERROR unresolved name `debug`
|
||||
//~| ERROR unresolved name `log`
|
||||
//~^ ERROR unresolved function `log`
|
||||
//~| ERROR unresolved value `debug`
|
||||
}
|
||||
|
|
|
@ -41,13 +41,13 @@ mod m2 {
|
|||
|
||||
fn f12() {
|
||||
check(m1::S{}); //~ ERROR c::Item
|
||||
check(m1::S); //~ ERROR unresolved name
|
||||
check(m1::S); //~ ERROR expected value, found type alias `m1::S`
|
||||
check(m2::S{}); //~ ERROR c::S
|
||||
check(m2::S); //~ ERROR c::Item
|
||||
}
|
||||
fn xf12() {
|
||||
check(xm1::S{}); //~ ERROR c::Item
|
||||
check(xm1::S); //~ ERROR unresolved name
|
||||
check(xm1::S); //~ ERROR expected value, found type alias `xm1::S`
|
||||
check(xm2::S{}); //~ ERROR c::S
|
||||
check(xm2::S); //~ ERROR c::Item
|
||||
}
|
||||
|
@ -107,13 +107,13 @@ mod m8 {
|
|||
|
||||
fn f78() {
|
||||
check(m7::V{}); //~ ERROR c::Item
|
||||
check(m7::V); //~ ERROR name of a struct or struct variant
|
||||
check(m7::V); //~ ERROR expected value, found struct variant `m7::V`
|
||||
check(m8::V{}); //~ ERROR c::E
|
||||
check(m8::V); //~ ERROR c::Item
|
||||
}
|
||||
fn xf78() {
|
||||
check(xm7::V{}); //~ ERROR c::Item
|
||||
check(xm7::V); //~ ERROR name of a struct or struct variant
|
||||
check(xm7::V); //~ ERROR expected value, found struct variant `xm7::V`
|
||||
check(xm8::V{}); //~ ERROR c::E
|
||||
check(xm8::V); //~ ERROR c::Item
|
||||
}
|
||||
|
|
|
@ -18,8 +18,8 @@ mod m {
|
|||
pub fn main() {
|
||||
use namespaced_enums::Foo::*;
|
||||
|
||||
foo(); //~ ERROR unresolved name `foo`
|
||||
m::foo(); //~ ERROR unresolved name `m::foo`
|
||||
bar(); //~ ERROR unresolved name `bar`
|
||||
m::bar(); //~ ERROR unresolved name `m::bar`
|
||||
foo(); //~ ERROR unresolved function `foo`
|
||||
m::foo(); //~ ERROR unresolved function `m::foo`
|
||||
bar(); //~ ERROR unresolved function `bar`
|
||||
m::bar(); //~ ERROR unresolved function `m::bar`
|
||||
}
|
||||
|
|
|
@ -28,8 +28,8 @@ mod m {
|
|||
pub fn main() {
|
||||
use m2::Foo::*;
|
||||
|
||||
foo(); //~ ERROR unresolved name `foo`
|
||||
m::foo(); //~ ERROR unresolved name `m::foo`
|
||||
bar(); //~ ERROR unresolved name `bar`
|
||||
m::bar(); //~ ERROR unresolved name `m::bar`
|
||||
foo(); //~ ERROR unresolved function `foo`
|
||||
m::foo(); //~ ERROR unresolved function `m::foo`
|
||||
bar(); //~ ERROR unresolved function `bar`
|
||||
m::bar(); //~ ERROR unresolved function `m::bar`
|
||||
}
|
||||
|
|
|
@ -11,4 +11,4 @@
|
|||
#[cfg_attr(all(), cfg_attr(all(), cfg(foo)))]
|
||||
fn f() {}
|
||||
|
||||
fn main() { f() } //~ ERROR unresolved name `f`
|
||||
fn main() { f() } //~ ERROR unresolved function `f`
|
||||
|
|
|
@ -18,26 +18,26 @@
|
|||
mod foo {
|
||||
mod baz {
|
||||
struct Test;
|
||||
impl Add for Test {} //~ ERROR: not in scope
|
||||
impl Clone for Test {} //~ ERROR: not in scope
|
||||
impl Iterator for Test {} //~ ERROR: not in scope
|
||||
impl ToString for Test {} //~ ERROR: not in scope
|
||||
impl Writer for Test {} //~ ERROR: not in scope
|
||||
impl Add for Test {} //~ ERROR unresolved trait `Add`
|
||||
impl Clone for Test {} //~ ERROR unresolved trait `Clone`
|
||||
impl Iterator for Test {} //~ ERROR unresolved trait `Iterator`
|
||||
impl ToString for Test {} //~ ERROR unresolved trait `ToString`
|
||||
impl Writer for Test {} //~ ERROR unresolved trait `Writer`
|
||||
|
||||
fn foo() {
|
||||
drop(2) //~ ERROR: unresolved name
|
||||
drop(2) //~ ERROR unresolved function `drop`
|
||||
}
|
||||
}
|
||||
|
||||
struct Test;
|
||||
impl Add for Test {} //~ ERROR: not in scope
|
||||
impl Clone for Test {} //~ ERROR: not in scope
|
||||
impl Iterator for Test {} //~ ERROR: not in scope
|
||||
impl ToString for Test {} //~ ERROR: not in scope
|
||||
impl Writer for Test {} //~ ERROR: not in scope
|
||||
impl Add for Test {} //~ ERROR unresolved trait `Add`
|
||||
impl Clone for Test {} //~ ERROR unresolved trait `Clone`
|
||||
impl Iterator for Test {} //~ ERROR unresolved trait `Iterator`
|
||||
impl ToString for Test {} //~ ERROR unresolved trait `ToString`
|
||||
impl Writer for Test {} //~ ERROR unresolved trait `Writer`
|
||||
|
||||
fn foo() {
|
||||
drop(2) //~ ERROR: unresolved name
|
||||
drop(2) //~ ERROR unresolved function `drop`
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -45,14 +45,14 @@ fn qux() {
|
|||
#[no_implicit_prelude]
|
||||
mod qux_inner {
|
||||
struct Test;
|
||||
impl Add for Test {} //~ ERROR: not in scope
|
||||
impl Clone for Test {} //~ ERROR: not in scope
|
||||
impl Iterator for Test {} //~ ERROR: not in scope
|
||||
impl ToString for Test {} //~ ERROR: not in scope
|
||||
impl Writer for Test {} //~ ERROR: not in scope
|
||||
impl Add for Test {} //~ ERROR unresolved trait `Add`
|
||||
impl Clone for Test {} //~ ERROR unresolved trait `Clone`
|
||||
impl Iterator for Test {} //~ ERROR unresolved trait `Iterator`
|
||||
impl ToString for Test {} //~ ERROR unresolved trait `ToString`
|
||||
impl Writer for Test {} //~ ERROR unresolved trait `Writer`
|
||||
|
||||
fn foo() {
|
||||
drop(2) //~ ERROR: unresolved name
|
||||
drop(2) //~ ERROR unresolved function `drop`
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,12 +17,12 @@
|
|||
// fail with the same error message).
|
||||
|
||||
struct Test;
|
||||
impl Add for Test {} //~ ERROR: not in scope
|
||||
impl Clone for Test {} //~ ERROR: not in scope
|
||||
impl Iterator for Test {} //~ ERROR: not in scope
|
||||
impl ToString for Test {} //~ ERROR: not in scope
|
||||
impl Writer for Test {} //~ ERROR: not in scope
|
||||
impl Add for Test {} //~ ERROR unresolved trait `Add`
|
||||
impl Clone for Test {} //~ ERROR unresolved trait `Clone`
|
||||
impl Iterator for Test {} //~ ERROR unresolved trait `Iterator`
|
||||
impl ToString for Test {} //~ ERROR unresolved trait `ToString`
|
||||
impl Writer for Test {} //~ ERROR unresolved trait `Writer`
|
||||
|
||||
fn main() {
|
||||
drop(2) //~ ERROR: unresolved name
|
||||
drop(2) //~ ERROR unresolved function `drop`
|
||||
}
|
||||
|
|
|
@ -15,5 +15,5 @@ extern crate empty_struct;
|
|||
//~^ WARN custom derive crates and `#[no_link]` crates have no effect without `#[macro_use]`
|
||||
|
||||
fn main() {
|
||||
empty_struct::XEmpty1; //~ ERROR unresolved name
|
||||
empty_struct::XEmpty1; //~ ERROR unresolved value `empty_struct::XEmpty1`
|
||||
}
|
||||
|
|
|
@ -14,11 +14,11 @@
|
|||
|
||||
trait Foo {
|
||||
fn bar() {
|
||||
let x = foo(); //~ ERROR unresolved name `foo`
|
||||
let x = foo(); //~ ERROR unresolved function `foo`
|
||||
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let x = y.; //~ ERROR unexpected token
|
||||
//~^ ERROR unresolved name `y`
|
||||
//~^ ERROR unresolved value `y`
|
||||
} //~ ERROR this file contains an un-closed delimiter
|
||||
|
|
|
@ -14,11 +14,11 @@
|
|||
|
||||
trait Foo {
|
||||
fn bar() {
|
||||
let x = foo(); //~ ERROR unresolved name `foo`
|
||||
let x = foo(); //~ ERROR unresolved function `foo`
|
||||
) //~ ERROR incorrect close delimiter: `)`
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let x = y.; //~ ERROR unexpected token
|
||||
//~^ ERROR unresolved name `y`
|
||||
//~^ ERROR unresolved value `y`
|
||||
}
|
||||
|
|
|
@ -12,5 +12,5 @@ macro_rules! foo { () => ( x ) }
|
|||
|
||||
fn main() {
|
||||
let foo!() = 2;
|
||||
x + 1; //~ ERROR unresolved name `x`
|
||||
x + 1; //~ ERROR unresolved value `x`
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ pub mod foo1 {
|
|||
fn test_glob1() {
|
||||
use foo1::*;
|
||||
|
||||
Bar(); //~ ERROR unresolved name `Bar`
|
||||
Bar(); //~ ERROR expected function, found trait `Bar`
|
||||
}
|
||||
|
||||
// private type, public value
|
||||
|
@ -42,7 +42,7 @@ pub mod foo2 {
|
|||
fn test_glob2() {
|
||||
use foo2::*;
|
||||
|
||||
let _x: Box<Bar>; //~ ERROR type name `Bar` is undefined or not in scope
|
||||
let _x: Box<Bar>; //~ ERROR expected type, found function `Bar`
|
||||
}
|
||||
|
||||
// neither public
|
||||
|
@ -57,8 +57,8 @@ pub mod foo3 {
|
|||
fn test_glob3() {
|
||||
use foo3::*;
|
||||
|
||||
Bar(); //~ ERROR unresolved name `Bar`
|
||||
let _x: Box<Bar>; //~ ERROR type name `Bar` is undefined or not in scope
|
||||
Bar(); //~ ERROR unresolved function `Bar`
|
||||
let _x: Box<Bar>; //~ ERROR unresolved type `Bar`
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
|
|
@ -27,13 +27,13 @@ pub mod foo1 {
|
|||
fn test_single1() {
|
||||
use foo1::Bar;
|
||||
|
||||
Bar(); //~ ERROR unresolved name `Bar`
|
||||
Bar(); //~ ERROR expected function, found trait `Bar`
|
||||
}
|
||||
|
||||
fn test_list1() {
|
||||
use foo1::{Bar,Baz};
|
||||
|
||||
Bar(); //~ ERROR unresolved name `Bar`
|
||||
Bar(); //~ ERROR expected function, found trait `Bar`
|
||||
}
|
||||
|
||||
// private type, public value
|
||||
|
@ -48,13 +48,13 @@ pub mod foo2 {
|
|||
fn test_single2() {
|
||||
use foo2::Bar;
|
||||
|
||||
let _x : Box<Bar>; //~ ERROR type name `Bar` is undefined
|
||||
let _x : Box<Bar>; //~ ERROR expected type, found function `Bar`
|
||||
}
|
||||
|
||||
fn test_list2() {
|
||||
use foo2::{Bar,Baz};
|
||||
|
||||
let _x: Box<Bar>; //~ ERROR type name `Bar` is undefined
|
||||
let _x: Box<Bar>; //~ ERROR expected type, found function `Bar`
|
||||
}
|
||||
|
||||
// neither public
|
||||
|
|
|
@ -57,6 +57,6 @@ fn main() {
|
|||
}
|
||||
|
||||
mod pathological {
|
||||
pub(bad::path) mod m1 {} //~ ERROR failed to resolve module path
|
||||
pub(bad::path) mod m1 {} //~ ERROR failed to resolve. Maybe a missing `extern crate bad;`?
|
||||
pub(foo) mod m2 {} //~ ERROR visibilities can only be restricted to ancestor modules
|
||||
}
|
||||
|
|
|
@ -16,11 +16,11 @@ macro_rules! m {
|
|||
|
||||
struct S<T>(T);
|
||||
m!{ S<u8> } //~ ERROR type or lifetime parameters in visibility path
|
||||
//~^ ERROR failed to resolve module path. Not a module `S`
|
||||
//~^ ERROR expected module, found struct `S`
|
||||
|
||||
mod foo {
|
||||
struct S(pub(foo<T>) ()); //~ ERROR type or lifetime parameters in visibility path
|
||||
//~^ ERROR type name `T` is undefined or not in scope
|
||||
//~^ ERROR unresolved type `T`
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -12,6 +12,6 @@
|
|||
|
||||
extern crate recursive_reexports;
|
||||
|
||||
fn f() -> recursive_reexports::S {} //~ ERROR type name `recursive_reexports::S` is undefined
|
||||
fn f() -> recursive_reexports::S {} //~ ERROR unresolved type `recursive_reexports::S`
|
||||
|
||||
fn main() {}
|
||||
|
|
24
src/test/compile-fail/resolve-bad-import-prefix.rs
Normal file
24
src/test/compile-fail/resolve-bad-import-prefix.rs
Normal file
|
@ -0,0 +1,24 @@
|
|||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
mod m {}
|
||||
enum E {}
|
||||
struct S;
|
||||
trait Tr {}
|
||||
|
||||
use {}; // OK
|
||||
use ::{}; // OK
|
||||
use m::{}; // OK
|
||||
use E::{}; // OK
|
||||
use S::{}; //~ ERROR expected module or enum, found struct `S`
|
||||
use Tr::{}; //~ ERROR expected module or enum, found trait `Tr`
|
||||
use Nonexistent::{}; //~ ERROR unresolved module or enum `Nonexistent`
|
||||
|
||||
fn main () {}
|
27
src/test/compile-fail/resolve-bad-visibility.rs
Normal file
27
src/test/compile-fail/resolve-bad-visibility.rs
Normal file
|
@ -0,0 +1,27 @@
|
|||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![feature(pub_restricted)]
|
||||
|
||||
enum E {}
|
||||
trait Tr {}
|
||||
|
||||
pub(E) struct S; //~ ERROR expected module, found enum `E`
|
||||
pub(Tr) struct Z; //~ ERROR expected module, found trait `Tr`
|
||||
pub(std::vec) struct F; //~ ERROR visibilities can only be restricted to ancestor modules
|
||||
pub(nonexistent) struct G; //~ ERROR unresolved module `nonexistent`
|
||||
pub(too_soon) struct H; //~ ERROR unresolved module `too_soon`
|
||||
|
||||
// Visibilities are resolved eagerly without waiting for modules becoming fully populated.
|
||||
// Visibilities can only use ancestor modules legally which are always available in time,
|
||||
// so the worst thing that can happen due to eager resolution is a suboptimal error message.
|
||||
mod too_soon {}
|
||||
|
||||
fn main () {}
|
|
@ -11,10 +11,10 @@
|
|||
fn main() {
|
||||
// Make sure primitive type fallback doesn't work in value namespace
|
||||
std::mem::size_of(u16);
|
||||
//~^ ERROR unresolved name `u16`
|
||||
//~^ ERROR expected value, found builtin type `u16`
|
||||
//~| ERROR this function takes 0 parameters but 1 parameter was supplied
|
||||
|
||||
// Make sure primitive type fallback doesn't work with global paths
|
||||
let _: ::u8;
|
||||
//~^ ERROR type name `::u8` is undefined or not in scope
|
||||
//~^ ERROR unresolved type `u8`
|
||||
}
|
||||
|
|
|
@ -10,10 +10,10 @@
|
|||
|
||||
|
||||
trait NewTrait : SomeNonExistentTrait {}
|
||||
//~^ ERROR trait `SomeNonExistentTrait` is not in scope
|
||||
//~^ ERROR unresolved trait `SomeNonExistentTrait`
|
||||
|
||||
impl SomeNonExistentTrait for isize {}
|
||||
//~^ ERROR trait `SomeNonExistentTrait` is not in scope
|
||||
//~^ ERROR unresolved trait `SomeNonExistentTrait`
|
||||
|
||||
fn f<T:SomeNonExistentTrait>() {}
|
||||
//~^ ERROR trait `SomeNonExistentTrait` is not in scope
|
||||
//~^ ERROR unresolved trait `SomeNonExistentTrait`
|
||||
|
|
|
@ -15,5 +15,5 @@
|
|||
#![crate_type="metadata"]
|
||||
|
||||
fn main() {
|
||||
let _ = Foo; //~ ERROR unresolved name `Foo`
|
||||
let _ = Foo; //~ ERROR unresolved value `Foo`
|
||||
}
|
||||
|
|
|
@ -19,6 +19,6 @@ fn main() {
|
|||
let x = 0;
|
||||
let foo = Foo {
|
||||
x,
|
||||
y //~ ERROR unresolved name `y`
|
||||
y //~ ERROR unresolved value `y`
|
||||
};
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ pub fn main() {
|
|||
// this now fails (correctly, I claim) because hygiene prevents
|
||||
// the assembled identifier from being a reference to the binding.
|
||||
assert!(concat_idents!(asd, f_f, dsa) == "<.<".to_string());
|
||||
//~^ ERROR: unresolved name `asdf_fdsa`
|
||||
//~^ ERROR unresolved value `asdf_fdsa`
|
||||
|
||||
assert_eq!(stringify!(use_mention_distinction), "use_mention_distinction");
|
||||
}
|
||||
|
|
|
@ -14,5 +14,5 @@
|
|||
fn foo() {}
|
||||
|
||||
fn main() {
|
||||
foo(); //~ ERROR unresolved name `foo`
|
||||
foo(); //~ ERROR unresolved function `foo`
|
||||
}
|
||||
|
|
66
src/test/compile-fail/ufcs-partially-resolved.rs
Normal file
66
src/test/compile-fail/ufcs-partially-resolved.rs
Normal file
|
@ -0,0 +1,66 @@
|
|||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![feature(associated_type_defaults)]
|
||||
|
||||
trait Tr {
|
||||
type Y = u16;
|
||||
fn Y() {}
|
||||
}
|
||||
impl Tr for u8 {}
|
||||
|
||||
trait Dr {
|
||||
type X = u16;
|
||||
fn Z() {}
|
||||
}
|
||||
impl Dr for u8 {}
|
||||
|
||||
enum E { Y }
|
||||
type A = u32;
|
||||
|
||||
fn main() {
|
||||
let _: <u8 as Tr>::N; //~ ERROR unresolved associated type `Tr::N`
|
||||
let _: <u8 as E>::N; //~ ERROR unresolved associated type `E::N`
|
||||
let _: <u8 as A>::N; //~ ERROR unresolved associated type `A::N`
|
||||
<u8 as Tr>::N; //~ ERROR unresolved method or associated constant `Tr::N`
|
||||
<u8 as E>::N; //~ ERROR unresolved method or associated constant `E::N`
|
||||
<u8 as A>::N; //~ ERROR unresolved method or associated constant `A::N`
|
||||
let _: <u8 as Tr>::Y; // OK
|
||||
let _: <u8 as E>::Y; //~ ERROR expected associated type, found variant `E::Y`
|
||||
<u8 as Tr>::Y; // OK
|
||||
<u8 as E>::Y; //~ ERROR expected method or associated constant, found unit variant `E::Y`
|
||||
|
||||
let _: <u8 as Tr>::N::NN; //~ ERROR unresolved associated type `Tr::N`
|
||||
let _: <u8 as E>::N::NN; //~ ERROR unresolved associated type `E::N`
|
||||
let _: <u8 as A>::N::NN; //~ ERROR unresolved associated type `A::N`
|
||||
<u8 as Tr>::N::NN; //~ ERROR unresolved associated type `Tr::N`
|
||||
<u8 as E>::N::NN; //~ ERROR unresolved associated type `E::N`
|
||||
<u8 as A>::N::NN; //~ ERROR unresolved associated type `A::N`
|
||||
let _: <u8 as Tr>::Y::NN; //~ ERROR ambiguous associated type
|
||||
let _: <u8 as E>::Y::NN; //~ ERROR expected associated type, found variant `E::Y`
|
||||
<u8 as Tr>::Y::NN; //~ ERROR no associated item named `NN` found for type `<u8 as Tr>::Y`
|
||||
<u8 as E>::Y::NN; //~ ERROR expected associated type, found variant `E::Y`
|
||||
|
||||
let _: <u8 as Tr::N>::NN; //~ ERROR unresolved associated type `Tr::N::NN`
|
||||
let _: <u8 as E::N>::NN; //~ ERROR unresolved associated type `E::N::NN`
|
||||
let _: <u8 as A::N>::NN; //~ ERROR unresolved associated type `A::N::NN`
|
||||
<u8 as Tr::N>::NN; //~ ERROR unresolved method or associated constant `Tr::N::NN`
|
||||
<u8 as E::N>::NN; //~ ERROR unresolved method or associated constant `E::N::NN`
|
||||
<u8 as A::N>::NN; //~ ERROR unresolved method or associated constant `A::N::NN`
|
||||
let _: <u8 as Tr::Y>::NN; //~ ERROR unresolved associated type `Tr::Y::NN`
|
||||
let _: <u8 as E::Y>::NN; //~ ERROR unresolved associated type `E::Y::NN`
|
||||
<u8 as Tr::Y>::NN; //~ ERROR unresolved method or associated constant `Tr::Y::NN`
|
||||
<u8 as E::Y>::NN; //~ ERROR unresolved method or associated constant `E::Y::NN`
|
||||
|
||||
let _: <u8 as Dr>::Z; //~ ERROR expected associated type, found method `Dr::Z`
|
||||
<u8 as Dr>::X; //~ ERROR expected method or associated constant, found associated type `Dr::X`
|
||||
let _: <u8 as Dr>::Z::N; //~ ERROR expected associated type, found method `Dr::Z`
|
||||
<u8 as Dr>::X::N; //~ ERROR no associated item named `N` found for type `<u8 as Dr>::X`
|
||||
}
|
|
@ -15,7 +15,7 @@
|
|||
enum Ty {
|
||||
A,
|
||||
B(Ty::A),
|
||||
//~^ ERROR: found value `Ty::A` used as a type
|
||||
//~^ ERROR expected type, found variant `Ty::A`
|
||||
}
|
||||
|
||||
|
||||
|
@ -25,6 +25,6 @@ enum E {
|
|||
}
|
||||
|
||||
impl E::A {}
|
||||
//~^ ERROR: found value `E::A` used as a type
|
||||
//~^ ERROR expected type, found variant `E::A`
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -17,6 +17,6 @@ extern crate xcrate_unit_struct;
|
|||
|
||||
fn main() {
|
||||
let _ = xcrate_unit_struct::StructWithFields;
|
||||
//~^ ERROR: `xcrate_unit_struct::StructWithFields` is the name of a struct or struct variant
|
||||
//~^ ERROR expected value, found struct `xcrate_unit_struct::StructWithFields`
|
||||
let _ = xcrate_unit_struct::Struct;
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
error[E0425]: unresolved name `bar`
|
||||
error[E0425]: unresolved value `bar`
|
||||
--> $DIR/tab.rs:14:2
|
||||
|
|
||||
14 | \tbar;
|
||||
| \t^^^ unresolved name
|
||||
| \t^^^ no resolution found
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
error[E0404]: `Bar` is not a trait
|
||||
error[E0404]: expected trait, found type alias `Bar`
|
||||
--> $DIR/two_files.rs:15:6
|
||||
|
|
||||
15 | impl Bar for Baz { }
|
||||
| ^^^ expected trait, found type alias
|
||||
|
|
||||
= note: type aliases cannot be used for traits
|
||||
| ^^^ type aliases cannot be used for traits
|
||||
|
||||
error: cannot continue compilation due to previous error
|
||||
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
error[E0425]: unresolved name `fake`
|
||||
error[E0425]: unresolved value `fake`
|
||||
--> $DIR/macro-backtrace-nested.rs:15:12
|
||||
|
|
||||
15 | () => (fake)
|
||||
| ^^^^ unresolved name
|
||||
| ^^^^ no resolution found
|
||||
...
|
||||
27 | 1 + call_nested_expr!();
|
||||
| ------------------- in this macro invocation
|
||||
|
||||
error[E0425]: unresolved name `fake`
|
||||
error[E0425]: unresolved value `fake`
|
||||
--> $DIR/macro-backtrace-nested.rs:15:12
|
||||
|
|
||||
15 | () => (fake)
|
||||
| ^^^^ unresolved name
|
||||
| ^^^^ no resolution found
|
||||
...
|
||||
28 | call_nested_expr_sum!();
|
||||
| ------------------------ in this macro invocation
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue