Commit Graph

247488 Commits

Author SHA1 Message Date
Nicholas Nethercote
260ae70140 Overhaul how stashed diagnostics work, again.
Stashed errors used to be counted as errors, but could then be
cancelled, leading to `ErrorGuaranteed` soundness holes. #120828 changed
that, closing the soundness hole. But it introduced other difficulties
because you sometimes have to account for pending stashed errors when
making decisions about whether errors have occured/will occur and it's
easy to overlook these.

This commit aims for a middle ground.
- Stashed errors (not warnings) are counted immediately as emitted
  errors, avoiding the possibility of forgetting to consider them.
- The ability to cancel (or downgrade) stashed errors is eliminated, by
  disallowing the use of `steal_diagnostic` with errors, and introducing
  the more restrictive methods `try_steal_{modify,replace}_and_emit_err`
  that can be used instead.

Other things:
- `DiagnosticBuilder::stash` and `DiagCtxt::stash_diagnostic` now both
  return `Option<ErrorGuaranteed>`, which enables the removal of two
  `delayed_bug` calls and one `Ty::new_error_with_message` call. This is
  possible because we store error guarantees in
  `DiagCtxt::stashed_diagnostics`.
- Storing the guarantees also saves us having to maintain a counter.
- Calls to the `stashed_err_count` method are no longer necessary
  alongside calls to `has_errors`, which is a nice simplification, and
  eliminates two more `span_delayed_bug` calls and one FIXME comment.
- Tests are added for three of the four fixed PRs mentioned below.
- `issue-121108.rs`'s output improved slightly, omitting a non-useful
  error message.

Fixes #121451.
Fixes #121477.
Fixes #121504.
Fixes #121508.
2024-02-29 11:08:27 +11:00
Nicholas Nethercote
ec25d6db53 Don't cancel stashed TraitMissingMethod errors.
This gives one extra error message on two tests, but is necessary to fix
bigger problems caused by the cancellation of stashed errors.

(Note: why not just avoid stashing altogether? Because that resulted in
additional output changes.)
2024-02-29 11:05:40 +11:00
Nicholas Nethercote
c4ec196c7e Don't cancel stashed OpaqueHiddenTypeMismatch errors.
This gives one extra error message on one test, but is necessary to fix
bigger problems caused by the cancellation of stashed errors.

(Note: why not just avoid stashing altogether? Because that resulted in
additional output changes.)
2024-02-29 11:05:38 +11:00
bors
c475e2303b Auto merge of #121489 - nnethercote:diag-renaming, r=davidtwco
Diagnostic renaming

Renaming various diagnostic types from `Diagnostic*` to `Diag*`. Part of https://github.com/rust-lang/compiler-team/issues/722. There are more to do but this is enough for one PR.

r? `@davidtwco`
2024-02-28 20:39:38 +00:00
bors
bf9c7a64ad Auto merge of #121741 - GuillaumeGomez:rollup-msrsrnk, r=GuillaumeGomez
Rollup of 12 pull requests

Successful merges:

 - #120051 (Add `display` method to `OsStr`)
 - #121226 (Fix issues in suggesting importing extern crate paths)
 - #121423 (Remove the `UntranslatableDiagnosticTrivial` lint.)
 - #121527 (unix_sigpipe: Simple fixes and improvements in tests)
 - #121572 (Add test case for primitive links in alias js)
 - #121661 (Changing some attributes to only_local.)
 - #121680 (Fix link generation for foreign macro in jump to definition feature)
 - #121686 (Adjust printing for RPITITs)
 - #121691 (handle unavailable creation time as `io::ErrorKind::Unsupported`)
 - #121695 (Split rustc_type_ir to avoid rustc_ast from depending on it)
 - #121698 (CFI: Fix typo in test file names)
 - #121702 (Process alias-relate obligations in CoerceUnsized loop)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-02-28 17:30:25 +00:00
Guillaume Gomez
1b08d1a92c
Rollup merge of #121702 - compiler-errors:coerce-alias-relate, r=lcnr
Process alias-relate obligations in CoerceUnsized loop

After #119106, we now emit `AliasRelate` goals when relating `?0` and `Alias<T, ..>` in the new solver. In the ad-hoc `CoerceUnsized` selection loop, we now may have `AliasRelate` goals which must be processed to constrain type variables which are mentioned in other goals.

---

