Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warning on conflicting keys #10316

Merged
merged 8 commits into from
Mar 10, 2022
Merged

Conversation

Rustin170506
Copy link
Member

@Rustin170506 Rustin170506 commented Jan 22, 2022

Signed-off-by: hi-rustin rustin.liu@gmail.com

What does this PR try to resolve?

close #10299 and close #10317

How should we test and review this PR?

  • Warning on conflicting proc_macro and crate_types keys.
  • Warning on conflicting dev-dependencies, build-dependencies, and default-features keys.

@rust-highfive
Copy link

r? @ehuss

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 22, 2022
@weihanglo
Copy link
Member

weihanglo commented Jan 22, 2022

I feel like crate-types got the same historic problem. Would you like to address it as well in this PR?

// The intention was to only accept `crate-type` here but historical
// versions of Cargo also accepted `crate_type`, so look for both.
#[serde(rename = "crate-type")]
crate_type: Option<Vec<String>>,
#[serde(rename = "crate_type")]
crate_type2: Option<Vec<String>>,

Edit: a few more fields in src/cargo/util/toml/mod.rs have alternative names. Just search 2: and you'll see 😆

@Rustin170506
Copy link
Member Author

Edit: a few of fields in src/cargo/util/toml/mod.rs have alternative name. Just search 2: and you'll see 😆

Sent an issue for this. #10317

I feel like crate-types got the same historic problem. Would you like to address it as well in this PR?

Yes, I also found it. I will address it later. Thanks for your review.

@Rustin170506 Rustin170506 changed the title Warning on conflicting proc_macro keys Warning on conflicting proc_macro and crate_types keys Jan 23, 2022
@alexcrichton
Copy link
Member

AFAIK this also affects dev-dependencies, build-dependencies, and default-features.

@ehuss ehuss added S-waiting-on-author Status: The marked PR is awaiting some action (such as code changes) from the PR author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 1, 2022
@Rustin170506 Rustin170506 force-pushed the rustin-patch-proc_macro branch from e4d03ac to 2a11cf3 Compare February 4, 2022 01:57
@Rustin170506
Copy link
Member Author

AFAIK this also affects dev-dependencies, build-dependencies, and default-features.

@alexcrichton I'm not quite sure what this effect means? I've added dev-deps to my tests but it doesn't seem to have any effect?

@alexcrichton
Copy link
Member

If we want to go so far as to warn on duplicate manifest keys like this (which I'm not 100% sold on but I won't block the effort) then there are other keys which can be duplicated, such as dev_dependencies and dev-dependencies. I don't think that this logic should only apply to one of the keys that's duplicate-able.

@Rustin170506
Copy link
Member Author

@alexcrichton I have created an issue to track other keys. #10317

@Rustin170506 Rustin170506 force-pushed the rustin-patch-proc_macro branch from dc3a4a3 to 2a11cf3 Compare February 5, 2022 03:30
@alexcrichton
Copy link
Member

r? @alexcrichton

Sorry I'm kind of confused, this PR is addressing some conflicting keys but not others? Is there a reason to not address the known ones here all using the same infrastructure?

@rust-highfive rust-highfive assigned alexcrichton and unassigned ehuss Feb 8, 2022
@Rustin170506
Copy link
Member Author

Is there a reason to not address the known ones here all using the same infrastructure?

My original thought was to warn only about the fields mentioned in the issue in this PR. So let me change them all in this PR.

@Rustin170506 Rustin170506 force-pushed the rustin-patch-proc_macro branch from 6b88b7d to 4b3f2d4 Compare February 9, 2022 14:36
@Rustin170506
Copy link
Member Author

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: The marked PR is awaiting some action (such as code changes) from the PR author. labels Feb 9, 2022
@Rustin170506 Rustin170506 changed the title Warning on conflicting proc_macro and crate_types keys Warning on conflicting keys Feb 9, 2022
@Rustin170506

This comment was marked as outdated.

@Rustin170506 Rustin170506 force-pushed the rustin-patch-proc_macro branch 2 times, most recently from 588e92b to c0bf37e Compare March 2, 2022 13:37
@Rustin170506
Copy link
Member Author

