Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

attempted .def_id() on invalid res: Err in rustdoc for pub(restricted) struct fields using derive helper macros #67006

Closed
ollie27 opened this issue Dec 4, 2019 · 4 comments · Fixed by #67106
Assignees
Labels
A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) A-resolve Area: Name resolution A-visibility Area: Visibility / privacy C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-high High priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@ollie27
Copy link
Member

ollie27 commented Dec 4, 2019

Originally from #64705 (comment) and #64705 (comment).

Reduced down to

Cargo.toml:

[package]
name = "repro-ironoxide"
version = "0.1.0"
edition = "2018"

[dependencies]
serde = { version = "~1.0", features = ["derive"] }

lib.rs:

mod internal {
    use serde::Serialize;
    #[derive(Serialize)]
    pub struct GroupAdmin {
        #[serde(flatten)]
        pub(in crate::internal) encrypted_msg: (),
    }
}
backtrace
error: internal compiler error: src\librustc\hir\def.rs:385: attempted .def_id() on invalid res: Err

thread 'rustc' panicked at 'Box<Any>', src\librustc_errors\lib.rs:892:9
stack backtrace:
   0: backtrace::backtrace::trace_unsynchronized<closure-1>
             at C:\Users\Oliver\AppData\Local\Cargo\registry\src\github.com-1ecc6299db9ec823\backtrace-0.3.40\src\backtrace\mod.rs:66
   1: std::sys_common::backtrace::_print_fmt
             at C:\Source\rust\src\libstd\sys_common\backtrace.rs:84
   2: std::sys_common::backtrace::_print::{{impl}}::fmt
             at C:\Source\rust\src\libstd\sys_common\backtrace.rs:61
   3: core::fmt::write
             at C:\Source\rust\src\libcore\fmt\mod.rs:1024
   4: std::io::Write::write_fmt<std::sys::windows::stdio::Stderr>
             at C:\Source\rust\src\libstd\io\mod.rs:1428
   5: std::sys_common::backtrace::_print
             at C:\Source\rust\src\libstd\sys_common\backtrace.rs:65
   6: std::sys_common::backtrace::print
             at C:\Source\rust\src\libstd\sys_common\backtrace.rs:50
   7: std::panicking::default_hook::{{closure}}
             at C:\Source\rust\src\libstd\panicking.rs:193
   8: std::panicking::default_hook
             at C:\Source\rust\src\libstd\panicking.rs:210
   9: std::panicking::rust_panic_with_hook
             at C:\Source\rust\src\libstd\panicking.rs:471
  10: std::panicking::begin_panic<rustc_errors::ExplicitBug>
             at C:\Source\rust\src\libstd\panicking.rs:404
  11: rustc_errors::HandlerInner::bug
             at C:\Source\rust\src\librustc_errors\lib.rs:892
  12: rustc_errors::Handler::bug
             at C:\Source\rust\src\librustc_errors\lib.rs:658
  13: rustc::util::bug::opt_span_bug_fmt::{{closure}}<syntax_pos::span_encoding::Span>
             at C:\Source\rust\src\librustc\util\bug.rs:36
  14: rustc::ty::context::tls::with_opt::{{closure}}<closure-0,!>
             at C:\Source\rust\src\librustc\ty\context.rs:1964
  15: rustc::ty::context::tls::with_context_opt<closure-0,!>
             at C:\Source\rust\src\librustc\ty\context.rs:1914
  16: rustc::ty::context::tls::with_opt<closure-0,!>
             at C:\Source\rust\src\librustc\ty\context.rs:1964
  17: rustc::util::bug::opt_span_bug_fmt<syntax_pos::span_encoding::Span>
             at C:\Source\rust\src\librustc\util\bug.rs:32
  18: rustc::util::bug::bug_fmt
             at C:\Source\rust\src\librustc\util\bug.rs:12
  19: rustc::hir::def::{{impl}}::def_id::{{closure}}<rustc::hir::HirId>
             at C:\Source\rust\src\librustc\macros.rs:42
  20: core::option::Option<rustc::hir::def_id::DefId>::unwrap_or_else
             at C:\Source\rust\src\libcore\option.rs:422
  21: rustc::hir::def::Res<rustc::hir::HirId>::def_id
             at C:\Source\rust\src\librustc\hir\def.rs:384
  22: rustdoc::clean::register_res
             at C:\Source\rust\src\librustdoc\clean\mod.rs:4327
  23: rustdoc::clean::{{impl}}::clean
             at C:\Source\rust\src\librustdoc\clean\mod.rs:3331
  24: rustdoc::clean::{{impl}}::clean
             at C:\Source\rust\src\librustdoc\clean\mod.rs:3291
  25: rustdoc::clean::{{impl}}::clean::{{closure}}
             at C:\Source\rust\src\librustdoc\clean\mod.rs:3414
  26: core::iter::adapters::map_fold::{{closure}}
             at C:\Source\rust\src\libcore\iter\adapters\mod.rs:704
  27: core::iter::traits::iterator::Iterator::fold::ok::{{closure}}
             at C:\Source\rust\src\libcore\iter\traits\iterator.rs:1829
  28: core::iter::traits::iterator::Iterator::try_fold
             at C:\Source\rust\src\libcore\iter\traits\iterator.rs:1710
  29: core::iter::traits::iterator::Iterator::fold
             at C:\Source\rust\src\libcore\iter\traits\iterator.rs:1832
  30: core::iter::adapters::{{impl}}::fold
             at C:\Source\rust\src\libcore\iter\adapters\mod.rs:737
  31: core::iter::traits::iterator::Iterator::for_each
             at C:\Source\rust\src\libcore\iter\traits\iterator.rs:632
  32: alloc::vec::{{impl}}::spec_extend
             at C:\Source\rust\src\liballoc\vec.rs:2022
  33: alloc::vec::{{impl}}::from_iter<rustdoc::clean::Item,core::iter::adapters::Map<core::slice::Iter<rustc::hir::StructField>, closure-0>>
             at C:\Source\rust\src\liballoc\vec.rs:2005
  34: alloc::vec::{{impl}}::from_iter
             at C:\Source\rust\src\liballoc\vec.rs:1892
  35: core::iter::traits::iterator::Iterator::collect
             at C:\Source\rust\src\libcore\iter\traits\iterator.rs:1494
  36: rustdoc::clean::{{impl}}::clean
             at C:\Source\rust\src\librustdoc\clean\mod.rs:85
  37: rustdoc::clean::{{impl}}::clean
             at C:\Source\rust\src\librustdoc\clean\mod.rs:3373
  38: rustdoc::clean::{{impl}}::clean::{{closure}}
             at C:\Source\rust\src\librustdoc\clean\mod.rs:601
  39: core::iter::adapters::map_fold::{{closure}}
             at C:\Source\rust\src\libcore\iter\adapters\mod.rs:704
  40: core::iter::traits::iterator::Iterator::fold::ok::{{closure}}
             at C:\Source\rust\src\libcore\iter\traits\iterator.rs:1829
  41: core::iter::traits::iterator::Iterator::try_fold
             at C:\Source\rust\src\libcore\iter\traits\iterator.rs:1710
  42: core::iter::traits::iterator::Iterator::fold
             at C:\Source\rust\src\libcore\iter\traits\iterator.rs:1832
  43: core::iter::adapters::{{impl}}::fold
             at C:\Source\rust\src\libcore\iter\adapters\mod.rs:737
  44: core::iter::traits::iterator::Iterator::for_each
             at C:\Source\rust\src\libcore\iter\traits\iterator.rs:632
  45: alloc::vec::{{impl}}::spec_extend
             at C:\Source\rust\src\liballoc\vec.rs:2022
  46: alloc::vec::{{impl}}::extend
             at C:\Source\rust\src\liballoc\vec.rs:1960
  47: rustdoc::clean::{{impl}}::clean
             at C:\Source\rust\src\librustdoc\clean\mod.rs:601
  48: rustdoc::clean::{{impl}}::clean::{{closure}}
             at C:\Source\rust\src\librustdoc\clean\mod.rs:606
  49: core::iter::adapters::map_fold::{{closure}}
             at C:\Source\rust\src\libcore\iter\adapters\mod.rs:704
  50: core::iter::traits::iterator::Iterator::fold::ok::{{closure}}
             at C:\Source\rust\src\libcore\iter\traits\iterator.rs:1829
  51: core::iter::traits::iterator::Iterator::try_fold
             at C:\Source\rust\src\libcore\iter\traits\iterator.rs:1710
  52: core::iter::traits::iterator::Iterator::fold
             at C:\Source\rust\src\libcore\iter\traits\iterator.rs:1832
  53: core::iter::adapters::{{impl}}::fold
             at C:\Source\rust\src\libcore\iter\adapters\mod.rs:737
  54: core::iter::traits::iterator::Iterator::for_each
             at C:\Source\rust\src\libcore\iter\traits\iterator.rs:632
  55: alloc::vec::{{impl}}::spec_extend
             at C:\Source\rust\src\liballoc\vec.rs:2022
  56: alloc::vec::{{impl}}::extend
             at C:\Source\rust\src\liballoc\vec.rs:1960
  57: rustdoc::clean::{{impl}}::clean
             at C:\Source\rust\src\librustdoc\clean\mod.rs:606
  58: rustdoc::clean::krate
             at C:\Source\rust\src\librustdoc\clean\mod.rs:161
  59: rustc::ty::context::tls::enter_global<closure-0,(rustdoc::clean::Crate, rustdoc::html::render::RenderInfo, rustdoc::config::RenderOptions)>
             at C:\Source\rust\src\librustc\ty\context.rs:1867
  60: rustdoc::core::run_core::{{closure}}::{{closure}}
             at C:\Source\rust\src\librustdoc\core.rs:379
  61: rustc_interface::interface::Compiler::enter
             at C:\Source\rust\src\librustc_interface\queries.rs:335
  62: rustdoc::core::run_core::{{closure}}
             at C:\Source\rust\src\librustdoc\core.rs:346
  63: rustc_interface::interface::run_compiler_in_existing_thread_pool<(rustdoc::clean::Crate, rustdoc::html::render::RenderInfo, rustdoc::config::RenderOptions),closure-6>
             at C:\Source\rust\src\librustc_interface\interface.rs:179
  64: rustdoc::core::run_core
             at C:\Source\rust\src\librustdoc\core.rs:346
  65: rustdoc::rust_input::{{closure}}
             at C:\Source\rust\src\librustdoc\lib.rs:485
  66: std::panic::{{impl}}::call_once<i32,closure-0>
             at C:\Source\rust\src\libstd\panic.rs:318
  67: std::panicking::try::do_call<std::panic::AssertUnwindSafe<closure-0>,i32>
             at C:\Source\rust\src\libstd\panicking.rs:292
  68: panic_unwind::__rust_maybe_catch_panic
             at C:\Source\rust\src\libpanic_unwind\lib.rs:81
  69: std::panicking::try
             at C:\Source\rust\src\libstd\panicking.rs:270
  70: std::panic::catch_unwind
             at C:\Source\rust\src\libstd\panic.rs:394
  71: rustc_driver::catch_fatal_errors<closure-0,i32>
             at C:\Source\rust\src\librustc_driver\lib.rs:1143
  72: rustdoc::rust_input
             at C:\Source\rust\src\librustdoc\lib.rs:482
  73: rustdoc::main_options
             at C:\Source\rust\src\librustdoc\lib.rs:441
  74: rustdoc::main_args::{{closure}}
             at C:\Source\rust\src\librustdoc\lib.rs:414
  75: rustc_interface::util::spawn_thread_pool::{{closure}}::{{closure}}::{{closure}}::{{closure}}
             at C:\Source\rust\src\librustc_interface\util.rs:167
  76: rustc::ty::context::tls::with_thread_locals::{{closure}}::{{closure}}
             at C:\Source\rust\src\librustc\ty\context.rs:1824
  77: std::thread::local::LocalKey<core::cell::Cell<fn(rustc_errors::diagnostic::Diagnostic*)>>::try_with
             at C:\Source\rust\src\libstd\thread\local.rs:262
  78: std::thread::local::LocalKey<core::cell::Cell<fn(rustc_errors::diagnostic::Diagnostic*)>>::with
             at C:\Source\rust\src\libstd\thread\local.rs:239
  79: rustc::ty::context::tls::with_thread_locals::{{closure}}
             at C:\Source\rust\src\librustc\ty\context.rs:1816
  80: std::thread::local::LocalKey<core::cell::Cell<fn(syntax_pos::span_encoding::Span, mut core::fmt::Formatter*) -> core::result::Result<(), core::fmt::Error>>>::try_with
             at C:\Source\rust\src\libstd\thread\local.rs:262
  81: std::thread::local::LocalKey<core::cell::Cell<fn(syntax_pos::span_encoding::Span, mut core::fmt::Formatter*) -> core::result::Result<(), core::fmt::Error>>>::with<core::cell::Cell<fn(syntax_pos::span_encoding::Span, mut core::fmt::Formatter*) -> core::res
             at C:\Source\rust\src\libstd\thread\local.rs:239
  82: rustc::ty::context::tls::with_thread_locals
             at C:\Source\rust\src\librustc\ty\context.rs:1808
  83: rustc_interface::util::spawn_thread_pool::{{closure}}::{{closure}}::{{closure}}
             at C:\Source\rust\src\librustc_interface\util.rs:167
  84: scoped_tls::ScopedKey<rustc_data_structures::sync::Lock<usize>>::set
             at C:\Users\Oliver\AppData\Local\Cargo\registry\src\github.com-1ecc6299db9ec823\scoped-tls-1.0.0\src\lib.rs:137
  85: rustc_interface::util::spawn_thread_pool::{{closure}}::{{closure}}
             at C:\Source\rust\src\librustc_interface\util.rs:163
  86: scoped_tls::ScopedKey<syntax_pos::Globals>::set
             at C:\Users\Oliver\AppData\Local\Cargo\registry\src\github.com-1ecc6299db9ec823\scoped-tls-1.0.0\src\lib.rs:137
  87: syntax::with_globals::{{closure}}
             at C:\Source\rust\src\libsyntax\lib.rs:62
  88: scoped_tls::ScopedKey<syntax::Globals>::set<syntax::Globals,closure-0,i32>
             at C:\Users\Oliver\AppData\Local\Cargo\registry\src\github.com-1ecc6299db9ec823\scoped-tls-1.0.0\src\lib.rs:137
  89: syntax::with_globals<closure-0,i32>
             at C:\Source\rust\src\libsyntax\lib.rs:61
  90: rustc_interface::util::scoped_thread::{{closure}}
             at C:\Source\rust\src\librustc_interface\util.rs:139
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
error: aborting due to previous error

