Commit Graph

243017 Commits

Author SHA1 Message Date
Guillaume Gomez
b0aa3d8198
Rollup merge of #119723 - nnethercote:rm-Zdont-buffer-diagnostics, r=compiler-errors
Remove `-Zdont-buffer-diagnostics`.

It was added in #54232. It seems like it was aimed at NLL development, which is well in the past. Also, it looks like `-Ztreat-err-as-bug` can be used to achieve the same effect. So it doesn't seem necessary.

r? ``@pnkfelix``
2024-01-09 13:23:18 +01:00
Guillaume Gomez
9b905417f5
Rollup merge of #119699 - cjgillot:simplify-unreachable, r=oli-obk
Merge dead bb pruning and unreachable bb deduplication.

Both routines share the same basic structure: iterate on all bbs to identify work, and then renumber bbs.

We can do both at once.
2024-01-09 13:23:18 +01:00
Guillaume Gomez
72fdaf52e0
Rollup merge of #119668 - cjgillot:transform-promote, r=oli-obk
Simplify implementation of MIR promotion

Non-functional changes.
Best read ignoring whitespace.
2024-01-09 13:23:17 +01:00
Guillaume Gomez
d3574beb5d
Rollup merge of #119527 - klensy:ordering, r=compiler-errors
don't reexport atomic::ordering via rustc_data_structures, use std import

This looks simpler.
2024-01-09 13:23:17 +01:00
Guillaume Gomez
5c9a8d7bb5
Rollup merge of #119282 - Urgau:check-cfg-rework-unstable-doc, r=JohnTitor
Rework and improve the unstable documentation of check-cfg

This PR rework and improve the unstable documentation of the check-cfg feature.

The goal is to have a simpler to understand documentation with examples that are more practical and less theoretical. As well as making the documentation more explicit about the whereabouts of the feature.

`@rustbot` label +T-compiler +F-check-cfg
2024-01-09 13:23:16 +01:00
Guillaume Gomez
df2f4ae4ac
Rollup merge of #118748 - devnexen:fbsd_getrandom_simpl, r=Nilstrieb,dtolnay
std: getrandom simplification for freebsd.

it is in the libcs' crate too now.
2024-01-09 13:23:16 +01:00
Guillaume Gomez
4a24b5bc05
Rollup merge of #117556 - obeis:static-mut-ref-lint, r=davidtwco
Disallow reference to `static mut` and adding `static_mut_ref` lint

Closes #114447

r? `@scottmcm`
2024-01-09 13:23:15 +01:00
Urgau
3611014722 Rework and improve unstable documentation of check-cfg 2024-01-09 10:51:32 +01:00
bors
be00c5a9b8 Auto merge of #118968 - aliemjay:canon-static, r=lcnr
unify query canonicalization mode

Exclude from canonicalization only the static lifetimes that appear in the param env because of #118965 . Any other occurrence can be canonicalized safely AFAICT.

r? `@lcnr`
2024-01-09 09:20:33 +00:00
bors
dc641039d2 Auto merge of #117703 - compiler-errors:recursive-async, r=lcnr
Support async recursive calls (as long as they have indirection)

Before #101692, we stored coroutine witness types directly inside of the coroutine. That means that a coroutine could not contain itself (as a witness field) without creating a cycle in the type representation of the coroutine, which we detected with the `OpaqueTypeExpander`, which is used to detect cycles when expanding opaque types after that are inferred to contain themselves.

After `-Zdrop-tracking-mir` was stabilized, we no longer store these generator witness fields directly, but instead behind a def-id based query. That means there is no technical obstacle in the compiler preventing coroutines from containing themselves per se, other than the fact that for a coroutine to have a non-infinite layout, it must contain itself wrapped in a layer of allocation indirection (like a `Box`).

This means that it should be valid for this code to work:

```
async fn async_fibonacci(i: u32) -> u32 {
    if i == 0 || i == 1 {
        i
    } else {
        Box::pin(async_fibonacci(i - 1)).await
          + Box::pin(async_fibonacci(i - 2)).await
    }
}
```

Whereas previously, you'd need to coerce the future to `Pin<Box<dyn Future<Output = ...>>` before `await`ing it, to prevent the async's desugared coroutine from containing itself across as await point.

This PR does two things:
1. Only report an error if an opaque expansion cycle is detected *not* through coroutine witness fields.
    * Instead, if we find an opaque cycle through coroutine witness fields, we compute the layout of the coroutine. If that results in a cycle error, we report it as a recursive async fn.
4. Reworks the way we report layout errors having to do with coroutines, to make up for the diagnostic regressions introduced by (1.). We actually do even better now, pointing out the call sites of the recursion!
2024-01-09 07:20:50 +00:00
bors
387e7a5e42 Auto merge of #119760 - matthiaskrgr:rollup-ti2xpp7, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #117744 (Add -Zuse-sync-unwind)
 - #118649 (Make inductive cycles in coherence ambiguous always)
 - #118979 (Use `assert_unsafe_precondition` for `char::from_u32_unchecked`)
 - #119619 (mir-opt and custom target fixes)
 - #119632 (Fix broken build for ESP IDF due to #119026)
 - #119712 (Adding alignment to the cases to test for specific error messages.)
 - #119734 (Miri subtree update)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-01-09 04:58:53 +00:00
Matthias Krüger
91fcc17117
Rollup merge of #119734 - RalfJung:miri, r=RalfJung
Miri subtree update

r? ``@ghost``
2024-01-09 05:33:23 +01:00
Matthias Krüger
deb504b777
Rollup merge of #119712 - madsravn:parsing-errors, r=estebank
Adding alignment to the cases to test for specific error messages.

Adding alignment to the list of cases to test for specific error message. Covers `>`, `^` and `<`.

Pinging people who chimed in last time ( https://github.com/rust-lang/rust/pull/106805 ): ``@estebank`` , ``@compiler-errors`` and ``@Nilstrieb``
2024-01-09 05:33:22 +01:00
Matthias Krüger
50982bd4ab
Rollup merge of #119632 - ivmarkov:master, r=Nilstrieb,dtolnay
Fix broken build for ESP IDF due to #119026

`target_os = "espidf"` in `libc` lacks the `SOMAXCONN` constant, but that's probably irrelevant in this context, as `UnixListener` is not supported on ESP IDF - it being a single process "OS" only.

The PR just re-uses the `128` constant so that the code builds. Trying to use the listener on ESP IDF will fail with `ENOSYS`, which is fine.

*UPDATE* Might not fail with `ENOSYS` - need to test what error code would be returned, but that doesn`t change anything.
2024-01-09 05:33:22 +01:00
Matthias Krüger
985b2ce70d
Rollup merge of #119619 - onur-ozkan:panic-abort-mir-opt, r=oli-obk
mir-opt and custom target fixes

From https://github.com/rust-lang/rust/issues/115642#issuecomment-1879589022

> > Could you please test the last two commits from https://github.com/onur-ozkan/rust/commits/panic-abort-mir-opt when you have the time? The first commit should resolve the error of using the nightly flag with a stable compiler, and the second one should resolve the custom target issue.

> I tested with the two commits and the errors of using nightly flag and custom target specs were not seen.
Testing was completed for the test suites like ui, run-pass-valgrind, coverage, mir-opt, codegen, assembly, incremental.

Fixes #115642
2024-01-09 05:33:22 +01:00
Matthias Krüger
b0c492cd6e
Rollup merge of #118979 - ChrisDenton:unwrap-const, r=Nilstrieb,dtolnay
Use `assert_unsafe_precondition` for `char::from_u32_unchecked`

Use `assert_unsafe_precondition` in `char::from_u32_unchecked` so that it can be stabilized as `const`.
2024-01-09 05:33:21 +01:00
Matthias Krüger
1974f5cba9
Rollup merge of #118649 - compiler-errors:coherence-ambig, r=lcnr
Make inductive cycles in coherence ambiguous always

Logical conclusion of https://github.com/rust-lang/rust/issues/114040
One step after #116493

cc https://github.com/rust-lang/trait-system-refactor-initiative/issues/20

r? lcnr to kick off the FCP after review... maybe we should wait until 1.75 is landed? In that case, I'd still like to get the FCP boxes checked sooner since that'll be near the holidays which means everyone's away.
2024-01-09 05:33:21 +01:00
Matthias Krüger
9e4843e42e
Rollup merge of #117744 - quininer:add-z-sync-uw, r=bjorn3
Add -Zuse-sync-unwind

Currently Rust uses async unwind by default, but async unwind will bring non-negligible size overhead. it would be nice to allow users to choose this.

In addition, async unwind currently prevents LLVM from generate compact unwind for MachO, if one wishes to generate compact unwind for MachO, then also needs this flag.
2024-01-09 05:33:20 +01:00
bors
a399117774 Auto merge of #119732 - lnicola:sync-from-ra, r=lnicola
Subtree update of `rust-analyzer`

r? ghost
2024-01-09 03:01:30 +00:00
bors
d6affcf520 Auto merge of #119754 - matthiaskrgr:rollup-7cht4m5, r=matthiaskrgr
Rollup of 10 pull requests

Successful merges:

 - #118903 (Improved support of collapse_debuginfo attribute for macros.)
 - #119033 (coverage: `llvm-cov` expects column numbers to be bytes, not code points)
 - #119598 (Fix a typo in core::ops::Deref's doc)
 - #119660 (remove an unnecessary stderr-per-bitwidth)
 - #119663 (tests: Normalize `\r\n` to `\n` in some run-make tests)
 - #119681 (coverage: Anonymize line numbers in branch views)
 - #119704 (Fix two variable binding issues in lint let_underscore)
 - #119725 (Add helper for when we want to know if an item has a host param)
 - #119738 (Add `riscv32imafc-esp-espidf` tier 3 target for the ESP32-P4.)
 - #119740 (Remove crossbeam-channel)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-01-09 00:04:47 +00:00
Matthias Krüger
1c9e862a3e
Rollup merge of #119740 - Mark-Simulacrum:drop-crossbeam, r=davidtwco
Remove crossbeam-channel

The standard library's std::sync::mpsc basically is a crossbeam channel, and for the use case here will definitely suffice. This drops this dependency from librustc_driver.
2024-01-09 00:19:36 +01:00
Matthias Krüger
eb6ce92473
Rollup merge of #119738 - esp-rs:esp32p4-espidf, r=Nilstrieb
Add `riscv32imafc-esp-espidf` tier 3 target for the ESP32-P4.

The tier 3 target answers in the original PR are still relevant, so please review them here: https://github.com/rust-lang/rust/pull/87666#issue-957268176

cc: ``@ivmarkov``
2024-01-09 00:19:36 +01:00
Matthias Krüger
cd93114deb
Rollup merge of #119725 - compiler-errors:has_effect_param, r=fmease
Add helper for when we want to know if an item has a host param

r? ````@fmease```` since you're a good reviewer and no good deed goes unpunished

This helper will see far more usages as built-in traits get constified.
2024-01-09 00:19:36 +01:00
Matthias Krüger
5efa69d979
Rollup merge of #119704 - chenyukang:yukang-fix-let_underscore, r=Nilstrieb
Fix two variable binding issues in lint let_underscore

Fixes #119696
Fixes #119697
2024-01-09 00:19:35 +01:00
Matthias Krüger
867a87d342
Rollup merge of #119681 - Zalathar:anon-branch, r=clubby789
coverage: Anonymize line numbers in branch views

Extracted from #118305, as this is now the only part of that PR that needs to touch compiletest.

---

Coverage tests run the `llvm-cov` tool to generate a coverage report for a test program, and then compare the report against a known-good snapshot.

We use the `anonymize_coverage_line_numbers` function to replace line numbers in coverage reports with `LL`, so that they are less sensitive to lines being added or removed. This PR augments the existing code by making it also support the slightly different line number syntax used when reporting branch regions.

Currently the compiler never emits branch regions, so there is no way to write a coverage test that makes use of this new capability. Instead, I've added a unit test that checks against some sample reports taken from #118305. That unit test can be removed when some form of branch coverage support gets merged, and real branch coverage tests are added to the coverage test suite.

(I have also manually tested this change as part of my draft branch-coverage PR.)
2024-01-09 00:19:35 +01:00
Matthias Krüger
e6bc9f0637
Rollup merge of #119663 - petrochenkov:rmakefix, r=Mark-Simulacrum
tests: Normalize `\r\n` to `\n` in some run-make tests

The output is produced by printf from C code in these cases, and printf prints in text mode, which means `\n` will be printed as `\r\n` on Windows.

In --bless mode the new output with `\r\n` will replace expected output in `tests/run-make/raw-dylib-*\output.txt` files, which use \n, always resulting in dirty files in the repo.
2024-01-09 00:19:34 +01:00
Matthias Krüger
34771e2f9a
Rollup merge of #119660 - RalfJung:const-ub-enum, r=oli-obk
remove an unnecessary stderr-per-bitwidth

also update some regexp, `a(lloc)?` would no longer match now that we have compiletest itself do alloc ID normalization.

r? ````@oli-obk````
2024-01-09 00:19:34 +01:00
Matthias Krüger
668e8b5541
Rollup merge of #119598 - Laura7089:fix/deref-typo, r=Nilstrieb
Fix a typo in core::ops::Deref's doc
2024-01-09 00:19:33 +01:00
Matthias Krüger
70e3f8d240
Rollup merge of #119033 - Zalathar:unicode, r=davidtwco
coverage: `llvm-cov` expects column numbers to be bytes, not code points

Normally the compiler emits column numbers as a 1-based number of Unicode code points.

But when we embed coverage mappings for `-Cinstrument-coverage`, those mappings will ultimately be read by the `llvm-cov` tool. That tool assumes that column numbers are 1-based numbers of *bytes*, and relies on that assumption when slicing up source code to apply highlighting (in HTML reports, and in text-based reports with colour).

For the very common case of all-ASCII source code, bytes and code points are the same, so the difference isn't noticeable. But for code that contains non-ASCII characters, emitting column numbers as code points will result in `llvm-cov` slicing strings in the wrong places, producing mangled output or fatal errors.

(See https://github.com/taiki-e/cargo-llvm-cov/issues/275 as an example of what can go wrong.)
2024-01-09 00:19:33 +01:00
Matthias Krüger
ee7d4c1561
Rollup merge of #118903 - azhogin:azhogin/skip_second_stmt_debuginfo.rs, r=petrochenkov
Improved support of collapse_debuginfo attribute for macros.

Added walk_chain_collapsed function to consider collapse_debuginfo attribute in parent macros in call chain.
Fixed collapse_debuginfo attribute processing for cranelift (there was if/else branches error swap).

cc https://github.com/rust-lang/rust/issues/100758
2024-01-09 00:19:32 +01:00
Nicholas Nethercote
a2b765fc37 Remove -Zdont-buffer-diagnostics.
It was added in #54232. It seems like it was aimed at NLL development,
which is well in the past. Also, it looks like `-Ztreat-err-as-bug` can
be used to achieve the same effect. So it doesn't seem necessary.
2024-01-09 09:47:36 +11:00
Camille GILLOT
5d6463c26c Make match exhaustive. 2024-01-08 22:42:07 +00:00
Camille GILLOT
cae0dc2833 Simplify code flow. 2024-01-08 22:42:07 +00:00
Camille GILLOT
8356802862 Move promote_consts back to rustc_mir_transform. 2024-01-08 22:42:07 +00:00
Michael Goulet
9a756034a9 Last nits 2024-01-08 20:32:06 +00:00
Michael Goulet
841184bcae Make cycle error more resilient to where it starts
Also don't recomment recursive_async crate anymore

Co-authored-by: lcnr <rust@lcnr.de>
2024-01-08 20:30:24 +00:00
Michael Goulet
fa2ff51ace Only compute layout of opaque if coroutine is the cause of an opaque cycle 2024-01-08 20:30:24 +00:00
Michael Goulet
199af7cef0 Point out source of recursion 2024-01-08 20:30:24 +00:00
Michael Goulet
82a2215481 Don't check for recursion in generator witness fields 2024-01-08 20:30:21 +00:00
Michael Goulet
dfb9f5df2c Rustdoc and Clippy stop misusing Key for Ty -> (adt) DefId 2024-01-08 20:30:10 +00:00
Michael Goulet
755b2da841 Value recovery can take the whole CycleError 2024-01-08 20:30:10 +00:00
Mads Ravn
506c06636b Removing redudant note from parse error 2024-01-08 19:41:01 +01:00
bors
ca663b06c5 Auto merge of #119606 - nnethercote:consuming-emit, r=oli-obk
Consuming `emit`

This PR makes `DiagnosticBuilder::emit` consuming, i.e. take `self` instead of `&mut self`. This is good because it doesn't make sense to emit a diagnostic twice.

This requires some changes to `DiagnosticBuilder` method changing -- every existing non-consuming chaining method gets a new consuming partner with a `_mv` suffix -- but permits a host of beneficial follow-up changes: more concise code through more chaining, removal of redundant diagnostic construction API methods, and removal of machinery to track the possibility of a diagnostic being emitted multiple times.

r? `@compiler-errors`
2024-01-08 16:06:28 +00:00
Michael Goulet
8abf133c4b Make inductive cycles in coherence ambiguous always 2024-01-08 15:03:59 +00:00
onur-ozkan
b888e2f82b fix the incorrect target on stage1 ui-fulldeps tests
Signed-off-by: onur-ozkan <work@onurozkan.dev>
2024-01-08 16:07:44 +03:00
onur-ozkan
26c71cbcf1 detect user-specified custom targets in compiletest
Signed-off-by: onur-ozkan <work@onurozkan.dev>
2024-01-08 16:07:41 +03:00
onur-ozkan
8aa7dd06f6 enable RUSTC_BOOTSTRAP on panic=abort mir-opt test
Signed-off-by: onur-ozkan <work@onurozkan.dev>
2024-01-08 16:07:30 +03:00
Scott Mabin
43ce53375c Add riscv32imafc-esp-espidf target for the ESP32-P4. 2024-01-08 12:54:06 +00:00
Zalathar
6971e9332d coverage: llvm-cov expects column numbers to be bytes, not code points 2024-01-08 21:58:46 +11:00
Andrew Zhogin
f2dbebafad Improved support of collapse_debuginfo attribute for macros. 2024-01-08 17:47:18 +07:00