Fix tests and improve error message if ::
isn't found
This commit is contained in:
parent
42bed03500
commit
f4e6ebd11a
@ -324,9 +324,10 @@ fn resolve<'path>(
|
||||
})
|
||||
// If there's no `::`, it's not an associated item.
|
||||
// So we can be sure that `rustc_resolve` was accurate when it said it wasn't resolved.
|
||||
.ok_or(ErrorKind::Resolve(ResolutionFailure::NotInScope(
|
||||
item_name.to_string().into(),
|
||||
)))?;
|
||||
.ok_or_else(|| {
|
||||
debug!("found no `::`, assumming {} was correctly not in scope", item_name);
|
||||
ErrorKind::Resolve(ResolutionFailure::NotInScope(item_name.to_string().into()))
|
||||
})?;
|
||||
|
||||
if let Some((path, prim)) = is_primitive(&path_root, ns) {
|
||||
let impls = primitive_impl(cx, &path).ok_or_else(|| {
|
||||
@ -361,6 +362,7 @@ fn resolve<'path>(
|
||||
|
||||
let (_, ty_res) = cx
|
||||
.enter_resolver(|resolver| {
|
||||
// only types can have associated items
|
||||
resolver.resolve_str_path_error(DUMMY_SP, &path_root, TypeNS, module_id)
|
||||
})
|
||||
.map_err(|_| {
|
||||
@ -1450,10 +1452,7 @@ fn resolution_failure(
|
||||
// FIXME: when are items neither a primitive nor a Def?
|
||||
if let Res::Def(_, def_id) = res {
|
||||
let name = cx.tcx.item_name(def_id);
|
||||
let note = format!(
|
||||
"`{}` has no field, variant, or associated item named `{}`",
|
||||
name, assoc_item
|
||||
);
|
||||
let note = format!("no `{}` in `{}`", assoc_item, name,);
|
||||
diag.note(¬e);
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ note: the lint level is defined here
|
||||
LL | #![deny(broken_intra_doc_links)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
= note: this link partially resolves to the type alias `TypeAlias`
|
||||
= note: `TypeAlias` has no field, variant, or associated item named `hoge`
|
||||
= note: no `hoge` in `TypeAlias`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
@ -1,9 +1,6 @@
|
||||
#![deny(broken_intra_doc_links)]
|
||||
//~^ NOTE lint level is defined
|
||||
|
||||
//! [std::io::oops]
|
||||
//! [std::io::oops::not::here]
|
||||
|
||||
// FIXME: this should say that it was skipped (maybe an allowed by default lint?)
|
||||
/// [<invalid syntax>]
|
||||
|
||||
@ -22,17 +19,17 @@
|
||||
/// [S::A]
|
||||
//~^ ERROR unresolved link
|
||||
//~| NOTE this link partially resolves
|
||||
//~| NOTE `S` has no field
|
||||
//~| NOTE no `A` in `S`
|
||||
|
||||
/// [S::fmt]
|
||||
//~^ ERROR unresolved link
|
||||
//~| NOTE this link partially resolves
|
||||
//~| NOTE `S` has no field
|
||||
//~| NOTE no `fmt` in `S`
|
||||
|
||||
/// [E::D]
|
||||
//~^ ERROR unresolved link
|
||||
//~| NOTE this link partially resolves
|
||||
//~| NOTE `E` has no field
|
||||
//~| NOTE no `D` in `E`
|
||||
|
||||
/// [u8::not_found]
|
||||
//~^ ERROR unresolved link
|
||||
@ -40,8 +37,8 @@
|
||||
|
||||
/// [S!]
|
||||
//~^ ERROR unresolved link
|
||||
//~| HELP to link to the unit struct, use its disambiguator
|
||||
//~| NOTE this link resolves to the unit struct `S`
|
||||
//~| HELP to link to the struct, use its disambiguator
|
||||
//~| NOTE this link resolves to the struct `S`
|
||||
pub fn f() {}
|
||||
#[derive(Debug)]
|
||||
pub struct S;
|
||||
@ -62,6 +59,9 @@ pub fn h() {}
|
||||
//~| NOTE not in the type namespace
|
||||
|
||||
/// [T::h!]
|
||||
//~^ ERROR unresolved link
|
||||
//~| NOTE no item named `T::h`
|
||||
//~| HELP to escape
|
||||
pub trait T {
|
||||
fn g() {}
|
||||
}
|
||||
|
@ -1,39 +1,19 @@
|
||||
error: unresolved link to `std::io::oops`
|
||||
--> $DIR/intra-link-errors.rs:4:6
|
||||
error: unresolved link to `path::to::nonexistent::module`
|
||||
--> $DIR/intra-link-errors.rs:8:6
|
||||
|
|
||||
LL | //! [std::io::oops]
|
||||
| ^^^^^^^^^^^^^
|
||||
LL | /// [path::to::nonexistent::module]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/intra-link-errors.rs:1:9
|
||||
|
|
||||
LL | #![deny(broken_intra_doc_links)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
= note: this link resolves to the crate `std`, which is not an enum
|
||||
= note: if this were an enum, it might have a variant which resolved
|
||||
= note: this link partially resolves to the module `io`
|
||||
= note: `io` has no field, variant, or associated item named `oops`
|
||||
|
||||
error: unresolved link to `std::io::oops::not::here`
|
||||
--> $DIR/intra-link-errors.rs:5:6
|
||||
|
|
||||
LL | //! [std::io::oops::not::here]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: no item named `std::io::oops::not` is in scope
|
||||
= help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
|
||||
|
||||
error: unresolved link to `path::to::nonexistent::module`
|
||||
--> $DIR/intra-link-errors.rs:11:6
|
||||
|
|
||||
LL | /// [path::to::nonexistent::module]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: no item named `path::to::nonexistent` is in scope
|
||||
= help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
|
||||
|
||||
error: unresolved link to `f::A`
|
||||
--> $DIR/intra-link-errors.rs:17:6
|
||||
--> $DIR/intra-link-errors.rs:14:6
|
||||
|
|
||||
LL | /// [f::A]
|
||||
| ^^^^
|
||||
@ -42,34 +22,34 @@ LL | /// [f::A]
|
||||
= help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
|
||||
|
||||
error: unresolved link to `S::A`
|
||||
--> $DIR/intra-link-errors.rs:22:6
|
||||
--> $DIR/intra-link-errors.rs:19:6
|
||||
|
|
||||
LL | /// [S::A]
|
||||
| ^^^^
|
||||
|
|
||||
= note: this link partially resolves to the struct `S`
|
||||
= note: `S` has no field, variant, or associated item named `A`
|
||||
= note: no `A` in `S`
|
||||
|
||||
error: unresolved link to `S::fmt`
|
||||
--> $DIR/intra-link-errors.rs:27:6
|
||||
--> $DIR/intra-link-errors.rs:24:6
|
||||
|
|
||||
LL | /// [S::fmt]
|
||||
| ^^^^^^
|
||||
|
|
||||
= note: this link partially resolves to the struct `S`
|
||||
= note: `S` has no field, variant, or associated item named `fmt`
|
||||
= note: no `fmt` in `S`
|
||||
|
||||
error: unresolved link to `E::D`
|
||||
--> $DIR/intra-link-errors.rs:32:6
|
||||
--> $DIR/intra-link-errors.rs:29:6
|
||||
|
|
||||
LL | /// [E::D]
|
||||
| ^^^^
|
||||
|
|
||||
= note: this link partially resolves to the enum `E`
|
||||
= note: `E` has no field, variant, or associated item named `D`
|
||||
= note: no `D` in `E`
|
||||
|
||||
error: unresolved link to `u8::not_found`
|
||||
--> $DIR/intra-link-errors.rs:37:6
|
||||
--> $DIR/intra-link-errors.rs:34:6
|
||||
|
|
||||
LL | /// [u8::not_found]
|
||||
| ^^^^^^^^^^^^^
|
||||
@ -77,7 +57,7 @@ LL | /// [u8::not_found]
|
||||
= note: the builtin type `u8` does not have an associated item named `not_found`
|
||||
|
||||
error: unresolved link to `S`
|
||||
--> $DIR/intra-link-errors.rs:41:6
|
||||
--> $DIR/intra-link-errors.rs:38:6
|
||||
|
|
||||
LL | /// [S!]
|
||||
| ^^ help: to link to the struct, use its disambiguator: `struct@S`
|
||||
@ -85,7 +65,7 @@ LL | /// [S!]
|
||||
= note: this link resolves to the struct `S`, which is not in the macro namespace
|
||||
|
||||
error: unresolved link to `T::g`
|
||||
--> $DIR/intra-link-errors.rs:59:6
|
||||
--> $DIR/intra-link-errors.rs:56:6
|
||||
|
|
||||
LL | /// [type@T::g]
|
||||
| ^^^^^^^^^ help: to link to the associated function, use its disambiguator: `T::g()`
|
||||
@ -93,7 +73,7 @@ LL | /// [type@T::g]
|
||||
= note: this link resolves to the associated function `g`, which is not in the type namespace
|
||||
|
||||
error: unresolved link to `T::h`
|
||||
--> $DIR/intra-link-errors.rs:64:6
|
||||
--> $DIR/intra-link-errors.rs:61:6
|
||||
|
|
||||
LL | /// [T::h!]
|
||||
| ^^^^^
|
||||
@ -102,12 +82,12 @@ LL | /// [T::h!]
|
||||
= help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
|
||||
|
||||
error: unresolved link to `S::h`
|
||||
--> $DIR/intra-link-errors.rs:51:6
|
||||
--> $DIR/intra-link-errors.rs:48:6
|
||||
|
|
||||
LL | /// [type@S::h]
|
||||
| ^^^^^^^^^ help: to link to the associated function, use its disambiguator: `S::h()`
|
||||
|
|
||||
= note: this link resolves to the associated function `h`, which is not in the type namespace
|
||||
|
||||
error: aborting due to 12 previous errors
|
||||
error: aborting due to 10 previous errors
|
||||
|
||||
|
@ -6,7 +6,7 @@ LL | //! Test with [Foo::baz], [Bar::foo], ...
|
||||
|
|
||||
= note: `#[warn(broken_intra_doc_links)]` on by default
|
||||
= note: this link partially resolves to the struct `Foo`
|
||||
= note: `Foo` has no field, variant, or associated item named `baz`
|
||||
= note: no `baz` in `Foo`
|
||||
|
||||
warning: unresolved link to `Bar::foo`
|
||||
--> $DIR/intra-links-warning.rs:3:35
|
||||
|
Loading…
Reference in New Issue
Block a user