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

Add error codes duplicates check #68639

Conversation

GuillaumeGomez
Copy link
Member

As asked in #67086.

r? @Mark-Simulacrum

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 29, 2020
@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-7 of your PR failed (pretty log, raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
2020-01-29T12:42:01.0953297Z ========================== Starting Command Output ===========================
2020-01-29T12:42:01.0955171Z [command]/bin/bash --noprofile --norc /home/vsts/work/_temp/ca148837-195a-4f9d-988b-dec431d07497.sh
2020-01-29T12:42:01.0955358Z 
2020-01-29T12:42:01.0958410Z ##[section]Finishing: Disable git automatic line ending conversion
2020-01-29T12:42:01.0963754Z ##[section]Starting: Checkout rust-lang/rust@refs/pull/68639/merge to s
2020-01-29T12:42:01.0965227Z Task         : Get sources
2020-01-29T12:42:01.0965303Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.
2020-01-29T12:42:01.0965336Z Version      : 1.0.0
2020-01-29T12:42:01.0965369Z Author       : Microsoft
---
2020-01-29T12:42:01.8796952Z ##[command]git remote add origin https://github.com/rust-lang/rust
2020-01-29T12:42:01.8805865Z ##[command]git config gc.auto 0
2020-01-29T12:42:01.8807995Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2020-01-29T12:42:01.8810440Z ##[command]git config --get-all http.proxy
2020-01-29T12:42:01.8816029Z ##[command]git -c http.extraheader="AUTHORIZATION: basic ***" fetch --force --tags --prune --progress --no-recurse-submodules --depth=2 origin +refs/heads/*:refs/remotes/origin/* +refs/pull/68639/merge:refs/remotes/pull/68639/merge

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@GuillaumeGomez GuillaumeGomez force-pushed the check-err-codes-duplicates branch from e266deb to ddc5b9e Compare January 30, 2020 12:47
@GuillaumeGomez
Copy link
Member Author

Fixed formatting issue.

@Mark-Simulacrum
Copy link
Member

I don't have much time to do review here, so would appreciate a more elaborate PR description that tells me:

  • what this is doing ("duplicates check" is a bit vague, or at least I'm not sure I understand it)
  • in particular, e.g. a description of exactly the conditions intended to be caught, and the cases that we are not intending to catch
  • brief description of what we had before that (may) overlap with this, i.e., other error code checks

@GuillaumeGomez
Copy link
Member Author

It counts the occurences of all error code, and detects the duplicates: you're not supposed to be able to use a same error code in two different places (otherwise, we might use one error code for two different errors).

So the check is pretty simple in itself: we read files, count the occurrences and check the numbers.

Before that, it was done through a macro which has been removed since then.

Copy link
Member

@Mark-Simulacrum Mark-Simulacrum left a comment

Choose a reason for hiding this comment

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

Looks like this currently depends on the other PR, too, as we currently have non-stringy error codes.

@@ -117,7 +158,7 @@ pub fn check(path: &Path, bad: &mut bool) {
eprintln!("{}", err);
}
println!("Found {} error codes with no tests", errors.len());
if !errors.is_empty() {
if !errors.is_empty() || errors_count != 0 {
Copy link
Member

Choose a reason for hiding this comment

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

Can we instead push into the errors vec instead of having two separate modes?

@Mark-Simulacrum
Copy link
Member

Do we have consensus as to not having duplicate error code usage? I personally feel like that's a pretty odd policy to have, but if @estebank and @rust-lang/wg-diagnostics feel that we should enforce this then I'm not opposed.

@oli-obk
Copy link
Contributor

oli-obk commented Jan 30, 2020

The policy existed for error codes because it was easy to mix up numbers. If we move to stringy error codes, all we need is a check that each has a test emitting it.

@Mark-Simulacrum
Copy link
Member

@oli-obk That's only true if we truly stringify error codes (e.g. borrow-check-use-after-drop), not the current "E0303", right? (And would need a different parser anyway).

But if mixing up number is the concern, then I guess we can do this. I still feel like that's something that can be fixed whenever it comes up and this doesn't in practice help much, but I also don't usually write errors or diagnostics in general :)

@oli-obk
Copy link
Contributor

oli-obk commented Jan 30, 2020

But if mixing up number is the concern, then I guess we can do this. I still feel like that's something that can be fixed whenever it comes up and this doesn't in practice help much, but I also don't usually write errors or diagnostics in general :)

We've never had problems with this because we've had this check. I have no idea if it would be a problem in practice ;)

@Mark-Simulacrum
Copy link
Member

We've not had this check for... some time now, right? In any case, I guess it doesn't matter. I'm fine with landing this (once my comments are resolved), and I probably also need to do another review pass after that to make sure the implementation is doing what it says it is.

@Mark-Simulacrum
Copy link
Member

I think there was some discussion in Zulip as well, but I don't have time to track that down anyway. The code here is (loosely) waiting on the diagnostics WG anyway probably or blocked on the other PR. Moving to waiting-on-team.

@Mark-Simulacrum Mark-Simulacrum added S-waiting-on-team Status: Awaiting decision from the relevant subteam (see the T-<team> label). and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 6, 2020
@crlf0710
Copy link
Member

crlf0710 commented Apr 5, 2020

@rustbot modify labels to +T-compiler

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Apr 5, 2020
@pnkfelix
Copy link
Member

pnkfelix commented Apr 9, 2020

@rustbot assign @oli-obk

@rustbot rustbot assigned oli-obk and unassigned Mark-Simulacrum Apr 9, 2020
@pnkfelix pnkfelix added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-team Status: Awaiting decision from the relevant subteam (see the T-<team> label). labels Apr 9, 2020
@pnkfelix
Copy link
Member

pnkfelix commented Apr 9, 2020

Discussed in T-compiler meeting. reassigning to @oli-obk as member of WG-diagnostics to decide whether to close as unnecessary, or to land.

@oli-obk
Copy link
Contributor

oli-obk commented Apr 9, 2020

Closing as we haven't had this check for quite a while and don't seem to have problems without it.

@oli-obk oli-obk closed this Apr 9, 2020
@GuillaumeGomez
Copy link
Member Author

GuillaumeGomez commented Apr 10, 2020

I strongly disagree on this opinion: before I migrated to the librustc_error_code, we had a check performed at compile-time through a macro. We lost this check and I had already to write fixes about new errors added (with no explanation) which already existed. So definitely, this is needed so I'll reopen the PR.

@Mark-Simulacrum
Copy link
Member

I had already to write fixes about new errors added (with no explanation) which already existed

I am confused by this -- I thought this lint was for accidentally reusing the same error code (accidentally), not about not having an error code? I've just re-read your comment #68639 (comment) and I feel like it matches my understanding, so it may be helpful to open a new issue or PR instead? Or maybe I'm just misunderstanding...

@GuillaumeGomez
Copy link
Member Author

The other lint checks if all error codes have an explanation. This lint checks that each error code is only used once.

@Centril
Copy link
Contributor

Centril commented Apr 10, 2020

I am in agreement with @oli-obk and @Mark-Simulacrum. One thing I noted at the meeting is that disallowing reusing an error code can have ungreat architectural implications force you have to have fn foo_error(..) -> DiagnosticBuilder<'_> and that can harm the effort towards #65031.

@GuillaumeGomez GuillaumeGomez deleted the check-err-codes-duplicates branch April 10, 2020 15:22
@GuillaumeGomez
Copy link
Member Author

At this point, I just wonder why I try to maintain/clean up this whole error system. No one wants it and no one wants to make another. That's one problem less off my shoulders. Good luck!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants