cargo::core

Enum SourceKind

Source
pub enum SourceKind {
    Git(GitReference),
    Path,
    Registry,
    SparseRegistry,
    LocalRegistry,
    Directory,
}
Expand description

The possible kinds of code source.

Variants§

§

Git(GitReference)

A git repository.

§

Path

A local path.

§

Registry

A remote registry.

§

SparseRegistry

A sparse registry.

§

LocalRegistry

A local filesystem-based registry.

§

Directory

A directory-based registry.

Implementations§

Trait Implementations§

Source§

impl Clone for SourceKind

Source§

fn clone(&self) -> SourceKind

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SourceKind

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Hash for SourceKind

Source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for SourceKind

Note that this is specifically not derived on SourceKind although the implementation here is very similar to what it might look like if it were otherwise derived.

The reason for this is somewhat obtuse. First of all the hash value of SourceKind makes its way into ~/.cargo/registry/index/github.com-XXXX which means that changes to the hash means that all Rust users need to redownload the crates.io index and all their crates. If possible we strive to not change this to make this redownloading behavior happen as little as possible. How is this connected to Ord you might ask? That’s a good question!

Since the beginning of time SourceKind has had #[derive(Hash)]. It for the longest time also derived the Ord and PartialOrd traits. In #8522, however, the implementation of Ord changed. This handwritten implementation forgot to sync itself with the originally derived implementation, namely placing git dependencies as sorted after all other dependencies instead of first as before.

This regression in #8522 (Rust 1.47) went unnoticed. When we switched back to a derived implementation in #9133 (Rust 1.52 beta) we only then ironically saw an issue (#9334). In #9334 it was observed that stable Rust at the time (1.51) was sorting git dependencies last, whereas Rust 1.52 beta would sort git dependencies first. This is because the PartialOrd implementation in 1.51 used #8522, the buggy implementation, which put git deps last. In 1.52 it was (unknowingly) restored to the pre-1.47 behavior with git dependencies first.

Because the breakage was only witnessed after the original breakage, this trait implementation is preserving the “broken” behavior. Put a different way:

  • Rust pre-1.47 sorted git deps first.
  • Rust 1.47 to Rust 1.51 sorted git deps last, a breaking change (#8522) that was never noticed.
  • Rust 1.52 restored the pre-1.47 behavior (#9133, without knowing it did so), and breakage was witnessed by actual users due to difference with 1.51.
  • Rust 1.52 (the source as it lives now) was fixed to match the 1.47-1.51 behavior (#9383), which is now considered intentionally breaking from the pre-1.47 behavior.

Note that this was all discovered when Rust 1.53 was in nightly and 1.52 was in beta. #9133 was in both beta and nightly at the time of discovery. For 1.52 #9383 reverted #9133, meaning 1.52 is the same as 1.51. On nightly (1.53) #9397 was created to fix the regression introduced by #9133 relative to the current stable (1.51).

That’s all a long winded way of saying “it’s weird that git deps hash first and are sorted last, but it’s the way it is right now”. The author of this comment chose to handwrite the Ord implementation instead of the Hash implementation, but it’s only required that at most one of them is hand-written because the other can be derived. Perhaps one day in the future someone can figure out how to remove this behavior.

Source§

fn cmp(&self, other: &SourceKind) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for SourceKind

Source§

fn eq(&self, other: &SourceKind) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for SourceKind

Forwards to Ord

Source§

fn partial_cmp(&self, other: &SourceKind) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Eq for SourceKind

Source§

impl StructuralPartialEq for SourceKind

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
§

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more

Layout§

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.

Size: 32 bytes

Size for each variant:

  • Git: 32 bytes
  • Path: 0 bytes
  • Registry: 0 bytes
  • SparseRegistry: 0 bytes
  • LocalRegistry: 0 bytes
  • Directory: 0 bytes