Description
Problem
The unstable scrape examples feature seems to somehow rely on some implicit reuse behavior that doesn't hold when users override settings in profiles causing dependencies to be built more than once.
I've noticed this with all the scrape-examples tests when changing these defaults to values users can already provide.
Steps
So for example, a simple project setup like the scrape_examples_basic
test ("foo/src/lib.rs" & "foo/examples/ex.rs") can make cargo panic by changing the foo
crate's profiles like:
- changing the panic method:
[profile.dev]
panic = "abort"
- opting into stripping:
[profile.dev]
strip = true
- changing the build-dependencies profile (strange because that example doesn't seem to have build dependencies ?) with either of the following 3 settings:
[profile.dev.build-override]
debug = 0
strip = true
incremental = false
It's unlikely that this list is exhaustive, as it's more about the fact that the dependencies and deduplication are different when these settings are used, I guess ?
Any of the changes above will make cargo panic like so, on nightly or master:
> cargo doc -Zunstable-options -Z rustdoc-scrape-examples=examples -v
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', src/tools/cargo/src/cargo/ops/cargo_compile.rs:1594:36
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Backtrace
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', src/cargo/ops/cargo_compile.rs:1596:28
stack backtrace:
0: rust_begin_unwind
at /rustc/f0c4da49983aa699f715caf681e3154b445fb60b/library/std/src/panicking.rs:584:5
1: core::panicking::panic_fmt
at /rustc/f0c4da49983aa699f715caf681e3154b445fb60b/library/core/src/panicking.rs:143:14
2: core::panicking::panic
at /rustc/f0c4da49983aa699f715caf681e3154b445fb60b/library/core/src/panicking.rs:48:5
3: core::option::Option<T>::unwrap
at /rustc/f0c4da49983aa699f715caf681e3154b445fb60b/library/core/src/option.rs:752:21
4: cargo::ops::cargo_compile::rebuild_unit_graph_shared::{{closure}}
at ./cargo/src/cargo/ops/cargo_compile.rs:1596:13
5: core::iter::adapters::map::map_fold::{{closure}}
at /rustc/f0c4da49983aa699f715caf681e3154b445fb60b/library/core/src/iter/adapters/map.rs:84:28
6: core::iter::traits::iterator::Iterator::fold
at /rustc/f0c4da49983aa699f715caf681e3154b445fb60b/library/core/src/iter/traits/iterator.rs:2285:21
7: <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::fold
at /rustc/f0c4da49983aa699f715caf681e3154b445fb60b/library/core/src/iter/adapters/map.rs:124:9
8: core::iter::traits::iterator::Iterator::for_each
at /rustc/f0c4da49983aa699f715caf681e3154b445fb60b/library/core/src/iter/traits/iterator.rs:773:9
9: <alloc::vec::Vec<T,A> as alloc::vec::spec_extend::SpecExtend<T,I>>::spec_extend
at /rustc/f0c4da49983aa699f715caf681e3154b445fb60b/library/alloc/src/vec/spec_extend.rs:40:17
10: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter_nested::SpecFromIterNested<T,I>>::from_iter
at /rustc/f0c4da49983aa699f715caf681e3154b445fb60b/library/alloc/src/vec/spec_from_iter_nested.rs:62:9
11: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
at /rustc/f0c4da49983aa699f715caf681e3154b445fb60b/library/alloc/src/vec/spec_from_iter.rs:33:9
12: <alloc::vec::Vec<T> as core::iter::traits::collect::FromIterator<T>>::from_iter
at /rustc/f0c4da49983aa699f715caf681e3154b445fb60b/library/alloc/src/vec/mod.rs:2552:9
13: core::iter::traits::iterator::Iterator::collect
at /rustc/f0c4da49983aa699f715caf681e3154b445fb60b/library/core/src/iter/traits/iterator.rs:1778:9
14: cargo::ops::cargo_compile::rebuild_unit_graph_shared
at ./cargo/src/cargo/ops/cargo_compile.rs:1592:28
15: cargo::ops::cargo_compile::create_bcx
at ./cargo/src/cargo/ops/cargo_compile.rs:607:25
16: cargo::ops::cargo_compile::compile_ws
at ./cargo/src/cargo/ops/cargo_compile.rs:285:15
17: cargo::ops::cargo_compile::compile_with_exec
at ./cargo/src/cargo/ops/cargo_compile.rs:276:5
18: cargo::ops::cargo_compile::compile
at ./cargo/src/cargo/ops/cargo_compile.rs:265:5
19: cargo::ops::cargo_doc::doc
at ./cargo/src/cargo/ops/cargo_doc.rs:20:23
20: cargo::commands::doc::exec
at ./cargo/src/bin/cargo/commands/doc.rs:56:5
21: cargo::cli::execute_subcommand
at ./cargo/src/bin/cargo/cli.rs:369:16
22: cargo::cli::main
at ./cargo/src/bin/cargo/cli.rs:176:5
23: cargo::main
at ./cargo/src/bin/cargo/main.rs:37:13
24: core::ops::function::FnOnce::call_once
at /rustc/f0c4da49983aa699f715caf681e3154b445fb60b/library/core/src/ops/function.rs:227:5
Version
any recent nighty or master