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: very unhelpful span info #45868

Closed
est31 opened this issue Nov 8, 2017 · 0 comments · Fixed by #47274
Closed

rustdoc: very unhelpful span info #45868

est31 opened this issue Nov 8, 2017 · 0 comments · Fixed by #47274
Assignees
Labels
T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@est31
Copy link
Member

est31 commented Nov 8, 2017

Do the following:

git clone https://github.com/rust-onig/rust-onig
cd rust-onig
git checkout 2381ea7fdc4b2dfef0905181cf26aa21b5a2ab17
git submodule update --init
cargo doc

Will yield the following output:

$ cargo doc
   Compiling onig_sys v66.1.1 (file://~/src/rust-onig/onig_sys)
 Documenting onig_sys v66.1.1 (file://~/src/rust-onig/onig_sys)
error: unknown start of token: `
 --> <stdin>:1:1
  |
1 | ```c
  | ^
  |
help: unicode character '`' (Grave Accent) looks like ''' (Single Quote), but it's not
 --> <stdin>:1:1
  |
1 | ```c
  | ^

error: Could not document `onig_sys`.

Caused by:
  process didn't exit successfully: `rustdoc --crate-name onig_sys onig_sys/src/lib.rs -o ~/src/rust-onig/target/doc -L dependency=~/src/rust-onig/target/debug/deps --extern libc=~/src/rust-onig/target/debug/deps/liblibc-db55a80d54675fa5.rlib` (exit code: 101)

This is very hard to debug! Which "```" section does Rust error on? Rustdoc should provide good and clear span info on this, with line numbers relative to the file, not relative to something else.

I could only debug this through removing each single ``` section and checking whether the error persists. This way I've found out that the following section is causing this:

    ///   Iterate function call for all names.
    ///
    ///  `int onig_foreach_name(regex_t* reg,
    ///                         int (*func)(const UChar*, const UChar*, int,int*,regex_t*,void*),
    ///                         void* arg)`
    ///
    /// # Returns
    ///
    ///  * normal return: 0
    ///  * error:         func's return value.
    ///
    /// # Arguments
    ///
    ///   1. reg:     regex object.
    ///   2. func:    callback function.
    ///
    ///     ```c
    ///     func(name, name_end, <number of groups>, <group number's list>,
    ///          reg, arg);
    ///     ```
    ///
    ///     if func does not return 0, then iteration is stopped.
    ///   3. arg:     argument for func.
    pub fn onig_foreach_name(reg: OnigRegex,
@GuillaumeGomez GuillaumeGomez added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. T-dev-tools-rustdoc labels Nov 8, 2017
@Manishearth Manishearth self-assigned this Jan 8, 2018
Manishearth added a commit to Manishearth/rust that referenced this issue Jan 10, 2018
Manishearth added a commit to Manishearth/rust that referenced this issue Jan 10, 2018
bors added a commit that referenced this issue Jan 14, 2018
Use correct line offsets for doctests

Not yet tested.

This doesn't handle char positions. It could if I collected a map of char offsets and lines, but this is a bit more work and requires hooking into the parser much more (unsure if it's possible).

r? @QuietMisdreavus

(fixes #45868)
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.

3 participants