rust-lang / rust-lang/rust

Tracking Issue for future-incompatibility lint `ambiguous_panic_imports`

Open
#147,319 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-lints A-maybe-future-edition A-resolve C-future-incompatibility C-tracking-issue T-lang
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

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 https://github.com/rust-lang/rust/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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the ambiguous_panic_imports lint description and implementation history in pull request #139493. Review the remaining checklist items—raising the lint level, reporting in dependencies, and deciding whether to make it a hard error; completion depends on resolving those policy and design decisions.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.