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

rustdoc ICE 'Deref section without derived id' #81395

Closed
SimonSapin opened this issue Jan 25, 2021 · 7 comments · Fixed by #81491
Closed

rustdoc ICE 'Deref section without derived id' #81395

SimonSapin opened this issue Jan 25, 2021 · 7 comments · Fixed by #81491
Assignees
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@SimonSapin
Copy link
Contributor

SimonSapin commented Jan 25, 2021

Code

Original:

git clone https://gitlab.freedesktop.org/gstreamer/gstreamer-rs
cd gstreamer-rs
RUST_BACKTRACE=1 cargo +nightly doc -p gstreamer-video --no-deps

Minimized:

pub struct Generic<T>(T);

impl<'a> std::ops::Deref for Generic<&'a mut ()> {
    type Target = Generic<&'a ()>;
    fn deref(&self) -> &Self::Target {
        unimplemented!()
    }
}

impl<'a> Generic<&'a ()> {
    pub fn some_method(&self) {}
}

Meta

rustc +nightly --version --verbose:

rustc 1.51.0-nightly (1d0d76f8d 2021-01-24)
binary: rustc
commit-hash: 1d0d76f8dd4f5f6ecbeab575b87edaf1c9f56bb8
commit-date: 2021-01-24
host: x86_64-unknown-linux-gnu
release: 1.51.0-nightly
LLVM version: 11.0.1

Error output

 Documenting gstreamer-video v0.17.0 (/home/simon/projects/servo-deps/gstreamer-rs/gstreamer-video)
thread 'rustc' panicked at 'Deref section without derived id', src/librustdoc/html/render/mod.rs:4427:22
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

error: internal compiler error: unexpected panic

error: Unrecognized option: 'crate-version'

error: could not document `gstreamer-video`
Backtrace

thread 'rustc' panicked at 'Deref section without derived id', src/librustdoc/html/render/mod.rs:4427:22
stack backtrace:
   0: rust_begin_unwind
             at /rustc/1d0d76f8dd4f5f6ecbeab575b87edaf1c9f56bb8/library/std/src/panicking.rs:493:5
   1: core::panicking::panic_fmt
             at /rustc/1d0d76f8dd4f5f6ecbeab575b87edaf1c9f56bb8/library/core/src/panicking.rs:92:14
   2: core::option::expect_failed
             at /rustc/1d0d76f8dd4f5f6ecbeab575b87edaf1c9f56bb8/library/core/src/option.rs:1258:5
   3: rustdoc::html::render::sidebar_deref_methods
   4: rustdoc::html::render::sidebar_assoc_items
   5: rustdoc::html::render::print_sidebar
   6: rustdoc::html::layout::render
   7: rustdoc::html::render::Context::render_item
   8: <rustdoc::html::render::Context as rustdoc::formats::renderer::FormatRenderer>::item
   9: rustdoc::formats::renderer::run_format
  10: rustdoc::run_renderer
  11: rustc_session::utils::<impl rustc_session::session::Session>::time
  12: rustc_interface::passes::QueryContext::enter
  13: rustc_interface::interface::create_compiler_and_run
  14: rustdoc::main_options
  15: scoped_tls::ScopedKey<T>::set

@SimonSapin SimonSapin added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ C-bug Category: This is a bug. labels Jan 25, 2021
@SimonSapin
Copy link
Contributor Author

When running with RUSTDOC_LOG=trace, the last few lines before the panic are:

INFO rustdoc::html::render Recursing into /home/simon/projects/servo-deps/gstreamer-rs/target/doc/gstreamer_video/video_frame
INFO rustdoc::html::render Documenting video_frame
INFO rustdoc::html::render Recursed; leaving /home/simon/projects/servo-deps/gstreamer-rs/target/doc/gstreamer_video/video_frame
INFO rustdoc::html::render Documenting VideoBufferExt
INFO rustdoc::html::render Documenting get_video_flags on Some("VideoBufferExt")
INFO rustdoc::html::render Documenting get_video_flags
INFO rustdoc::html::render Documenting set_video_flags on Some("VideoBufferExt")
INFO rustdoc::html::render Documenting set_video_flags
INFO rustdoc::html::render Documenting unset_video_flags on Some("VideoBufferExt")
INFO rustdoc::html::render Documenting unset_video_flags
INFO rustdoc::html::render Documenting associated items of Some("VideoBufferExt")
INFO rustdoc::html::render Documenting VideoFrameRef
INFO rustdoc::html::render Documenting associated items of Some("VideoFrameRef")
thread 'rustc' panicked at 'Deref section without derived id', src/librustdoc/html/render/mod.rs:4427:22

VideoFrameRef seems relevant since it has a Deref impl:

impl<'a> ops::Deref for VideoFrameRef<&'a mut gst::BufferRef> {
    type Target = VideoFrameRef<&'a gst::BufferRef>;

    fn deref(&self) -> &Self::Target {
        unsafe {
            &*(self as *const VideoFrameRef<&'a mut gst::BufferRef>
                as *const VideoFrameRef<&'a gst::BufferRef>)
        }
    }
}
#[derive(Debug)]
pub struct VideoFrameRef<T> {
    frame: ffi::GstVideoFrame,
    buffer: Option<T>,
    info: crate::VideoInfo,
    unmap: bool,
}

@SimonSapin
Copy link
Contributor Author

Minimized:

pub struct Generic<T>(T);

impl<'a> std::ops::Deref for Generic<&'a mut ()> {
    type Target = Generic<&'a ()>;
    fn deref(&self) -> &Self::Target {
        unimplemented!()
    }
}

impl<'a> Generic<&'a ()> {
    pub fn some_method(&self) {}
}

@SNCPlay42
Copy link
Contributor

searched nightlies: from nightly-2020-11-12 to nightly-2021-01-17
regressed nightly: nightly-2021-01-09
searched commits: from c8915ee to 26438b4
regressed commit: 937f629

bisected with cargo-bisect-rustc v0.6.0

Host triple: x86_64-unknown-linux-gnu
Reproduce with:

cargo bisect-rustc --start=2020-11-12 --end=2021-01-17 --preserve -- doc 

Regressed in #80653.

@rustbot label regression-from-stable-to-nightly

@rustbot rustbot added regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Jan 26, 2021
@jyn514
Copy link
Member

jyn514 commented Jan 26, 2021

cc @jryans - do you have time to figure out what's going wrong here?

@jryans
Copy link
Contributor

jryans commented Jan 26, 2021

Yes, I believe so, I'll see what I can do here.

@rustbot claim

@GuillaumeGomez
Copy link
Member

@jryans Please ping me once you open the PR (@jyn514 is taking a break :) )

@jryans
Copy link
Contributor

jryans commented Jan 28, 2021

The core issue is the Deref recursion cycle handling... It focuses only on DefIds and wasn't anticipating targets that differ only in generic type args. I believe I see the tweak we'll need here, so I should have a PR in the next day or so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. 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.

6 participants