Skip to content

Conversation

compiler-errors
Copy link
Member

Successful merges:

r? @ghost
@rustbot modify labels: rollup

Create a similar rollup

compiler-errors and others added 30 commits November 13, 2023 16:56
Currently, `Handler::fatal` returns `FatalError`. But `Session::fatal`
returns `!`, because it calls `Handler::fatal` and then calls `raise` on
the result. This inconsistency is unfortunate.

This commit changes `Handler::fatal` to do the `raise` itself, changing
its return type to `!`. This is safe because there are only two calls to
`Handler::fatal`, one in `rustc_session` and one in
`rustc_codegen_cranelift`, and they both call `raise` on the result.

`HandlerInner::fatal` still returns `FatalError`, so I renamed it
`fatal_no_raise` to emphasise the return type difference.
They each have a single call site.

Note: the `make_diagnostic_builder` calls in `lib.rs` will be replaced
in a subsequent commit.
`sess` is a terribly misleading name for a `Handler`! This confused me
for a bit.
That's what is mostly used. This commit changes a few `EM` and `E` and
`T` type variables to `G`.
`Diagnostic::new` can be used instead.
These impls are all needed for just a single `IntoDiagnostic` type, not
a family of them.

Note that `ErrorGuaranteed` is the default type parameter for
`IntoDiagnostic`.
By making it generic, instead of only for `EmissionGuarantee = ()`, we
can use it everywhere.
`Handler` is a wrapper around `HanderInner`. Some functions on
on `Handler` just forward to the samed-named functions on
`HandlerInner`.

This commit removes as many of those as possible, implementing functions
on `Handler` where possible, to avoid the boilerplate required for
forwarding. The commit is moderately large but it's very mechanical.
This is weird: `HandlerInner::emit` calls
`HandlerInner::emit_diagnostic`, but only after doing a
`treat-err-as-bug` check. Which is fine, *except* that there are
multiple others paths for an `Error` or `Fatal` diagnostic to be passed
to `HandlerInner::emit_diagnostic` without going through
`HandlerInner::emit`, e.g. `Handler::span_err` call
`Handler::emit_diag_at_span`, which calls `emit_diagnostic`.
So that suggests that the coverage for `treat-err-as-bug` is incomplete.

