Commit Graph

243409 Commits

Author SHA1 Message Date
Nicholas Nethercote
f5c0cd0bd1 Inline and remove three functions.
Each of these has a single call site: `source_file_to_parser`,
`try_file_to_source_file`, `file_to_source_file`. Having them separate
just makes the code longer and harder to read.

Also, `maybe_file_to_stream` doesn't need to be `pub`.
2024-01-11 16:55:10 +11:00
Nicholas Nethercote
552bed8048 Remove DiagnosticBuilder::into_diagnostic from -Ztreat-err-as-bug consideration.
It seems very wrong to have a `-Ztreat-err-as-bug` check here before the
error is even emitted.

Once that's done:
- `into_diagnostic` is infallible, so its return type doesn't need the
  `Option`;
- the `&'a DiagCtxt` also isn't needed, because only one callsite uses
  it, and it already have access to it via `self.dcx`;
- the comments about dcx disabling buffering are no longer true, this is
  unconditional now;
- and the `debug!` seems unnecessary... the comment greatly overstates
  its importance because few diagnostics come through `into_diagnostic`,
  and `-Ztrack-diagnostics` exists anyway.
2024-01-11 16:55:10 +11:00
Nicholas Nethercote
a0f5431e23 Move code around.
No point computing `warnings` and `errors` if we're going to return
early before they're used.
2024-01-11 16:55:10 +11:00
Nicholas Nethercote
2aac288c18 Use the right level with -Ztreat-err-as-bug.
Errors in `DiagCtxtInner::emit_diagnostic` are never set to
`Level::Bug`, because the condition never succeeds, because
`self.treat_err_as_bug()` is called *before* the error counts are
incremented.

This commit switches to `self.treat_next_err_as_bug()`, fixing the
problem. This changes the error message output to actually say "internal
compiler error".
2024-01-11 16:55:10 +11:00
Nicholas Nethercote
f0a3684c1e Inline and remove DiagCtxtInner::bump_{lint_err,err}_count.
They have one and two call sites respectively, and they just make the
code harder to read.
2024-01-11 16:54:22 +11:00
Zalathar
124fff0777 coverage: Add enums to accommodate other kinds of coverage mappings 2024-01-11 16:43:12 +11:00
Zalathar
c5932182ad coverage: Store extracted spans as a flat list of mappings
This is less elegant in some ways, since we no longer visit a BCB's spans as a
batch, but will make it much easier to add support for other kinds of coverage
mapping regions (e.g. branch regions or gap regions).
2024-01-11 16:43:01 +11:00
Zalathar
8f98b54a7e coverage: Extract helper function term_for_bcb 2024-01-11 16:07:38 +11:00
bors
3a6bf351a3 Auto merge of #119677 - cjgillot:early-cfg-opt, r=oli-obk
Reorder early post-inlining passes.

`RemoveZsts`, `RemoveUnneededDrops` and `UninhabitedEnumBranching` only depend on types, so they should be executed together early after MIR inlining introduces those types.

This does not change the end-result, but this makes the pipeline a bit more consistent.
2024-01-11 04:09:07 +00:00
bors
65b323b168 Auto merge of #119837 - matthiaskrgr:rollup-l2olpad, r=matthiaskrgr
Rollup of 11 pull requests

Successful merges:

 - #115046 (Use version-sorting for all sorting)
 - #118915 (Add some comments, add `can_define_opaque_ty` check to `try_normalize_ty_recur`)
 - #119006 (Fix is_global special address handling)
 - #119637 (Pass LLVM error message back to pass wrapper.)
 - #119715 (Exhaustiveness: abort on type error)
 - #119763 (Cleanup things in and around `Diagnostic`)
 - #119788 (change function name in comments)
 - #119790 (Fix all_trait* methods to return all traits available in StableMIR)
 - #119803 (Silence some follow-up errors [1/x])
 - #119804 (Stabilize mutex_unpoison feature)
 - #119832 (Meta: Add project const traits to triagebot config)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-01-11 02:10:34 +00:00
Matthias Krüger
1189d230bd
Rollup merge of #119832 - fmease:project-const-traits-triagebot, r=compiler-errors
Meta: Add project const traits to triagebot config

r? compiler-errors or project-const-traits
2024-01-11 03:02:44 +01:00
Matthias Krüger
f92cde4f9a
Rollup merge of #119804 - tmccombs:stabilize-unpoison, r=cuviper
Stabilize mutex_unpoison feature

Closes #96469

`@rustbot` +T-libs-api
2024-01-11 03:02:44 +01:00
Matthias Krüger
d37de53425
Rollup merge of #119803 - oli-obk:even_more_follow_up_errors, r=compiler-errors
Silence some follow-up errors [1/x]

this is one piece of the requested cleanups from https://github.com/rust-lang/rust/pull/117449

When we use `-> impl SomeTrait<_>` as a return type, we are both using the "infer return type suggestion" code path, and the infer opaque type code path within the same function. That can lead to confusing diagnostics, so silence all opaque type diagnostics in that case.
2024-01-11 03:02:43 +01:00
Matthias Krüger
d93df41c1d
Rollup merge of #119790 - celinval:smir-all-traits, r=oli-obk
Fix all_trait* methods to return all traits available in StableMIR

Also provide a mechanism to retrieve traits and implementations for a given crate.

This fixes https://github.com/rust-lang/project-stable-mir/issues/37
2024-01-11 03:02:42 +01:00
Matthias Krüger
6238698ab5
Rollup merge of #119788 - mj10021:issue-119787-fix, r=oli-obk
change function name in comments

fixes #119787 where I believe an incorrect function name is used in the comments
2024-01-11 03:02:42 +01:00
Matthias Krüger
88493fca13
Rollup merge of #119763 - nnethercote:cleanup-Diagnostic, r=oli-obk
Cleanup things in and around `Diagnostic`

These changes all arose when I was looking closely at how to simplify `DiagCtxtInner::emit_diagnostic`.

r? `@compiler-errors`
2024-01-11 03:02:41 +01:00
Matthias Krüger
4dcc5a05ea
Rollup merge of #119715 - Nadrieril:graceful-type-error, r=compiler-errors
Exhaustiveness: abort on type error

This adds an error path to exhaustiveness checking so that we abort instead of ICEing when encountering a stray `ty::Error`.

Fixes https://github.com/rust-lang/rust/issues/119493
Fixes https://github.com/rust-lang/rust/issues/119778

r? `@compiler-errors`
2024-01-11 03:02:41 +01:00
Matthias Krüger
b6ef8b6d94
Rollup merge of #119637 - aoli-al:master, r=cuviper
Pass LLVM error message back to pass wrapper.

When rustc fails to load a plugin, it should provide more detailed error message. Before this PR, rustc prints:

```
error: failed to run LLVM passes: Failed to load pass pluginPLUGIN_NAME.so
```

This PR passes LLVM errors back to rustc. After this PR, rustc prints:

```
error: failed to run LLVM passes: Could not load library 'PLUGIN_NAME.so': PLUGIN_NAME.so: undefined symbol: _ZN4llvm9DebugFlagE
```

This PR only contains usability improvements and does not change any functionality. Thus, no new unit test is implemented.
2024-01-11 03:02:40 +01:00
Matthias Krüger
0f2d12ebc1
Rollup merge of #119006 - jstasiak:fix-special-ip-ranges, r=cuviper
Fix is_global special address handling

IANA explicitly documents 192.0.0.9/32, 192.0.0.9/32 and 2001:30::/28 as globally reachable[1][2] and the is_global implementations declare following IANA so let's make this happen.

In case of 2002::/16 IANA says N/A so I think it's safe to say we shouldn't return true from is_global for addresses in that block.

[1] https://www.iana.org/assignments/iana-ipv4-special-registry/iana-ipv4-special-registry.xhtml
[2] https://www.iana.org/assignments/iana-ipv6-special-registry/iana-ipv6-special-registry.xhtml
2024-01-11 03:02:40 +01:00
Matthias Krüger
859874f3eb
Rollup merge of #118915 - compiler-errors:alias-nits, r=lcnr
Add some comments, add `can_define_opaque_ty` check to `try_normalize_ty_recur`

Follow-up from #117278, since I was recently re-reviewing this code.
2024-01-11 03:02:39 +01:00
Matthias Krüger
3cc4e02519
Rollup merge of #115046 - joshtriplett:master, r=compiler-errors
Use version-sorting for all sorting

Add a description of a version-sorting algorithm. (This algorithm does
not precisely match `strverscmp`; it's intentionally simpler in its
handling of leading zeroes, and produces a result easier for humans to
easily understand and do by hand.)

Change all references to sorting to use version-sorting.

Change all references to "ASCIIbetically" to instead say "sort
non-lowercase before lowercase".
2024-01-11 03:02:39 +01:00
hi-rustin
784b50cece chore: remove unnecessary blank line
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2024-01-11 09:45:21 +08:00
bors
0a8923361e Auto merge of #119688 - Nadrieril:dont-alloc-custom-wildcards, r=compiler-errors
Exhaustiveness: use an `Option` instead of allocating fictitious patterns

In the process of exhaustiveness checking, `Matrix` stores a 2D array of patterns. Those are subpatterns of the patterns we were provided as input, _except_ sometimes we allocate some extra wildcard patterns to fill a hole during specialization.

Morally though, we could store `Option<&'p DeconstructedPat>` in the matrix, where `None` signifies a wildcard. That way we'd only have "real" patterns in the matrix and we wouldn't need the arena to allocate these wildcards. This is what this PR does.

This is part of me splitting up https://github.com/rust-lang/rust/pull/119581 for ease of review.

r? `@compiler-errors`
2024-01-11 00:04:10 +00:00
Jakub Stasiak
4621357d14 Make is_global/is_unicast_global special address handling complete
IANA explicitly documents 192.0.0.9/32, 192.0.0.9/32 and 2001:30::/28 as
globally reachable[1][2] and the is_global implementations declare
following IANA so let's make this happen.

In case of 2002::/16 IANA says N/A so I think it's safe to say we
shouldn't return true there either.

[1] https://www.iana.org/assignments/iana-ipv4-special-registry/iana-ipv4-special-registry.xhtml
[2] https://www.iana.org/assignments/iana-ipv6-special-registry/iana-ipv6-special-registry.xhtml
2024-01-11 01:03:34 +01:00
Nicholas Nethercote
dd61eba3c3 Simplify lint error counting.
Of the error levels satisfying `is_error`, `Level::Error` is the only
one that can be a lint, so there's no need to check for it.