For example, in the included test, we try to coerce `&<ManuallyDrop<T> as Deref>::Target` to `&dyn Foo`. This requires proving:
* 1 `&<ManuallyDrop<T> as Deref>::Target: CoerceUnsized<&dyn Foo>`
    * 2 `<ManuallyDrop<T> as Deref>::Target alias-relate ?0`
    * 3 `?0: Unsize<dyn Foo>`
        * 4 `?0: Foo`
        * 5 `?0: Sized`

If we don't process goal (2.) before processing goal (3.), then we hit ambiguity since `?0` is never constrained, and therefore we bail out, refusing to coerce the types. After processing (2.), we know `?0 := T`, and the rest of the goals can be processed normally.
2024-02-28 16:04:54 +01:00
Guillaume Gomez
ca69a1ff75
Rollup merge of #121698 - rcvalle:rust-cfi-fix-typo, r=compiler-errors
CFI: Fix typo in test file names

Fixes typo (i.e., saniziter) in test file names.
2024-02-28 16:04:54 +01:00
Guillaume Gomez
a62cfe04d6
Rollup merge of #121695 - oli-obk:split_ty_utils, r=compiler-errors
Split rustc_type_ir to avoid rustc_ast from depending on it

unblocks #121576

and resolves a FIXME in `rustc_ast`'s `Cargo.toml`

The new crate is tiny, but it will get bigger in #121576
2024-02-28 16:04:53 +01:00
Guillaume Gomez
2492f93222
Rollup merge of #121691 - janstarke:handle-missing-creation-time-as-unsupported, r=cuviper
handle unavailable creation time as `io::ErrorKind::Unsupported`
2024-02-28 16:04:53 +01:00
Guillaume Gomez
a0027e86aa
Rollup merge of #121686 - compiler-errors:rpitit-printing, r=lcnr
Adjust printing for RPITITs

1. Call RPITITs `{synthetic#N}` instead of `{opaque#N}`.
2. Fall back to printing the RPITIT like an opaque even when printed as an `AliasTy`, just like we do for `ty::Alias`.

You could argue that (2.) is misleading, but I believe it's more consistent than naming `{synthetic#N}`, which I assume approximately nobody knows where that def path name comes from.

r? lcnr
2024-02-28 16:04:52 +01:00
Guillaume Gomez
b609afeaf2
Rollup merge of #121680 - GuillaumeGomez:foreign-macro-jump-to-def, r=notriddle
Fix link generation for foreign macro in jump to definition feature

The crate name is already added to the link so it shouldn't be added a second time for local foreign macros.

r? ``@notriddle``
2024-02-28 16:04:52 +01:00
Guillaume Gomez
796af693ad
Rollup merge of #121661 - surechen:change_attribute_to_local_20240226, r=lcnr
Changing some attributes to only_local.

Modified according to https://github.com/rust-lang/compiler-team/issues/505.

By running test cases, I found that modifying the attribute's only_local tag sometimes causes some unintuitive error reports, so I tend to split it into multiple PRs and edit a small number of attributes each time to prevent too many changes at once. Prevent possible subsequent difficulties in locating problems.

r? ``@lcnr``
2024-02-28 16:04:51 +01:00
Guillaume Gomez
65b190d34d
Rollup merge of #121572 - notriddle:notriddle/test-case-121106, r=GuillaumeGomez
Add test case for primitive links in alias js

Follow up #121490

CC #121106
2024-02-28 16:04:51 +01:00
Guillaume Gomez
d8e6550838
Rollup merge of #121527 - Enselic:unix_sigpipe-tests-fixes, r=davidtwco
unix_sigpipe: Simple fixes and improvements in tests

In https://github.com/rust-lang/rust/pull/120832 I included 5 preparatory commits.

It will take a while before discussions there and in https://github.com/rust-lang/rust/issues/62569 is settled, so here is a PR that splits out 4 of the commits that are easy to review, to get them out of the way.

r? ``@davidtwco`` who already approved these commits in https://github.com/rust-lang/rust/pull/120832 (but I have tweaked them a bit and rebased them since then).

For the convenience of my reviewer, here are the full commit messages of the commits:
<details>
<summary>Click to expand</summary>

