Skip to content

Tracking Issue for future-incompatibility lint ambiguous_panic_imports #147319

@Voultapher

Description

@Voultapher

This is the tracking issue for the ambiguous_panic_imports future-compatibility warning and other related errors. The goal of this page is to describe why this change was made and how you can fix code that is affected by it. It also provides a place to ask questions or register a complaint if you feel the change should not be made. For more information on the policy around future-compatibility warnings, see our breaking change policy guidelines.

What is the warning for?

Glob importing the standard library in a no_std crate can lead to an ambiguous name resolution for the macro panic which is defined both in core and std.

Why was this change made?

The core::panic resolution after use std::prelude::v1::* is deemed surprising and should be opted into explicitly. This issue was discovered and became relevant in github.com//pull/139493.

Example

#![no_std]

extern crate std;
use std::prelude::v1::*;

fn xx() {
    panic!(); // resolves to core::panic
}

Recommendations

Explicitly import panic with use core::panic; to maintain the previous semantics or use std::panic; if that was the original intention.

When will this warning become a hard error?

This has not yet been decided.

Steps

  • Implement the lint
  • Raise lint level to deny
  • Change the lint to report in dependencies
  • Switch to a hard error

Implementation history

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.A-resolveArea: Name/path resolution done by `rustc_resolve` specificallyC-future-incompatibilityCategory: Future-incompatibility lintsC-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCT-langRelevant to the language team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions