Skip to content

When the write! macro's result is chained stability warnings show up, and the expansion site is not reported #22013

@renato-zannon

Description

@renato-zannon

Example:

fn main() {
    let mut buffer = Vec::new();
    writeln!(&mut buffer, "foo").unwrap();
}

This errors as:

<std macros>:2:20: 2:66 warning: use of unstable library feature 'io'
<std macros>:2 ( & mut * $ dst ) . write_fmt ( format_args ! ( $ ( $ arg ) * ) ) )
                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:2:20: 2:66 help: add #![feature(io)] to the crate attributes to silence this warning
<std macros>:2 ( & mut * $ dst ) . write_fmt ( format_args ! ( $ ( $ arg ) * ) ) )
                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Contrast that with the error when the .unwrap() is removed:

<std macros>:2:1: 2:66 warning: unused result which must be used, #[warn(unused_must_use)] on by default
<std macros>:2 ( & mut * $ dst ) . write_fmt ( format_args ! ( $ ( $ arg ) * ) ) )
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<std macros>:1:1: 2:68 note: in expansion of write!
<std macros>:2:1: 2:46 note: expansion site
<std macros>:1:1: 4:66 note: in expansion of writeln!
src/main.rs:3:5: 3:34 note: expansion site

This can be pretty hairy to find if the project has many crates (my project euler repo, which is where I observed this, has 60+ executables).

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions