rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
97k stars 12.54k forks source link

linkcheck should check links in diagnostics messages #54602

Open Havvy opened 5 years ago

Havvy commented 5 years ago

The linkcheck tool does not check that links emitted by diagnostics messages are correct. E.g. we have at least one wrong link as per issue #54555. It would be useful to have linkcheck be able to check those links.

ryzokuken commented 4 years ago

Hi @Havvy. I'd like to give this one a try. Can you point me to the source code for the tool?

ryzokuken commented 4 years ago

Okay, I guess https://github.com/rust-lang/rust/blob/7760cd0fbbbf2c59a625e075a5bdfa88b8e30f8a/src/tools/linkchecker/linkcheck.sh is what needs to be changed?

Havvy commented 4 years ago

I cannot mentor here. I know nothing about how linkcheck works.

ryzokuken commented 4 years ago

@Havvy alright, thanks anyway. I'm trying to compile src/tools/linkcheck and do what I can, let's hope I can figure this out by myself in case nobody chimes in...

ryzokuken commented 4 years ago

Okay, so I don't know yet where the diagnostics messages are emitted, but in src/tools/linkchecker/main.rs there's a function called check that takes a file path as an argument, reads the file and checks all the links in https://github.com/rust-lang/rust/blob/ec1f28f9614292c36b371d3758afffdd52cb9786/src/tools/linkchecker/main.rs#L172-L270. I guess a good first step would be to refactor this logic into a separate function? Maybe call it something like check_link that just takes a string link as input?

ryzokuken commented 4 years ago

This particular message is emitted at https://github.com/rust-lang/rust/blob/ec1f28f9614292c36b371d3758afffdd52cb9786/src/libcore/marker.rs#L83-L93.

ehuss commented 4 years ago

@ryzokuken The linkchecker does not check external links (on purpose). External link checking in CI is prone to random errors, throttling, and other problems.

Also, there isn't really a way to extract error messages from the code base. One could possibly scan for all https:// links in all .rs code, but care should be taken (for example, handling backslashes, angle brackets, etc.).

I'm not sure this is really feasible to do in an automated fashion in a reliable way. Perhaps a manual script could be built that would list all the links in .rs code, and then feed that into a link checking tool. There are dozens out there. Some Rust projects are using mdbook-linkcheck, perhaps you could just dump the links into a .md file and use that. I've also used https://github.com/linkchecker/linkchecker and a few others, but they all have their shortcomings.

Enselic commented 9 months ago

I'm not sure this is really feasible to do in an automated fashion in a reliable way.

I think the E-needs-help label was added under the assumption that this would be straightforward to automate in a reliable way. Let's remove the label since that is not the case.