Rollup merge of #51391 - estebank:docspan, r=GuillaumeGomez

Use spans pointing at the inside of a rustdoc attribute

Follow up to #51111.

Point to the link in a rustdoc attribute where intralink resolution failed, instead of the full rustdoc attribute's span.

r? @GuillaumeGomez cc @kennytm
This commit is contained in:
Mark Rousskov 2018-06-08 17:21:02 -06:00 committed by GitHub
commit 32ed5acf98
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 177 additions and 43 deletions

View file

@ -10,10 +10,48 @@
// compile-pass
//! Test with [Foo::baz], [Bar::foo], ...
//!
//! and [Uniooon::X].
//! Test with [Foo::baz], [Bar::foo], ...
//! , [Uniooon::X] and [Qux::Z].
//!
//! , [Uniooon::X] and [Qux::Z].
/// [Qux:Y]
pub struct Foo {
pub bar: usize,
}
/// Foo
/// bar [BarA] bar
/// baz
pub fn a() {}
/**
* Foo
* bar [BarB] bar
* baz
*/
pub fn b() {}
/** Foo
bar [BarC] bar
baz
let bar_c_1 = 0;
let bar_c_2 = 0;
let g = [bar_c_1];
let h = g[bar_c_2];
*/
pub fn c() {}
#[doc = "Foo\nbar [BarD] bar\nbaz"]
pub fn d() {}
macro_rules! f {
($f:expr) => {
#[doc = $f]
pub fn f() {}
}
}
f!("Foo\nbar [BarF] bar\nbaz");

View file

@ -1,39 +1,105 @@
warning: [Foo::baz] cannot be resolved, ignoring it...
--> $DIR/intra-links-warning.rs:13:1
warning: `[Foo::baz]` cannot be resolved, ignoring it...
--> $DIR/intra-links-warning.rs:13:23
|
13 | / //! Test with [Foo::baz], [Bar::foo], ...
14 | | //!
15 | | //! and [Uniooon::X].
| |_____________________^
13 | //! Test with [Foo::baz], [Bar::foo], ...
| ^^^^^^^^ cannot be resolved, ignoring
warning: `[Bar::foo]` cannot be resolved, ignoring it...
--> $DIR/intra-links-warning.rs:13:35
|
13 | //! Test with [Foo::baz], [Bar::foo], ...
| ^^^^^^^^ cannot be resolved, ignoring
warning: `[Uniooon::X]` cannot be resolved, ignoring it...
--> $DIR/intra-links-warning.rs:14:13
|
14 | //! , [Uniooon::X] and [Qux::Z].
| ^^^^^^^^^^ cannot be resolved, ignoring
warning: `[Qux::Z]` cannot be resolved, ignoring it...
--> $DIR/intra-links-warning.rs:14:30
|
14 | //! , [Uniooon::X] and [Qux::Z].
| ^^^^^^ cannot be resolved, ignoring
warning: `[Uniooon::X]` cannot be resolved, ignoring it...
--> $DIR/intra-links-warning.rs:16:14
|
16 | //! , [Uniooon::X] and [Qux::Z].
| ^^^^^^^^^^ cannot be resolved, ignoring
warning: `[Qux::Z]` cannot be resolved, ignoring it...
--> $DIR/intra-links-warning.rs:16:31
|
16 | //! , [Uniooon::X] and [Qux::Z].
| ^^^^^^ cannot be resolved, ignoring
warning: `[Qux:Y]` cannot be resolved, ignoring it...
--> $DIR/intra-links-warning.rs:18:13
|
18 | /// [Qux:Y]
| ^^^^^ cannot be resolved, ignoring
warning: `[BarA]` cannot be resolved, ignoring it...
--> $DIR/intra-links-warning.rs:24:10
|
24 | /// bar [BarA] bar
| ^^^^ cannot be resolved, ignoring
warning: `[BarB]` cannot be resolved, ignoring it...
--> $DIR/intra-links-warning.rs:28:1
|
28 | / /**
29 | | * Foo
30 | | * bar [BarB] bar
31 | | * baz
32 | | */
| |___^
|
= note: the link appears in this line:
Test with [Foo::baz], [Bar::foo], ...
^^^^^^^^
bar [BarB] bar
^^^^
warning: [Bar::foo] cannot be resolved, ignoring it...
--> $DIR/intra-links-warning.rs:13:1
warning: `[BarC]` cannot be resolved, ignoring it...
--> $DIR/intra-links-warning.rs:35:1
|
13 | / //! Test with [Foo::baz], [Bar::foo], ...
14 | | //!
15 | | //! and [Uniooon::X].
| |_____________________^
35 | / /** Foo
36 | |
37 | | bar [BarC] bar
38 | | baz
... |
44 | |
45 | | */
| |__^
|
= note: the link appears in this line:
Test with [Foo::baz], [Bar::foo], ...
^^^^^^^^
bar [BarC] bar
^^^^
warning: [Uniooon::X] cannot be resolved, ignoring it...
--> $DIR/intra-links-warning.rs:13:1
warning: `[BarD]` cannot be resolved, ignoring it...
--> $DIR/intra-links-warning.rs:48:1
|
13 | / //! Test with [Foo::baz], [Bar::foo], ...
14 | | //!
15 | | //! and [Uniooon::X].
| |_____________________^
48 | #[doc = "Foo/nbar [BarD] bar/nbaz"]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: the link appears in this line:
and [Uniooon::X].
^^^^^^^^^^
bar [BarD] bar
^^^^
warning: `[BarF]` cannot be resolved, ignoring it...
--> $DIR/intra-links-warning.rs:53:9
|
53 | #[doc = $f]
| ^^^^^^^^^^^
...
57 | f!("Foo/nbar [BarF] bar/nbaz");
| ------------------------------- in this macro invocation
|
= note: the link appears in this line:
bar [BarF] bar
^^^^