Skip to content

rustdoc fails at 'not a doc-comment' #15976

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

Closed
SimonSapin opened this issue Jul 25, 2014 · 1 comment · Fixed by #16766
Closed

rustdoc fails at 'not a doc-comment' #15976

SimonSapin opened this issue Jul 25, 2014 · 1 comment · Fixed by #16766
Labels
T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@SimonSapin
Copy link
Contributor

Apparently, desugar_doc tries to call strip_doc_comment_decoration to convert to "desugar" a comment that was not "sugared" in the first place.

Test case:

This bug is not triggered if the comment is moved to the crate top-level (rather than a module), or when running rustdoc on a.rs directly

a.rs

pub mod a { #![doc = "Test"] }

b.rs

extern crate a;

Build commands and output:

$ rustc --crate-type lib a.rs
$ RUST_BACKTRACE=1 rustdoc b.rs -L .
task '<unnamed>' failed at 'not a doc-comment: Test', /home/rustbuild/src/rust-buildbot/slave/nightly-linux/build/src/libsyntax/ast_util.rs:784
stack backtrace:
   1:     0x7f698a7645f0 - rt::backtrace::imp::write::h196d0788fd5af7e2J7p
   2:     0x7f698a7678f0 - failure::on_fail::h19a8129d7de62dbfYsq
   3:     0x7f698f60b3f0 - unwind::begin_unwind_inner::h7290ff1071e375d5VTd
   4:     0x7f698f60b070 - unwind::begin_unwind_fmt::hf1eab6137b01c57f4Qd
   5:     0x7f698b2f4bc0 - parse::lexer::comments::strip_doc_comment_decoration::h52bebd21516a3103KnF
   6:     0x7f698b2f4560 - attr::Attribute.AttributeMethods::desugar_doc::h7a442bdc81fe475ah5z
   7:     0x7f698fbbb160 - clean::ast..Attribute.Clean<Attribute>::clean::hd76d78f14d0f290auLb
   8:     0x7f698fbbafa0 - clean::inline::load_attrs::closure.$x22closure$x22$LP$20267$RP$
   9:     0x7f698fbb97b0 - clean::inline::load_attrs::closure.$x22closure$x22$LP$20195$RP$
  10:     0x7f698e764110 - metadata::decoder::get_item_attrs::h77c4d1d788ecba74Ucs
  11:     0x7f698e34c5e0 - metadata::csearch::get_item_attrs::hb646accdef04951coju
  12:     0x7f698fbdad10 - clean::cstore..crate_metadata.Clean<ExternalCrate>::clean::closure.$x22closure$x22$LP$22274$RP$
  13:     0x7f698e75a480 - metadata::decoder::each_child_of_item_or_crate::closure.$x22closure$x22$LP$132187$RP$
  14:     0x7f698af4acf0 - ebml::reader::tagged_docs::h21531a795db2c3e7Bif
  15:     0x7f698e75a160 - metadata::decoder::each_child_of_item_or_crate::h1c9197ded6464680IFr
  16:     0x7f698e75bf00 - metadata::decoder::each_top_level_item_of_crate::hfac63c9cf5ae2ee3PNr
  17:     0x7f698e20db70 - metadata::csearch::each_top_level_item_of_crate::hc7c15deef877aab6Nau
  18:     0x7f698fbd7cf0 - clean::cstore..crate_metadata.Clean<ExternalCrate>::clean::heb2e784f535b3f79YMa
  19:     0x7f698fbd7a50 - clean::visit_ast..RustdocVisitor<'a>.Clean<Crate>::clean::closure.$x22closure$x22$LP$22227$RP$
  20:     0x7f698e164a20 - metadata::cstore::CStore::iter_crate_data::h3d5af457708f90c8TUt
  21:     0x7f698fbd6870 - clean::visit_ast..RustdocVisitor<'a>.Clean<Crate>::clean::h70c51df18eff4f69HEa
  22:     0x7f698fc27190 - core::run_core::hebd872ca8878a181wJh
  23:     0x7f698fcf7250 - rust_input::closure.$x22closure$x22$LP$29353$RP$
  24:     0x7f698fcee460 - task::TaskBuilder<S>::try_future::closure.$x22closure$x22$LP$29159$RP$
  25:     0x7f698f95d750 - task::spawn_opts::closure.$x22closure$x22$LP$8216$RP$
  26:     0x7f698f6622c0 - rust_try
  27:     0x7f698f6086d0 - unwind::try::hc5b79cf0d453a48a0Hd
  28:     0x7f698f608430 - task::Task::run::h573b47a3c64dd74bQSc
  29:     0x7f698f95d540 - task::spawn_opts::closure.$x22closure$x22$LP$8162$RP$
  30:     0x7f698f60a4a0 - thread::thread_start::hcb4d88eeb2fea24bUfd
  31:     0x7f698a208060 - start_thread
  32:     0x7f698f2e0489 - __clone
  33:                0x0 - <unknown>
task '<main>' failed at 'called `Result::unwrap()` on an `Err` value: Box<core::any::Any:Send>', /home/rustbuild/src/rust-buildbot/slave/nightly-linux/build/src/libcore/result.rs:548
stack backtrace:
   1:     0x7f698a7645f0 - rt::backtrace::imp::write::h196d0788fd5af7e2J7p
   2:     0x7f698a7678f0 - failure::on_fail::h19a8129d7de62dbfYsq
   3:     0x7f698f60b3f0 - unwind::begin_unwind_inner::h7290ff1071e375d5VTd
   4:     0x7f698f60b070 - unwind::begin_unwind_fmt::hf1eab6137b01c57f4Qd
   5:     0x7f698f60b030 - rust_begin_unwind
   6:     0x7f698f64ead0 - failure::begin_unwind::h39adb6de70d2239e5Wj
   7:     0x7f698fcdd810 - rust_input::h265dda0f703d2e9cxxt
   8:     0x7f698fcd24b0 - main_args::h70b9b0a493223a01o7s
   9:     0x7f698fcd2390 - main::h5520cb0cd7bfd3c851s
  10:     0x7f698f95de50 - start::closure.$x22closure$x22$LP$8280$RP$
  11:     0x7f698f6622c0 - rust_try
  12:     0x7f698f6086d0 - unwind::try::hc5b79cf0d453a48a0Hd
  13:     0x7f698f608430 - task::Task::run::h573b47a3c64dd74bQSc
  14:     0x7f698f95db00 - start::h9f770763fd166b762ke
  15:     0x7f698f95da70 - lang_start::hcbacf09ceac44709mke
  16:     0x7f698f216f10 - __libc_start_main
  17:                0x0 - <unknown>
@alexcrichton
Copy link
Member

The relevant FIXME is here:

// FIXME this isn't quite always true, it's just true about 99% of
// the time when dealing with documentation. For example,
// this would treat doc comments of the form `#[doc = "foo"]`
// incorrectly.

kevinmehall added a commit to kevinmehall/rust that referenced this issue Aug 26, 2014
…ng#15976

As of 8876ce4, `is_sugared_doc` is encoded in metadata, so there is no
need to assume that doc attributes came from sugared comments.
bors added a commit that referenced this issue Aug 27, 2014
As of 8876ce4, `is_sugared_doc` is encoded in metadata, so there is no
need to assume that all `doc` attributes came from sugared comments.

Fixes #15976
bors added a commit to rust-lang-ci/rust that referenced this issue Dec 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

2 participants