Skip to content

Commit

Permalink
Auto merge of rust-lang#7385 - xFrednet:0000-fix-broken-deploy, r=fli…
Browse files Browse the repository at this point in the history
…p1995

Fixed broken deploy script due to multiline configuration docs

The deploy script on master currently runs into an error (See [log](https://github.com/rust-lang/rust-clippy/runs/2865828873)) due to the new configuration documentation added in rust-lang#7299. The current documentation collection for the configuration macro sadly doesn't support multiline doc comments. This will be changes in the future with the new metadata collector tracked in rust-lang#7172 For now we have to use `<br>` inside doc comments to add paragraphs.

This PR restricts `define_Conf!` macro to single lines and adds a comment explaining the reasoning behind it. It also adjusted the actual document parsing to fix a bug. (The parsing was automatically stopping on the first curly bracket, even if it was part of a doc comment).

changelog: none
  • Loading branch information
bors committed Jun 21, 2021
2 parents 404bd1a + 96a9786 commit 86bf28d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
15 changes: 7 additions & 8 deletions clippy_lints/src/utils/conf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,18 @@ impl TryConf {
}
}

/// Note that the configuration parsing currently doesn't support documentation that will
/// that spans over several lines. This will be possible with the new implementation
/// See (rust-clippy#7172)
macro_rules! define_Conf {
($(
$(#[doc = $doc:literal])*
#[doc = $doc:literal]
$(#[conf_deprecated($dep:literal)])?
($name:ident: $ty:ty = $default:expr),
)*) => {
/// Clippy lint configuration
pub struct Conf {
$($(#[doc = $doc])* pub $name: $ty,)*
$(#[doc = $doc] pub $name: $ty,)*
}

mod defaults {
Expand Down Expand Up @@ -109,7 +112,7 @@ macro_rules! define_Conf {
stringify!($name),
stringify!($ty),
format!("{:?}", super::defaults::$name()),
concat!($($doc,)*),
$doc,
deprecation_reason,
)
},
Expand Down Expand Up @@ -198,11 +201,7 @@ define_Conf! {
(upper_case_acronyms_aggressive: bool = false),
/// Lint: _CARGO_COMMON_METADATA. For internal testing only, ignores the current `publish` settings in the Cargo manifest.
(cargo_ignore_publish: bool = false),
/// Lint: NONSTANDARD_MACRO_BRACES. Enforce the named macros always use the braces specified.
///
/// A `MacroMatcher` can be added like so `{ name = "macro_name", brace = "(" }`.
/// If the macro is could be used with a full path two `MacroMatcher`s have to be added one
/// with the full path `crate_name::macro_name` and one with just the macro name.
/// Lint: NONSTANDARD_MACRO_BRACES. Enforce the named macros always use the braces specified. <br> A `MacroMatcher` can be added like so `{ name = "macro_name", brace = "(" }`. If the macro is could be used with a full path two `MacroMatcher`s have to be added one with the full path `crate_name::macro_name` and one with just the macro name.
(standard_macro_braces: Vec<crate::nonstandard_macro_braces::MacroMatcher> = Vec::new()),
}

Expand Down
4 changes: 2 additions & 2 deletions util/lintlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

lintname_re = re.compile(r'''pub\s+([A-Z_][A-Z_0-9]*)''')
group_re = re.compile(r'''\s*([a-z_][a-z_0-9]+)''')
conf_re = re.compile(r'''define_Conf! {\n([^}]*)\n}''', re.MULTILINE)
conf_re = re.compile(r'''define_Conf! {\n((?!\n})[\s\S])*\n}''', re.MULTILINE)
confvar_re = re.compile(
r'''/// Lint: ([\w,\s]+)\. (.*)\n\s*\(([^:]+):\s*([^\s=]+)\s*=\s*([^\.\)]+).*\),''', re.MULTILINE)
comment_re = re.compile(r'''\s*/// ?(.*)''')
Expand Down Expand Up @@ -91,7 +91,7 @@ def parse_configs(path):
contents = fp.read()

match = re.search(conf_re, contents)
confvars = re.findall(confvar_re, match.group(1))
confvars = re.findall(confvar_re, match.group(0))

for (lints, doc, name, ty, default) in confvars:
for lint in lints.split(','):
Expand Down

0 comments on commit 86bf28d

Please sign in to comment.