pub struct CargoFormatter;Trait Implementations§
Source§impl DiagnosticMessages for CargoFormatter
impl DiagnosticMessages for CargoFormatter
Source§fn yanked_message(&self) -> &'static str
fn yanked_message(&self) -> &'static str
Source§fn yanked_label(&self) -> &'static str
fn yanked_label(&self) -> &'static str
Source§fn deprecated_message(&self) -> &'static str
fn deprecated_message(&self) -> &'static str
Source§fn deprecated_label(&self) -> &'static str
fn deprecated_label(&self) -> &'static str
Source§impl DiagnosticPolicy for CargoFormatter
impl DiagnosticPolicy for CargoFormatter
Source§fn strict_semver_prerelease_exclusion(&self) -> bool
fn strict_semver_prerelease_exclusion(&self) -> bool
semver::VersionReq::matches excludes pre-releases unless requirement itself pins
to the same X.Y.Z tuple with a pre-release tag — strict SemVer 2.0.0 semantics (#299).
Source§fn supports_package_rename(&self) -> bool
fn supports_package_rename(&self) -> bool
crate::Deprecation::replacement)
is safe to offer as a “Replace with X” rename quickfix. Read moreSource§fn yanked_diagnostic_applies_to(
&self,
_dep: &dyn Dependency,
_requirement: &VersionReq,
) -> bool
fn yanked_diagnostic_applies_to( &self, _dep: &dyn Dependency, _requirement: &VersionReq, ) -> bool
crate::lsp_helpers::requirement_matches_only_yanked) should evaluate requirement
at all for this ecosystem. Read moreSource§impl OsvNaming for CargoFormatter
impl OsvNaming for CargoFormatter
Source§fn osv_package_name(&self, dep: &dyn Dependency) -> Option<String>
fn osv_package_name(&self, dep: &dyn Dependency) -> Option<String>
dep’s package name, or None if
this dependency cannot be mapped (e.g. a non-GitHub Swift package). Read moreSource§fn osv_version_to_native(&self, version: &str) -> String
fn osv_version_to_native(&self, version: &str) -> String
crate::osv::Advisory::fixed_versions) into this ecosystem’s
own version namespace, as used in manifests and by the registry. Read moreSource§impl PackageNaming for CargoFormatter
impl PackageNaming for CargoFormatter
Source§fn validate_package_name(&self, name: &str) -> Result<(), InvalidPackageName>
fn validate_package_name(&self, name: &str) -> Result<(), InvalidPackageName>
Validates a crate name against crates.io’s naming rules.
crates.io accepts only non-empty names starting with an ASCII letter or _,
followed by ASCII alphanumeric characters plus -/_, up to MAX_NAME_LENGTH
characters. The base charset+non-empty check reuses
sparse::is_safe_crate_name_charset — the same predicate
sparse::is_safe_crate_name builds on for the sparse-index URL-injection
gate — rather than duplicating it. This method deliberately calls the
charset-only variant, not is_safe_crate_name itself: that function also
bundles in a 128-byte URL-safety cap unrelated to crates.io’s real naming
rules, which would make a charset-valid name over 128 bytes report the wrong
“invalid characters” reason instead of reaching this method’s own
MAX_NAME_LENGTH check below. The leading-character rule and
MAX_NAME_LENGTH are layered on top here because they are specific to this
diagnostic-accuracy question, not to URL-splicing safety (see
MAX_NAME_LENGTH’s doc for why the two length caps intentionally differ). A
name that fails this can never resolve on crates.io, so this override lets
the “Invalid package name” diagnostic (deps-core’s
formatter.validate_package_name gate) surface the accurate reason instead
of the generic “Unknown package” a registry-side lookup failure produces
(#382).
The charset check (via sparse::is_safe_crate_name_charset) and the
leading-character check both run before the length check, so a name that is
both non-ASCII and longer than MAX_NAME_LENGTH chars (e.g. a repeated CJK
name) reports the charset violation rather than a misleading “too long” —
the length in bytes of such a name can exceed the limit even when its
character count does not, and vice versa, so the length check counts
chars(), not bytes.
§Errors
Returns InvalidPackageName if name is empty, starts with a digit or
-, contains a character outside [A-Za-z0-9_-] (for example a non-ASCII
name like "日本語"), or exceeds MAX_NAME_LENGTH characters.
Source§fn normalize_package_name(&self, name: &PackageName) -> String
fn normalize_package_name(&self, name: &PackageName) -> String
Source§impl PackageRendering for CargoFormatter
impl PackageRendering for CargoFormatter
Source§fn suppress_package_url(&self, source: &DependencySource) -> bool
fn suppress_package_url(&self, source: &DependencySource) -> bool
Suppresses the hover heading’s crates.io link for any source other than plain
DependencySource::Registry or a verified crates.io mirror (spec FR-014, F2) — a
genuinely different AlternateRegistry resolves against a different index entirely,
so Self::package_url’s crates.io link would point at an unrelated (or simply
nonexistent) public crate once live version data from the real registry renders
beside it. A mirror’s crates.io link stays correct: it is crates.io content, just
fetched elsewhere.
Source§fn format_version_for_text_edit(&self, version: &ConcreteVersion) -> String
fn format_version_for_text_edit(&self, version: &ConcreteVersion) -> String
Source§fn package_url(&self, name: &PackageName) -> String
fn package_url(&self, name: &PackageName) -> String
Source§fn format_version_replacing(
&self,
version: &ConcreteVersion,
_current: &str,
) -> String
fn format_version_replacing( &self, version: &ConcreteVersion, _current: &str, ) -> String
version as a replacement for the existing requirement text
current, preserving current’s operator/pin style where the
ecosystem supports more than one. Read moreSource§fn format_version_replacing_for(
&self,
_dep: &dyn Dependency,
version: &ConcreteVersion,
current: &str,
) -> String
fn format_version_replacing_for( &self, _dep: &dyn Dependency, version: &ConcreteVersion, current: &str, ) -> String
format_version_replacing, but also
carries the dependency identity version/current apply to. Read moreSource§fn is_position_on_dependency(
&self,
dep: &dyn Dependency,
position: Position,
) -> bool
fn is_position_on_dependency( &self, dep: &dyn Dependency, position: Position, ) -> bool
Source§impl RequirementResolution for CargoFormatter
impl RequirementResolution for CargoFormatter
Source§fn compile_requirement(
&self,
requirement: &VersionReq,
) -> Option<Box<dyn RequirementMatcher>>
fn compile_requirement( &self, requirement: &VersionReq, ) -> Option<Box<dyn RequirementMatcher>>
Compiles requirement via semver::VersionReq, the same crate deps-cargo’s
registry uses for matching — precise range semantics (^, ~, comparator lists),
unlike the default version_satisfies_requirement heuristic this method
deliberately does not reuse (see that method’s docs).
Source§fn version_satisfies_requirement(
&self,
version: &ConcreteVersion,
requirement: &str,
) -> bool
fn version_satisfies_requirement( &self, version: &ConcreteVersion, requirement: &str, ) -> bool
Source§fn is_requirement_up_to_date(
&self,
requirement: &VersionReq,
latest: &ConcreteVersion,
) -> bool
fn is_requirement_up_to_date( &self, requirement: &VersionReq, latest: &ConcreteVersion, ) -> bool
latest, given its declared requirement. Read moreSource§fn requirement_is_unresolved(&self, _requirement: &VersionReq) -> bool
fn requirement_is_unresolved(&self, _requirement: &VersionReq) -> bool
requirement could not be resolved to a concrete version constraint (e.g. an
unexpanded property/variable placeholder rather than a real version or range). Read moreSource§fn requirement_status(
&self,
requirement: &VersionReq,
latest: &ConcreteVersion,
) -> RequirementStatus
fn requirement_status( &self, requirement: &VersionReq, latest: &ConcreteVersion, ) -> RequirementStatus
is_requirement_up_to_date that distinguishes “confirmed up to
date” from “could not be resolved, so we don’t know.” Read moreSource§fn requirement_status_for(
&self,
dep: &dyn Dependency,
requirement: &VersionReq,
latest: &ConcreteVersion,
) -> RequirementStatus
fn requirement_status_for( &self, dep: &dyn Dependency, requirement: &VersionReq, latest: &ConcreteVersion, ) -> RequirementStatus
requirement_status, but also hands the ecosystem
the dependency itself — for an ecosystem whose requirement text alone is ambiguous
between two shapes with different resolution rules, and which already computed the
disambiguating classification once, at parse time, onto the dependency (deps-gitlab-ci’s
PinStyle, #466 review M-c: a bare "1.2" is Partial under its component: pin
grammar but Branch under its simpler project: ref grammar — indistinguishable from
the text alone). Read moreSource§fn requirement_is_undecidable_given_available(
&self,
_requirement: &VersionReq,
_available: &[ConcreteVersion],
) -> bool
fn requirement_is_undecidable_given_available( &self, _requirement: &VersionReq, _available: &[ConcreteVersion], ) -> bool
available in a way indistinguishable from “never published” — and, if so, whether
requirement names a version-space region that specific omission could explain, given
the versions actually observed in available. Read moreSource§fn manifest_requirement_is_resolved_version(&self, dep: &dyn Dependency) -> bool
fn manifest_requirement_is_resolved_version(&self, dep: &dyn Dependency) -> bool
dep’s manifest version-requirement line is itself the exact
version already selected — never a range. Read moreSource§impl SourcePolicy for CargoFormatter
impl SourcePolicy for CargoFormatter
Source§fn can_resolve_source(&self, source: &DependencySource) -> bool
fn can_resolve_source(&self, source: &DependencySource) -> bool
Extends the default (crates.io-only) resolvability to a resolved
DependencySource::AlternateRegistry too — CargoRegistry (the value behind
CargoEcosystem::registry()) routes that source to the alternate index’s own
crate::sparse::SparseIndexClient, so it is exactly as resolvable as a plain
DependencySource::Registry dependency, just against a different index (spec
FR-016).
Source§fn source_is_public_registry_content(&self, source: &DependencySource) -> bool
fn source_is_public_registry_content(&self, source: &DependencySource) -> bool
A verified crates.io mirror (AlternateRegistry { mirrors_crates_io: true, .. },
spec plan-1b §1.3, F1/F1b) counts as public-registry content alongside plain
DependencySource::Registry — Cargo verifies per-version checksum equality
against crates.io for a [source.crates-io] replace-with mirror, so its content is
exactly as trustworthy as crates.io’s own for OSV scanning and hover-link purposes,
even though the fetch itself goes to the mirror’s index, not to crates.io.