diff options
| author | Joshua Nelson <jyn514@gmail.com> | 2021-05-18 21:46:41 -0400 |
|---|---|---|
| committer | Joshua Nelson <jyn514@gmail.com> | 2021-06-04 08:05:54 -0400 |
| commit | 15fec1fb80b5264d7e2d3382478424abb9afb3d1 (patch) | |
| tree | 791ffbf60606253828e89a8176ef8d0ef0ad35bd /compiler/rustc_passes/src | |
| parent | c4c2ab57a43737867982fafc8cfacd9b069fee96 (diff) | |
| download | rust-15fec1fb80b5264d7e2d3382478424abb9afb3d1.tar.gz rust-15fec1fb80b5264d7e2d3382478424abb9afb3d1.zip | |
Remove `doc(include)`
Diffstat (limited to 'compiler/rustc_passes/src')
| -rw-r--r-- | compiler/rustc_passes/src/check_attr.rs | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs index bf574bbfbb5..91b64611511 100644 --- a/compiler/rustc_passes/src/check_attr.rs +++ b/compiler/rustc_passes/src/check_attr.rs @@ -705,7 +705,7 @@ impl CheckAttrVisitor<'tcx> { let mut is_valid = true; if let Some(list) = attr.meta().and_then(|mi| mi.meta_item_list().map(|l| l.to_vec())) { - for meta in list { + for meta in &list { if let Some(i_meta) = meta.meta_item() { match i_meta.name_or_empty() { sym::alias @@ -757,7 +757,6 @@ impl CheckAttrVisitor<'tcx> { | sym::html_no_source | sym::html_playground_url | sym::html_root_url - | sym::include | sym::inline | sym::issue_tracker_base_url | sym::keyword @@ -792,6 +791,30 @@ impl CheckAttrVisitor<'tcx> { ); diag.note("`doc(spotlight)` is now a no-op"); } + if i_meta.has_name(sym::include) { + if let Some(value) = i_meta.value_str() { + // if there are multiple attributes, the suggestion would suggest deleting all of them, which is incorrect + let applicability = if list.len() == 1 { + Applicability::MachineApplicable + } else { + Applicability::MaybeIncorrect + }; + let inner = if attr.style == AttrStyle::Inner { + "!" + } else { + "" + }; + diag.span_suggestion( + attr.meta().unwrap().span, + "use `doc = include_str!` instead", + format!( + "#{}[doc = include_str!(\"{}\")]", + inner, value + ), + applicability, + ); + } + } diag.emit(); }, ); |