This commit removes `HandlerInner::emit` and moves the
`treat-err-as-bug` check to `HandlerInner::emit_diagnostic`, so it
cannot by bypassed.
This makes `Handler::fatal` more like `Handler::{err,warn,bug,note}`.
…pressions_from_macros`

This already wasn't passed in bootstrap.py and the lint itself already warns-by-default for 2 years now and has already been added to the future-incompat group in Rust 1.68.

See rust-lang#79813 for the tracking issue.
…ules_2024, r=TaKO8Ki

Implement 2024-edition lifetime capture rules RFC

Implements rust-lang/rfcs#3498.
…compiler-errors

Add support for making lib features internal

We have the notion of an "internal" lang feature: a feature that is never intended to be stabilized, and using which can cause ICEs and other issues without that being considered a bug.

This extends that idea to lib features as well. It is an alternative to rust-lang#115623: instead of using an attribute to declare lib features internal, we simply do this based on the name. Everything ending in `_internals` or `_internal` is considered internal.

Then we rename `core_intrinsics` to `core_intrinsics_internal`, which fixes rust-lang#115597.
…tebank

Pretty print `Fn<(..., ...)>` trait refs with parentheses (almost) always

It's almost always better, at least in diagnostics, to print `Fn(i32, u32)` instead of `Fn<(i32, u32)>`.

Related to but doesn't fix rust-lang#118225. That needs a separate fix.
…or-diagnostic, r=lcnr

Add `deeply_normalize_for_diagnostics`, use it in coherence

r? lcnr

Normalize trait refs used for coherence error reporting with `-Ztrait-solver=next-coherence`.

Two things:
1. I said before that we can't add this to `TyErrCtxt` because we compute `OverlapResult`s even if there are no diagnostics being emitted, e.g. for a reservation impl.
2. I didn't want to add this to an `InferCtxtExt` trait because I felt it was unnecessary. I don't particularly care about the API though.
…jubilee

Simplify Default for tuples

Doesn't need a separate block for each element
…errors

Fix parser ICE when recovering `dyn`/`impl` after `for<...>`

Fixes rust-lang#118564
…-2, r=compiler-errors

Cleanup error handlers some more

A sequel to rust-lang#118470.

r? ``@compiler-errors``
bootstrap(builder.rs): Don't explicitly warn against `semicolon_in_expressions_from_macros`

This already wasn't passed in bootstrap.py and the lint itself already warns-by-default for 2 years now and has already been added to the future-incompat group in Rust 1.68.

See rust-lang#79813 for the tracking issue.
@rustbot rustbot added A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) rollup A PR which is a rollup labels Dec 5, 2023
@compiler-errors
Copy link
Member Author

@bors r+ rollup=never p=8

@bors
Copy link
Collaborator

bors commented Dec 5, 2023

📌 Commit 8542d84 has been approved by compiler-errors

It is now in the queue for this repository.

@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 Dec 5, 2023
@rust-log-analyzer
Copy link
Collaborator

The job x86_64-gnu-llvm-16 failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
GITHUB_ENV=/home/runner/work/_temp/_runner_file_commands/set_env_52be55a4-749b-48a2-a0fc-dd84aa8ba976
GITHUB_EVENT_NAME=pull_request
GITHUB_EVENT_PATH=/home/runner/work/_temp/_github_workflow/event.json
GITHUB_GRAPHQL_URL=https://api.github.com/graphql
GITHUB_HEAD_REF=rollup-k4g47bl
GITHUB_JOB=pr
GITHUB_PATH=/home/runner/work/_temp/_runner_file_commands/add_path_52be55a4-749b-48a2-a0fc-dd84aa8ba976
GITHUB_REF=refs/pull/118653/merge
GITHUB_REF_NAME=118653/merge
GITHUB_REF_PROTECTED=false
---

---- [ui] tests/ui/feature-gates/feature-gate-lifetime-capture-rules-2024.rs stdout ----
diff of stderr:

13 LL | fn foo(x: &Vec<i32>) -> impl Sized + '_ {
15 
- error: aborting due to previous error
+ error: aborting due to 1 previous error
17 
17 
18 For more information about this error, try `rustc --explain E0700`.
19 


The actual stderr differed from the expected stderr.
Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/feature-gates/feature-gate-lifetime-capture-rules-2024/feature-gate-lifetime-capture-rules-2024.stderr
To only update this specific test, also pass `--test-args feature-gates/feature-gate-lifetime-capture-rules-2024.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
status: exit status: 1
command: RUSTC_ICE="0" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/feature-gates/feature-gate-lifetime-capture-rules-2024.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/feature-gates/feature-gate-lifetime-capture-rules-2024" "-A" "unused" "-A" "internal_features" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/feature-gates/feature-gate-lifetime-capture-rules-2024/auxiliary"
--- stderr -------------------------------
--- stderr -------------------------------
error[E0700]: hidden type for `impl Sized` captures lifetime that does not appear in bounds
##[error]  --> /checkout/tests/ui/feature-gates/feature-gate-lifetime-capture-rules-2024.rs:2:5
   |
LL | fn foo(x: &Vec<i32>) -> impl Sized {
   |           ---------     ---------- opaque type defined here
   |           |
   |           hidden type `&Vec<i32>` captures the anonymous lifetime defined here
   |     ^
   |
   |
help: to declare that `impl Sized` captures `'_`, you can add an explicit `'_` lifetime bound
   |
LL | fn foo(x: &Vec<i32>) -> impl Sized + '_ {

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0700`.
For more information about this error, try `rustc --explain E0700`.
------------------------------------------


---- [ui] tests/ui/impl-trait/implicit-capture-late.rs stdout ----
diff of stderr:

4 LL | fn foo(x: Vec<i32>) -> Box<dyn for<'a> Deref<Target = impl ?Sized>> {
6 
- error: aborting due to previous error
+ error: aborting due to 1 previous error
8 
---
status: exit status: 1
command: RUSTC_ICE="0" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/impl-trait/implicit-capture-late.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/impl-trait/implicit-capture-late" "-A" "unused" "-A" "internal_features" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/impl-trait/implicit-capture-late/auxiliary"
stdout: none
--- stderr -------------------------------
error[E0657]: `impl Trait` can only capture lifetimes bound at the fn or impl level
   |
   |
LL | fn foo(x: Vec<i32>) -> Box<dyn for<'a> Deref<Target = impl ?Sized>> {

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0657`.

@compiler-errors
Copy link
Member Author

One sec, fixing that issue in the 2024-lifetime capture rules PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) rollup A PR which is a rollup S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants