rust-lang / rust-lang/rfcs

Incorporating functions in Rust lang/prelude with clashing function name with a dependency crate in cargo toml

Open
#3,209 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Markdown
Stars
6.6k
Forks
1.7k
Avg merge
16h 14m
Merged PRs (30d)
1

Description

I have some suggestions as to how to go about incorporating functions with the same function name as that of a dependency crate in order to prevent conflicts.

rust-lang/rust#79524 has inspired me to create this RFC.

My suggestion goes something like this:

  1. Add a flag to Cargo.toml to load std functions before dependency functions which is by default added for new rust versions (personally I would want to include it as a feature of a new Rust edition, but since 2021 got released just now I am not so sure) even if the user declares to use the dependency crate globally unless the user marks it as something like !important or priority use
  2. If there is a function with the same name in the std lib as that of dependency, and if the stdlib function is used clippy should show a warning. Needless to say if any error occurs while compiling, proper source of the function should be made evident in the error messages.
  3. All of this is not required if the dependency crate is not called upon in the Cargo.toml

Contributor guide

No contributing guide indexed for this repository

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 by reading rust-lang/rust#79524 and the proposed behavior in this issue. Define how Cargo.toml dependency declarations, standard-library name precedence, clippy warnings, and compiler diagnostics should interact. Done means the proposal has a settled, implementable design with clear behavior when the dependency is absent.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
build-system, compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.