Commit Graph

246125 Commits

Author SHA1 Message Date
Michael Goulet
c763f833d1 Only point out non-diverging arms for match suggestions 2024-02-15 15:44:46 +00:00
bors
fa9f77ff35 Auto merge of #120931 - chenyukang:yukang-cleanup-hashmap, r=michaelwoerister
Clean up potential_query_instability with FxIndexMap and UnordMap

From https://github.com/rust-lang/rust/pull/120485#issuecomment-1916437191

r? `@michaelwoerister`
2024-02-15 12:36:37 +00:00
bors
6a4222b511 Auto merge of #116564 - oli-obk:evaluated_static_in_metadata, r=RalfJung,cjgillot
Store static initializers in metadata instead of the MIR of statics.

This means that adding generic statics would be even more difficult, as we can't evaluate statics from other crates anymore, but the subtle issue I have encountered make me think that having this be an explicit problem is better.

The issue is that

```rust
static mut FOO: &mut u32 = &mut 42;
static mut BAR = unsafe { FOO };
```

gets different allocations, instead of referring to the same one. This is also true for non-static mut, but promotion makes `static FOO: &u32 = &42;` annoying to demo.

Fixes https://github.com/rust-lang/rust/issues/61345

## Why is this being done?

In order to ensure all crates see the same nested allocations (which is the last issue that needs fixing before we can stabilize [`const_mut_refs`](https://github.com/rust-lang/rust/issues/57349)), I am working on creating anonymous (from the Rust side, to LLVM it's like a regular static item) static items for the nested allocations in a static. If we evaluate the static item in a downstream crate again, we will end up duplicating its nested allocations (and in some cases, like the `match` case, even duplicate the main allocation).
2024-02-15 10:28:31 +00:00
Oli Scherer
73b38c661d Do not allocate a second "background" alloc id for the main allocation of a static.
Instead we re-use the static's alloc id within the interpreter for its initializer to refer to the `Allocation` that only exists within the interpreter.
2024-02-15 10:25:18 +00:00
Oli Scherer
e2386270df Return ConstAllocation from eval_static_initializer query directly 2024-02-15 10:25:18 +00:00
Oli Scherer
be6ccf13e3 Store static initializers in metadata instead of the MIR of statics. 2024-02-15 10:25:18 +00:00
Oli Scherer
95004e5ae2 Add new query just for static initializers 2024-02-15 10:25:18 +00:00
Oli Scherer
fc9d1a8133 Split a bool argument into two named functions 2024-02-15 10:25:18 +00:00
Amanjeev Sethi
ca109af2ac Add regression test 2024-02-15 10:25:06 +00:00
bors
4ae1e79876 Auto merge of #121131 - matthiaskrgr:rollup-mo3b8nz, r=matthiaskrgr
Rollup of 10 pull requests

Successful merges:

 - #111106 (Add known issue of let binding to format_args doc)
 - #118749 (Make contributing to windows bindings easier)
 - #120982 (Add APIs for fetching foreign items )
 - #121022 (rustdoc: cross-crate re-exports: correctly render late-bound params in source order even if early-bound params are present)
 - #121082 (Clarified docs on non-atomic oprations on owned/mut refs to atomics)
 - #121084 (Make sure `tcx.create_def` also depends on the forever red node, instead of just `tcx.at(span).create_def`)
 - #121098 (Remove unnecessary else block from `thread_local!` expanded code)
 - #121105 (Do not report overflow errors on ConstArgHasType goals)
 - #121116 (Reinstate some delayed bugs.)
 - #121122 (Enforce coroutine-closure layouts are identical)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-02-15 08:29:42 +00:00
Matthias Krüger
829b59a47d
Rollup merge of #121122 - compiler-errors:identical-layouts, r=oli-obk
Enforce coroutine-closure layouts are identical

Enforce that for an async closure, the by-ref and by-move coroutine layouts are identical. This is just a sanity check to make sure that optimizations aren't doing anything fishy.

r? oli-obk
2024-02-15 09:20:23 +01:00
Matthias Krüger
4899108109
Rollup merge of #121116 - nnethercote:fix-121103-121108, r=oli-obk
Reinstate some delayed bugs.

These were changed to `has_errors` assertions in #121071 because that seemed reasonable, but evidently not.

Fixes #121103.
Fixes #121108.
2024-02-15 09:20:21 +01:00
Matthias Krüger
888fe709e6
Rollup merge of #121105 - compiler-errors:no-const-ty-overflow, r=oli-obk
Do not report overflow errors on ConstArgHasType goals

This is 10% of a fix for #121090, since it at least means that we no longer mention the `ConstArgHasType` goal as the cause for the overflow. Instead, now we mention:
```
overflow evaluating the requirement `{closure@$DIR/overflow-during-mono.rs:13:41: 13:44}: Sized`
```
which is not much better, but slightly.

r? oli-obk
2024-02-15 09:20:21 +01:00
Matthias Krüger
15d9e2c0f1
Rollup merge of #121098 - ShoyuVanilla:thread-local-unnecessary-else, r=Nilstrieb
Remove unnecessary else block from `thread_local!` expanded code

Some expanded codes make ["unnecessary else block" warnings](https://github.com/rust-lang/rust-analyzer/issues/16556#issuecomment-1944271716) for Rust Analyzer
2024-02-15 09:20:20 +01:00
Matthias Krüger
f62d981a18
Rollup merge of #121084 - oli-obk:create_def_forever_red2, r=WaffleLapkin
Make sure `tcx.create_def` also depends on the forever red node, instead of just `tcx.at(span).create_def`

oversight from https://github.com/rust-lang/rust/pull/119136

Not actually an issue, because all uses of `tcx.create_def` were in the resolver, which is `eval_always`, but still good to harden against future uses of `create_def`

cc `@petrochenkov` `@WaffleLapkin`
2024-02-15 09:20:20 +01:00
Matthias Krüger
e5186aaf4d
Rollup merge of #121082 - peterjoel:atomic-docs, r=cuviper
Clarified docs on non-atomic oprations on owned/mut refs to atomics

I originally misinterpreted the documentation to mean that the compiler can/will automatically optimise away atomic operations whenever the data is owned or mutably referenced.

On re-reading I think it is not technically incorrect, but specifically mentioning _how_ the atomic operations can be avoided also prevents this misunderstanding.
2024-02-15 09:20:19 +01:00
Matthias Krüger
f9a0675c3c
Rollup merge of #121022 - fmease:rustdoc-x-crate-late-bound-lt-src-order, r=GuillaumeGomez
rustdoc: cross-crate re-exports: correctly render late-bound params in source order even if early-bound params are present

r? ghost
2024-02-15 09:20:18 +01:00
Matthias Krüger
71466ca804
Rollup merge of #120982 - momvart:smir-61-foreign_kind, r=oli-obk
Add APIs for fetching foreign items

Closes https://github.com/rust-lang/project-stable-mir/issues/61
2024-02-15 09:20:18 +01:00
Matthias Krüger
09776009ea
Rollup merge of #118749 - ChrisDenton:winsys, r=cuviper
Make contributing to windows bindings easier

This PR does three things:

- Automatically sorts bindings so contributors don't have to. I should have done this to begin with but was lazy.
- Renames `windows_sys.lst` to `bindings.txt`. This [matches the windows-rs repository](8e71051ea8/crates/tools/sys/bindings.txt) (and repos that copy it). I believe consistency with other projects helps get people orientated.
- Adds a `README.md` file explaining what this is about and how to add bindings. This has the benefit of being directly editable and it's rendered when viewed online. Also people are understandably jumping right into the `windows_sys.rs` file via ripgrep or github search and so missing that it's generated. A `README.md` alongside it is at least slightly more obvious in that case. There is still a small note at the top of `windows_sys` in case people do read from the beginning.

None of this has any impact on the actual code generated. It's purely to make the new contributors workflow a bit nicer.
2024-02-15 09:20:17 +01:00
Matthias Krüger
0238d2619f
Rollup merge of #111106 - Stargateur:doc/format_args, r=m-ou-se
Add known issue of let binding to format_args doc

Simply add doc about https://github.com/rust-lang/rust/issues/92698.

 `@rustbot` label +T-rustdoc -T-libs

 r? `@GuillaumeGomez`
2024-02-15 09:20:16 +01:00
bors
bd6b336133 Auto merge of #121125 - ehuss:fix-small-cstr, r=Mark-Simulacrum
Fix SmallCStr conversion from CStr

The conversion from CStr to SmallCStr was not including the null byte. SmallCStr requires a trailing null. This caused `as_c_str` to either panic if std is built with debug assertions, or to have some corrupt memory behavior.
2024-02-15 06:04:25 +00:00
Eric Huss
217e5e484d Fix SmallCStr conversion from CStr 2024-02-14 18:40:53 -08:00
Michael Goulet
e6a21f549e Enforce coroutine-closure layouts are identical 2024-02-15 01:18:09 +00:00
León Orell Valerian Liehr
a8d869e1d1
rustdoc: cross-crate re-exports: correctly render late-bound params in source order even if early-bound params are present 2024-02-15 01:40:38 +01:00
Nicholas Nethercote
64a9c9cfea Reinstate some delayed bugs.
These were changed to `has_errors` assertions in #121071 because that
seemed reasonable, but evidently not.

Fixes #121103.
Fixes #121108.
2024-02-15 09:26:45 +11:00
Peter Hall
9cccf20899 Clarified docs on non-atomic oprations on owned/mut refs to atomics 2024-02-14 20:14:45 +00:00
bors
ee9c7c940c Auto merge of #120847 - oli-obk:track_errors9, r=compiler-errors
Continue compilation after check_mod_type_wf errors

The ICEs fixed here were probably reachable through const eval gymnastics before, but now they are easily reachable without that, too.

The new errors are often bugfixes, where useful errors were missing, because they were reported after the early abort. In other cases sometimes they are just duplication of already emitted errors, which won't be user-visible due to deduplication.

fixes https://github.com/rust-lang/rust/issues/120860
2024-02-14 18:32:19 +00:00
Michael Goulet
01c974ff98 Do not report overflow errors on ConstArgHasType goals 2024-02-14 18:02:55 +00:00
Mohammad Omidvar
2e691a5c12 Rewrite foreign item kind query using DefKind 2024-02-14 17:38:36 +00:00
Shoyu Vanilla
fa1e35c833 Remove unnecessary else block from thread_local! expanded code 2024-02-15 02:35:37 +09:00
Oli Scherer
55f9aed9c7 Move all the heavy lifting from TyCtxtAt::create_def into TyCtxt::create_def 2024-02-14 16:03:49 +00:00
bors
502ce8287b Auto merge of #121086 - GuillaumeGomez:rollup-y82fs9y, r=GuillaumeGomez
Rollup of 6 pull requests

Successful merges:

 - #120893 (Move some tests)
 - #120966 (Remove importing suggestions when there is a shadowed typo candidate)
 - #121035 (Format `async` trait bounds in rustfmt)
 - #121075 (Fix false positive with if let and ranges)
 - #121083 (Extend documentation for `Ty::to_opt_closure_kind` method)
 - #121084 (Make sure `tcx.create_def` also depends on the forever red node, instead of just `tcx.at(span).create_def`)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-02-14 15:45:34 +00:00
Guillaume Gomez
2062325145
Rollup merge of #121084 - oli-obk:create_def_forever_red2, r=WaffleLapkin
Make sure `tcx.create_def` also depends on the forever red node, instead of just `tcx.at(span).create_def`

oversight from https://github.com/rust-lang/rust/pull/119136

Not actually an issue, because all uses of `tcx.create_def` were in the resolver, which is `eval_always`, but still good to harden against future uses of `create_def`

cc `@petrochenkov` `@WaffleLapkin`
2024-02-14 15:41:30 +01:00
Guillaume Gomez
c2ae07d20d
Rollup merge of #121083 - GuillaumeGomez:doc-to_opt_closure_kind, r=compiler-errors
Extend documentation for `Ty::to_opt_closure_kind` method

This API was... surprising to use. With a little extra documentation, the weirdness can be reduced quite a lot. :)

r? `@compiler-errors`
2024-02-14 15:41:29 +01:00
Guillaume Gomez
18c935d000
Rollup merge of #121075 - chenyukang:yukang-fix-121070-lint-range, r=oli-obk
Fix false positive with if let and ranges

Fixes #121070
2024-02-14 15:41:28 +01:00
Guillaume Gomez
dd4851b338
Rollup merge of #121035 - compiler-errors:rustfmt-asyncness, r=calebcartwright
Format `async` trait bounds in rustfmt

r? `@ytmimi` or `@calebcartwright`

This PR opts to do formatting in the rust-lang/rust tree because otherwise we'd have to wait until a full sync, and rustfmt is currently totally removing the `async` keyword.

cc https://github.com/rust-lang/rustfmt/issues/6070
2024-02-14 15:41:27 +01:00
Guillaume Gomez
8e690fdd6a
Rollup merge of #120966 - chenyukang:yukang-fix-120599-resolve, r=pnkfelix
Remove importing suggestions when there is a shadowed typo candidate

Fixes #120559
2024-02-14 15:41:27 +01:00
Guillaume Gomez
b36e094802
Rollup merge of #120893 - c410-f3r:testsssssss, r=petrochenkov
Move some tests

r? `@petrochenkov`
2024-02-14 15:41:26 +01:00
Guillaume Gomez
9ef9f737ca Extend documentation for Ty::to_opt_closure_kind method 2024-02-14 15:24:44 +01:00
Oli Scherer
2e900edde1 Make sure tcx.create_def also depends on the forever red node, instead of just tcx.at(span).create_def 2024-02-14 14:08:19 +00:00
bors
340bb19fea Auto merge of #121078 - oli-obk:rollup-p11zsav, r=oli-obk
Rollup of 13 pull requests

Successful merges:

 - #116387 (Additional doc links and explanation of `Wake`.)
 - #118738 (Netbsd10 update)
 - #118890 (Clarify the lifetimes of allocations returned by the `Allocator` trait)
 - #120498 (Uplift `TypeVisitableExt` into `rustc_type_ir`)
 - #120530 (Be less confident when `dyn` suggestion is not checked for object safety)
 - #120915 (Fix suggestion span for `?Sized` when param type has default)
 - #121015 (Optimize `delayed_bug` handling.)
 - #121024 (implement `Default` for `AsciiChar`)
 - #121039 (Correctly compute adjustment casts in GVN)
 - #121045 (Fix two UI tests with incorrect directive / invalid revision)
 - #121049 (Do not point at `#[allow(_)]` as the reason for compat lint triggering)
 - #121071 (Use fewer delayed bugs.)
 - #121073 (Fix typos in `OneLock` doc)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-02-14 12:04:03 +00:00
Oli Scherer
25806f8d80 Use the correct char type on all platforms 2024-02-14 11:12:19 +00:00
Oli Scherer
5f6390f947 Continue compilation after check_mod_type_wf errors 2024-02-14 11:00:30 +00:00
Oli Scherer
96635da982
Rollup merge of #121073 - IgorLaborieWefox:patch-1, r=workingjubilee
Fix typos in `OneLock` doc
2024-02-14 11:53:43 +01:00
Oli Scherer
638f5259fe
Rollup merge of #121071 - nnethercote:fewer-delayed-bugs, r=oli-obk
Use fewer delayed bugs.

For some cases where it's clear that an error has already occurred, e.g.:
- there's a comment stating exactly that, or
- things like HIR lowering, where we are lowering an error kind

The commit also tweaks some comments around delayed bug sites.

r? `@oli-obk`
2024-02-14 11:53:42 +01:00
Oli Scherer
9e31121985
Rollup merge of #121049 - estebank:issue-121009, r=fmease
Do not point at `#[allow(_)]` as the reason for compat lint triggering

Fix #121009.
2024-02-14 11:53:42 +01:00
Oli Scherer
f77870e170
Rollup merge of #121045 - jieyouxu:fix-ui-tests, r=oli-obk
Fix two UI tests with incorrect directive / invalid revision

- `tests/ui/borrowck/copy-suggestion-region-vid.rs` had a `ui_test`-style directive on compiletest: `//`@run-rustfix`.`
- `tests/ui/asm/inline-syntax.rs` has directives for a undeclared revision `[x86_64_allowed]` which seems to have the same directives as declared revision `[x86_64]`.
2024-02-14 11:53:41 +01:00
Oli Scherer
93bc34073e
Rollup merge of #121039 - cjgillot:gvn-adjust, r=compiler-errors
Correctly compute adjustment casts in GVN

Fixes https://github.com/rust-lang/rust/issues/120925

r? `@oli-obk`
2024-02-14 11:53:41 +01:00
Oli Scherer
c1a80211f5
Rollup merge of #121024 - joseluis:feat-asciichar-default, r=scottmcm
implement `Default` for `AsciiChar`

This implements `Default` for `AsciiChar` in order to match `char`'s implementation.

From all the different possible ways to do this I think the clearest one is to have both `char` and `AsciiChar` impls together.

I've also updated the doc-comment of the default variant since rustdoc doesn't seem to indicate it otherwise. Probably the text could be improved, though. I couldn't find any similar examples in the codebase and suggestions are welcomed.

r? `@scottmcm`
2024-02-14 11:53:40 +01:00
Oli Scherer
bad2cb08de
Rollup merge of #121015 - nnethercote:opt-delayed-bug, r=oli-obk
Optimize `delayed_bug` handling.

Once we have emitted at least one error, delayed bugs won't be used. So we can (a) we can (a) discard any existing delayed bugs, and (b) stop recording any new delayed bugs.

This eliminates a longstanding `FIXME` comment. There should be no soundness issues because it's not possible to un-emit an error.

r? `@oli-obk`
2024-02-14 11:53:40 +01:00