rust-lang / rust-lang/rust-bindgen

How can I get more information about "Should have a used entry for the template arg"?

Open
#2,938 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Rust
Stars
5.3k
Forks
829
Avg merge
1d 1h
Merged PRs (30d)
15

Description

I encountered this panic after upgrading macOS SDK.

It seems to be related to new C++ headers of the SDK. I'd like to check the related types and adding them to blocklist types.

Could you advise how can I check the error causing type names?

Error messages:

thread 'main' panicked at /opt/cargo/registry/src/index.crates.io-6f17d22bba15001f/bindgen-0.70.1/ir/analysis/template_params.rs:254:22:
  Should have a used entry for the template arg
  stack backtrace:
     0: rust_begin_unwind
               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/panicking.rs:652:5
     1: core::panicking::panic_fmt
               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/panicking.rs:72:14
     2: core::panicking::panic_display
               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/panicking.rs:263:5
     3: core::option::expect_failed
               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/option.rs:1994:5
     4: core::option::Option<T>::expect
               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/option.rs:895:21
     5: bindgen::ir::analysis::template_params::UsedTemplateParameters::constrain_instantiation_of_blocklisted_template::{{closure}}
               at /opt/cargo/registry/src/index.crates.io-6f17d22bba15001f/bindgen-0.70.1/ir/analysis/template_params.rs:252:17
     6: core::iter::adapters::map::map_fold::{{closure}}
               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/iter/adapters/map.rs:89:28
     7: core::iter::adapters::filter::filter_fold::{{closure}}
               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/iter/adapters/filter.rs:41:44
     8: core::iter::adapters::map::map_fold::{{closure}}
               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/iter/adapters/map.rs:89:21
     9: <core::slice::iter::Iter<T> as core::iter::traits::iterator::Iterator>::fold
               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/slice/iter/macros.rs:230:27
    10: <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::fold
               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/iter/adapters/map.rs:129:9
    11: <core::iter::adapters::filter::Filter<I,P> as core::iter::traits::iterator::Iterator>::fold
               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/iter/adapters/filter.rs:157:9
    12: <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::fold
               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/iter/adapters/map.rs:129:9
    13: <core::iter::adapters::fuse::Fuse<I> as core::iter::traits::iterator::Iterator>::fold
               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/iter/adapters/fuse.rs:98:19
    14: core::iter::adapters::flatten::FlattenCompat<I,U>::iter_fold
               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/iter/adapters/flatten.rs:482:15
    15: <core::iter::adapters::flatten::FlattenCompat<I,U> as core::iter::traits::iterator::Iterator>::fold
               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/iter/adapters/flatten.rs:668:9
    16: <core::iter::adapters::flatten::FlatMap<I,U,F> as core::iter::traits::iterator::Iterator>::fold
               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/iter/adapters/flatten.rs:89:9
    17: core::iter::traits::iterator::Iterator::for_each
               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/iter/traits/iterator.rs:818:9
    18: <alloc::collections::btree::set::BTreeSet<T,A> as core::iter::traits::collect::Extend<T>>::extend
               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/alloc/src/collections/btree/set.rs:1321:9
    19: bindgen::ir::analysis::template_params::UsedTemplateParameters::constrain_instantiation_of_blocklisted_template
               at /opt/cargo/registry/src/index.crates.io-6f17d22bba15001f/bindgen-0.70.1/ir/analysis/template_params.rs:265:9
    20: <bindgen::ir::analysis::template_params::UsedTemplateParameters as bindgen::ir::analysis::MonotoneFramework>::constrain
               at /opt/cargo/registry/src/index.crates.io-6f17d22bba15001f/bindgen-0.70.1/ir/analysis/template_params.rs:553:21
    21: bindgen::ir::analysis::analyze
               at /opt/cargo/registry/src/index.crates.io-6f17d22bba15001f/bindgen-0.70.1/ir/analysis/mod.rs:166:43
    22: bindgen::ir::context::BindgenContext::find_used_template_parameters
               at /opt/cargo/registry/src/index.crates.io-6f17d22bba15001f/bindgen-0.70.1/ir/context.rs:1371:31
    23: bindgen::ir::context::BindgenContext::gen
               at /opt/cargo/registry/src/index.crates.io-6f17d22bba15001f/bindgen-0.70.1/ir/context.rs:1223:9
    24: bindgen::codegen::codegen
               at /opt/cargo/registry/src/index.crates.io-6f17d22bba15001f/bindgen-0.70.1/codegen/mod.rs:4963:5
    25: bindgen::Bindings::generate
               at /opt/cargo/registry/src/index.crates.io-6f17d22bba15001f/bindgen-0.70.1/lib.rs:907:13
    26: bindgen::Builder::generate
               at /opt/cargo/registry/src/index.crates.io-6f17d22bba15001f/bindgen-0.70.1/lib.rs:349:9
    27: build_script_build::main
               at ./build.rs:828:20
    28: core::ops::function::FnOnce::call_once
               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/ops/function.rs:250:5

Related code: https://github.com/rust-lang/rust-bindgen/blob/main/bindgen/ir/analysis/template_params.rs#L240-L263

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at bindgen/ir/analysis/template_params.rs lines 240-263 and the build.rs:828 generation call shown in the trace; reproduce the panic after the macOS SDK upgrade and inspect the template-parameter/blocklist path. Done means identifying the offending type names and documenting how to inspect or blocklist them.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, rust
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.