Skip to content

Compiler warnings are not raised for code enclosed in macros #16360

Closed
@cskr

Description

@cskr

When deprecated API usage is enclosed in a macro like try!, no warning is raised. However, using it directly in match does.

Below is an example using the deprecated url crate from rust nightly distribution. A warning is raised only in the use_match function.

extern crate url;

use url::Url;

fn main() {
    println!("Host: {}", use_try("http://localhost").unwrap())
    println!("Host: {}", use_match("http://localhost").unwrap())
}

fn use_try(s: &str) -> Result<String, String> {
    let u = try!(Url::parse(s));
    Ok(u.host)
}

fn use_match(s: &str) -> Result<String, String> {
    return match Url::parse(s) {
        Ok(u) => Ok(u.host),
        Err(e) => Err(e)
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions