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

Make ErrorReported impossible to construct outside rustc_errors #93222

Merged
merged 1 commit into from
Mar 18, 2022

Conversation

mark-i-m
Copy link
Member

There are a few places were we have to construct it, though, and a few
places that are more invasive to change. To do this, we create a
constructor with a long obvious name.

cc #69426 @varkor @eddyb @estebank

I actually didn't see that I was assigned to this issue until now...

@rust-highfive
Copy link
Collaborator

Some changes occured to rustc_codegen_cranelift

cc @bjorn3

Some changes occured to the CTFE / Miri engine

cc @rust-lang/miri

Some changes occured to the CTFE / Miri engine

cc @rust-lang/miri

Some changes occurred in clean/types.rs.

cc @camelid

@rustbot rustbot added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Jan 23, 2022
@rust-highfive
Copy link
Collaborator

r? @wesleywiser

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 23, 2022
@rust-log-analyzer

This comment has been minimized.

@camelid
Copy link
Member

camelid commented Jan 23, 2022

@mark-i-m I think your formatter isn't working correctly. Can you run ./x.py fmt?

Comment on lines 362 to 365
if recursion_limit_hit {
// If we hit a recursion limit, exit early to avoid later passes getting overwhelmed
// with a large AST
Err(ErrorReported)
Err(ErrorReported::new_i_know_what_im_doing())
Copy link
Member

Choose a reason for hiding this comment

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

Looks like reduced_recursion_limit could contain an ErrorReported.

Copy link
Member Author

Choose a reason for hiding this comment

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

Coming from where?

Copy link
Member

Choose a reason for hiding this comment

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

From whatever set it, which presumably produced an error in the process.

Copy link
Member Author

Choose a reason for hiding this comment

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

IIUC, it starts out set and only becomes None if there is no error... so there may not be another good place to generate an ErrorReported...

Comment on lines 1152 to 1145
if value.is::<rustc_errors::FatalErrorMarker>() {
ErrorReported
ErrorReported::new_i_know_what_im_doing()
Copy link
Member

Choose a reason for hiding this comment

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

This should be a downcast, not just .is::<...>(), and FatalErrorMarker should contain ErrorReported.

Copy link
Member Author

Choose a reason for hiding this comment

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

Unfortunately, this is difficult because FatalError is defined in rustc_span

@@ -1000,6 +1003,8 @@ impl HandlerInner {
} else {
self.bump_warn_count();
}

ErrorReported::new_i_know_what_im_doing()
Copy link
Member

Choose a reason for hiding this comment

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

This needs to check diagnostic.is_error().

Copy link
Member

Choose a reason for hiding this comment

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

Overall, it feels like the nice thing would be to seal ErrorReported and have an impl in the same "sealed" module that ErrorReported would be in, with a wrapper method for self.emitter.emit_diagnostic(diagnostic); that checks for the conditions for ErrorReported and creates it if necessary.

Another wrapper could be added for self.delayed_span_bugs.push(diagnostic);. Those should be the only cases in which you can guarantee ErrorReported. Error deduplication can keep a ErrorReported around for reuse (in general, this should be favored because it's free, being a ZST).

if self.err_count() == old_count {
Ok(result)
} else {
Err(ErrorReported::new_i_know_what_im_doing())
Copy link
Member

Choose a reason for hiding this comment

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

err_count can be something like Option<(NonZeroUsize, ErrorReported)>, making this only slightly harder than simply ==.

Copy link
Member Author

Choose a reason for hiding this comment

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

Tried this, but it creates a lot of noise everywhere else that err_count is used...

@bors
Copy link
Contributor

bors commented Mar 16, 2022

📌 Commit bb8d430 has been approved by oli-obk

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 16, 2022
@Dylan-DPC
Copy link
Member

@bors p=100 (testing to see if ci works fine now after the outage earlier)

@bors
Copy link
Contributor

bors commented Mar 16, 2022

⌛ Testing commit bb8d430 with merge 5f69cbe7530c8201946c38966e9e4dc424aa0ed6...

@Dylan-DPC
Copy link
Member

@bors retry

@bors
Copy link
Contributor

bors commented Mar 16, 2022

⌛ Testing commit bb8d430 with merge d4c27e66acfef0714867a438bad92a8501dc3ac4...

@rust-log-analyzer
Copy link
Collaborator

A job failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)

@bors
Copy link
Contributor

bors commented Mar 16, 2022

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Mar 16, 2022
@rust-log-analyzer
Copy link
Collaborator

The job dist-arm-linux failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
   Compiling tracing v0.1.30
   Compiling tracing-subscriber v0.3.8
   Compiling vfs-notify v0.0.0 (/checkout/src/tools/rust-analyzer/crates/vfs-notify)
[RUSTC-TIMING] tracing test:false 0.460
##[warning]You are running out of disk space. The runner will stop working when the machine runs out of disk space. Free space left: 44 MB
   Compiling chalk-solve v0.76.0
[RUSTC-TIMING] salsa test:false 1.965
   Compiling tracing-tree v0.2.0
[RUSTC-TIMING] chalk_ir test:false 3.386
[RUSTC-TIMING] chalk_ir test:false 3.386
[RUSTC-TIMING] tracing_tree test:false 0.708
[RUSTC-TIMING] serde_derive test:false 5.610
error: linking with `arm-unknown-linux-gnueabi-gcc` failed: exit status: 1
  |
  = note: "arm-unknown-linux-gnueabi-gcc" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools/arm-unknown-linux-gnueabi/release/deps/serde_derive-1c64612b4d1c4131.serde_derive.36e1ed17-cgu.0.rcgu.o" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools/arm-unknown-linux-gnueabi/release/deps/serde_derive-1c64612b4d1c4131.serde_derive.36e1ed17-cgu.1.rcgu.o" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools/arm-unknown-linux-gnueabi/release/deps/serde_derive-1c64612b4d1c4131.serde_derive.36e1ed17-cgu.10.rcgu.o" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools/arm-unknown-linux-gnueabi/release/deps/serde_derive-1c64612b4d1c4131.serde_derive.36e1ed17-cgu.11.rcgu.o" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools/arm-unknown-linux-gnueabi/release/deps/serde_derive-1c64612b4d1c4131.serde_derive.36e1ed17-cgu.12.rcgu.o" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools/arm-unknown-linux-gnueabi/release/deps/serde_derive-1c64612b4d1c4131.serde_derive.36e1ed17-cgu.13.rcgu.o" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools/arm-unknown-linux-gnueabi/release/deps/serde_derive-1c64612b4d1c4131.serde_derive.36e1ed17-cgu.14.rcgu.o" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools/arm-unknown-linux-gnueabi/release/deps/serde_derive-1c64612b4d1c4131.serde_derive.36e1ed17-cgu.15.rcgu.o" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools/arm-unknown-linux-gnueabi/release/deps/serde_derive-1c64612b4d1c4131.serde_derive.36e1ed17-cgu.2.rcgu.o" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools/arm-unknown-linux-gnueabi/release/deps/serde_derive-1c64612b4d1c4131.serde_derive.36e1ed17-cgu.3.rcgu.o" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools/arm-unknown-linux-gnueabi/release/deps/serde_derive-1c64612b4d1c4131.serde_derive.36e1ed17-cgu.4.rcgu.o" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools/arm-unknown-linux-gnueabi/release/deps/serde_derive-1c64612b4d1c4131.serde_derive.36e1ed17-cgu.5.rcgu.o" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools/arm-unknown-linux-gnueabi/release/deps/serde_derive-1c64612b4d1c4131.serde_derive.36e1ed17-cgu.6.rcgu.o" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools/arm-unknown-linux-gnueabi/release/deps/serde_derive-1c64612b4d1c4131.serde_derive.36e1ed17-cgu.7.rcgu.o" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools/arm-unknown-linux-gnueabi/release/deps/serde_derive-1c64612b4d1c4131.serde_derive.36e1ed17-cgu.8.rcgu.o" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools/arm-unknown-linux-gnueabi/release/deps/serde_derive-1c64612b4d1c4131.serde_derive.36e1ed17-cgu.9.rcgu.o" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools/arm-unknown-linux-gnueabi/release/deps/serde_derive-1c64612b4d1c4131.4xd0hql15h5k1l1c.rcgu.rmeta" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools/arm-unknown-linux-gnueabi/release/deps/serde_derive-1c64612b4d1c4131.50gmajltkdnga9u2.rcgu.o" "-Wl,--as-needed" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools/arm-unknown-linux-gnueabi/release/deps" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools/release/deps" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/arm-unknown-linux-gnueabi/lib" "-Wl,-Bstatic" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools/arm-unknown-linux-gnueabi/release/deps/libsyn-7d31747358504eaf.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools/arm-unknown-linux-gnueabi/release/deps/libquote-4f94274b116a9aad.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools/arm-unknown-linux-gnueabi/release/deps/libproc_macro2-10b840fcf23687bd.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools/arm-unknown-linux-gnueabi/release/deps/libunicode_xid-92585a8fa6816842.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/arm-unknown-linux-gnueabi/lib/libproc_macro-29aa747a197b2d60.rlib" "-Wl,--start-group" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/arm-unknown-linux-gnueabi/lib/libstd-acb2b27900f34390.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/arm-unknown-linux-gnueabi/lib/libpanic_unwind-0bb039c99fa28850.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/arm-unknown-linux-gnueabi/lib/libobject-10cdb874a07e8a1e.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/arm-unknown-linux-gnueabi/lib/libmemchr-66734357af67f97e.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/arm-unknown-linux-gnueabi/lib/libaddr2line-7c02e8d9675a7df5.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/arm-unknown-linux-gnueabi/lib/libgimli-2425d5df657b506f.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/arm-unknown-linux-gnueabi/lib/librustc_demangle-043520ef23d94346.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/arm-unknown-linux-gnueabi/lib/libstd_detect-5114e2ffd5edc1ad.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/arm-unknown-linux-gnueabi/lib/libhashbrown-6e715bbe22aa8d55.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/arm-unknown-linux-gnueabi/lib/libminiz_oxide-b9df0042f4307efb.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/arm-unknown-linux-gnueabi/lib/libadler-488e8618602396dd.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/arm-unknown-linux-gnueabi/lib/librustc_std_workspace_alloc-34fbebe8f4e9abe7.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/arm-unknown-linux-gnueabi/lib/libunwind-3badbeca193a8c7b.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/arm-unknown-linux-gnueabi/lib/libcfg_if-00e326e791b4d746.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/arm-unknown-linux-gnueabi/lib/liblibc-1717943138cbec79.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/arm-unknown-linux-gnueabi/lib/liballoc-6944b356eb3c5d32.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/arm-unknown-linux-gnueabi/lib/librustc_std_workspace_core-16c9d9a485713471.rlib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/arm-unknown-linux-gnueabi/lib/libcore-21d632ec5a739f36.rlib" "-Wl,--end-group" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/arm-unknown-linux-gnueabi/lib/libcompiler_builtins-ce94c46225e07142.rlib" "-Wl,-Bdynamic" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-Wl,--eh-frame-hdr" "-Wl,-znoexecstack" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/arm-unknown-linux-gnueabi/lib" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools/arm-unknown-linux-gnueabi/release/deps/libserde_derive-1c64612b4d1c4131.so" "-Wl,--gc-sections" "-shared" "-Wl,-zrelro,-znow" "-nodefaultlibs" "-Wl,-z,origin" "-Wl,-rpath,$ORIGIN/../lib"
  = note: collect2: error: ld returned 1 exit status

[RUSTC-TIMING] serde_derive test:false 6.249
error: could not compile `serde_derive` due to previous error
warning: build failed, waiting for other jobs to finish...
warning: build failed, waiting for other jobs to finish...
[RUSTC-TIMING] tracing_subscriber test:false 4.301
error: failed to write /tmp/rustceAvTxY/lib.rmeta: No space left on device (os error 28)
error: build failed
error: build failed
thread 'main' panicked at 'rust-analyzer always builds', src/bootstrap/dist.rs:1079:14
[TIMING] ToolBuild { compiler: Compiler { stage: 1, host: TargetSelection { triple: "x86_64-unknown-linux-gnu", file: None } }, target: TargetSelection { triple: "arm-unknown-linux-gnueabi", file: None }, tool: "rust-analyzer", path: "src/tools/rust-analyzer/crates/rust-analyzer", mode: ToolRustc, is_optional_tool: true, source_type: Submodule, extra_features: [] } -- 23.655
[TIMING] RustAnalyzer { compiler: Compiler { stage: 1, host: TargetSelection { triple: "x86_64-unknown-linux-gnu", file: None } }, target: TargetSelection { triple: "arm-unknown-linux-gnueabi", file: None }, extra_features: [] } -- 0.000
Build completed unsuccessfully in 0:40:12

@ehuss
Copy link
Contributor

ehuss commented Mar 17, 2022

@bors retry

Ran out of space. For some reason, the runner had an unusually small root partition (84G instead of the normal 667G). Investigation is needed, but tree is closed for now.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 17, 2022
@bors
Copy link
Contributor

bors commented Mar 17, 2022

⌛ Testing commit bb8d430 with merge c1e4de654ee31e9f368af371fe8bd269c0ec546e...

@bors
Copy link
Contributor

bors commented Mar 17, 2022

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Mar 17, 2022
@ehuss
Copy link
Contributor

ehuss commented Mar 17, 2022

@bors retry p=0

Back to the docker cache/cmake problem.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 17, 2022
bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 18, 2022
Rollup of 10 pull requests

Successful merges:

 - rust-lang#91133 (Improve `unsafe` diagnostic)
 - rust-lang#93222 (Make ErrorReported impossible to construct outside `rustc_errors`)
 - rust-lang#93745 (Stabilize ADX target feature)
 - rust-lang#94309 ([generator_interior] Be more precise with scopes of borrowed places)
 - rust-lang#94698 (Remove redundant code from copy-suggestions)
 - rust-lang#94731 (Suggest adding `{ .. }` around a const function call with arguments)
 - rust-lang#94960 (Fix many spelling mistakes)
 - rust-lang#94982 (Add deprecated_safe feature gate and attribute, cc rust-lang#94978)
 - rust-lang#94997 (debuginfo: Fix ICE when generating name for type that produces a layout error.)
 - rust-lang#95000 (Fixed wrong type name in comment)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 7e1415e into rust-lang:master Mar 18, 2022
@rustbot rustbot added this to the 1.61.0 milestone Mar 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.