Skip to content

[patch] with duplicate values causes panic #7264

@ehuss

Description

@ehuss

Problem
A [patch] table with multiple values using package can cause a panic.

[package]
name = "foo"
version = "0.1.0"
edition = "2018"

[dependencies]
bitflags = "1.0"

[patch.crates-io]
bitflags = {git="https://github.com/bitflags/bitflags.git"}
bitflags2 = {git="https://github.com/bitflags/bitflags.git", package="bitflags"}

Results in:

    Updating git repository `https://github.com/bitflags/bitflags.git`
thread 'main' panicked at 'assertion failed: remaining.next().is_none()', src/tools/cargo/src/cargo/core/registry.rs:648:13
stack backtrace:
   0: std::panicking::default_hook::{{closure}}
   1: std::panicking::default_hook
   2: std::panicking::rust_panic_with_hook
   3: std::panicking::begin_panic
   4: <core::iter::adapters::Map<I,F> as core::iter::traits::iterator::Iterator>::fold
   5: <alloc::vec::Vec<T> as alloc::vec::SpecExtend<T,I>>::from_iter
   6: cargo::core::summary::Summary::map_dependencies
   7: cargo::core::registry::lock
   8: cargo::ops::resolve::resolve_with_previous
   9: cargo::ops::resolve::resolve_with_registry
  10: cargo::ops::resolve::resolve_ws_with_method
  11: cargo::ops::cargo_compile::compile_ws
  12: cargo::ops::cargo_compile::compile
  13: cargo::commands::build::exec
  14: cargo::cli::main
  15: cargo::main
  16: std::rt::lang_start::{{closure}}
  17: std::panicking::try::do_call
  18: __rust_maybe_catch_panic
  19: std::rt::lang_start_internal
  20: main

Notes

This appears to happen ever since package renaming was introduced up to latest nightly-2019-08-19.

Obviously you shouldn't have two patches to the same location, but it shouldn't panic.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-dependency-resolutionArea: dependency resolution and the resolverA-patchArea: [patch] table overrideC-bugCategory: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions