Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions compiler/rustc_resolve/src/check_unused.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,13 @@ impl<'a, 'ra, 'tcx> AsMut<Resolver<'ra, 'tcx>> for UnusedImportCheckVisitor<'a,
}

impl<'a, 'ra, 'tcx> Visitor<'a> for UnusedImportCheckVisitor<'a, 'ra, 'tcx> {
// Don't walk into attributes because imports can appear
// inside (e.g #[doc = {use std::{io,fmt};}]). They have
Comment thread
bb1yd marked this conversation as resolved.
// a different owner, so they will cause an ICE if we visit
// them. Note that this doc attribute is not valid and will
// be rejected during AST lowering.
fn visit_attribute(&mut self, _: &'a rustc_ast::Attribute) {}

fn visit_item(&mut self, item: &'a ast::Item) {
self.item_span = item.span_with_attributes();
match &item.kind {
Expand Down
7 changes: 7 additions & 0 deletions tests/ui/attributes/use-tree-in-docs.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Don't ICE when use tree appears in docs. (#163355)
#![feature(generic_assert)]
#[doc = assert !(b)]
//~^ ERROR attribute value must be a literal
use std as x;

fn main(){}
8 changes: 8 additions & 0 deletions tests/ui/attributes/use-tree-in-docs.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
error: attribute value must be a literal
--> $DIR/use-tree-in-docs.rs:3:9
|
LL | #[doc = assert !(b)]
| ^^^^^^^^^^^

error: aborting due to 1 previous error

Loading