diff --git a/src/cargo/core/resolver/mod.rs b/src/cargo/core/resolver/mod.rs index 8db8159cad9..54e8517f4e8 100644 --- a/src/cargo/core/resolver/mod.rs +++ b/src/cargo/core/resolver/mod.rs @@ -778,8 +778,6 @@ fn activate_deps_loop<'a>( &mut remaining_candidates, &mut conflicting_activations, ).ok_or_else(|| { - // if we hit an activation error and we are out of other combinations - // then just report that error activation_error( &cx, registry, @@ -827,8 +825,13 @@ fn activate_deps_loop<'a>( // Add an entry to the `backtrack_stack` so // we can try the next one if this one fails. - if has_another && successfully_activated { - backtrack_stack.push(backtrack); + if successfully_activated { + if has_another { + backtrack_stack.push(backtrack); + } + } else { + // `activate` changed `cx` and then failed so put things back. + cx = backtrack.context_backup; } } } diff --git a/tests/testsuite/generate_lockfile.rs b/tests/testsuite/generate_lockfile.rs index efd0c6124ec..8419df1698a 100644 --- a/tests/testsuite/generate_lockfile.rs +++ b/tests/testsuite/generate_lockfile.rs @@ -88,7 +88,7 @@ fn no_index_update() { .build(); assert_that(p.cargo("generate-lockfile"), - execs().with_status(0).with_stdout("") + execs().with_stdout("") .with_stderr_contains(" Updating registry `https://github.com/rust-lang/crates.io-index`")); assert_that(p.cargo("generate-lockfile").masquerade_as_nightly_cargo().arg("-Zno-index-update"),