```
commit 948b1d68ab (HEAD -> unix_sigpipe-tests-fixes, origin/unix_sigpipe-tests-fixes)
Author: Martin Nordholts <martin.nordholts@codetale.se>
Date:   Fri Feb 9 07:57:27 2024 +0100

    tests: Add unix_sigpipe-different-duplicates.rs test variant

    To make sure that

        #[unix_sigpipe = "x"]
        #[unix_sigpipe = "y"]

    behaves like

        #[unix_sigpipe = "x"]
        #[unix_sigpipe = "x"]

commit d14f15862d
Author: Martin Nordholts <martin.nordholts@codetale.se>
Date:   Fri Feb 9 08:47:47 2024 +0100

    tests: Combine unix_sigpipe-not-used.rs and unix_sigpipe-only-feature.rs

    The only difference between the files is the presence/absence of

        #![feature(unix_sigpipe)]

    attribute. Avoid duplication by using revisions instead.

commit a1cb3dba84
Author: Martin Nordholts <martin.nordholts@codetale.se>
Date:   Fri Feb 9 06:44:56 2024 +0100

    tests: Rename unix_sigpipe.rs to unix_sigpipe-bare.rs for clarity

    The test is for the "bare" variant of the attribute that looks like this:

        #[unix_sigpipe]

    which is not allowed, because it must look like this:

        #[unix_sigpipe = "sig_ign"]

commit e060274e55
Author: Martin Nordholts <martin.nordholts@codetale.se>
Date:   Fri Feb 9 05:48:24 2024 +0100

    tests: Fix typo unix_sigpipe-error.rs -> unix_sigpipe-sig_ign.rs

    There is no error expected. It's simply the "regular" test for sig_ign.
    So rename it.
```

</details>

Tracking issue: https://github.com/rust-lang/rust/issues/97889
2024-02-28 16:04:50 +01:00
Guillaume Gomez
587d8282ef
Rollup merge of #121423 - nnethercote:rm-UntranslatableDiagnosticTrivial, r=davidtwco
Remove the `UntranslatableDiagnosticTrivial` lint.

It's a specialized form of the `UntranslatableDiagnostic` lint that is deny-by-default.

Now that `UntranslatableDiagnostic` has been changed from allow-by-default to deny-by-default, the trivial variant is no longer needed.

r? ``@davidtwco``
2024-02-28 16:04:50 +01:00
Guillaume Gomez
c5dafe66ba
Rollup merge of #121226 - chenyukang:yukang-fix-import-alias, r=davidtwco
Fix issues in suggesting importing extern crate paths

Fixes #121168

r? ``@petrochenkov``
2024-02-28 16:04:49 +01:00
Guillaume Gomez
d8404084c0
Rollup merge of #120051 - riverbl:os-str-display, r=m-ou-se
Add `display` method to `OsStr`

Add `display` method to `OsStr` for lossy display of an `OsStr` which may contain invalid unicode.

Invalid Unicode sequences are replaced with `U+FFFD REPLACEMENT CHARACTER`.

