Provide more context on incorrect inner attribute
Suggest changing an inner attribute into an outer attribute if followed by an item.
This commit is contained in:
parent
fcce644119
commit
39ceab02a6
15 changed files with 382 additions and 67 deletions
|
@ -1,10 +1,10 @@
|
||||||
use super::{AttrWrapper, Capturing, Parser, PathStyle};
|
use super::{AttrWrapper, Capturing, ForceCollect, Parser, PathStyle};
|
||||||
use rustc_ast as ast;
|
use rustc_ast as ast;
|
||||||
use rustc_ast::attr;
|
use rustc_ast::attr;
|
||||||
use rustc_ast::token::{self, Nonterminal};
|
use rustc_ast::token::{self, Nonterminal};
|
||||||
use rustc_ast_pretty::pprust;
|
use rustc_ast_pretty::pprust;
|
||||||
use rustc_errors::{error_code, PResult};
|
use rustc_errors::{error_code, DiagnosticBuilder, PResult};
|
||||||
use rustc_span::{sym, Span};
|
use rustc_span::{sym, BytePos, Span};
|
||||||
use std::convert::TryInto;
|
use std::convert::TryInto;
|
||||||
|
|
||||||
use tracing::debug;
|
use tracing::debug;
|
||||||
|
@ -25,6 +25,12 @@ pub(super) const DEFAULT_INNER_ATTR_FORBIDDEN: InnerAttrPolicy<'_> = InnerAttrPo
|
||||||
prev_attr_sp: None,
|
prev_attr_sp: None,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum OuterAttributeType {
|
||||||
|
DocComment,
|
||||||
|
DocBlockComment,
|
||||||
|
Attribute,
|
||||||
|
}
|
||||||
|
|
||||||
impl<'a> Parser<'a> {
|
impl<'a> Parser<'a> {
|
||||||
/// Parses attributes that appear before an item.
|
/// Parses attributes that appear before an item.
|
||||||
pub(super) fn parse_outer_attributes(&mut self) -> PResult<'a, AttrWrapper> {
|
pub(super) fn parse_outer_attributes(&mut self) -> PResult<'a, AttrWrapper> {
|
||||||
|
@ -49,18 +55,32 @@ impl<'a> Parser<'a> {
|
||||||
Some(self.parse_attribute(inner_parse_policy)?)
|
Some(self.parse_attribute(inner_parse_policy)?)
|
||||||
} else if let token::DocComment(comment_kind, attr_style, data) = self.token.kind {
|
} else if let token::DocComment(comment_kind, attr_style, data) = self.token.kind {
|
||||||
if attr_style != ast::AttrStyle::Outer {
|
if attr_style != ast::AttrStyle::Outer {
|
||||||
self.sess
|
let span = self.token.span;
|
||||||
.span_diagnostic
|
let mut err = self.sess.span_diagnostic.struct_span_err_with_code(
|
||||||
.struct_span_err_with_code(
|
span,
|
||||||
self.token.span,
|
|
||||||
"expected outer doc comment",
|
"expected outer doc comment",
|
||||||
error_code!(E0753),
|
error_code!(E0753),
|
||||||
)
|
);
|
||||||
.note(
|
if let Some(replacement_span) = self.annotate_following_item_if_applicable(
|
||||||
"inner doc comments like this (starting with \
|
&mut err,
|
||||||
`//!` or `/*!`) can only appear before items",
|
span,
|
||||||
)
|
match comment_kind {
|
||||||
.emit();
|
token::CommentKind::Line => OuterAttributeType::DocComment,
|
||||||
|
token::CommentKind::Block => OuterAttributeType::DocBlockComment,
|
||||||
|
},
|
||||||
|
) {
|
||||||
|
err.note(
|
||||||
|
"inner doc comments like this (starting with `//!` or `/*!`) can \
|
||||||
|
only appear before items",
|
||||||
|
);
|
||||||
|
err.span_suggestion_verbose(
|
||||||
|
replacement_span,
|
||||||
|
"you might have meant to write a regular comment",
|
||||||
|
String::new(),
|
||||||
|
rustc_errors::Applicability::MachineApplicable,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
err.emit();
|
||||||
}
|
}
|
||||||
self.bump();
|
self.bump();
|
||||||
just_parsed_doc_comment = true;
|
just_parsed_doc_comment = true;
|
||||||
|
@ -97,7 +117,7 @@ impl<'a> Parser<'a> {
|
||||||
inner_parse_policy, self.token
|
inner_parse_policy, self.token
|
||||||
);
|
);
|
||||||
let lo = self.token.span;
|
let lo = self.token.span;
|
||||||
// Attributse can't have attributes of their own
|
// Attributes can't have attributes of their own [Editor's note: not with that attitude]
|
||||||
self.collect_tokens_no_attrs(|this| {
|
self.collect_tokens_no_attrs(|this| {
|
||||||
if this.eat(&token::Pound) {
|
if this.eat(&token::Pound) {
|
||||||
let style = if this.eat(&token::Not) {
|
let style = if this.eat(&token::Not) {
|
||||||
|
@ -125,6 +145,75 @@ impl<'a> Parser<'a> {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn annotate_following_item_if_applicable(
|
||||||
|
&self,
|
||||||
|
err: &mut DiagnosticBuilder<'_>,
|
||||||
|
span: Span,
|
||||||
|
attr_type: OuterAttributeType,
|
||||||
|
) -> Option<Span> {
|
||||||
|
let mut snapshot = self.clone();
|
||||||
|
let lo = span.lo()
|
||||||
|
+ BytePos(match attr_type {
|
||||||
|
OuterAttributeType::Attribute => 1,
|
||||||
|
_ => 2,
|
||||||
|
});
|
||||||
|
let hi = lo + BytePos(1);
|
||||||
|
let replacement_span = span.with_lo(lo).with_hi(hi);
|
||||||
|
if let OuterAttributeType::DocBlockComment | OuterAttributeType::DocComment = attr_type {
|
||||||
|
snapshot.bump();
|
||||||
|
}
|
||||||
|
loop {
|
||||||
|
// skip any other attributes, we want the item
|
||||||
|
if snapshot.token.kind == token::Pound {
|
||||||
|
if let Err(mut err) = snapshot.parse_attribute(InnerAttrPolicy::Permitted) {
|
||||||
|
err.cancel();
|
||||||
|
return Some(replacement_span);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
match snapshot.parse_item_common(
|
||||||
|
AttrWrapper::empty(),
|
||||||
|
true,
|
||||||
|
false,
|
||||||
|
|_| true,
|
||||||
|
ForceCollect::No,
|
||||||
|
) {
|
||||||
|
Ok(Some(item)) => {
|
||||||
|
let attr_name = match attr_type {
|
||||||
|
OuterAttributeType::Attribute => "attribute",
|
||||||
|
_ => "doc comment",
|
||||||
|
};
|
||||||
|
err.span_label(
|
||||||
|
item.span,
|
||||||
|
&format!("the inner {} doesn't annotate this {}", attr_name, item.kind.descr()),
|
||||||
|
);
|
||||||
|
err.span_suggestion_verbose(
|
||||||
|
replacement_span,
|
||||||
|
&format!(
|
||||||
|
"to annotate the {}, change the {} from inner to outer style",
|
||||||
|
item.kind.descr(),
|
||||||
|
attr_name
|
||||||
|
),
|
||||||
|
(match attr_type {
|
||||||
|
OuterAttributeType::Attribute => "",
|
||||||
|
OuterAttributeType::DocBlockComment => "*",
|
||||||
|
OuterAttributeType::DocComment => "/",
|
||||||
|
})
|
||||||
|
.to_string(),
|
||||||
|
rustc_errors::Applicability::MachineApplicable,
|
||||||
|
);
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
Err(mut item_err) => {
|
||||||
|
item_err.cancel();
|
||||||
|
}
|
||||||
|
Ok(None) => {}
|
||||||
|
}
|
||||||
|
Some(replacement_span)
|
||||||
|
}
|
||||||
|
|
||||||
pub(super) fn error_on_forbidden_inner_attr(&self, attr_sp: Span, policy: InnerAttrPolicy<'_>) {
|
pub(super) fn error_on_forbidden_inner_attr(&self, attr_sp: Span, policy: InnerAttrPolicy<'_>) {
|
||||||
if let InnerAttrPolicy::Forbidden { reason, saw_doc_comment, prev_attr_sp } = policy {
|
if let InnerAttrPolicy::Forbidden { reason, saw_doc_comment, prev_attr_sp } = policy {
|
||||||
let prev_attr_note =
|
let prev_attr_note =
|
||||||
|
@ -138,11 +227,20 @@ impl<'a> Parser<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
diag.note(
|
diag.note(
|
||||||
"inner attributes, like `#![no_std]`, annotate the item enclosing them, \
|
"inner attributes, like `#![no_std]`, annotate the item enclosing them, and \
|
||||||
and are usually found at the beginning of source files. \
|
are usually found at the beginning of source files",
|
||||||
Outer attributes, like `#[test]`, annotate the item following them.",
|
);
|
||||||
|
if self
|
||||||
|
.annotate_following_item_if_applicable(
|
||||||
|
&mut diag,
|
||||||
|
attr_sp,
|
||||||
|
OuterAttributeType::Attribute,
|
||||||
)
|
)
|
||||||
.emit();
|
.is_some()
|
||||||
|
{
|
||||||
|
diag.note("outer attributes, like `#[test]`, annotate the item following them");
|
||||||
|
};
|
||||||
|
diag.emit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,8 @@ error: an inner attribute is not permitted in this context
|
||||||
LL | #[cfg(FALSE)] fn e() { let _ = box #![attr] 0; }
|
LL | #[cfg(FALSE)] fn e() { let _ = box #![attr] 0; }
|
||||||
| ^^^^^^^^
|
| ^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files. Outer attributes, like `#[test]`, annotate the item following them.
|
= note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files
|
||||||
|
= note: outer attributes, like `#[test]`, annotate the item following them
|
||||||
|
|
||||||
error: expected expression, found `]`
|
error: expected expression, found `]`
|
||||||
--> $DIR/attr-stmt-expr-attr-bad.rs:7:40
|
--> $DIR/attr-stmt-expr-attr-bad.rs:7:40
|
||||||
|
@ -24,7 +25,8 @@ error: an inner attribute is not permitted in this context
|
||||||
LL | #[cfg(FALSE)] fn e() { let _ = foo(#![attr]); }
|
LL | #[cfg(FALSE)] fn e() { let _ = foo(#![attr]); }
|
||||||
| ^^^^^^^^
|
| ^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files. Outer attributes, like `#[test]`, annotate the item following them.
|
= note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files
|
||||||
|
= note: outer attributes, like `#[test]`, annotate the item following them
|
||||||
|
|
||||||
error: expected expression, found `)`
|
error: expected expression, found `)`
|
||||||
--> $DIR/attr-stmt-expr-attr-bad.rs:11:44
|
--> $DIR/attr-stmt-expr-attr-bad.rs:11:44
|
||||||
|
@ -38,7 +40,8 @@ error: an inner attribute is not permitted in this context
|
||||||
LL | #[cfg(FALSE)] fn e() { let _ = x.foo(#![attr]); }
|
LL | #[cfg(FALSE)] fn e() { let _ = x.foo(#![attr]); }
|
||||||
| ^^^^^^^^
|
| ^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files. Outer attributes, like `#[test]`, annotate the item following them.
|
= note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files
|
||||||
|
= note: outer attributes, like `#[test]`, annotate the item following them
|
||||||
|
|
||||||
error: expected expression, found `)`
|
error: expected expression, found `)`
|
||||||
--> $DIR/attr-stmt-expr-attr-bad.rs:14:46
|
--> $DIR/attr-stmt-expr-attr-bad.rs:14:46
|
||||||
|
@ -52,7 +55,8 @@ error: an inner attribute is not permitted in this context
|
||||||
LL | #[cfg(FALSE)] fn e() { let _ = 0 + #![attr] 0; }
|
LL | #[cfg(FALSE)] fn e() { let _ = 0 + #![attr] 0; }
|
||||||
| ^^^^^^^^
|
| ^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files. Outer attributes, like `#[test]`, annotate the item following them.
|
= note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files
|
||||||
|
= note: outer attributes, like `#[test]`, annotate the item following them
|
||||||
|
|
||||||
error: an inner attribute is not permitted in this context
|
error: an inner attribute is not permitted in this context
|
||||||
--> $DIR/attr-stmt-expr-attr-bad.rs:19:33
|
--> $DIR/attr-stmt-expr-attr-bad.rs:19:33
|
||||||
|
@ -60,7 +64,8 @@ error: an inner attribute is not permitted in this context
|
||||||
LL | #[cfg(FALSE)] fn e() { let _ = !#![attr] 0; }
|
LL | #[cfg(FALSE)] fn e() { let _ = !#![attr] 0; }
|
||||||
| ^^^^^^^^
|
| ^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files. Outer attributes, like `#[test]`, annotate the item following them.
|
= note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files
|
||||||
|
= note: outer attributes, like `#[test]`, annotate the item following them
|
||||||
|
|
||||||
error: an inner attribute is not permitted in this context
|
error: an inner attribute is not permitted in this context
|
||||||
--> $DIR/attr-stmt-expr-attr-bad.rs:21:33
|
--> $DIR/attr-stmt-expr-attr-bad.rs:21:33
|
||||||
|
@ -68,7 +73,8 @@ error: an inner attribute is not permitted in this context
|
||||||
LL | #[cfg(FALSE)] fn e() { let _ = -#![attr] 0; }
|
LL | #[cfg(FALSE)] fn e() { let _ = -#![attr] 0; }
|
||||||
| ^^^^^^^^
|
| ^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files. Outer attributes, like `#[test]`, annotate the item following them.
|
= note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files
|
||||||
|
= note: outer attributes, like `#[test]`, annotate the item following them
|
||||||
|
|
||||||
error: expected one of `!`, `.`, `::`, `;`, `?`, `else`, `{`, or an operator, found `#`
|
error: expected one of `!`, `.`, `::`, `;`, `?`, `else`, `{`, or an operator, found `#`
|
||||||
--> $DIR/attr-stmt-expr-attr-bad.rs:23:34
|
--> $DIR/attr-stmt-expr-attr-bad.rs:23:34
|
||||||
|
@ -82,7 +88,8 @@ error: an inner attribute is not permitted in this context
|
||||||
LL | #[cfg(FALSE)] fn e() { let _ = || #![attr] foo; }
|
LL | #[cfg(FALSE)] fn e() { let _ = || #![attr] foo; }
|
||||||
| ^^^^^^^^
|
| ^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files. Outer attributes, like `#[test]`, annotate the item following them.
|
= note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files
|
||||||
|
= note: outer attributes, like `#[test]`, annotate the item following them
|
||||||
|
|
||||||
error: an inner attribute is not permitted in this context
|
error: an inner attribute is not permitted in this context
|
||||||
--> $DIR/attr-stmt-expr-attr-bad.rs:27:40
|
--> $DIR/attr-stmt-expr-attr-bad.rs:27:40
|
||||||
|
@ -90,7 +97,8 @@ error: an inner attribute is not permitted in this context
|
||||||
LL | #[cfg(FALSE)] fn e() { let _ = move || #![attr] foo; }
|
LL | #[cfg(FALSE)] fn e() { let _ = move || #![attr] foo; }
|
||||||
| ^^^^^^^^
|
| ^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files. Outer attributes, like `#[test]`, annotate the item following them.
|
= note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files
|
||||||
|
= note: outer attributes, like `#[test]`, annotate the item following them
|
||||||
|
|
||||||
error: an inner attribute is not permitted in this context
|
error: an inner attribute is not permitted in this context
|
||||||
--> $DIR/attr-stmt-expr-attr-bad.rs:29:35
|
--> $DIR/attr-stmt-expr-attr-bad.rs:29:35
|
||||||
|
@ -98,7 +106,8 @@ error: an inner attribute is not permitted in this context
|
||||||
LL | #[cfg(FALSE)] fn e() { let _ = || #![attr] {foo}; }
|
LL | #[cfg(FALSE)] fn e() { let _ = || #![attr] {foo}; }
|
||||||
| ^^^^^^^^
|
| ^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files. Outer attributes, like `#[test]`, annotate the item following them.
|
= note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files
|
||||||
|
= note: outer attributes, like `#[test]`, annotate the item following them
|
||||||
|
|
||||||
error: an inner attribute is not permitted in this context
|
error: an inner attribute is not permitted in this context
|
||||||
--> $DIR/attr-stmt-expr-attr-bad.rs:31:40
|
--> $DIR/attr-stmt-expr-attr-bad.rs:31:40
|
||||||
|
@ -106,7 +115,8 @@ error: an inner attribute is not permitted in this context
|
||||||
LL | #[cfg(FALSE)] fn e() { let _ = move || #![attr] {foo}; }
|
LL | #[cfg(FALSE)] fn e() { let _ = move || #![attr] {foo}; }
|
||||||
| ^^^^^^^^
|
| ^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files. Outer attributes, like `#[test]`, annotate the item following them.
|
= note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files
|
||||||
|
= note: outer attributes, like `#[test]`, annotate the item following them
|
||||||
|
|
||||||
error: expected expression, found `..`
|
error: expected expression, found `..`
|
||||||
--> $DIR/attr-stmt-expr-attr-bad.rs:33:40
|
--> $DIR/attr-stmt-expr-attr-bad.rs:33:40
|
||||||
|
@ -126,7 +136,8 @@ error: an inner attribute is not permitted in this context
|
||||||
LL | #[cfg(FALSE)] fn e() { let _ = #[attr] &#![attr] 0; }
|
LL | #[cfg(FALSE)] fn e() { let _ = #[attr] &#![attr] 0; }
|
||||||
| ^^^^^^^^
|
| ^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files. Outer attributes, like `#[test]`, annotate the item following them.
|
= note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files
|
||||||
|
= note: outer attributes, like `#[test]`, annotate the item following them
|
||||||
|
|
||||||
error: an inner attribute is not permitted in this context
|
error: an inner attribute is not permitted in this context
|
||||||
--> $DIR/attr-stmt-expr-attr-bad.rs:39:45
|
--> $DIR/attr-stmt-expr-attr-bad.rs:39:45
|
||||||
|
@ -134,7 +145,8 @@ error: an inner attribute is not permitted in this context
|
||||||
LL | #[cfg(FALSE)] fn e() { let _ = #[attr] &mut #![attr] 0; }
|
LL | #[cfg(FALSE)] fn e() { let _ = #[attr] &mut #![attr] 0; }
|
||||||
| ^^^^^^^^
|
| ^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files. Outer attributes, like `#[test]`, annotate the item following them.
|
= note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files
|
||||||
|
= note: outer attributes, like `#[test]`, annotate the item following them
|
||||||
|
|
||||||
error: outer attributes are not allowed on `if` and `else` branches
|
error: outer attributes are not allowed on `if` and `else` branches
|
||||||
--> $DIR/attr-stmt-expr-attr-bad.rs:41:37
|
--> $DIR/attr-stmt-expr-attr-bad.rs:41:37
|
||||||
|
@ -151,7 +163,8 @@ error: an inner attribute is not permitted in this context
|
||||||
LL | #[cfg(FALSE)] fn e() { let _ = if 0 {#![attr]}; }
|
LL | #[cfg(FALSE)] fn e() { let _ = if 0 {#![attr]}; }
|
||||||
| ^^^^^^^^
|
| ^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files. Outer attributes, like `#[test]`, annotate the item following them.
|
= note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files
|
||||||
|
= note: outer attributes, like `#[test]`, annotate the item following them
|
||||||
|
|
||||||
error: expected one of `.`, `;`, `?`, `else`, or an operator, found `#`
|
error: expected one of `.`, `;`, `?`, `else`, or an operator, found `#`
|
||||||
--> $DIR/attr-stmt-expr-attr-bad.rs:45:40
|
--> $DIR/attr-stmt-expr-attr-bad.rs:45:40
|
||||||
|
@ -174,7 +187,8 @@ error: an inner attribute is not permitted in this context
|
||||||
LL | #[cfg(FALSE)] fn e() { let _ = if 0 {} else {#![attr]}; }
|
LL | #[cfg(FALSE)] fn e() { let _ = if 0 {} else {#![attr]}; }
|
||||||
| ^^^^^^^^
|
| ^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files. Outer attributes, like `#[test]`, annotate the item following them.
|
= note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files
|
||||||
|
= note: outer attributes, like `#[test]`, annotate the item following them
|
||||||
|
|
||||||
error: outer attributes are not allowed on `if` and `else` branches
|
error: outer attributes are not allowed on `if` and `else` branches
|
||||||
--> $DIR/attr-stmt-expr-attr-bad.rs:51:45
|
--> $DIR/attr-stmt-expr-attr-bad.rs:51:45
|
||||||
|
@ -200,7 +214,8 @@ error: an inner attribute is not permitted in this context
|
||||||
LL | #[cfg(FALSE)] fn e() { let _ = if 0 {} else if 0 {#![attr]}; }
|
LL | #[cfg(FALSE)] fn e() { let _ = if 0 {} else if 0 {#![attr]}; }
|
||||||
| ^^^^^^^^
|
| ^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files. Outer attributes, like `#[test]`, annotate the item following them.
|
= note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files
|
||||||
|
= note: outer attributes, like `#[test]`, annotate the item following them
|
||||||
|
|
||||||
error: outer attributes are not allowed on `if` and `else` branches
|
error: outer attributes are not allowed on `if` and `else` branches
|
||||||
--> $DIR/attr-stmt-expr-attr-bad.rs:57:45
|
--> $DIR/attr-stmt-expr-attr-bad.rs:57:45
|
||||||
|
@ -217,7 +232,8 @@ error: an inner attribute is not permitted in this context
|
||||||
LL | #[cfg(FALSE)] fn e() { let _ = if let _ = 0 {#![attr]}; }
|
LL | #[cfg(FALSE)] fn e() { let _ = if let _ = 0 {#![attr]}; }
|
||||||
| ^^^^^^^^
|
| ^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files. Outer attributes, like `#[test]`, annotate the item following them.
|
= note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files
|
||||||
|
= note: outer attributes, like `#[test]`, annotate the item following them
|
||||||
|
|
||||||
error: expected one of `.`, `;`, `?`, `else`, or an operator, found `#`
|
error: expected one of `.`, `;`, `?`, `else`, or an operator, found `#`
|
||||||
--> $DIR/attr-stmt-expr-attr-bad.rs:61:48
|
--> $DIR/attr-stmt-expr-attr-bad.rs:61:48
|
||||||
|
@ -240,7 +256,8 @@ error: an inner attribute is not permitted in this context
|
||||||
LL | #[cfg(FALSE)] fn e() { let _ = if let _ = 0 {} else {#![attr]}; }
|
LL | #[cfg(FALSE)] fn e() { let _ = if let _ = 0 {} else {#![attr]}; }
|
||||||
| ^^^^^^^^
|
| ^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files. Outer attributes, like `#[test]`, annotate the item following them.
|
= note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files
|
||||||
|
= note: outer attributes, like `#[test]`, annotate the item following them
|
||||||
|
|
||||||
error: outer attributes are not allowed on `if` and `else` branches
|
error: outer attributes are not allowed on `if` and `else` branches
|
||||||
--> $DIR/attr-stmt-expr-attr-bad.rs:67:53
|
--> $DIR/attr-stmt-expr-attr-bad.rs:67:53
|
||||||
|
@ -266,7 +283,8 @@ error: an inner attribute is not permitted in this context
|
||||||
LL | #[cfg(FALSE)] fn e() { let _ = if let _ = 0 {} else if let _ = 0 {#![attr]}; }
|
LL | #[cfg(FALSE)] fn e() { let _ = if let _ = 0 {} else if let _ = 0 {#![attr]}; }
|
||||||
| ^^^^^^^^
|
| ^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files. Outer attributes, like `#[test]`, annotate the item following them.
|
= note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files
|
||||||
|
= note: outer attributes, like `#[test]`, annotate the item following them
|
||||||
|
|
||||||
error: an inner attribute is not permitted following an outer attribute
|
error: an inner attribute is not permitted following an outer attribute
|
||||||
--> $DIR/attr-stmt-expr-attr-bad.rs:74:32
|
--> $DIR/attr-stmt-expr-attr-bad.rs:74:32
|
||||||
|
@ -276,7 +294,8 @@ LL | #[cfg(FALSE)] fn s() { #[attr] #![attr] let _ = 0; }
|
||||||
| |
|
| |
|
||||||
| previous outer attribute
|
| previous outer attribute
|
||||||
|
|
|
|
||||||
= note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files. Outer attributes, like `#[test]`, annotate the item following them.
|
= note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files
|
||||||
|
= note: outer attributes, like `#[test]`, annotate the item following them
|
||||||
|
|
||||||
error: an inner attribute is not permitted following an outer attribute
|
error: an inner attribute is not permitted following an outer attribute
|
||||||
--> $DIR/attr-stmt-expr-attr-bad.rs:76:32
|
--> $DIR/attr-stmt-expr-attr-bad.rs:76:32
|
||||||
|
@ -286,37 +305,56 @@ LL | #[cfg(FALSE)] fn s() { #[attr] #![attr] 0; }
|
||||||
| |
|
| |
|
||||||
| previous outer attribute
|
| previous outer attribute
|
||||||
|
|
|
|
||||||
= note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files. Outer attributes, like `#[test]`, annotate the item following them.
|
= note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files
|
||||||
|
= note: outer attributes, like `#[test]`, annotate the item following them
|
||||||
|
|
||||||
error: an inner attribute is not permitted following an outer attribute
|
error: an inner attribute is not permitted following an outer attribute
|
||||||
--> $DIR/attr-stmt-expr-attr-bad.rs:78:32
|
--> $DIR/attr-stmt-expr-attr-bad.rs:78:32
|
||||||
|
|
|
|
||||||
LL | #[cfg(FALSE)] fn s() { #[attr] #![attr] foo!(); }
|
LL | #[cfg(FALSE)] fn s() { #[attr] #![attr] foo!(); }
|
||||||
| ------- ^^^^^^^^ not permitted following an outer attribute
|
| ------- ^^^^^^^^ ------- the inner attribute doesn't annotate this item macro invocation
|
||||||
| |
|
| | |
|
||||||
|
| | not permitted following an outer attribute
|
||||||
| previous outer attribute
|
| previous outer attribute
|
||||||
|
|
|
|
||||||
= note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files. Outer attributes, like `#[test]`, annotate the item following them.
|
= note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files
|
||||||
|
help: to annotate the item macro invocation, change the attribute from inner to outer style
|
||||||
|
|
|
||||||
|
LL - #[cfg(FALSE)] fn s() { #[attr] #![attr] foo!(); }
|
||||||
|
LL + #[cfg(FALSE)] fn s() { #[attr] #[attr] foo!(); }
|
||||||
|
|
|
||||||
|
|
||||||
error: an inner attribute is not permitted following an outer attribute
|
error: an inner attribute is not permitted following an outer attribute
|
||||||
--> $DIR/attr-stmt-expr-attr-bad.rs:80:32
|
--> $DIR/attr-stmt-expr-attr-bad.rs:80:32
|
||||||
|
|
|
|
||||||
LL | #[cfg(FALSE)] fn s() { #[attr] #![attr] foo![]; }
|
LL | #[cfg(FALSE)] fn s() { #[attr] #![attr] foo![]; }
|
||||||
| ------- ^^^^^^^^ not permitted following an outer attribute
|
| ------- ^^^^^^^^ ------- the inner attribute doesn't annotate this item macro invocation
|
||||||
| |
|
| | |
|
||||||
|
| | not permitted following an outer attribute
|
||||||
| previous outer attribute
|
| previous outer attribute
|
||||||
|
|
|
|
||||||
= note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files. Outer attributes, like `#[test]`, annotate the item following them.
|
= note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files
|
||||||
|
help: to annotate the item macro invocation, change the attribute from inner to outer style
|
||||||
|
|
|
||||||
|
LL - #[cfg(FALSE)] fn s() { #[attr] #![attr] foo![]; }
|
||||||
|
LL + #[cfg(FALSE)] fn s() { #[attr] #[attr] foo![]; }
|
||||||
|
|
|
||||||
|
|
||||||
error: an inner attribute is not permitted following an outer attribute
|
error: an inner attribute is not permitted following an outer attribute
|
||||||
--> $DIR/attr-stmt-expr-attr-bad.rs:82:32
|
--> $DIR/attr-stmt-expr-attr-bad.rs:82:32
|
||||||
|
|
|
|
||||||
LL | #[cfg(FALSE)] fn s() { #[attr] #![attr] foo!{}; }
|
LL | #[cfg(FALSE)] fn s() { #[attr] #![attr] foo!{}; }
|
||||||
| ------- ^^^^^^^^ not permitted following an outer attribute
|
| ------- ^^^^^^^^ ------ the inner attribute doesn't annotate this item macro invocation
|
||||||
| |
|
| | |
|
||||||
|
| | not permitted following an outer attribute
|
||||||
| previous outer attribute
|
| previous outer attribute
|
||||||
|
|
|
|
||||||
= note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files. Outer attributes, like `#[test]`, annotate the item following them.
|
= note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files
|
||||||
|
help: to annotate the item macro invocation, change the attribute from inner to outer style
|
||||||
|
|
|
||||||
|
LL - #[cfg(FALSE)] fn s() { #[attr] #![attr] foo!{}; }
|
||||||
|
LL + #[cfg(FALSE)] fn s() { #[attr] #[attr] foo!{}; }
|
||||||
|
|
|
||||||
|
|
||||||
error[E0586]: inclusive range with no end
|
error[E0586]: inclusive range with no end
|
||||||
--> $DIR/attr-stmt-expr-attr-bad.rs:88:35
|
--> $DIR/attr-stmt-expr-attr-bad.rs:88:35
|
||||||
|
|
|
@ -3,8 +3,16 @@ error: an inner attribute is not permitted in this context
|
||||||
|
|
|
|
||||||
LL | #![lang = "foo"]
|
LL | #![lang = "foo"]
|
||||||
| ^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^
|
||||||
|
LL |
|
||||||
|
LL | fn foo() {}
|
||||||
|
| ----------- the inner attribute doesn't annotate this function
|
||||||
|
|
|
||||||
|
= note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files
|
||||||
|
help: to annotate the function, change the attribute from inner to outer style
|
||||||
|
|
|
||||||
|
LL - #![lang = "foo"]
|
||||||
|
LL + #[lang = "foo"]
|
||||||
|
|
|
|
||||||
= note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files. Outer attributes, like `#[test]`, annotate the item following them.
|
|
||||||
|
|
||||||
error[E0522]: definition of an unknown language item: `foo`
|
error[E0522]: definition of an unknown language item: `foo`
|
||||||
--> $DIR/attr.rs:5:1
|
--> $DIR/attr.rs:5:1
|
||||||
|
|
|
@ -5,6 +5,11 @@ LL | if true /*!*/ {}
|
||||||
| ^^^^^
|
| ^^^^^
|
||||||
|
|
|
|
||||||
= note: inner doc comments like this (starting with `//!` or `/*!`) can only appear before items
|
= note: inner doc comments like this (starting with `//!` or `/*!`) can only appear before items
|
||||||
|
help: you might have meant to write a regular comment
|
||||||
|
|
|
||||||
|
LL - if true /*!*/ {}
|
||||||
|
LL + if true /**/ {}
|
||||||
|
|
|
||||||
|
|
||||||
error: outer attributes are not allowed on `if` and `else` branches
|
error: outer attributes are not allowed on `if` and `else` branches
|
||||||
--> $DIR/doc-comment-in-if-statement.rs:2:13
|
--> $DIR/doc-comment-in-if-statement.rs:2:13
|
||||||
|
|
|
@ -8,8 +8,16 @@ LL | | */
|
||||||
LL |
|
LL |
|
||||||
LL | #![recursion_limit="100"]
|
LL | #![recursion_limit="100"]
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ not permitted following an outer attribute
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^ not permitted following an outer attribute
|
||||||
|
LL |
|
||||||
|
LL | fn main() {}
|
||||||
|
| ------------ the inner attribute doesn't annotate this function
|
||||||
|
|
|
||||||
|
= note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files
|
||||||
|
help: to annotate the function, change the attribute from inner to outer style
|
||||||
|
|
|
||||||
|
LL - #![recursion_limit="100"]
|
||||||
|
LL + #[recursion_limit="100"]
|
||||||
|
|
|
|
||||||
= note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files. Outer attributes, like `#[test]`, annotate the item following them.
|
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -6,8 +6,15 @@ LL | #[feature(lang_items)]
|
||||||
LL |
|
LL |
|
||||||
LL | #![recursion_limit="100"]
|
LL | #![recursion_limit="100"]
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ not permitted following an outer attribute
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^ not permitted following an outer attribute
|
||||||
|
LL | fn main() {}
|
||||||
|
| ------------ the inner attribute doesn't annotate this function
|
||||||
|
|
|
||||||
|
= note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files
|
||||||
|
help: to annotate the function, change the attribute from inner to outer style
|
||||||
|
|
|
||||||
|
LL - #![recursion_limit="100"]
|
||||||
|
LL + #[recursion_limit="100"]
|
||||||
|
|
|
|
||||||
= note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files. Outer attributes, like `#[test]`, annotate the item following them.
|
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
27
src/test/ui/parser/issue-30318.fixed
Normal file
27
src/test/ui/parser/issue-30318.fixed
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
// run-rustfix
|
||||||
|
#![allow(unused)]
|
||||||
|
fn foo() { }
|
||||||
|
|
||||||
|
/// Misplaced comment...
|
||||||
|
//~^ ERROR expected outer doc comment
|
||||||
|
fn bar() { } //~ NOTE the inner doc comment doesn't annotate this function
|
||||||
|
|
||||||
|
#[test] //~ ERROR an inner attribute is not permitted in this context
|
||||||
|
fn baz() { } //~ NOTE the inner attribute doesn't annotate this function
|
||||||
|
//~^^ NOTE inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually
|
||||||
|
|
||||||
|
/** Misplaced comment... */
|
||||||
|
//~^ ERROR expected outer doc comment
|
||||||
|
fn bat() { } //~ NOTE the inner doc comment doesn't annotate this function
|
||||||
|
|
||||||
|
fn main() { }
|
||||||
|
|
||||||
|
// Misplaced comment...
|
||||||
|
//~^ ERROR expected outer doc comment
|
||||||
|
//~| NOTE inner doc comments like this (starting with `//!` or `/*!`) can only appear before items
|
||||||
|
//~| NOTE other attributes here
|
||||||
|
/* Misplaced comment... */
|
||||||
|
//~^ ERROR expected outer doc comment
|
||||||
|
//~| NOTE this doc comment doesn't document anything
|
||||||
|
//~| ERROR expected item after doc comment
|
||||||
|
//~| NOTE inner doc comments like this (starting with `//!` or `/*!`) can only appear before items
|
|
@ -1,7 +1,27 @@
|
||||||
|
// run-rustfix
|
||||||
|
#![allow(unused)]
|
||||||
fn foo() { }
|
fn foo() { }
|
||||||
|
|
||||||
//! Misplaced comment...
|
//! Misplaced comment...
|
||||||
//~^ ERROR expected outer doc comment
|
//~^ ERROR expected outer doc comment
|
||||||
//~| NOTE inner doc comments like this (starting with `//!` or `/*!`) can only appear before items
|
fn bar() { } //~ NOTE the inner doc comment doesn't annotate this function
|
||||||
|
|
||||||
|
#![test] //~ ERROR an inner attribute is not permitted in this context
|
||||||
|
fn baz() { } //~ NOTE the inner attribute doesn't annotate this function
|
||||||
|
//~^^ NOTE inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually
|
||||||
|
|
||||||
|
/*! Misplaced comment... */
|
||||||
|
//~^ ERROR expected outer doc comment
|
||||||
|
fn bat() { } //~ NOTE the inner doc comment doesn't annotate this function
|
||||||
|
|
||||||
fn main() { }
|
fn main() { }
|
||||||
|
|
||||||
|
//! Misplaced comment...
|
||||||
|
//~^ ERROR expected outer doc comment
|
||||||
|
//~| NOTE inner doc comments like this (starting with `//!` or `/*!`) can only appear before items
|
||||||
|
//~| NOTE other attributes here
|
||||||
|
/*! Misplaced comment... */
|
||||||
|
//~^ ERROR expected outer doc comment
|
||||||
|
//~| NOTE this doc comment doesn't document anything
|
||||||
|
//~| ERROR expected item after doc comment
|
||||||
|
//~| NOTE inner doc comments like this (starting with `//!` or `/*!`) can only appear before items
|
||||||
|
|
|
@ -1,11 +1,81 @@
|
||||||
error[E0753]: expected outer doc comment
|
error[E0753]: expected outer doc comment
|
||||||
--> $DIR/issue-30318.rs:3:1
|
--> $DIR/issue-30318.rs:5:1
|
||||||
|
|
|
||||||
|
LL | //! Misplaced comment...
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
LL |
|
||||||
|
LL | fn bar() { }
|
||||||
|
| ------------ the inner doc comment doesn't annotate this function
|
||||||
|
|
|
||||||
|
help: to annotate the function, change the doc comment from inner to outer style
|
||||||
|
|
|
||||||
|
LL | /// Misplaced comment...
|
||||||
|
| ~
|
||||||
|
|
||||||
|
error: an inner attribute is not permitted in this context
|
||||||
|
--> $DIR/issue-30318.rs:9:1
|
||||||
|
|
|
||||||
|
LL | #![test]
|
||||||
|
| ^^^^^^^^
|
||||||
|
LL | fn baz() { }
|
||||||
|
| ------------ the inner attribute doesn't annotate this function
|
||||||
|
|
|
||||||
|
= note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files
|
||||||
|
help: to annotate the function, change the attribute from inner to outer style
|
||||||
|
|
|
||||||
|
LL - #![test]
|
||||||
|
LL + #[test]
|
||||||
|
|
|
||||||
|
|
||||||
|
error[E0753]: expected outer doc comment
|
||||||
|
--> $DIR/issue-30318.rs:13:1
|
||||||
|
|
|
||||||
|
LL | /*! Misplaced comment... */
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
LL |
|
||||||
|
LL | fn bat() { }
|
||||||
|
| ------------ the inner doc comment doesn't annotate this function
|
||||||
|
|
|
||||||
|
help: to annotate the function, change the doc comment from inner to outer style
|
||||||
|
|
|
||||||
|
LL | /** Misplaced comment... */
|
||||||
|
| ~
|
||||||
|
|
||||||
|
error[E0753]: expected outer doc comment
|
||||||
|
--> $DIR/issue-30318.rs:19:1
|
||||||
|
|
|
|
||||||
LL | //! Misplaced comment...
|
LL | //! Misplaced comment...
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: inner doc comments like this (starting with `//!` or `/*!`) can only appear before items
|
= note: inner doc comments like this (starting with `//!` or `/*!`) can only appear before items
|
||||||
|
help: you might have meant to write a regular comment
|
||||||
|
|
|
||||||
|
LL - //! Misplaced comment...
|
||||||
|
LL + // Misplaced comment...
|
||||||
|
|
|
||||||
|
|
||||||
error: aborting due to previous error
|
error[E0753]: expected outer doc comment
|
||||||
|
--> $DIR/issue-30318.rs:23:1
|
||||||
|
|
|
||||||
|
LL | /*! Misplaced comment... */
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: inner doc comments like this (starting with `//!` or `/*!`) can only appear before items
|
||||||
|
help: you might have meant to write a regular comment
|
||||||
|
|
|
||||||
|
LL - /*! Misplaced comment... */
|
||||||
|
LL + /* Misplaced comment... */
|
||||||
|
|
|
||||||
|
|
||||||
|
error: expected item after doc comment
|
||||||
|
--> $DIR/issue-30318.rs:23:1
|
||||||
|
|
|
||||||
|
LL | //! Misplaced comment...
|
||||||
|
| ------------------------ other attributes here
|
||||||
|
...
|
||||||
|
LL | /*! Misplaced comment... */
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ this doc comment doesn't document anything
|
||||||
|
|
||||||
|
error: aborting due to 6 previous errors
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0753`.
|
For more information about this error, try `rustc --explain E0753`.
|
||||||
|
|
|
@ -2,4 +2,5 @@ fn main() {
|
||||||
let unused = ();
|
let unused = ();
|
||||||
|
|
||||||
#![allow(unused_variables)] //~ ERROR not permitted in this context
|
#![allow(unused_variables)] //~ ERROR not permitted in this context
|
||||||
|
fn foo() {}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,8 +3,15 @@ error: an inner attribute is not permitted in this context
|
||||||
|
|
|
|
||||||
LL | #![allow(unused_variables)]
|
LL | #![allow(unused_variables)]
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
LL | fn foo() {}
|
||||||
|
| ----------- the inner attribute doesn't annotate this function
|
||||||
|
|
|
||||||
|
= note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files
|
||||||
|
help: to annotate the function, change the attribute from inner to outer style
|
||||||
|
|
|
||||||
|
LL - #![allow(unused_variables)]
|
||||||
|
LL + #[allow(unused_variables)]
|
||||||
|
|
|
|
||||||
= note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files. Outer attributes, like `#[test]`, annotate the item following them.
|
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,8 @@ error: an inner attribute is not permitted in this context
|
||||||
LL | let a = #![allow(warnings)] (1, 2);
|
LL | let a = #![allow(warnings)] (1, 2);
|
||||||
| ^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files. Outer attributes, like `#[test]`, annotate the item following them.
|
= note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files
|
||||||
|
= note: outer attributes, like `#[test]`, annotate the item following them
|
||||||
|
|
||||||
error: an inner attribute is not permitted in this context
|
error: an inner attribute is not permitted in this context
|
||||||
--> $DIR/stmt_expr_attrs_placement.rs:10:14
|
--> $DIR/stmt_expr_attrs_placement.rs:10:14
|
||||||
|
@ -12,7 +13,8 @@ error: an inner attribute is not permitted in this context
|
||||||
LL | let b = (#![allow(warnings)] 1, 2);
|
LL | let b = (#![allow(warnings)] 1, 2);
|
||||||
| ^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files. Outer attributes, like `#[test]`, annotate the item following them.
|
= note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files
|
||||||
|
= note: outer attributes, like `#[test]`, annotate the item following them
|
||||||
|
|
||||||
error: an inner attribute is not permitted in this context
|
error: an inner attribute is not permitted in this context
|
||||||
--> $DIR/stmt_expr_attrs_placement.rs:15:10
|
--> $DIR/stmt_expr_attrs_placement.rs:15:10
|
||||||
|
@ -20,7 +22,8 @@ error: an inner attribute is not permitted in this context
|
||||||
LL | (#![allow(warnings)] 1, 2)
|
LL | (#![allow(warnings)] 1, 2)
|
||||||
| ^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files. Outer attributes, like `#[test]`, annotate the item following them.
|
= note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files
|
||||||
|
= note: outer attributes, like `#[test]`, annotate the item following them
|
||||||
|
|
||||||
error: an inner attribute is not permitted in this context
|
error: an inner attribute is not permitted in this context
|
||||||
--> $DIR/stmt_expr_attrs_placement.rs:21:18
|
--> $DIR/stmt_expr_attrs_placement.rs:21:18
|
||||||
|
@ -28,7 +31,8 @@ error: an inner attribute is not permitted in this context
|
||||||
LL | let e = (#![allow(warnings)] 1, 2);
|
LL | let e = (#![allow(warnings)] 1, 2);
|
||||||
| ^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files. Outer attributes, like `#[test]`, annotate the item following them.
|
= note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files
|
||||||
|
= note: outer attributes, like `#[test]`, annotate the item following them
|
||||||
|
|
||||||
error: an inner attribute is not permitted in this context
|
error: an inner attribute is not permitted in this context
|
||||||
--> $DIR/stmt_expr_attrs_placement.rs:26:14
|
--> $DIR/stmt_expr_attrs_placement.rs:26:14
|
||||||
|
@ -36,7 +40,8 @@ error: an inner attribute is not permitted in this context
|
||||||
LL | let e = [#![allow(warnings)] 1, 2];
|
LL | let e = [#![allow(warnings)] 1, 2];
|
||||||
| ^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files. Outer attributes, like `#[test]`, annotate the item following them.
|
= note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files
|
||||||
|
= note: outer attributes, like `#[test]`, annotate the item following them
|
||||||
|
|
||||||
error: an inner attribute is not permitted in this context
|
error: an inner attribute is not permitted in this context
|
||||||
--> $DIR/stmt_expr_attrs_placement.rs:29:14
|
--> $DIR/stmt_expr_attrs_placement.rs:29:14
|
||||||
|
@ -44,7 +49,8 @@ error: an inner attribute is not permitted in this context
|
||||||
LL | let f = [#![allow(warnings)] 1; 0];
|
LL | let f = [#![allow(warnings)] 1; 0];
|
||||||
| ^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files. Outer attributes, like `#[test]`, annotate the item following them.
|
= note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files
|
||||||
|
= note: outer attributes, like `#[test]`, annotate the item following them
|
||||||
|
|
||||||
error: an inner attribute is not permitted in this context
|
error: an inner attribute is not permitted in this context
|
||||||
--> $DIR/stmt_expr_attrs_placement.rs:36:24
|
--> $DIR/stmt_expr_attrs_placement.rs:36:24
|
||||||
|
@ -52,7 +58,8 @@ error: an inner attribute is not permitted in this context
|
||||||
LL | let h = MyStruct { #![allow(warnings)] field: 0 };
|
LL | let h = MyStruct { #![allow(warnings)] field: 0 };
|
||||||
| ^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files. Outer attributes, like `#[test]`, annotate the item following them.
|
= note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files
|
||||||
|
= note: outer attributes, like `#[test]`, annotate the item following them
|
||||||
|
|
||||||
error: aborting due to 7 previous errors
|
error: aborting due to 7 previous errors
|
||||||
|
|
||||||
|
|
12
src/test/ui/proc-macro/issue-86781-bad-inner-doc.fixed
Normal file
12
src/test/ui/proc-macro/issue-86781-bad-inner-doc.fixed
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
// aux-build:test-macros.rs
|
||||||
|
// run-rustfix
|
||||||
|
|
||||||
|
#[macro_use]
|
||||||
|
extern crate test_macros;
|
||||||
|
|
||||||
|
/// Inner doc comment
|
||||||
|
//~^ ERROR expected outer doc comment
|
||||||
|
#[derive(Empty)]
|
||||||
|
pub struct Foo; //~ NOTE the inner doc comment doesn't annotate this struct
|
||||||
|
|
||||||
|
fn main() {}
|
|
@ -1,4 +1,5 @@
|
||||||
// aux-build:test-macros.rs
|
// aux-build:test-macros.rs
|
||||||
|
// run-rustfix
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate test_macros;
|
extern crate test_macros;
|
||||||
|
@ -6,6 +7,6 @@ extern crate test_macros;
|
||||||
//! Inner doc comment
|
//! Inner doc comment
|
||||||
//~^ ERROR expected outer doc comment
|
//~^ ERROR expected outer doc comment
|
||||||
#[derive(Empty)]
|
#[derive(Empty)]
|
||||||
pub struct Foo;
|
pub struct Foo; //~ NOTE the inner doc comment doesn't annotate this struct
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
|
@ -1,10 +1,16 @@
|
||||||
error[E0753]: expected outer doc comment
|
error[E0753]: expected outer doc comment
|
||||||
--> $DIR/issue-86781-bad-inner-doc.rs:6:1
|
--> $DIR/issue-86781-bad-inner-doc.rs:7:1
|
||||||
|
|
|
|
||||||
LL | //! Inner doc comment
|
LL | //! Inner doc comment
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
...
|
||||||
|
LL | pub struct Foo;
|
||||||
|
| --------------- the inner doc comment doesn't annotate this struct
|
||||||
|
|
|
|
||||||
= note: inner doc comments like this (starting with `//!` or `/*!`) can only appear before items
|
help: to annotate the struct, change the doc comment from inner to outer style
|
||||||
|
|
|
||||||
|
LL | /// Inner doc comment
|
||||||
|
| ~
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue