Repository navigation
feat(ffi): rename one instance by its path, as exclude leaves one out #243
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
Changes from all commits
4b27e0f
310ed65
9f6b61d
7b86b7f
6f47d7b
1bb0719
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,7 +22,8 @@ pub struct Config { | |
| pub exclude: Vec<String>, | ||
| /// C names, without the prefix, for paths from the crate root whose names the rule | ||
| /// makes clash: `"session::Stats" = "session_stats_snapshot"`. A type's methods are | ||
| /// named through its new name. A field is named by its path as `exclude` names it. | ||
| /// named through its new name. Paths match as `exclude`'s do, so an instance's renames | ||
| /// it alone, and a field is named by its path as `exclude` names it. | ||
| #[serde(default)] | ||
| pub rename: BTreeMap<String, String>, | ||
| /// Other packages exported into the same library, each a dependency of `package`, by | ||
|
|
@@ -42,6 +43,18 @@ pub struct Items { | |
| pub rename: BTreeMap<String, String>, | ||
| } | ||
|
|
||
| /// The keys `exclude` and `rename` name the item at `shown` by, its path with its | ||
| /// instances' arguments, longest first: each prefix of it as is, then without the | ||
| /// arguments, which names the generic item's every instance. Each comes with its length. | ||
| pub fn keys(shown: &[String]) -> impl Iterator<Item = (usize, String)> + '_ { | ||
| (1..=shown.len()).rev().flat_map(move |len| { | ||
| let exact = shown[..len].join("::"); | ||
| let generic: Vec<&str> = shown[..len].iter().map(|s| s.split('<').next().unwrap_or(s)).collect(); | ||
| let generic = Some(generic.join("::")).filter(|generic| *generic != exact); | ||
| std::iter::once(exact).chain(generic).map(move |key| (len, key)) | ||
|
Comment on lines
+51
to
+54
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
For a generic method on a generic type instance, the matcher emits only the fully instantiated path and the fully generic path, omitting the key that selects all method instances on one owner instance. For example, the existing fixture's Useful? React with 👍 / 👎. |
||
| }) | ||
| } | ||
|
|
||
| impl Config { | ||
| pub fn load(path: &Path) -> Result<Self, String> { | ||
| let text = std::fs::read_to_string(path).map_err(|err| format!("reading {}: {err}", path.display()))?; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The commit explicitly states that moq has no consumer for this feature, and the only added uses are synthetic fixture renames. This violates
AGENTS.md's requirement that every change have a consumer using it now, with moq as the first consumer. The deleted quest also explicitly deferred this work until a consumer encounters a clash that existing renames cannot resolve. Keep the feature deferred until that concrete use exists, or include the consumer that justifies expanding the configuration and naming machinery.AGENTS.md reference: AGENTS.md:L33-L33
Useful? React with 👍 / 👎.