-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Rustdoc render public underscore_imports as Re-exports #80267
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
799e822
f502263
0c217a6
d261176
b3b74a9
8a4e7a7
1990713
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
Cannot use `doc(inline)` with wildcard imports | ||
|
||
Erroneous code example: | ||
|
||
```compile_fail,E0780 | ||
extern crate foo; | ||
|
||
jyn514 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
#[doc(inline)] // error: invalid doc argument | ||
pub use foo::Foo as _; | ||
``` | ||
|
||
When using a wildcard import the `doc` attribute currently only supports: | ||
|
||
* hidden | ||
|
||
To fix this error either change to one of the available arguments or remove the | ||
`doc` attribute. | ||
jyn514 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
Example: | ||
|
||
``` | ||
extern crate foo; | ||
|
||
jyn514 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
pub use foo::Foo as _; | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2157,12 +2157,26 @@ impl Clean<Vec<Item>> for doctree::Import<'_> { | |
return Vec::new(); | ||
} | ||
|
||
let inlined = self.attrs.lists(sym::doc).has_word(sym::inline); | ||
let pub_underscore = self.vis.node.is_pub() && self.name == kw::Underscore; | ||
|
||
if pub_underscore && inlined { | ||
rustc_errors::struct_span_err!( | ||
cx.tcx.sess, | ||
self.attrs.lists(sym::doc).next().unwrap().span(), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This might be wrong if there are multiple #[doc = "xxx"]
#[doc(inline)]
pub use foo::Foo as _; There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was working as is, maybe because of https://github.com/rust-lang/rust/blob/master/compiler/rustc_ast/src/ast.rs#L496. |
||
E0780, | ||
"inline with wildcard import" | ||
jyn514 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
) | ||
.span_label(self.span, "wildcard import") | ||
jyn514 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
.emit(); | ||
} | ||
|
||
// We consider inlining the documentation of `pub use` statements, but we | ||
// forcefully don't inline if this is not public or if the | ||
// #[doc(no_inline)] attribute is present. | ||
// Don't inline doc(hidden) imports so they can be stripped at a later stage. | ||
let mut denied = !self.vis.node.is_pub() | ||
|| (self.vis.node.is_pub() && self.name == kw::Underscore) | ||
|| pub_underscore | ||
|| self.attrs.iter().any(|a| { | ||
a.has_name(sym::doc) | ||
&& match a.meta_item_list() { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#![crate_name = "foo"] | ||
|
||
pub trait Foo {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// aux-build:issue-61592.rs | ||
|
||
extern crate foo; | ||
|
||
#[doc(inline)] //~ ERROR | ||
pub use foo::Foo as _; | ||
|
||
fn main() {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
error[E0780]: inline with wildcard import | ||
--> $DIR/issue-61592.rs:5:7 | ||
| | ||
LL | #[doc(inline)] | ||
| ^^^^^^ | ||
LL | pub use foo::Foo as _; | ||
| ---------------------- wildcard import | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0780`. |
Uh oh!
There was an error while loading. Please reload this page.