Skip to content

An unused output of some macros in std (e.g., format!()) should produce a unused_must_use warning. #126475

Open
@theemathas

Description

Code

fn main() {
    format!("{}", 1);
}

Current output

No errors or warnings

Desired output

warning: unused return value of `format!()` that must be used

Rationale and extra context

The format!() macro could probably expand to code containing std::hint::must_use.

List of macros with similar issues:

  • cfg!()
  • column!(), line!(), file!(), module_path!()
  • concat!(), stringify!()
  • env!(), option_env!()
  • format!(), format_args!()
  • include_bytes!(), include_str!()
  • matches!()
  • vec!()
  • pin::pin!()

Other cases

No response

Rust Version

Nightly rust on playground: 1.81.0-nightly (2024-06-13 f1586001ace26df7cafe)

Anything else?

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions