Skip to content

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

Closed
weihanglo wants to merge 1 commit intorust-lang:masterfrom
weihanglo:unstable-feature
Closed

refactor: factor out Config from core::features#13278
weihanglo wants to merge 1 commit intorust-lang:masterfrom
weihanglo:unstable-feature

Conversation

@weihanglo
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

),
Status::Unstable => {
if let Some(allow) = &config.cli_unstable().allow_features {
if let Some(allow) = allow_features {
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Member Author

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

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