This change also makes the `std::ffi::os_str` module public (see https://github.com/rust-lang/libs-team/issues/326#issuecomment-1894160023).

- ACP: https://github.com/rust-lang/libs-team/issues/326
- Tracking issue: #120048
2024-02-28 16:04:49 +01:00
bors
d377991bad Auto merge of #121699 - weihanglo:update-cargo, r=weihanglo
Update cargo

16 commits in 194a60b2952bd5d12ba15dd2577a97eed7d3c587..8964c8ccff6e420e2a38b8696d178d69fab84d9d
2024-02-21 01:53:45 +0000 to 2024-02-27 19:22:46 +0000
- feat: Add "-Zpublic-dependency" for public-dependency feature. (rust-lang/cargo#13340)
- Stabilize global cache data tracking. (rust-lang/cargo#13492)
- chore: bump baseline version requirement of sub crates (rust-lang/cargo#13494)
- fix(doctest): search native libs in build script outputs (rust-lang/cargo#13490)
- chore: fixed a typo(two-&gt;too) (rust-lang/cargo#13489)
- test: relax help text assertion (rust-lang/cargo#13488)
- refactor: clean up for `GlobalContext` rename (rust-lang/cargo#13486)
- test(cli): Verify terminal styling (rust-lang/cargo#13461)
- fix(cli): Respect CARGO_TERM_COLOR in '--list' and '-Zhelp' (rust-lang/cargo#13479)
- Error messages when collecting workspace members now mention the workspace root location (rust-lang/cargo#13480)
- fix(add): Improve error when adding registry packages while vendored (rust-lang/cargo#13281)
- [docs]:Add missing jump links (rust-lang/cargo#13478)
- Add global_cache_tracker stability tests. (rust-lang/cargo#13467)
- fix(cli): Control clap colors through config (rust-lang/cargo#13463)
- chore: remove the unused function (rust-lang/cargo#13472)
- Fix missing brackets (rust-lang/cargo#13470)
2024-02-28 15:03:14 +00:00
Nicholas Nethercote
5e29e26b96 Remove the UntranslatableDiagnosticTrivial lint.
It's a specialized form of the `UntranslatableDiagnostic` lint that is
deny-by-default.

Now that `UntranslatableDiagnostic` has been changed from
allow-by-default to deny-by-default, the trivial variant is no longer
needed.
2024-02-28 10:53:04 +11:00
Nicholas Nethercote
8f3b007abc Rename DiagnosticImportance as DiagImportance. 2024-02-28 08:55:38 +11:00
Nicholas Nethercote
9b3520e876 Rename DiagnosticStyledString as DiagStyledString. 2024-02-28 08:55:37 +11:00
Nicholas Nethercote
6280a8c3fe Rename DiagnosticSymbolList as DiagSymbolList. 2024-02-28 08:55:37 +11:00
Nicholas Nethercote
e3c19a2928 Rename DiagnosticLocation as DiagLocation. 2024-02-28 08:55:37 +11:00
Nicholas Nethercote
d0ef108ce9 Rename DiagnosticArgFromDisplay as DiagArgFromDisplay. 2024-02-28 08:55:37 +11:00
Nicholas Nethercote
8199632aa8 Rename DiagnosticArg{,Map,Name,Value} as DiagArg{,Map,Name,Value}. 2024-02-28 08:55:37 +11:00
Nicholas Nethercote
899cb40809 Rename DiagnosticBuilder as Diag.
Much better!

Note that this involves renaming (and updating the value of)
`DIAGNOSTIC_BUILDER` in clippy.
2024-02-28 08:55:35 +11:00
Weihang Lo
2dbdb8a751
Update cargo 2024-02-27 16:42:47 -05:00
Nicholas Nethercote
4e1f9bd528 Rename SubDiagnostic as Subdiag.
Note the change of the `D` to `d`, to match all the other names that
have `Subdiag` in them, such as `SubdiagnosticMessage` and
`derive(Subdiagnostic)`.
2024-02-28 08:33:25 +11:00
Nicholas Nethercote
366536ba2b Rename DelayedDiagnostic as DelayedDiagInner. 2024-02-28 08:33:25 +11:00
Nicholas Nethercote
6588f5b749 Rename Diagnostic as DiagInner.
I started by changing it to `DiagData`, but that didn't feel right.
`DiagInner` felt much better.
2024-02-28 08:33:25 +11:00
bors
ef324565d0 Auto merge of #119616 - rylev:wasm32-wasi-preview2, r=petrochenkov,m-ou-se
Add a new `wasm32-wasi-preview2` target

This is the initial implementation of the MCP https://github.com/rust-lang/compiler-team/issues/694 creating a new tier 3 target `wasm32-wasi-preview2`. That MCP has been seconded and will most likely be approved in a little over a week from now. For more information on the need for this target, please read the [MCP](https://github.com/rust-lang/compiler-team/issues/694).

There is one aspect of this PR that will become insta-stable once these changes reach a stable compiler:
* A new `target_family` named `wasi` is introduced. This target family incorporates all wasi targets including `wasm32-wasi` and its derivative `wasm32-wasi-preview1-threads`. The difference between `target_family = wasi` and `target_os = wasi` will become much clearer when `wasm32-wasi` is renamed to `wasm32-wasi-preview1` and the `target_os` becomes `wasm32-wasi-preview1`. You can read about this target rename in [this MCP](https://github.com/rust-lang/compiler-team/issues/695) which has also been seconded and will hopefully be officially approved soon.

Additional technical details include:
* Both `std::sys::wasi_preview2` and `std::os::wasi_preview2` have been created and mostly use `#[path]` annotations on their submodules to reach into the existing `wasi` (soon to be `wasi_preview1`) modules. Over time the differences between `wasi_preview1` and `wasi_preview2` will grow and most like all `#[path]` based module aliases will fall away.
* Building `wasi-preview2` relies on a [`wasi-sdk`](https://github.com/WebAssembly/wasi-sdk) in the same way that `wasi-preview1` does (one must include a `wasi-root` path in the `Config.toml` pointing to sysroot included in the wasi-sdk). The target should build against [wasi-sdk v21](https://github.com/WebAssembly/wasi-sdk/releases/tag/wasi-sdk-21) without modifications. However, the wasi-sdk itself is growing [preview2 support](https://github.com/WebAssembly/wasi-sdk/pull/370) so this might shift rapidly. We will be following along quickly to make sure that building the target remains possible as the wasi-sdk changes.
* This requires a [patch to libc](https://github.com/rylev/rust-libc/tree/wasm32-wasi-preview2) that we'll need to land in conjunction with this change. Until that patch lands the target won't actually build.
2024-02-27 20:57:38 +00:00
Michael Goulet
cc584ba245 Process alias-relate obligations in CoerceUnsized loop 2024-02-27 20:07:58 +00:00
Ramon de C Valle
c7476f86b5 CFI: Fix typo in test file names
Fixes typo (i.e., saniziter) in test file names.
2024-02-27 11:03:02 -08:00
bors
1e4f9e302c Auto merge of #121677 - flip1995:clippy-subtree-update, r=Manishearth
Clippy subtree update

r? `@Manishearth`
2024-02-27 18:28:06 +00:00
Oli Scherer
8a6d3535f7 Split rustc_type_ir to avoid rustc_ast from depending on it 2024-02-27 18:11:23 +00:00
Michael Goulet
b57ddfe079 Print RPITIT like an opaque 2024-02-27 17:43:40 +00:00
Michael Goulet
1feef44daf rename RPITIT from opaque to synthetic 2024-02-27 17:43:40 +00:00
Jan Starke
7e10a5c724
handle unavailable creation time as io::ErrorKind::Unsupported 2024-02-27 17:45:20 +01:00
bors
8790c3cc7c Auto merge of #119636 - devnexen:linux_tcp_defer_accept, r=m-ou-se
os::net: expanding TcpStreamExt for Linux with `tcp_deferaccept`.

allows for socket to process only when there is data to process, the option sets a number of seconds until the data is ready.
2024-02-27 16:00:39 +00:00
Guillaume Gomez
4dd05e6424 Add regression test for link generation on foreign macro in jump to defintion feature 2024-02-27 16:20:11 +01:00
Guillaume Gomez
8719b74027 Fix link generation for locate foreign macro in jump to definition feature 2024-02-27 16:19:19 +01:00
Ryan Levick
5e9bed7b1e
Rename wasm32-wasi-preview2 to wasm32-wasip2
Signed-off-by: Ryan Levick <me@ryanlevick.com>
2024-02-27 10:14:45 -05:00
Ryan Levick
f115064631 Add the wasm32-wasi-preview2 target
Signed-off-by: Ryan Levick <me@ryanlevick.com>
2024-02-27 09:58:04 -05:00
Philipp Krones
f99056bd87
Update Cargo.lock 2024-02-27 15:50:23 +01:00
Philipp Krones
ad7513e874
Merge commit '10136170fe9ed01e46aeb4f4479175b79eb0e3c7' into clippy-subtree-update 2024-02-27 15:50:17 +01:00
bors
10136170fe Auto merge of #12363 - oli-obk:bump_ui_test, r=flip1995
lower `bstr` version requirement to `1.6.0`

test changes are due to https://github.com/oli-obk/ui_test/pull/201 (cc `@Jarcho)`

changelog: none
2024-02-27 13:46:14 +00:00
Oli Scherer
592fe89997 lower bstr version requirement to 1.6.0 2024-02-27 13:34:01 +00:00
bors
b6e4299415 Auto merge of #121548 - RalfJung:ffi-unwind-intrinsics, r=davidtwco
ffi_unwind_calls: treat RustIntrinsic like regular Rust calls

Also add some comments to `abi_can_unwind` to explain what happens.

r? `@nbdd0121`  Cc `@BatmanAoD`
2024-02-27 13:33:35 +00:00
Ralf Jung
f5c80dcd5a intrinsics.rs: add some notes on unwinding 2024-02-27 12:28:25 +01:00
Ralf Jung
bd3ea3e096 ffi_unwind_calls: treat RustIntrinsic like regular Rust calls 2024-02-27 12:28:25 +01:00