Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Add test for rustX codeblock attribute
  • Loading branch information
GuillaumeGomez committed Dec 12, 2023
commit 98aa20b0a7ee519b23f37d76c1d093f50c43d863
8 changes: 8 additions & 0 deletions tests/rustdoc-ui/lints/check-attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,11 @@ pub fn foobar() {}
/// boo
/// ```
pub fn b() {}

/// b
//~^ ERROR
///
/// ```rust2018
/// boo
/// ```
pub fn c() {}
13 changes: 12 additions & 1 deletion tests/rustdoc-ui/lints/check-attr.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -171,5 +171,16 @@ LL | | /// ```
|
= help: the code block will either not be tested if not marked as a rust one or the code will be wrapped inside a main function

error: aborting due to 12 previous errors
error: unknown attribute `rust2018`. Did you mean `edition2018`?
--> $DIR/check-attr.rs:43:1
|
LL | / /// b
LL | |
LL | | ///
LL | | /// ```rust2018
LL | | /// boo
LL | | /// ```
| |_______^

error: aborting due to 13 previous errors

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if you write two bad attributes in a row?

```rust2018 shouldpanic
panic!();
```

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This:

warning: unknown attribute `rust2018`
 --> foo.rs:3:1
  |
3 | / /**
4 | | ```rust2018 shouldpanic
5 | | panic!();
6 | | ```
7 | | */
  | |__^
  |
  = help: there is an attribute with a similar name: `edition2018`
  = note: `#[warn(rustdoc::invalid_codeblock_attributes)]` on by default

warning: unknown attribute `shouldpanic`
 --> foo.rs:3:1
  |
3 | / /**
4 | | ```rust2018 shouldpanic
5 | | panic!();
6 | | ```
7 | | */
  | |__^
  |
  = help: there is an attribute with a similar name: `should_panic`
  = help: the code block will either not be tested if not marked as a rust one or won't fail if it doesn't panic when running

warning: 2 warnings emitted