@alexcrichton Friendly Ping~

@alexcrichton
Copy link
Member

Thanks for the PR, but I'm going to be stepping down from the Cargo team so I'm going to un-assign myself from this. The Cargo team will help review this when they get a chance.

@alexcrichton alexcrichton removed their assignment Mar 8, 2022
@weihanglo weihanglo removed their request for review March 9, 2022 00:31
@weihanglo weihanglo self-assigned this Mar 9, 2022
Copy link
Member

@weihanglo weihanglo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would love to reuse a function to remove code duplication (though it helps little 🥲). And the warning message should point out that the old field is ignored. Something like

fn warn_on_deprecated(new_path: &str, name: &str, kind: &str, warnings: &mut Vec<String>) {
    let old_path = new_path.replace("-", "_");
    warnings.push(format!(
        "conflicting between `{new_path}` and `{old_path}` in the `{name}` {kind}.\n
        `{old_path}` is ignored and not recommended for use in the future"
    ))
}

tests/testsuite/build.rs Outdated Show resolved Hide resolved
tests/testsuite/build.rs Outdated Show resolved Hide resolved
tests/testsuite/build.rs Show resolved Hide resolved
src/cargo/util/toml/mod.rs Outdated Show resolved Hide resolved
tests/testsuite/build.rs Outdated Show resolved Hide resolved
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
@Rustin170506 Rustin170506 force-pushed the rustin-patch-proc_macro branch 2 times, most recently from 486c771 to 961f0da Compare March 9, 2022 16:01
@Rustin170506
Copy link
Member Author

Rustin170506 commented Mar 9, 2022

I would love to reuse a function to remove code duplication

Added. Thanks for your review! 💚 💙 💜 💛 ❤️

@Rustin170506 Rustin170506 requested a review from weihanglo March 9, 2022 16:04
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
@Rustin170506 Rustin170506 force-pushed the rustin-patch-proc_macro branch from 961f0da to 8b895cc Compare March 9, 2022 16:08
@weihanglo
Copy link
Member

@bors r+

Thanks!

@bors
Copy link
Contributor

bors commented Mar 10, 2022

📌 Commit 8b895cc has been approved by weihanglo

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 10, 2022
@bors
Copy link
Contributor

bors commented Mar 10, 2022

⌛ Testing commit 8b895cc with merge 56ccd1f...

@bors
Copy link
Contributor

bors commented Mar 10, 2022

☀️ Test successful - checks-actions
Approved by: weihanglo
Pushing 56ccd1f to master...

@bors bors merged commit 56ccd1f into rust-lang:master Mar 10, 2022
@Rustin170506 Rustin170506 deleted the rustin-patch-proc_macro branch March 10, 2022 01:28
bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 19, 2022
Update cargo

9 commits in 65c82664263feddc5fe2d424be0993c28d46377a..109bfbd055325ef87a6e7f63d67da7e838f8300b
2022-03-09 02:32:56 +0000 to 2022-03-17 21:43:09 +0000
- Refactor RegistryData::load to handle management of the index cache (rust-lang/cargo#10482)
- Separate VCS command paths with "--" (rust-lang/cargo#10483)
- Fix panic when artifact target is used for `[target.'cfg(&lt;target&gt;)'.dependencies` (rust-lang/cargo#10433)
- Bump git2@0.14.2 and libgit2-sys@0.13.2 (rust-lang/cargo#10479)
- vendor: Don't allow multiple values for --sync (rust-lang/cargo#10448)
- Use types to make clere (credential process || token) (rust-lang/cargo#10471)
- Warning on conflicting keys (rust-lang/cargo#10316)
- Registry functions return Poll to enable parallel fetching of index data (rust-lang/cargo#10064)
- Refine the contributor guide (rust-lang/cargo#10468)
@ehuss ehuss added this to the 1.61.0 milestone Apr 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Warn on conflicting keys of src/cargo/util/toml/mod.rs Warn on Conflicting Keys
7 participants