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

More reductions in error handling diversity #67770

Merged
merged 2 commits into from Jan 8, 2020

Conversation

@Centril
Copy link
Member

Centril commented Jan 1, 2020

In this follow up to #67744, we:

  • Remove all fatal / error / warning macros in syntax except for struct_span_err, which is moved to rustc_errors.

  • Lintify some hard-coded warnings which used warning macros.

  • Defatalize some errors.

In general, the goal here is to make it painful to use fatal or unstructured errors and so we hopefully won't see many of these creep in.

Fixes #67933.

@rust-highfive

This comment was marked as outdated.

Copy link
Collaborator

rust-highfive commented Jan 1, 2020

r? @eddyb

(rust_highfive has picked a reviewer for you, use r? to override)

@Centril

This comment has been minimized.

Copy link
Member Author

Centril commented Jan 1, 2020

Copy link
Member

Mark-Simulacrum left a comment

Some of my comments I think get obsoleted by future commits, but along with them, two higher-level comments:

  • no real point to moving span_err and friends to struct_span_err(...).emit()
  • it is not clear that removing the macros, rather than (e.g.) moving to rustc_errors is helpful

I'm also not super happy with moving things to lints in this PR; feels like maybe there's some discussion to be had, and it's not clear that it brings us benefits from the PR goals perspective. Maybe we could split those commits out? I don't know if we need (e.g.) sign off or so. Seems like probably no, and indeed moving to lints is good.

Would also be good to do some rebase magic and cleanup commits (a few are misspelled or essential duplicates of each other, e.g., I would roll in all the "unused" macro removal into the ~last commit which removes the syntax::diagnostics::macros module.

src/test/ui/lint/lint-uppercase-variables.stderr Outdated Show resolved Hide resolved
src/librustc_metadata/locator.rs Show resolved Hide resolved
src/librustc_typeck/structured_errors.rs Outdated Show resolved Hide resolved
src/librustc_typeck/check/mod.rs Show resolved Hide resolved
@petrochenkov petrochenkov self-assigned this Jan 1, 2020
@bors

This comment was marked as resolved.

Copy link
Contributor

bors commented Jan 1, 2020

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

@Centril Centril force-pushed the Centril:reduce-diversity-2 branch 5 times, most recently from c34ca3b to be8f29e Jan 1, 2020
@Centril

This comment has been minimized.

Copy link
Member Author

Centril commented Jan 1, 2020

(For the benefit of everyone reading, here's a summary of notes I left on Discord...)

  • no real point to moving span_err and friends to struct_span_err(...).emit()

The point is to encourage adding .span_suggestion(...), .span_label(...) and whatnot by not immediately emitting the error ("the right thing should be more convenient"). Eventually we can maybe rename to error!(...).emit(); once diversity is further reduced.

it is not clear that removing the macros, rather than (e.g.) moving to rustc_errors is helpful

I think we should make it harder to emit unstructured / fatal errors as well as hard-coded warnings, and those macros are in the way of that. Also, the diagnostics builder API is good enough that help!(...) et. al feels unnecessary.

I'm also not super happy with moving things to lints in this PR; feels like maybe there's some discussion to be had, and it's not clear that it brings us benefits from the PR goals perspective. Maybe we could split those commits out? I don't know if we need (e.g.) sign off or so. Seems like probably no, and indeed moving to lints is good.

So lintifying these enabled nixing some of the macros. Beyond that, hard-coded warnings are not something we want outside of things like the NLL transition (which are super rare and don't deserve sugar).

Would also be good to do some rebase magic and cleanup commits (a few are misspelled or essential duplicates of each other, e.g., I would roll in all the "unused" macro removal into the ~last commit which removes the syntax::diagnostics::macros module.

Squashed all into one commit. :)

@Mark-Simulacrum

This comment has been minimized.

Copy link
Member

Mark-Simulacrum commented Jan 2, 2020

Changes look fine to me overall; probably makes sense to wait for @petrochenkov here though.

@petrochenkov

This comment has been minimized.

Copy link
Contributor

petrochenkov commented Jan 2, 2020

Eventually we can maybe rename to error!(...).emit();

+1, if the errors are spanned and structural by default, then it doesn't make sense to write struct_span.

@petrochenkov

This comment has been minimized.

Copy link
Contributor

petrochenkov commented Jan 2, 2020

We also probably need a variation of struct_span_err without an error code though, errors with codes are not an overwhelming majority right now, unlike e.g. spanned errors.
(But that kind of depends on the decision about error codes in general.)

@Centril

This comment has been minimized.

Copy link
Member Author

Centril commented Jan 2, 2020

The variant without a code is just self.struct_span_err(...) (not a macro) though? (It works well enough in the parser... At least I've never wanted for more.)

@petrochenkov

This comment has been minimized.

Copy link
Contributor

petrochenkov commented Jan 2, 2020

@Centril
You have to write &format!(...) with self.struct_span_err, which is kind of annoying.

@Centril

This comment has been minimized.

Copy link
Member Author

Centril commented Jan 2, 2020

Review comments should be addressed now (except for the new variation on the macro, which I think could be done some other time).

@rust-highfive

This comment was marked as resolved.

Copy link
Collaborator

rust-highfive commented Jan 2, 2020

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-02T12:50:55.5262543Z ##[command]git remote add origin https://github.com/rust-lang/rust
2020-01-02T12:50:55.5450023Z ##[command]git config gc.auto 0
2020-01-02T12:50:55.5529401Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2020-01-02T12:50:56.3413065Z ##[command]git config --get-all http.proxy
2020-01-02T12:50:56.3421174Z ##[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/67770/merge:refs/remotes/pull/67770/merge
---
2020-01-02T13:48:16.4935592Z .................................................................................................... 1500/9468
2020-01-02T13:48:22.0574235Z .................................................................................................... 1600/9468
2020-01-02T13:48:26.7307664Z .................................................................................................... 1700/9468
2020-01-02T13:48:35.7190666Z .................................................................................................... 1800/9468
2020-01-02T13:48:43.3966626Z .i.................................................................................................. 1900/9468
2020-01-02T13:48:49.6411843Z .......................................................................................iiiii........ 2000/9468
2020-01-02T13:49:10.5398917Z .................................................................................................... 2200/9468
2020-01-02T13:49:12.7033749Z .................................................................................................... 2300/9468
2020-01-02T13:49:14.9644929Z .................................................................................................... 2400/9468
2020-01-02T13:49:20.7943915Z .................................................................................................... 2500/9468
---
2020-01-02T13:52:11.8538916Z ..................i...............i................................................................. 4900/9468
2020-01-02T13:52:21.4018619Z .................................................................................................... 5000/9468
2020-01-02T13:52:26.6507850Z ...............................................................i.................................... 5100/9468
2020-01-02T13:52:34.6742271Z .................................................................................................... 5200/9468
2020-01-02T13:52:41.9484215Z ..............................ii.ii...........i..................................................... 5300/9468
2020-01-02T13:52:51.0739346Z .................................................................................................... 5500/9468
2020-01-02T13:53:01.0243147Z .................................................................................................... 5600/9468
2020-01-02T13:53:07.8945159Z .............i...................................................................................... 5700/9468
2020-01-02T13:53:13.8750725Z .................................................................................................... 5800/9468
2020-01-02T13:53:13.8750725Z .................................................................................................... 5800/9468
2020-01-02T13:53:24.3777818Z .................................................................................................... 5900/9468
2020-01-02T13:53:35.5584987Z .ii...i..ii...........i............................................................................. 6000/9468
2020-01-02T13:53:52.5765919Z .................................................................................................... 6200/9468
2020-01-02T13:53:59.7828902Z .................................................................................................... 6300/9468
2020-01-02T13:53:59.7828902Z .................................................................................................... 6300/9468
2020-01-02T13:54:14.9914930Z ............................i..ii................................................................... 6400/9468
2020-01-02T13:54:34.2454493Z .................................................................................................... 6600/9468
2020-01-02T13:54:36.3053470Z ...i................................................................................................ 6700/9468
2020-01-02T13:54:38.5412560Z .................................................................................................... 6800/9468
2020-01-02T13:54:40.9391003Z ...i................................................................................................ 6900/9468
---
2020-01-02T13:56:14.8874394Z .................................................................................................... 7500/9468
2020-01-02T13:56:19.6103548Z .................................................................................................... 7600/9468
2020-01-02T13:56:24.8023200Z .................................................................................................... 7700/9468
2020-01-02T13:56:34.6124490Z .................................................................................................... 7800/9468
2020-01-02T13:56:41.7865749Z ......................................iiii.......................................................... 7900/9468
2020-01-02T13:56:55.8559139Z .................................................................................................... 8100/9468
2020-01-02T13:57:04.0338523Z .................................................................................................... 8200/9468
2020-01-02T13:57:17.6057968Z .................................................................................................... 8300/9468
2020-01-02T13:57:25.1307213Z .................................................................................................... 8400/9468
---
2020-01-02T13:59:39.5005475Z  finished in 6.397
2020-01-02T13:59:39.5186590Z Check compiletest suite=codegen mode=codegen (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2020-01-02T13:59:40.4740938Z 
2020-01-02T13:59:40.4741521Z running 166 tests
2020-01-02T13:59:42.4937560Z iiii......i........ii..iiii...i....i...........i............i..i..................i....i............ 100/166
2020-01-02T13:59:44.9744756Z i.i.i...iii..iiiiiii.......................iii............ii......
2020-01-02T13:59:44.9745341Z 
2020-01-02T13:59:44.9745407Z  finished in 4.931
2020-01-02T13:59:44.9745724Z Check compiletest suite=codegen-units mode=codegen-units (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2020-01-02T13:59:44.9745782Z 
---
2020-01-02T13:59:46.4600842Z  finished in 1.992
2020-01-02T13:59:46.4779967Z Check compiletest suite=assembly mode=assembly (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2020-01-02T13:59:46.6227436Z 
2020-01-02T13:59:46.6227624Z running 9 tests
2020-01-02T13:59:46.6229001Z iiiiiiiii
2020-01-02T13:59:46.6229327Z 
2020-01-02T13:59:46.6229749Z  finished in 0.144
2020-01-02T13:59:46.6407771Z Check compiletest suite=incremental mode=incremental (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2020-01-02T13:59:47.4820994Z 
---
2020-01-02T14:00:05.8725974Z  finished in 19.231
2020-01-02T14:00:05.8941504Z Check compiletest suite=debuginfo mode=debuginfo-gdb+lldb (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2020-01-02T14:00:06.0616093Z 
2020-01-02T14:00:06.0616321Z running 124 tests
2020-01-02T14:00:30.5241638Z .iiiii..ii.....i..i...i..i.i.i..i..i..iii....ii.ii....ii..........iiii..........i.....i..ii.......ii 100/124
2020-01-02T14:00:34.5244981Z .i.iii.....iiiiii.....ii
2020-01-02T14:00:34.5246595Z 
2020-01-02T14:00:34.5249416Z  finished in 28.630
2020-01-02T14:00:34.5253290Z Uplifting stage1 rustc (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2020-01-02T14:00:34.5253815Z Copying stage2 rustc from stage1 (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu / x86_64-unknown-linux-gnu)
---
2020-01-02T14:13:04.7729913Z 
2020-01-02T14:13:04.7730862Z    Doc-tests core
2020-01-02T14:13:09.0874029Z 
2020-01-02T14:13:09.0874930Z running 2439 tests
2020-01-02T14:13:17.8523324Z ......iiiii......................................................................................... 100/2439
2020-01-02T14:13:26.6759161Z ..................................................................................ii................ 200/2439
2020-01-02T14:13:46.5413051Z ................i................................................................................... 400/2439
2020-01-02T14:13:46.5413051Z ................i................................................................................... 400/2439
2020-01-02T14:13:55.6072565Z ................................................................i..i..................iiii.......... 500/2439
2020-01-02T14:14:12.1413669Z .................................................................................................... 700/2439
2020-01-02T14:14:20.3408641Z .................................................................................................... 800/2439
2020-01-02T14:14:28.5095798Z .................................................................................................... 900/2439
2020-01-02T14:14:36.7356800Z .................................................................................................... 1000/2439
---
2020-01-02T14:18:01.5141029Z .thread '<unnamed>' panicked at 'explicit panic', src/libstd/sync/mutex.rs:694:13
2020-01-02T14:18:01.5152435Z ...thread '<unnamed>' panicked at 'assertion failed: `(left == right)`
2020-01-02T14:18:01.5152738Z   left: `1`,
2020-01-02T14:18:01.5153286Z  right: `2`', src/libstd/sync/mutex.rs:657:13
2020-01-02T14:18:01.5190378Z ..........thread '<unnamed>' panicked at 'test panic in inner thread to poison RwLock', src/libstd/sync/rwlock.rs:792:13
2020-01-02T14:18:01.5204460Z ...thread '<unnamed>' panicked at 'test panic in inner thread to poison RwLock', src/libstd/sync/rwlock.rs:768:13
2020-01-02T14:18:01.5213796Z ..thread '<unnamed>' panicked at 'explicit panic', src/libstd/sync/rwlock.rs:704:13
2020-01-02T14:18:01.5220961Z .thread '<unnamed>' panicked at 'explicit panic', src/libstd/sync/rwlock.rs:632:13
2020-01-02T14:18:01.5233610Z .thread '<unnamed>' panicked at 'explicit panic', src/libstd/sync/rwlock.rs.:644:13
2020-01-02T14:18:01.5250481Z thread '<unnamed>' panicked at 'explicit panic', src/libstd/sync/rwlock.rs:619:13
2020-01-02T14:18:03.5866670Z ...........................thread '<unnamed>' panicked at 'What the answer to my lifetimes dilemma is?', src/libstd/sys_common/remutex.rs:229:13
2020-01-02T14:18:03.5910685Z ........................... 700/760
2020-01-02T14:18:03.6003443Z ................................thread '<unnamed>' panicked at 'explicit panic', src/libstd/thread/mod.rs:1560:37
---
2020-01-02T14:18:10.6051240Z 
2020-01-02T14:18:10.6090287Z running 1002 tests
2020-01-02T14:18:27.4764819Z i................................................................................................... 100/1002
2020-01-02T14:18:37.1460214Z .................................................................................................... 200/1002
2020-01-02T14:18:44.0137140Z .................iii......i......i...i......i....................................................... 300/1002
2020-01-02T14:18:48.7734982Z .................................................................................................... 400/1002
2020-01-02T14:18:55.6117259Z ..........................................i.i.....................................ii................ 500/1002
2020-01-02T14:19:07.8865302Z .................................................................................................... 700/1002
2020-01-02T14:19:07.8865302Z .................................................................................................... 700/1002
2020-01-02T14:19:14.2848470Z ............................iiii.................................................................... 800/1002
2020-01-02T14:19:27.6931103Z .................................................................................................... 900/1002
2020-01-02T14:19:34.2925994Z ..................................................iiii.............................................. 1000/1002
2020-01-02T14:19:34.3473262Z test result: ok. 982 passed; 0 failed; 20 ignored; 0 measured; 0 filtered out
2020-01-02T14:19:34.3474317Z 
2020-01-02T14:19:34.3595911Z  finished in 171.006
2020-01-02T14:19:34.3609794Z Testing term stage1 (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
---
2020-01-02T14:37:29.7242754Z ---- /checkout/obj/build/x86_64-unknown-linux-gnu/test/error-index.md - Rust_Compiler_Error_Index::E0566 (line 10150) stdout ----
2020-01-02T14:37:29.7242832Z error[E0566]: conflicting representation hints
2020-01-02T14:37:29.7243299Z  --> /checkout/obj/build/x86_64-unknown-linux-gnu/test/error-index.md:10151:8
2020-01-02T14:37:29.7243349Z   |
2020-01-02T14:37:29.7243413Z 3 | #[repr(u32, u64)] // warning!
2020-01-02T14:37:29.7243485Z 
2020-01-02T14:37:29.7243524Z error: aborting due to previous error
2020-01-02T14:37:29.7243569Z 
2020-01-02T14:37:29.7243838Z For more information about this error, try `rustc --explain E0566`.
---
2020-01-02T14:37:29.7245272Z   local time: Thu Jan  2 14:37:29 UTC 2020
2020-01-02T14:37:29.9854325Z   network time: Thu, 02 Jan 2020 14:37:29 GMT
2020-01-02T14:37:29.9859296Z == end clock drift check ==
2020-01-02T14:37:31.0936300Z 
2020-01-02T14:37:31.1030010Z ##[error]Bash exited with code '1'.
2020-01-02T14:37:31.1080234Z ##[section]Starting: Checkout
2020-01-02T14:37:31.1082317Z ==============================================================================
2020-01-02T14:37:31.1082373Z Task         : Get sources
2020-01-02T14:37:31.1082436Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.

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)

@Centril Centril force-pushed the Centril:reduce-diversity-2 branch from 5728919 to 185f28e Jan 2, 2020
Centril added 2 commits Dec 31, 2019
- remove syntax::{help!, span_help!, span_note!}
- remove unused syntax::{struct_span_fatal, struct_span_err_or_warn!, span_err_or_warn!}
- lintify check_for_bindings_named_same_as_variants + conflicting_repr_hints
- inline syntax::{struct_span_warn!, diagnostic_used!}
- stringify_error_code! -> error_code! & use it more.
- find_plugin_registrar: de-fatalize an error
- de-fatalize metadata errors
- move type_error_struct! to rustc_typeck
- struct_span_err! -> rustc_errors
@Centril Centril force-pushed the Centril:reduce-diversity-2 branch from effdacf to 20ebb80 Jan 8, 2020
@Centril

This comment has been minimized.

Copy link
Member Author

Centril commented Jan 8, 2020

@bors r=petrochenkov

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Jan 8, 2020

📌 Commit 20ebb80 has been approved by petrochenkov

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Jan 8, 2020

⌛️ Testing commit 20ebb80 with merge ed6468d...

bors added a commit that referenced this pull request Jan 8, 2020
More reductions in error handling diversity

In this follow up to #67744, we:

- Remove all fatal / error / warning macros in `syntax` except for `struct_span_err`, which is moved to `rustc_errors`.

- Lintify some hard-coded warnings which used warning macros.

- Defatalize some errors.

In general, the goal here is to make it painful to use fatal or unstructured errors and so we hopefully won't see many of these creep in.

Fixes #67933.
@bors

This comment has been minimized.

Copy link
Contributor

bors commented Jan 8, 2020

☀️ Test successful - checks-azure
Approved by: petrochenkov
Pushing ed6468d to master...

@bors bors added the merged-by-bors label Jan 8, 2020
@bors bors merged commit 20ebb80 into rust-lang:master Jan 8, 2020
5 checks passed
5 checks passed
homu Test successful
Details
pr Build #20200108.8 succeeded
Details
pr (Linux mingw-check) Linux mingw-check succeeded
Details
pr (Linux x86_64-gnu-llvm-7) Linux x86_64-gnu-llvm-7 succeeded
Details
pr (Linux x86_64-gnu-tools) Linux x86_64-gnu-tools succeeded
Details
@rust-highfive

This comment has been minimized.

Copy link
Collaborator

rust-highfive commented Jan 8, 2020

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.

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)

@Centril Centril deleted the Centril:reduce-diversity-2 branch Jan 8, 2020
Centril added a commit to Centril/rust that referenced this pull request Jan 11, 2020
Extract `rustc_ast_passes`, move gating, & refactor linting

Based on rust-lang#67770.

This PR extracts a crate `rustc_ast_passes`:

- `ast_validation.rs`, which is contributed by `rustc_passes` (now only has HIR based passes) -- the goal here is to improve recompilation of the parser,
- `feature_gate.rs`, which is contributed by `syntax` and performs post-expansion-gating & final erroring for pre-expansion gating,
- `show_span`, which is contributed by `syntax`.

To facilitate this, we first have to also:

- Move `{leveled_}feature_err{_err}` from `syntax::feature_gate::check` into `rustc_session::parse`.
- Move `get_features` into `rustc_parse::config`, the only place it is used.
- Move some some lint datatypes and traits, e.g. `LintBuffer`, `BufferedEarlyLint`, `BuiltinLintDiagnostics`, `LintPass`, and `LintArray` into `rustc_session::lint`.
- Move all the hard-wired lint `static`s into `rustc_session::lint::builtin`.
Centril added a commit to Centril/rust that referenced this pull request Jan 11, 2020
Extract `rustc_ast_passes`, move gating, & refactor linting

Based on rust-lang#67770.

This PR extracts a crate `rustc_ast_passes`:

- `ast_validation.rs`, which is contributed by `rustc_passes` (now only has HIR based passes) -- the goal here is to improve recompilation of the parser,
- `feature_gate.rs`, which is contributed by `syntax` and performs post-expansion-gating & final erroring for pre-expansion gating,
- `show_span`, which is contributed by `syntax`.

To facilitate this, we first have to also:

- Move `{leveled_}feature_err{_err}` from `syntax::feature_gate::check` into `rustc_session::parse`.
- Move `get_features` into `rustc_parse::config`, the only place it is used.
- Move some some lint datatypes and traits, e.g. `LintBuffer`, `BufferedEarlyLint`, `BuiltinLintDiagnostics`, `LintPass`, and `LintArray` into `rustc_session::lint`.
- Move all the hard-wired lint `static`s into `rustc_session::lint::builtin`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

6 participants
You can’t perform that action at this time.