Skip to content

False positive for empty_line_after_outer_attr with #[doc=""] attribute #2460

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
pftbest opened this issue Feb 14, 2018 · 2 comments
Closed

Comments

@pftbest
Copy link

pftbest commented Feb 14, 2018

This code produces a warning:

#[doc = "
Returns the escaped value of the textual representation of
its arguments in a form suitable for embedding in a URL query.

# Example
``
use gtmpl::template;
let url = template(r#\"{{ urlquery \"foo bar?\" }}\"#, 0);
assert_eq!(&url.unwrap(), \"foo%20bar%3F\");
``
"]
pub fn urlquery(args: &[Arc<Value>]) -> Result<Arc<Value>, String> {
    if args.len() != 1 {
        return Err(String::from("urlquery requires one argument"));
    }

    match *args[0] {
        Value::String(ref s) => Ok(varc!(
            utf8_percent_encode(s, DEFAULT_ENCODE_SET).to_string()
        )),
        _ => Err(String::from("Arguments need to be of type String")),
    }
}
warning: Found an empty line after an outer attribute. Perhaps you forgot to add a '!' to make it an inner attribute?
   --> src/funcs.rs:383:1
    |
383 | / #[doc = "
384 | | Returns the escaped value of the textual representation of
385 | | its arguments in a form suitable for embedding in a URL query.
386 | |
...   |
393 | | "]
394 | | pub fn urlquery(args: &[Arc<Value>]) -> Result<Arc<Value>, String> {
    | |_
    |
    = note: #[warn(empty_line_after_outer_attr)] on by default
    = help: for further information visit https://rust-lang-nursery.github.io/rust-clippy/v0.0.186/index.html#empty_line_after_outer_attr

cc @phansch

@phansch
Copy link
Member

phansch commented Feb 15, 2018

Thanks for the report! I managed to reduce the code a bit:

#[doc = "
sometext

"]
pub fn function() -> bool {
    true
}

Note that the function needs to return something in order to produce this false positive. This took me a while to figure out and is.. interesting. I hope to have a fix by next week 👍

@oli-obk
Copy link
Contributor

oli-obk commented Feb 21, 2018

fixed in #2473

@oli-obk oli-obk closed this as completed Feb 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants