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 --test mis-reports origins of #[deny(warnings)] #66622

Open
kentfredric opened this issue Nov 22, 2019 · 0 comments
Open

rustdoc --test mis-reports origins of #[deny(warnings)] #66622

kentfredric opened this issue Nov 22, 2019 · 0 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-doctests Area: Documentation tests, run by rustdoc A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@kentfredric
Copy link

Here's an example I stumbled onto with a copy of rand 0.5.6:

 RUSTFLAGS="--cap-lints warn" cargo test --doc  --verbose
... 
 test src/prng/chacha.rs - prng::chacha::ChaChaRng::new_unseeded (line 115) ... ok
test src/prelude.rs - prelude (line 17) ... ok
test src/rngs/jitter.rs - rngs::jitter::JitterRng (line 72) ... FAILED
test src/lib.rs - sample (line 1020) ... ok
test src/rngs/adapter/read.rs - rngs::adapter::read::ReadRng (line 35) ... ok
test src/rngs/jitter.rs - rngs::jitter::JitterRng::new_with_timer (line 318) ... ok
...
failures:

---- src/rngs/jitter.rs - rngs::jitter::JitterRng (line 72) stdout ----
error: trait objects without an explicit `dyn` are deprecated
  --> src/rngs/jitter.rs:79:33
   |
10 | fn try_main() -> Result<(), Box<Error>> {
   |                                 ^^^^^ help: use `dyn`: `dyn Error`
   |
note: lint level defined here
  --> src/rngs/jitter.rs:71:9
   |
2  | #![deny(warnings)]
   |         ^^^^^^^^
   = note: `#[deny(bare_trait_objects)]` implied by `#[deny(warnings)]`

error: aborting due to previous error

Couldn't compile the test.

failures:
    src/rngs/jitter.rs - rngs::jitter::JitterRng (line 72)

Note there is a lot wrong here:

  1. The line numbers on the "source listing" don't correspond at all to the context line given ( 2 vs 71 )
  2. The lines cited don't at all correspond with any of the files mentioned.
cat -n src/rngs/jitter.rs | grep -C3 "^\s*71\s"
    68	/// https://github.com/usnistgov/SP800-90B_EntropyAssessment).
    69	///
    70	/// Use the following code using [`timer_stats`] to collect the data:
    71	///
    72	/// ```no_run
    73	/// use rand::jitter::JitterRng;
    74	/// #
 cat -n src/rngs/jitter.rs | grep -C3 "^\s*2\s"
     1	// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
     2	// file at the top-level directory of this distribution and at
     3	// https://rust-lang.org/COPYRIGHT.
     4	//
     5	// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or

No, instead, this rule is inserted somewhere else entirely:

 grep -C3 "deny" -nr src/
src/lib.rs-226-       html_favicon_url = "https://www.rust-lang.org/favicon.ico",
src/lib.rs-227-       html_root_url = "https://docs.rs/rand/0.5.6")]
src/lib.rs-228-
src/lib.rs:229:#![deny(missing_docs)]
src/lib.rs:230:#![deny(missing_debug_implementations)]
src/lib.rs:231:#![doc(test(attr(allow(unused_variables), deny(warnings))))]
src/lib.rs-232-
src/lib.rs-233-#![cfg_attr(not(feature="std"), no_std)]
src/lib.rs-234-#![cfg_attr(all(feature="alloc", not(feature="std")), feature(alloc))]

Obviously macros are to blame here, but as it stands, this makes this reported error source entirely useless, not only is it getting the line and the file wrong, it cites a literal string that doesn't even exist as-stated in the source code, presenting it under the guise of being literal source code.

I'm probably gonna also have to file another bug about that whole "--cap-lints warn does absolutely nothing" deal it has going on there.

@jonas-schievink jonas-schievink added A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Nov 22, 2019
@jyn514 jyn514 added A-doctests Area: Documentation tests, run by rustdoc A-diagnostics Area: Messages for errors, warnings, and lints labels Aug 27, 2020
@fmease fmease added A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. and removed A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. labels Dec 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-doctests Area: Documentation tests, run by rustdoc A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
Status: No status
Development

No branches or pull requests

4 participants