about summary refs log tree commit diff
AgeCommit message (Collapse)AuthorLines
2024-01-05Update cargoWeihang Lo-0/+0
2024-01-05Auto merge of #119634 - matthiaskrgr:rollup-v2xt7et, r=matthiaskrgrbors-609/+1272
Rollup of 8 pull requests Successful merges: - #119151 (Hide foreign `#[doc(hidden)]` paths in import suggestions) - #119350 (Imply outlives-bounds on lazy type aliases) - #119354 (Make `negative_bounds` internal & fix some of its issues) - #119506 (Use `resolutions(()).effective_visiblities` to avoid cycle errors in `report_object_error`) - #119554 (Fix scoping for let chains in match guards) - #119563 (Check yield terminator's resume type in borrowck) - #119589 (cstore: Remove unnecessary locking from `CrateMetadata`) - #119622 (never patterns: Document behavior of never patterns with macros-by-example) r? `@ghost` `@rustbot` modify labels: rollup
2024-01-05Rollup merge of #119622 - Nadrieril:never_patterns_macros, r=compiler-errorsMatthias Krüger-0/+54
never patterns: Document behavior of never patterns with macros-by-example `never_patterns` makes `!` parse as a pattern so I was worried about breaking macros-by-example matching. Turns out we're fine because the cases that now match `$p:pat` used to error in the past. The only tricky case is `!` by itself, which backwards-compatibly doesn't match `$p:pat`. I have no idea why tho, I didn't think of that when I was implementing parsing :sweat_smile:. This adds tests so we don't regress the current behavior. r? `@compiler-errors`
2024-01-05Rollup merge of #119589 - petrochenkov:cdatalock, r=Mark-SimulacrumMatthias Krüger-58/+58
cstore: Remove unnecessary locking from `CrateMetadata` Locks and atomics in `CrateMetadata` fields were necessary before https://github.com/rust-lang/rust/pull/107765 when `CStore` was cloneable, but now they are not necessary and can be removed after restructuring the code a bit to please borrow checker. All remaining locked fields in `CrateMetadata` are lazily populated caches.
2024-01-05Rollup merge of #119563 - compiler-errors:coroutine-resume, r=oli-obkMatthias Krüger-36/+190
Check yield terminator's resume type in borrowck In borrowck, we didn't check that the lifetimes of the `TerminatorKind::Yield`'s `resume_place` were actually compatible with the coroutine's signature. That means that the lifetimes were totally going unchecked. Whoops! This PR implements this checking. Fixes #119564 r? types
2024-01-05Rollup merge of #119554 - matthewjasper:remove-guard-distinction, ↵Matthias Krüger-292/+272
r=compiler-errors Fix scoping for let chains in match guards If let guards were previously represented as a different type of guard in HIR and THIR. This meant that let chains in match guards were not handled correctly because they were treated exactly like normal guards. - Remove `hir::Guard` and `thir::Guard`. - Make the scoping different between normal guards and if let guards also check for let chains. closes #118593
2024-01-05Rollup merge of #119506 - ↵Matthias Krüger-1/+110
compiler-errors:visibilities-for-object-safety-error, r=Nilstrieb Use `resolutions(()).effective_visiblities` to avoid cycle errors in `report_object_error` Inside of `report_object_error`, using the `effective_visibilities` query causes cycles since it calls `type_of`, which itself may call `typeck`, which may end up reporting its own object-safety errors. Fixes #119346 Fixes #119502
2024-01-05Rollup merge of #119354 - fmease:negative_bounds-fixes, r=compiler-errorsMatthias Krüger-90/+251
Make `negative_bounds` internal & fix some of its issues r? compiler-errors
2024-01-05Rollup merge of #119350 - fmease:lazy-ty-aliases-implied-bounds, ↵Matthias Krüger-97/+211
r=compiler-errors Imply outlives-bounds on lazy type aliases Fixes #118479. r? types
2024-01-05Rollup merge of #119151 - Jules-Bertholet:no-foreign-doc-hidden-suggest, ↵Matthias Krüger-35/+126
r=davidtwco Hide foreign `#[doc(hidden)]` paths in import suggestions Stops the compiler from suggesting to import foreign `#[doc(hidden)]` paths. ```@rustbot``` label A-suggestion-diagnostics
2024-01-05Auto merge of #119192 - michaelwoerister:mcp533-push, r=cjgillotbors-147/+256
Replace a number of FxHashMaps/Sets with stable-iteration-order alternatives This PR replaces almost all of the remaining `FxHashMap`s in query results with either `FxIndexMap` or `UnordMap`. The only case that is missing is the `EffectiveVisibilities` struct which turned out to not be straightforward to transform. Once that is done too, we can remove the `HashStable` implementation from `HashMap`. The first commit adds the `StableCompare` trait which is a companion trait to `StableOrd`. Some types like `Symbol` can be compared in a cross-session stable way, but their `Ord` implementation is not stable. In such cases, a `StableCompare` implementation can be provided to offer a lightweight way for stable sorting. The more heavyweight option is to sort via `ToStableHashKey`, but then sorting needs to have access to a stable hashing context and `ToStableHashKey` can also be expensive as in the case of `Symbol` where it has to allocate a `String`. The rest of the commits are rather mechanical and don't overlap, so they are best reviewed individually. Part of [MCP 533](https://github.com/rust-lang/compiler-team/issues/533).
2024-01-05Document behavior of `!` with MbENadrieril-0/+54
2024-01-05Auto merge of #119621 - compiler-errors:rollup-5mxtvuk, r=compiler-errorsbors-1830/+1560
Rollup of 10 pull requests Successful merges: - #119034 (Allow coverage tests to ignore test modes, and to enable color in coverage reports) - #119148 (Tweak suggestions for bare trait used as a type) - #119538 (Cleanup error handlers: round 5) - #119566 (Remove `-Zdump-mir-spanview`) - #119567 (Remove `-Zreport-delayed-bugs`.) - #119577 (Migrate memory overlap check from validator to lint) - #119583 (Make `intrinsics::assume` const stable) - #119586 ([rustdoc] Fix invalid handling for static method calls in jump to definition feature) - #119588 (Move `i586-unknown-netbsd` from tier 2 to tier 3 platform support table) - #119601 (`Emitter` cleanups) r? `@ghost` `@rustbot` modify labels: rollup
2024-01-05Rollup merge of #119601 - nnethercote:Emitter-cleanups, r=oli-obkMichael Goulet-52/+465
`Emitter` cleanups Some improvements I found while looking at this code. r? `@oli-obk`
2024-01-05Rollup merge of #119588 - Nemo157:i586-netbsd-tier-3, r=NilstriebMichael Goulet-1/+1
Move `i586-unknown-netbsd` from tier 2 to tier 3 platform support table It appears it was intended to be tier 3, but was accidentally added to tier 2. Based on inspecting the PR adding it the table https://github.com/rust-lang/rust/pull/117170 and the fact that it is not built in CI which is one of the tier 2 requirements. cc ````@he32```` r? ````@Nilstrieb````
2024-01-05Rollup merge of #119586 - GuillaumeGomez:jump-to-def-static-methods, r=notriddleMichael Goulet-21/+60
[rustdoc] Fix invalid handling for static method calls in jump to definition feature I realized when working on a clippy lint that static method calls on `Self` could not give me the method `Res`. For that, we need to use `typeck` and so that's what I did in here. It fixes the linking to static method calls. r? ````@notriddle````
2024-01-05Rollup merge of #119583 - AngelicosPhosphoros:const_assume, r=RalfJungMichael Goulet-3/+1
Make `intrinsics::assume` const stable Closes https://github.com/rust-lang/rust/issues/76972 Blocks https://github.com/rust-lang/rust/pull/119452 Approved in https://github.com/rust-lang/rust/pull/119452#issuecomment-1875741678 r? `@RalfJung`
2024-01-05Rollup merge of #119577 - tmiasko:lint, r=oli-obkMichael Goulet-264/+115
Migrate memory overlap check from validator to lint The check attempts to identify potential undefined behaviour, rather than whether MIR is well-formed. It belongs in the lint not validator. Follow up to changes from #119077.
2024-01-05Rollup merge of #119567 - nnethercote:rm-Zreport-delayed-bugs, r=oli-obkMichael Goulet-17/+3
Remove `-Zreport-delayed-bugs`. It's not used within the repository in any way (e.g. in tests), and doesn't seem useful. It was added in #52568. r? ````@oli-obk````
2024-01-05Rollup merge of #119566 - Zalathar:remove-spanview, r=Swatinem,NilstriebMichael Goulet-919/+2
Remove `-Zdump-mir-spanview` The `-Zdump-mir-spanview` flag was added back in #76074, as a development/debugging aid for the initial work on what would eventually become `-Cinstrument-coverage`. It causes the compiler to emit an HTML file containing a function's source code, with various spans highlighted based on the contents of MIR. When the suggestion was made to [triage and remove unnecessary `-Z` flags (Zulip)](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/.60-Z.60.20option.20triage), I noted that this flag could potentially be worth removing, but I wanted to keep it around to see whether I found it useful for my own coverage work. But when I actually tried to use it, I ran into various issues (e.g. it crashes on `tests/coverage/closure.rs`). If I can't trust it to work properly without a full overhaul, then instead of diving down a rabbit hole of trying to fix arcane span-handling bugs, it seems better to just remove this obscure old code entirely. --- ````@rustbot```` label +A-code-coverage
2024-01-05Rollup merge of #119538 - nnethercote:cleanup-errors-5, r=compiler-errorsMichael Goulet-464/+369
Cleanup error handlers: round 5 More rustc_errors cleanups. A sequel to https://github.com/rust-lang/rust/pull/119171. r? ````@compiler-errors````
2024-01-05Rollup merge of #119148 - estebank:bare-traits, r=davidtwcoMichael Goulet-75/+412
Tweak suggestions for bare trait used as a type ``` error[E0782]: trait objects must include the `dyn` keyword --> $DIR/not-on-bare-trait-2021.rs:11:11 | LL | fn bar(x: Foo) -> Foo { | ^^^ | help: use a generic type parameter, constrained by the trait `Foo` | LL | fn bar<T: Foo>(x: T) -> Foo { | ++++++++ ~ help: you can also use `impl Foo`, but users won't be able to specify the type paramer when calling the `fn`, having to rely exclusively on type inference | LL | fn bar(x: impl Foo) -> Foo { | ++++ help: alternatively, use a trait object to accept any type that implements `Foo`, accessing its methods at runtime using dynamic dispatch | LL | fn bar(x: &dyn Foo) -> Foo { | ++++ error[E0782]: trait objects must include the `dyn` keyword --> $DIR/not-on-bare-trait-2021.rs:11:19 | LL | fn bar(x: Foo) -> Foo { | ^^^ | help: use `impl Foo` to return an opaque type, as long as you return a single underlying type | LL | fn bar(x: Foo) -> impl Foo { | ++++ help: alternatively, you can return an owned trait object | LL | fn bar(x: Foo) -> Box<dyn Foo> { | +++++++ + ``` Fix #119525: ``` error[E0038]: the trait `Ord` cannot be made into an object --> $DIR/bare-trait-dont-suggest-dyn.rs:3:33 | LL | fn ord_prefer_dot(s: String) -> Ord { | ^^^ `Ord` cannot be made into an object | note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety> --> $SRC_DIR/core/src/cmp.rs:LL:COL | = note: the trait cannot be made into an object because it uses `Self` as a type parameter ::: $SRC_DIR/core/src/cmp.rs:LL:COL | = note: the trait cannot be made into an object because it uses `Self` as a type parameter help: consider using an opaque type instead | LL | fn ord_prefer_dot(s: String) -> impl Ord { | ++++ ```
2024-01-05Rollup merge of #119034 - Zalathar:ignore-mode, r=davidtwcoMichael Goulet-14/+132
Allow coverage tests to ignore test modes, and to enable color in coverage reports This PR adds two new header directives to compiletest, intended for use by coverage tests (and by #119033 in particular). The new headers are: - `// ignore-mode-{mode}` causes a test to not be run in a particular compiletest mode (e.g. `ignore-mode-coverage-run`). - This can theoretically be used by any test, but coverage tests are currently the only ones that automatically run in multiple modes, so it's not very useful for other kinds of test. - `// llvm-cov-flags: --use-color` makes `coverage-run` tests pass the flag `--use-color` when generating coverage reports. - For most tests, non-coloured reports are easier to read and more portable across platforms. But for #119033 specifically, we want to test that `llvm-cov` slices up source text correctly, which only happens when colour output is enabled.
2024-01-05Use `resolutions(()).effective_visiblities` to avoid cycle errorsMichael Goulet-1/+110
2024-01-05Auto merge of #118991 - nikic:scalar-pair, r=nagisabors-74/+80
Separate immediate and in-memory ScalarPair representation Currently, we assume that ScalarPair is always represented using a two-element struct, both as an immediate value and when stored in memory. This currently works fairly well, but runs into problems with https://github.com/rust-lang/rust/pull/116672, where a ScalarPair involving an i128 type can no longer be represented as a two-element struct in memory. For example, the tuple `(i32, i128)` needs to be represented in-memory as `{ i32, [3 x i32], i128 }` to satisfy alignment requirements. Using `{ i32, i128 }` instead will result in the second element being stored at the wrong offset (prior to LLVM 18). Resolve this issue by no longer requiring that the immediate and in-memory type for ScalarPair are the same. The in-memory type will now look the same as for normal struct types (and will include padding filler and similar), while the immediate type stays a simple two-element struct type. This also means that booleans in immediate ScalarPair are now represented as i1 rather than i8, just like we do everywhere else. The core change here is to llvm_type (which now treats ScalarPair as a normal struct) and immediate_llvm_type (which returns the two-element struct that llvm_type used to produce). The rest is fixing things up to no longer assume these are the same. In particular, this switches places that try to get pointers to the ScalarPair elements to use byte-geps instead of struct-geps.
2024-01-05Auto merge of #117673 - matthewjasper:thir-unsafeck-stabilization, r=cjgillotbors-4844/+879
Stabilize THIR unsafeck - Removes `-Zthir-unsafeck`, stabilizing the behaviour of `-Zthir-unsafeck=on`. - Removes MIR unsafeck. - Union patterns are now unsafe unless the field is matched to a wildcard pattern. Opening for a crater run in case we need a compatibility lint.
2024-01-05Update clippy for hir::Guard removalMatthew Jasper-112/+56
2024-01-05Restore if let guard temporary scoping differenceMatthew Jasper-2/+89
Match guards with an if let guard or an if let chain guard should have a temporary scope of the whole arm. This is to allow ref bindings to temporaries to borrow check.
2024-01-05Remove `thir::Guard`Matthew Jasper-74/+55
Use Expr instead. Use `ExprKind::Let` to represent if let guards.
2024-01-05Remove `hir::Guard`Matthew Jasper-109/+77
Use Expr instead. Use `ExprKind::Let` to represent if let guards.
2024-01-05Make test compatible with 32-bit as wellNikita Popov-1/+1
2024-01-05Handle context for const patterns correctlyMatthew Jasper-1/+31
2024-01-05Stabilize THIR unsafeckMatthew Jasper-329/+307
2024-01-05Remove revisions for THIR unsafeckMatthew Jasper-4667/+694
This is to make the diff when stabilizing it easier to review.
2024-01-05Auto merge of #118899 - veera-sivarajan:fix-makefile, r=Mark-Simulacrumbors-1/+0
fix(tests): remove check for `echo` fixes: #56222 Removes check for `echo` as it doesn't seem to be used anywhere.
2024-01-05Auto merge of #118297 - shepmaster:warn-dead-tuple-fields, r=WaffleLapkinbors-412/+406
Merge `unused_tuple_struct_fields` into `dead_code` This implicitly upgrades the lint from `allow` to `warn` and places it into the `unused` lint group. [Discussion on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Moving.20.60unused_tuple_struct_fields.60.20from.20allow.20to.20warn)
2024-01-05Change printing of "`--error-format` is unstable" errors.Nicholas Nethercote-11/+2
Currently for these two errors we go to the effort of switching to a standard JSON emitter, for no obvious reason, and unlike any other errors. This behaviour was added for `pretty-json` in #45737, and then `human-annotate-rs` copied it some time later when it was added. This commit changes things to just using the requested emitter, which is simpler and consistent with other errors. Old output: ``` $ rustc --error-format pretty-json {"$message_type":"diagnostic","message":"`--error-format=pretty-json` is unstable","code":null,"level":"error","spans":[],"children":[],"rendered":"error: `--error-format=pretty-json` is unstable\n\n"} $ rustc --error-format human-annotate-rs {"$message_type":"diagnostic","message":"`--error-format=human-annotate-rs` is unstable","code":null,"level":"error","spans":[],"children":[],"rendered":"error: `--error-format=human-annotate-rs` is unstable\n\n"} ``` New output: ``` $ rustc --error-format pretty-json { "$message_type": "diagnostic", "message": "`--error-format=pretty-json` is unstable", "code": null, "level": "error", "spans": [], "children": [], "rendered": "error: `--error-format=pretty-json` is unstable\n\n" } $ rustc --error-format human-annotate-rs error: `--error-format=human-annotate-rs` is unstable ```
2024-01-05Unbreak `tests/ui/lint/use_suggestion_json.rs`.Nicholas Nethercote-3/+423
PR #82639 changed UI tests so `-Z unstable-options` aren't passed to UI tests by default. This completely broke `use_suggestion_json.rs`, which uses the unstable `--error-format=pretty-json` option. The expected output went from 400 lines of pretty JSON error messages to a single JSON error saying "`--error-format=pretty-json` is unstable"! This commit adds `-Z unstable-options` back and reinstates the old expected output, with some minor changes to account for shifted spans and slightly JSON output changes since then.
2024-01-05Auto merge of #118861 - Veykril:r-a-in-tree, r=onur-ozkanbors-11/+21
Set the `in-rust-tree` feature for all rust-analyzer{-proc-macro-srv} steps Some context: This came up in https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Frust-analyzer/topic/libraryfying.20match.20checking.3F where `test` and `check` behaved differently for rust-analyzer r? `@onur-ozkan`
2024-01-05Allow coverage tests to enable `llvm-cov --use-color`Zalathar-0/+35
2024-01-05Extract a `split_flags` helper in header directive parsingZalathar-9/+16
2024-01-05Allow tests to ignore individual test modesZalathar-3/+54
Normally, each test in `tests/coverage` is automatically run in both `coverage-map` mode and `coverage-run` mode. This new family of directives allows an individual test to specify that it should not be run in a particular mode.
2024-01-05Check for profiler support via a flag, instead of an environment varZalathar-2/+27
2024-01-05Auto merge of #117213 - oli-obk:check_item_type_cleanup, r=estebankbors-300/+365
Reorder check_item_type diagnostics so they occur next to the corresponding `check_well_formed` diagnostics The first commit is just a cleanup. The second commit moves most checks from `check_mod_item_types` into `check_well_formed`, invoking the checks in lockstep per-item instead of iterating over all items twice.
2024-01-05Add some comments to `Emitter`.Nicholas Nethercote-3/+5
There are three functions only used for the JSON format.
2024-01-05Rename `AnnotateSnippetEmitterWriter` as `AnnotateSnippetEmitter`.Nicholas Nethercote-6/+6
For consistency with other `Emitter` impls.
2024-01-05Rename `EmitterWriter` as `HumanEmitter`.Nicholas Nethercote-29/+29
For consistency with other `Emitter` impls, such as `JsonEmitter`, `SilentEmitter`, `SharedEmitter`, etc.
2024-01-04Migrate memory overlap check from validator to lintTomasz Miąsko-237/+85
The check attempts to identify potential undefined behaviour, rather than whether MIR is well-formed. It belongs in the lint not validator.
2024-01-04Fix validation and linting of injected MIRTomasz Miąsko-16/+22
Reevaluate `body.should_skip()` after updating the MIR phase to ensure that injected MIR is processed correctly. Update a few custom MIR tests that were ill-formed for the injected phase.
2024-01-04Visit only reachable blocks in MIR lintTomasz Miąsko-15/+12
No functional changes - all checks have been emitted conditionally on block being rechable already.