(And even if it wasn't, it would make more sense to include
non-`Error`-but-`is_error` lints under `lint_err_count` than under
`err_count`.)
2024-01-11 07:56:20 +11:00
Nicholas Nethercote
56c3265c7b Replace warn_count.
There are four functions that adjust error and warning counts:
- `stash_diagnostic` (increment)
- `steal_diagnostic` (decrement)
- `emit_stashed_diagnostics) (decrement)
- `emit_diagnostic` (increment)

The first three all behave similarly, and only update `warn_count` for
forced warnings. But the last one updates `warn_count` for both forced
and non-forced warnings.

Seems like a bug. How should it be fixed? Well, `warn_count` is only
used in one place: `DiagCtxtInner::drop`, where it's part of the
condition relating to the printing of `good_path_delayed_bugs`. The
intention of that condition seems to be "have any errors been printed?"
so this commit replaces `warn_count` with `has_printed`, which is set
when printing occurs. This is simpler than all the ahead-of-time
incrementing and decrementing.
2024-01-11 07:56:20 +11:00
Nicholas Nethercote
8866780d02 Move DiagCtxtInner::deduplicated_warn_count.
To put it next to a similar field.
2024-01-11 07:56:20 +11:00
Nicholas Nethercote
12ba450d14 Reset lint_err_count in DiagCtxt::reset_err_count.
It's missing but should obviously be included.
2024-01-11 07:56:20 +11:00
Nicholas Nethercote
0e388f2192 Change how force-warn lint diagnostics are recorded.
`is_force_warn` is only possible for diagnostics with `Level::Warning`,
but it is currently stored in `Diagnostic::code`, which every diagnostic
has.

This commit:
- removes the boolean `DiagnosticId::Lint::is_force_warn` field;
- adds a `ForceWarning` variant to `Level`.

Benefits:
- The common `Level::Warning` case now has no arguments, replacing
  lots of `Warning(None)` occurrences.
- `rustc_session::lint::Level` and `rustc_errors::Level` are more
  similar, both having `ForceWarning` and `Warning`.
2024-01-11 07:56:17 +11:00
Nicholas Nethercote
06cf881969 Rename TRACK_DIAGNOSTICS as TRACK_DIAGNOSTIC.
Because the values put into it are functions named `track_diagnostic`
and `default_track_diagnostic`.
2024-01-11 07:55:03 +11:00
Nilstrieb
da26317a8a Stop mentioning internal lang items in no_std binary errors
When writing a no_std binary, you'll be greeted with nonsensical errors
mentioning lang items like eh_personality and start. That's pretty bad
because it makes you think that you need to define them somewhere! But
oh no, now you're getting the `internal_features` lint telling you that
you shouldn't use them! But you need a no_std binary! What now?

No problem! Writing a no_std binary is super easy. Just use panic=abort
and supply your own platform specific entrypoint symbol (like `main`)
and you're good to go. Would be nice if the compiler told you that,
right?

This makes it so that it does do that.
2024-01-10 21:18:54 +01:00
León Orell Valerian Liehr
7d61535ef0
Add project const traits to triagebot config 2024-01-10 20:09:27 +01:00
Eric Huss
f7e8739eac Add debug info for macOS CI actions 2024-01-10 10:54:46 -08:00
bors
a2d9d73e60 Auto merge of #119751 - nnethercote:error-api-fixes, r=oli-obk
Diagnostic API fixes

Some improvements to diagnostic APIs: improve some naming, use shortcuts in more places, and add a couple of missing methods.

r? `@compiler-errors`
2024-01-10 18:03:53 +00:00
Michael Goulet
427c55c65c Simplify some redundant names 2024-01-10 16:29:23 +00:00
Michael Goulet
3799568895 More comments 2024-01-10 16:29:23 +00:00
Michael Goulet
f49b0dcce2 Check reveal and can_define_opaque_ty in try_normalize_ty_recur 2024-01-10 16:21:58 +00:00
Simonas Kazlauskas
837be0de5f bootstrap: exclude link_jobs from check_ci_llvm! checks
This option is largely there to help people to manage the memory usage
on their systems during the LLVM build. The linking phase is as usual
are the heaviest part of the build and if in an unlucky conincidence the
circumstances align to kick off N_CORES links at the same time, not even
hundreds of GiB of memory may suffice. It makes a lot of sense for
developers to set&forget this option unconditionally.

Not to mention, this option does not, in any way, affect the generated
code (at least as far as I know.) It really doesn’t matter what
option the CI build LLVM used here and/or if it matches with the user’s
configuration.

Finally, 0 actual link jobs implied by `download-ci-llvm` is guaranteed
to stay within the limits that are reasonable to set with this option.
2024-01-10 17:06:36 +02:00
Nadrieril
dee657f9f9 Add test case for #119778 2024-01-10 14:50:48 +01:00
Thayne McCombs
1ed855dedf Stabilize mutex_unpoison feature
Closes #96469

@rustbot +T-libs-api
2024-01-10 02:34:34 -07:00
Oli Scherer
0e82aaeb67 Avoid follow up errors 2024-01-10 08:52:44 +00:00
Oli Scherer
972c95a6e2 Turn some free functions into methods 2024-01-10 08:52:44 +00:00
Oli Scherer
ba27e22f67 Use a ty::Error instead of patching up a type after erroring 2024-01-10 08:52:44 +00:00
Nikita Popov
9ff3083b27 Update LLVM submodule 2024-01-10 09:35:29 +01:00
bors
e927184629 Auto merge of #119797 - matthiaskrgr:rollup-nn2lt39, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 - #106893 (Explain base expression for struct update syntax)
 - #119769 (rustdoc: offset generic args of cross-crate trait object types when cleaning)
 - #119772 (Fix an ICE that occurs after an error has already been reported)
 - #119782 (rint intrinsics: caution against actually trying to check for floating-point exceptions)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-01-10 07:10:57 +00:00
Matthias Krüger
3fcddf19e7
Rollup merge of #119782 - RalfJung:rint, r=cuviper
rint intrinsics: caution against actually trying to check for floating-point exceptions
2024-01-10 06:28:45 +01:00
Matthias Krüger
4571ef9152
Rollup merge of #119772 - oli-obk:whackamole, r=compiler-errors
Fix an ICE that occurs after an error has already been reported

fixes #117491

cc `@jswrenn`
2024-01-10 06:28:45 +01:00
Matthias Krüger
7c378d0058
Rollup merge of #119769 - fmease:rustdoc-off-by-one-dyn-trait-def-gen-args, r=GuillaumeGomez
rustdoc: offset generic args of cross-crate trait object types when cleaning

Fixes #119529.

This PR contains several refactorings apart from the bug fix.
Best reviewed commit by commit.
r? GuillaumeGomez
2024-01-10 06:28:44 +01:00
Matthias Krüger
33f27d32a9
Rollup merge of #106893 - clubby789:struct-update-help, r=compiler-errors
Explain base expression for struct update syntax

Fixes #106890

`@rustbot` label +A-diagnostics
2024-01-10 06:28:44 +01:00
bors
9273d63f07 Auto merge of #119794 - weihanglo:update-cargo, r=weihanglo
Update cargo

14 commits in 2ce45605d9db521b5fd6c1211ce8de6055fdb24e..3e428a38a34e820a461d2cc082e726d3bda71bcb
2024-01-04 18:04:13 +0000 to 2024-01-09 20:46:36 +0000
- refactor: replace `iter_join` with `itertools::join` (rust-lang/cargo#13275)
- docs(unstable): doc comments for items and fields (rust-lang/cargo#13274)
- crates-io: Set `Content-Type: application/json` only for requests with a body payload (rust-lang/cargo#13264)
- fix: only inherit workspace package table if the new package is a member (rust-lang/cargo#13261)
- feat(cli): add colors to `-Zhelp` console output (rust-lang/cargo#13269)
- chore(deps): update msrv (rust-lang/cargo#13266)
- refactor(toml): Make it more obvious to update package-dependent fields (rust-lang/cargo#13267)
- chore(ci): Fix MSRV:3 updates (rust-lang/cargo#13268)
- chore(ci): Shot-in-the-dark fix for MSRV updating (rust-lang/cargo#13265)
- fix: set OUT_DIR for all units with build scripts (rust-lang/cargo#13204)
- fix(manifest): Provide unused key warnings for lints table (rust-lang/cargo#13262)
- test(manifest): Verify we warn on unused workspace.package fields (rust-lang/cargo#13263)
- docs(changelog): Call out cargo-new lockfile change (rust-lang/cargo#13260)
- chore: Add dependency dashboard (rust-lang/cargo#13255)

r? ghost
2024-01-10 05:12:46 +00:00