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

refactor: factor out Config from core::features #13278

Closed
wants to merge 1 commit into from

Conversation

weihanglo
Copy link
Member

What does this PR try to resolve?

To decouple manifest logic from config.toml behavior, a trait
UnstableFeatureContext is created for Features to query any
necessary information from the outer context.

This is a path toward a new package for high-level manifest processing
logic. The goal is to break out behavior for Config into several
small contexts, which can be imported when needed.

How should we test and review this PR?

There is no functional change.

The plan is to add more context impls into util::config::context.

Additional information

Related to #4614

To decouple manifest logic from `config.toml` behavior, a trait
`UnstableFeatureContext` is created for `Features` to query any
necessary information from the outer context.

This is a path toward a new package for high-level manifest processing
logic. The goal is to break out behavior for `Config` into several
small contexts, which can be imported when needed.
@rustbot
Copy link
Collaborator

rustbot commented Jan 10, 2024

r? @ehuss

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added A-configuration Area: cargo config files and env vars A-unstable Area: nightly unstable support S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 10, 2024
@epage
Copy link
Contributor

epage commented Jan 10, 2024

Could you lay out your motivation and plan in #4614? I'm a bit concerned that #4614 is a large, invasive project that will affect maintainability with limited gains.

Example concerns

  • Manifest dependent on core types
  • The parsing and prepare-for-publish logic seem highly related but the abstraction for the latter is very leaky
  • More contexts being required by manifests, like for diagnostics (can't + traits with dyn but can with impl)
  • Filesystem interactions
  • Layering the packages so a manifest parsing package has access to the relevant context traits and the contexts have access to their needed types

@@ -598,7 +598,7 @@ impl Features {
see_docs()
),
Status::Unstable => {
if let Some(allow) = &config.cli_unstable().allow_features {
if let Some(allow) = allow_features {
Copy link
Contributor

Choose a reason for hiding this comment

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

imo this change loses some important context of which set of allowed features this is. This is specifically the -Z / CLI features. Maybe cli_allow_features for the trait method and variable??

use crate::core::features::UnstableFeatureContext;
use crate::Config;

impl UnstableFeatureContext for Config {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not usually a fan of trait impls being separate from either the trait or the struct definition.

Copy link
Contributor

Choose a reason for hiding this comment

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

(annotate-snippets took this to an extreme)

@ehuss
Copy link
Contributor

ehuss commented Jan 18, 2024

@rustbot author

@rustbot rustbot 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 Jan 18, 2024
@weihanglo
Copy link
Member Author

Close as this is not relevant at this moment. See #4614 (comment) for possible directions forward.

@weihanglo weihanglo closed this Jan 27, 2024
@weihanglo weihanglo deleted the unstable-feature branch December 22, 2024 21:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-configuration Area: cargo config files and env vars A-unstable Area: nightly unstable support S-waiting-on-author Status: The marked PR is awaiting some action (such as code changes) from the PR author.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants