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

Use syn in needless_doctest_main lint #4729

Closed
wants to merge 1 commit into from
Closed

Conversation

llogiq
Copy link
Contributor

@llogiq llogiq commented Oct 25, 2019

changelog: none

This fixes #4698 by only linting non-empty fn main()s. This is not a perfect solution, but I don't want to omit linting if any macro call or attribute is detected, as that would result in many false negatives.

@llogiq
Copy link
Contributor Author

llogiq commented Oct 25, 2019

PS.: My toolchain doesn't work right now, so I pushed without ui-test stderr. Will fix later.

@flip1995
Copy link
Member

Once #4733 is merged sh setup-toolchain.sh should repair your toolchain

@flip1995 flip1995 added the S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status) label Oct 25, 2019
@llogiq
Copy link
Contributor Author

llogiq commented Oct 25, 2019

That failure is sure strange. Anyone have an idea why it happens?

@flip1995
Copy link
Member

This didn't happen in other builds, I restarted the build, let's see if this was a temporary failure.

@llogiq
Copy link
Contributor Author

llogiq commented Oct 26, 2019

Now that my toolchain works again, I get the same failure, so I doubt it's an intermittent CI problem.

@flip1995
Copy link
Member

Yeah CI failed also with the same error. This is probably the syn dep?

@llogiq
Copy link
Contributor Author

llogiq commented Oct 27, 2019

$!@&/ my toolchain broke again, but with nightly clippy url lints all right.

@llogiq
Copy link
Contributor Author

llogiq commented Oct 31, 2019

I got my toolchain to work again, but I'm still stumped with the error. Somehow linting the url crate fails. So I checked out the crate and fixed all the things that triggered deny lints. Now I have a crate that will cargo clippy all right, yet error with ../rust-clippy/target/debug/cargo-clippy. But the error is not quite helpful. I may have to set up a debugger.

@llogiq
Copy link
Contributor Author

llogiq commented Nov 4, 2019

When I remove the DOGFOOD=1 environment variable, I at least get some output:

error: could not compile `compiletest_rs`.

Caused by:
  process didn't exit successfully: `/home/andre/projects/rust-clippy/target/debug/clippy-driver rustc --crate-name compiletest_rs /home/andre/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/compiletest_rs-0.3.25/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type lib --emit=dep-info,metadata -C debuginfo=2 --cfg 'feature="tempfile"' --cfg 'feature="tmp"' -C metadata=27802b1352277af2 -C extra-filename=-27802b1352277af2 --out-dir /home/andre/projects/rust-clippy/target/debug/deps -L dependency=/home/andre/projects/rust-clippy/target/debug/deps --extern diff=/home/andre/projects/rust-clippy/target/debug/deps/libdiff-755bb338ea3b20a8.rmeta --extern filetime=/home/andre/projects/rust-clippy/target/debug/deps/libfiletime-e2c3d36fd54227dd.rmeta --extern getopts=/home/andre/projects/rust-clippy/target/debug/deps/libgetopts-a816befb1e871618.rmeta --extern libc=/home/andre/projects/rust-clippy/target/debug/deps/liblibc-59a6a91606d5fea4.rmeta --extern log=/home/andre/projects/rust-clippy/target/debug/deps/liblog-4e52c9677c53ec66.rmeta --extern regex=/home/andre/projects/rust-clippy/target/debug/deps/libregex-435419156b9782fa.rmeta --extern rustfix=/home/andre/projects/rust-clippy/target/debug/deps/librustfix-1aa34b9865fe93fb.rmeta --extern serde=/home/andre/projects/rust-clippy/target/debug/deps/libserde-3e923fc05a224778.rmeta --extern serde_derive=/home/andre/projects/rust-clippy/target/debug/deps/libserde_derive-feb33ffe27e37f75.so --extern serde_json=/home/andre/projects/rust-clippy/target/debug/deps/libserde_json-598da86897c4a0df.rmeta --extern tempfile=/home/andre/projects/rust-clippy/target/debug/deps/libtempfile-d515c087062eb600.rmeta --cap-lints allow -C opt-level=z -L native=/home/andre/projects/rust-clippy/target/debug/build/backtrace-sys-385c9f475b72720d/out` (exit code: 101)
warning: build failed, waiting for other jobs to finish...
warning: error: usage of mem::forget on Drop type
  --> $DIR/mem_forget.rs:17:5
   |
17 |     std::mem::forget(seven);
   |     ^^^^^^^^^^^^^^^^^^^^^^^

error: could not compile `clippy_lints`.

Caused by:
  process didn't exit successfully: `/home/andre/projects/rust-clippy/target/debug/clippy-driver rustc --edition=2018 --crate-name clippy_lints clippy_lints/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type lib --emit=dep-info,metadata,link -C debuginfo=2 -C metadata=85dd49635c08f5e5 -C extra-filename=-85dd49635c08f5e5 --out-dir /home/andre/projects/rust-clippy/target/debug/deps -L dependency=/home/andre/projects/rust-clippy/target/debug/deps --extern cargo_metadata=/home/andre/projects/rust-clippy/target/debug/deps/libcargo_metadata-59c910bfe900d38d.rmeta --extern if_chain=/home/andre/projects/rust-clippy/target/debug/deps/libif_chain-2368ca381ecc2ba9.rmeta --extern itertools=/home/andre/projects/rust-clippy/target/debug/deps/libitertools-c63f95e7461cb3ed.rmeta --extern lazy_static=/home/andre/projects/rust-clippy/target/debug/deps/liblazy_static-acb528c94fa5c69e.rmeta --extern matches=/home/andre/projects/rust-clippy/target/debug/deps/libmatches-50652eea742e7e74.rmeta --extern pulldown_cmark=/home/andre/projects/rust-clippy/target/debug/deps/libpulldown_cmark-94c8e23d6fa9ea0f.rmeta --extern quine_mc_cluskey=/home/andre/projects/rust-clippy/target/debug/deps/libquine_mc_cluskey-c943ddc427c7e602.rmeta --extern regex_syntax=/home/andre/projects/rust-clippy/target/debug/deps/libregex_syntax-6ccfd53ae1f0f2c3.rmeta --extern semver=/home/andre/projects/rust-clippy/target/debug/deps/libsemver-681bdff70ac9eaa5.rmeta --extern serde=/home/andre/projects/rust-clippy/target/debug/deps/libserde-6817b117026a30be.rmeta --extern smallvec=/home/andre/projects/rust-clippy/target/debug/deps/libsmallvec-97bb4c44c1e5d068.rmeta --extern syn=/home/andre/projects/rust-clippy/target/debug/deps/libsyn-77ab4e1e5789337d.rmeta --extern toml=/home/andre/projects/rust-clippy/target/debug/deps/libtoml-77239ce8617b87d7.rmeta --extern unicode_normalization=/home/andre/projects/rust-clippy/target/debug/deps/libunicode_normalization-067577faba9383b7.rmeta --extern url=/home/andre/projects/rust-clippy/target/debug/deps/liburl-c9ac2b446a4e6777.rmeta -C opt-level=z` (exit code: 101)

However, that error seems to originate from a UI test, so it's likely not the error to look for.

@bors
Copy link
Contributor

bors commented Nov 6, 2019

☔ The latest upstream changes (presumably #4777) made this pull request unmergeable. Please resolve the merge conflicts.

@llogiq
Copy link
Contributor Author

llogiq commented Nov 8, 2019

This gets weirder and weirder. Now our linux build fails and the others work. Btw. I've debugged locally and my local build failed because of a full disk; I've tried on a bigger machine and it worked.

@phansch
Copy link
Member

phansch commented Nov 28, 2019

@bors try

@bors
Copy link
Contributor

bors commented Nov 28, 2019

⌛ Trying commit 1077c23 with merge fcd7e14...

bors added a commit that referenced this pull request Nov 28, 2019
Use syn in needless_doctest_main lint

changelog: none

This fixes #4698 by only linting non-empty `fn main()`s. This is not a perfect solution, but I don't want to omit linting if any macro call or attribute is detected, as that would result in many false negatives.
@bors
Copy link
Contributor

bors commented Nov 28, 2019

💔 Test failed - status-appveyor

Comment on lines 34 to 36
# cargo requires serde feat in its url dep
# see https://github.com/rust-lang/rust/pull/63587#issuecomment-522343864
url = { version = "2.1.0", features = ["serde"] }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think features could be dropped entirely because it's handled by rustc-workspace-hack: https://github.com/rust-lang/rust/blob/4752c05af4a5f392de026f9ae1877eae030be359/src/tools/rustc-workspace-hack/Cargo.toml#L66

Dogfood has hidden the error but maybe this change will help (it failed to build url).

@mati865
Copy link
Contributor

mati865 commented Nov 29, 2019

I think you will have to rebase to make PR CI green.

@flip1995 flip1995 closed this Nov 29, 2019
@flip1995 flip1995 reopened this Nov 29, 2019
@flip1995
Copy link
Member

That should be enough.

@mati865
Copy link
Contributor

mati865 commented Nov 29, 2019

Now url builds fine but cargo_metadata fails.
We gonna need full error message.

@bors
Copy link
Contributor

bors commented Dec 1, 2019

☔ The latest upstream changes (presumably #4866) made this pull request unmergeable. Please resolve the merge conflicts.

@llogiq
Copy link
Contributor Author

llogiq commented Jan 15, 2020

I've rebased, hopefully this will now work. It does so locally.

@llogiq
Copy link
Contributor Author

llogiq commented Jan 17, 2020

We likely overflow some space quota with this. In my local tests, I build with RUSTFLAGS='-C opt_level=z', because otherwise running the tests exhausts my available hard disk space.

As the benefits of doing this are not too big, I'll just close this for now.

@llogiq llogiq closed this Jan 17, 2020
bors added a commit that referenced this pull request Aug 16, 2020
…nishearth,flip1995

Parse doctests in needless_doctest_main

This switches from text-based search to running the parser to avoid false positives. Inspired by how [rustdoc](https://github.com/rust-lang/rust/blob/3f3250500fe152b5759c21453ba9a9129808d0d8/src/librustdoc/test.rs#L366) handles this and by #4729.

cc @llogiq

changelog: Fix multiple false positives in [`needless_doctest_main`].

Fixes #5879
Fixes #4906
Fixes #5103
Fixes #4698
@llogiq llogiq deleted the needless-doc-main-syn branch October 17, 2020 19:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

needless_doctest_main yields false positive with proc macros
5 participants