error: Could not document `repro-ironoxide`.

This bisects to 5c5b8af namely #64694 (cc. @petrochenkov). This may have the same root cause as #64705 because again we're seeing a Def::Err in the path for pub(in crate::internal).

@ollie27 ollie27 added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. A-resolve Area: Name resolution I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ I-nominated A-visibility Area: Visibility / privacy A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-bug Category: This is a bug. labels Dec 4, 2019
@Centril

This comment has been minimized.

@pnkfelix
Copy link
Member

pnkfelix commented Dec 5, 2019

triage: already assigned. P-high, removing nomination.

@pnkfelix pnkfelix added P-high High priority and removed I-nominated labels Dec 5, 2019
@petrochenkov
Copy link
Contributor

petrochenkov commented Dec 6, 2019

The root issue is in rustc, not in rustdoc.
Field visibility resolution swallows errors somehow if non-builtin attributes are involved.

Minimized:

struct S {
    #[rustfmt::skip]
    pub(in nonexistent) field: u8 // OK, but should be an error
}

fn main() {}

This is a regression from 1.39 (with #63468 being the likely reason).

@petrochenkov petrochenkov added regression-from-stable-to-stable Performance or correctness regression from one stable version to another. and removed regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. labels Dec 6, 2019
@petrochenkov
Copy link
Contributor

Fixed in #67106.

@bors bors closed this as completed in 5c6941b Dec 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) A-resolve Area: Name resolution A-visibility Area: Visibility / privacy C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-high High priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants