Skip to content

Commit 8aeaf98

Browse files
Rename from Lowered to Canonical (#9447)
By request: #9341 (review).
1 parent 7a0a5a8 commit 8aeaf98

File tree

8 files changed

+78
-76
lines changed

8 files changed

+78
-76
lines changed

crates/uv-pep508/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ use url::Url;
2727

2828
use cursor::Cursor;
2929
pub use marker::{
30-
ContainsMarkerTree, ExtraMarkerTree, ExtraOperator, InMarkerTree, LoweredMarkerValueExtra,
31-
LoweredMarkerValueString, LoweredMarkerValueVersion, MarkerEnvironment,
30+
CanonicalMarkerValueExtra, CanonicalMarkerValueString, CanonicalMarkerValueVersion,
31+
ContainsMarkerTree, ExtraMarkerTree, ExtraOperator, InMarkerTree, MarkerEnvironment,
3232
MarkerEnvironmentBuilder, MarkerExpression, MarkerOperator, MarkerTree, MarkerTreeContents,
3333
MarkerTreeKind, MarkerValue, MarkerValueExtra, MarkerValueString, MarkerValueVersion,
3434
MarkerWarningKind, StringMarkerTree, StringVersion, VersionMarkerTree,

crates/uv-pep508/src/marker/algebra.rs

+17-17
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ use uv_pep440::{release_specifier_to_range, Operator, Version, VersionSpecifier}
5757
use version_ranges::Ranges;
5858

5959
use crate::marker::lowering::{
60-
LoweredMarkerValueExtra, LoweredMarkerValueString, LoweredMarkerValueVersion,
60+
CanonicalMarkerValueExtra, CanonicalMarkerValueString, CanonicalMarkerValueVersion,
6161
};
6262
use crate::marker::MarkerValueExtra;
6363
use crate::ExtraOperator;
@@ -162,18 +162,18 @@ impl InternerGuard<'_> {
162162
// to disjoint version ranges.
163163
MarkerExpression::Version { key, specifier } => match key {
164164
MarkerValueVersion::ImplementationVersion => (
165-
Variable::Version(LoweredMarkerValueVersion::ImplementationVersion),
165+
Variable::Version(CanonicalMarkerValueVersion::ImplementationVersion),
166166
Edges::from_specifier(specifier),
167167
),
168168
MarkerValueVersion::PythonFullVersion => (
169-
Variable::Version(LoweredMarkerValueVersion::PythonFullVersion),
169+
Variable::Version(CanonicalMarkerValueVersion::PythonFullVersion),
170170
Edges::from_specifier(specifier),
171171
),
172172
// Normalize `python_version` markers to `python_full_version` nodes.
173173
MarkerValueVersion::PythonVersion => {
174174
match python_version_to_full_version(normalize_specifier(specifier)) {
175175
Ok(specifier) => (
176-
Variable::Version(LoweredMarkerValueVersion::PythonFullVersion),
176+
Variable::Version(CanonicalMarkerValueVersion::PythonFullVersion),
177177
Edges::from_specifier(specifier),
178178
),
179179
Err(node) => return node,
@@ -188,18 +188,18 @@ impl InternerGuard<'_> {
188188
negated,
189189
} => match key {
190190
MarkerValueVersion::ImplementationVersion => (
191-
Variable::Version(LoweredMarkerValueVersion::ImplementationVersion),
191+
Variable::Version(CanonicalMarkerValueVersion::ImplementationVersion),
192192
Edges::from_versions(&versions, negated),
193193
),
194194
MarkerValueVersion::PythonFullVersion => (
195-
Variable::Version(LoweredMarkerValueVersion::PythonFullVersion),
195+
Variable::Version(CanonicalMarkerValueVersion::PythonFullVersion),
196196
Edges::from_versions(&versions, negated),
197197
),
198198
// Normalize `python_version` markers to `python_full_version` nodes.
199199
MarkerValueVersion::PythonVersion => {
200200
match Edges::from_python_versions(versions, negated) {
201201
Ok(edges) => (
202-
Variable::Version(LoweredMarkerValueVersion::PythonFullVersion),
202+
Variable::Version(CanonicalMarkerValueVersion::PythonFullVersion),
203203
edges,
204204
),
205205
Err(node) => return node,
@@ -275,14 +275,14 @@ impl InternerGuard<'_> {
275275
name: MarkerValueExtra::Extra(extra),
276276
operator: ExtraOperator::Equal,
277277
} => (
278-
Variable::Extra(LoweredMarkerValueExtra::Extra(extra)),
278+
Variable::Extra(CanonicalMarkerValueExtra::Extra(extra)),
279279
Edges::from_bool(true),
280280
),
281281
MarkerExpression::Extra {
282282
name: MarkerValueExtra::Extra(extra),
283283
operator: ExtraOperator::NotEqual,
284284
} => (
285-
Variable::Extra(LoweredMarkerValueExtra::Extra(extra)),
285+
Variable::Extra(CanonicalMarkerValueExtra::Extra(extra)),
286286
Edges::from_bool(false),
287287
),
288288
// Invalid extras are always `false`.
@@ -443,7 +443,7 @@ impl InternerGuard<'_> {
443443
// Look for a `python_full_version` expression, otherwise
444444
// we recursively simplify.
445445
let Node {
446-
var: Variable::Version(LoweredMarkerValueVersion::PythonFullVersion),
446+
var: Variable::Version(CanonicalMarkerValueVersion::PythonFullVersion),
447447
children: Edges::Version { ref edges },
448448
} = node
449449
else {
@@ -516,7 +516,7 @@ impl InternerGuard<'_> {
516516
return NodeId::FALSE;
517517
}
518518
if matches!(i, NodeId::TRUE) {
519-
let var = Variable::Version(LoweredMarkerValueVersion::PythonFullVersion);
519+
let var = Variable::Version(CanonicalMarkerValueVersion::PythonFullVersion);
520520
let edges = Edges::Version {
521521
edges: Edges::from_range(&py_range),
522522
};
@@ -525,7 +525,7 @@ impl InternerGuard<'_> {
525525

526526
let node = self.shared.node(i);
527527
let Node {
528-
var: Variable::Version(LoweredMarkerValueVersion::PythonFullVersion),
528+
var: Variable::Version(CanonicalMarkerValueVersion::PythonFullVersion),
529529
children: Edges::Version { ref edges },
530530
} = node
531531
else {
@@ -621,26 +621,26 @@ pub(crate) enum Variable {
621621
///
622622
/// This is the highest order variable as it typically contains the most complex
623623
/// ranges, allowing us to merge ranges at the top-level.
624-
Version(LoweredMarkerValueVersion),
624+
Version(CanonicalMarkerValueVersion),
625625
/// A string marker, such as `os_name`.
626-
String(LoweredMarkerValueString),
626+
String(CanonicalMarkerValueString),
627627
/// A variable representing a `<key> in <value>` expression for a particular
628628
/// string marker and value.
629629
In {
630-
key: LoweredMarkerValueString,
630+
key: CanonicalMarkerValueString,
631631
value: String,
632632
},
633633
/// A variable representing a `<value> in <key>` expression for a particular
634634
/// string marker and value.
635635
Contains {
636-
key: LoweredMarkerValueString,
636+
key: CanonicalMarkerValueString,
637637
value: String,
638638
},
639639
/// A variable representing the existence or absence of a given extra.
640640
///
641641
/// We keep extras at the leaves of the tree, so when simplifying extras we can
642642
/// trivially remove the leaves without having to reconstruct the entire tree.
643-
Extra(LoweredMarkerValueExtra),
643+
Extra(CanonicalMarkerValueExtra),
644644
}
645645

646646
/// A decision node in an Algebraic Decision Diagram.

crates/uv-pep508/src/marker/environment.rs

+13-13
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::sync::Arc;
22

33
use uv_pep440::{Version, VersionParseError};
44

5-
use crate::{LoweredMarkerValueString, LoweredMarkerValueVersion, StringVersion};
5+
use crate::{CanonicalMarkerValueString, CanonicalMarkerValueVersion, StringVersion};
66

77
/// The marker values for a python interpreter, normally the current one
88
///
@@ -33,28 +33,28 @@ struct MarkerEnvironmentInner {
3333

3434
impl MarkerEnvironment {
3535
/// Returns of the PEP 440 version typed value of the key in the current environment
36-
pub fn get_version(&self, key: LoweredMarkerValueVersion) -> &Version {
36+
pub fn get_version(&self, key: CanonicalMarkerValueVersion) -> &Version {
3737
match key {
38-
LoweredMarkerValueVersion::ImplementationVersion => {
38+
CanonicalMarkerValueVersion::ImplementationVersion => {
3939
&self.implementation_version().version
4040
}
41-
LoweredMarkerValueVersion::PythonFullVersion => &self.python_full_version().version,
41+
CanonicalMarkerValueVersion::PythonFullVersion => &self.python_full_version().version,
4242
}
4343
}
4444

4545
/// Returns of the stringly typed value of the key in the current environment
46-
pub fn get_string(&self, key: LoweredMarkerValueString) -> &str {
46+
pub fn get_string(&self, key: CanonicalMarkerValueString) -> &str {
4747
match key {
48-
LoweredMarkerValueString::ImplementationName => self.implementation_name(),
49-
LoweredMarkerValueString::OsName => self.os_name(),
50-
LoweredMarkerValueString::PlatformMachine => self.platform_machine(),
51-
LoweredMarkerValueString::PlatformPythonImplementation => {
48+
CanonicalMarkerValueString::ImplementationName => self.implementation_name(),
49+
CanonicalMarkerValueString::OsName => self.os_name(),
50+
CanonicalMarkerValueString::PlatformMachine => self.platform_machine(),
51+
CanonicalMarkerValueString::PlatformPythonImplementation => {
5252
self.platform_python_implementation()
5353
}
54-
LoweredMarkerValueString::PlatformRelease => self.platform_release(),
55-
LoweredMarkerValueString::PlatformSystem => self.platform_system(),
56-
LoweredMarkerValueString::PlatformVersion => self.platform_version(),
57-
LoweredMarkerValueString::SysPlatform => self.sys_platform(),
54+
CanonicalMarkerValueString::PlatformRelease => self.platform_release(),
55+
CanonicalMarkerValueString::PlatformSystem => self.platform_system(),
56+
CanonicalMarkerValueString::PlatformVersion => self.platform_version(),
57+
CanonicalMarkerValueString::SysPlatform => self.sys_platform(),
5858
}
5959
}
6060
}

crates/uv-pep508/src/marker/lowering.rs

+25-25
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ use crate::{MarkerValueExtra, MarkerValueString, MarkerValueVersion};
77
/// Those environment markers with a PEP 440 version as value such as `python_version`
88
#[derive(Copy, Clone, Debug, Eq, Hash, PartialEq, PartialOrd, Ord)]
99
#[allow(clippy::enum_variant_names)]
10-
pub enum LoweredMarkerValueVersion {
10+
pub enum CanonicalMarkerValueVersion {
1111
/// `implementation_version`
1212
ImplementationVersion,
1313
/// `python_full_version`
1414
PythonFullVersion,
1515
}
1616

17-
impl Display for LoweredMarkerValueVersion {
17+
impl Display for CanonicalMarkerValueVersion {
1818
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
1919
match self {
2020
Self::ImplementationVersion => f.write_str("implementation_version"),
@@ -23,18 +23,18 @@ impl Display for LoweredMarkerValueVersion {
2323
}
2424
}
2525

26-
impl From<LoweredMarkerValueVersion> for MarkerValueVersion {
27-
fn from(value: LoweredMarkerValueVersion) -> Self {
26+
impl From<CanonicalMarkerValueVersion> for MarkerValueVersion {
27+
fn from(value: CanonicalMarkerValueVersion) -> Self {
2828
match value {
29-
LoweredMarkerValueVersion::ImplementationVersion => Self::ImplementationVersion,
30-
LoweredMarkerValueVersion::PythonFullVersion => Self::PythonFullVersion,
29+
CanonicalMarkerValueVersion::ImplementationVersion => Self::ImplementationVersion,
30+
CanonicalMarkerValueVersion::PythonFullVersion => Self::PythonFullVersion,
3131
}
3232
}
3333
}
3434

3535
/// Those environment markers with an arbitrary string as value such as `sys_platform`
3636
#[derive(Copy, Clone, Debug, Eq, Hash, PartialEq, PartialOrd, Ord)]
37-
pub enum LoweredMarkerValueString {
37+
pub enum CanonicalMarkerValueString {
3838
/// `implementation_name`
3939
ImplementationName,
4040
/// `os_name`
@@ -54,7 +54,7 @@ pub enum LoweredMarkerValueString {
5454
SysPlatform,
5555
}
5656

57-
impl From<MarkerValueString> for LoweredMarkerValueString {
57+
impl From<MarkerValueString> for CanonicalMarkerValueString {
5858
fn from(value: MarkerValueString) -> Self {
5959
match value {
6060
MarkerValueString::ImplementationName => Self::ImplementationName,
@@ -77,24 +77,24 @@ impl From<MarkerValueString> for LoweredMarkerValueString {
7777
}
7878
}
7979

80-
impl From<LoweredMarkerValueString> for MarkerValueString {
81-
fn from(value: LoweredMarkerValueString) -> Self {
80+
impl From<CanonicalMarkerValueString> for MarkerValueString {
81+
fn from(value: CanonicalMarkerValueString) -> Self {
8282
match value {
83-
LoweredMarkerValueString::ImplementationName => Self::ImplementationName,
84-
LoweredMarkerValueString::OsName => Self::OsName,
85-
LoweredMarkerValueString::PlatformMachine => Self::PlatformMachine,
86-
LoweredMarkerValueString::PlatformPythonImplementation => {
83+
CanonicalMarkerValueString::ImplementationName => Self::ImplementationName,
84+
CanonicalMarkerValueString::OsName => Self::OsName,
85+
CanonicalMarkerValueString::PlatformMachine => Self::PlatformMachine,
86+
CanonicalMarkerValueString::PlatformPythonImplementation => {
8787
Self::PlatformPythonImplementation
8888
}
89-
LoweredMarkerValueString::PlatformRelease => Self::PlatformRelease,
90-
LoweredMarkerValueString::PlatformSystem => Self::PlatformSystem,
91-
LoweredMarkerValueString::PlatformVersion => Self::PlatformVersion,
92-
LoweredMarkerValueString::SysPlatform => Self::SysPlatform,
89+
CanonicalMarkerValueString::PlatformRelease => Self::PlatformRelease,
90+
CanonicalMarkerValueString::PlatformSystem => Self::PlatformSystem,
91+
CanonicalMarkerValueString::PlatformVersion => Self::PlatformVersion,
92+
CanonicalMarkerValueString::SysPlatform => Self::SysPlatform,
9393
}
9494
}
9595
}
9696

97-
impl Display for LoweredMarkerValueString {
97+
impl Display for CanonicalMarkerValueString {
9898
/// Normalizes deprecated names to the proper ones
9999
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
100100
match self {
@@ -112,12 +112,12 @@ impl Display for LoweredMarkerValueString {
112112

113113
/// The [`ExtraName`] value used in `extra` markers.
114114
#[derive(Clone, Debug, Eq, Hash, PartialEq, PartialOrd, Ord)]
115-
pub enum LoweredMarkerValueExtra {
115+
pub enum CanonicalMarkerValueExtra {
116116
/// A valid [`ExtraName`].
117117
Extra(ExtraName),
118118
}
119119

120-
impl LoweredMarkerValueExtra {
120+
impl CanonicalMarkerValueExtra {
121121
/// Returns the [`ExtraName`] value.
122122
pub fn extra(&self) -> &ExtraName {
123123
match self {
@@ -126,15 +126,15 @@ impl LoweredMarkerValueExtra {
126126
}
127127
}
128128

129-
impl From<LoweredMarkerValueExtra> for MarkerValueExtra {
130-
fn from(value: LoweredMarkerValueExtra) -> Self {
129+
impl From<CanonicalMarkerValueExtra> for MarkerValueExtra {
130+
fn from(value: CanonicalMarkerValueExtra) -> Self {
131131
match value {
132-
LoweredMarkerValueExtra::Extra(extra) => Self::Extra(extra),
132+
CanonicalMarkerValueExtra::Extra(extra) => Self::Extra(extra),
133133
}
134134
}
135135
}
136136

137-
impl Display for LoweredMarkerValueExtra {
137+
impl Display for CanonicalMarkerValueExtra {
138138
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
139139
match self {
140140
Self::Extra(extra) => extra.fmt(f),

crates/uv-pep508/src/marker/mod.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ mod simplify;
1717
mod tree;
1818

1919
pub use environment::{MarkerEnvironment, MarkerEnvironmentBuilder};
20-
pub use lowering::{LoweredMarkerValueExtra, LoweredMarkerValueString, LoweredMarkerValueVersion};
20+
pub use lowering::{
21+
CanonicalMarkerValueExtra, CanonicalMarkerValueString, CanonicalMarkerValueVersion,
22+
};
2123
pub use tree::{
2224
ContainsMarkerTree, ExtraMarkerTree, ExtraOperator, InMarkerTree, MarkerExpression,
2325
MarkerOperator, MarkerTree, MarkerTreeContents, MarkerTreeDebugGraph, MarkerTreeKind,

0 commit comments

Comments
 (0)