Commit graph

246515 commits

Author SHA1 Message Date
Guillaume Gomez 7d6c99dd06
Rollup merge of #121088 - nikic:evex512, r=Amanieu
Implicitly enable evex512 if avx512 is enabled

LLVM 18 requires the evex512 feature to allow use of zmm registers. LLVM automatically sets it when using a generic CPU, but not when `-C target-cpu` is specified. This will result either in backend legalization crashes, or code unexpectedly using ymm instead of zmm registers.

For now, make sure that `avx512*` features imply `evex512`. Long term we'll probably have to deal with the AVX10 mess somehow.

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

r? `@Amanieu`
2024-02-15 14:33:01 +01:00
Guillaume Gomez bf323ba3ac
Rollup merge of #120672 - devnexen:update_thread_stack_guardpages_fbsd, r=m-ou-se
std::thread update freebsd stack guard handling.

up to now, it had been assumed the stack guard setting default is not touched in the field but some user might just want to disable it or increase it. checking it once at runtime should be enough.
2024-02-15 14:33:00 +01:00
Guillaume Gomez 472c820eb3
Rollup merge of #120505 - Amanieu:fix-btreemap-cursor-remove, r=m-ou-se
Fix BTreeMap's Cursor::remove_{next,prev}

These would incorrectly leave `current` as `None` after a failed attempt to remove an element (due to the cursor already being at the start/end).
2024-02-15 14:33:00 +01:00
Guillaume Gomez 9fdab38877
Rollup merge of #120449 - udoprog:document-unsized-rc-arc-from-raw, r=m-ou-se
Document requirements for unsized {Rc,Arc}::from_raw

This seems to be implied due to these types supporting operation-less unsized coercions. Taken together with the [established behavior of a wide to thin pointer cast](https://github.com/rust-lang/reference/pull/1451) it would enable unsafe downcasting of these containers.

Note that the term "data pointer" is adopted from https://github.com/rust-lang/rfcs/pull/3559

See also this [internals thread](https://internals.rust-lang.org/t/can-unsafe-smart-pointer-downcasts-be-correct/20229/2).
2024-02-15 14:32:59 +01:00
Guillaume Gomez 4085421e92 Update rust book cfg chapter 2024-02-15 14:18:19 +01:00
Guillaume Gomez 33e9fc5d8d Update ui tests to take into account the new clippy cfg 2024-02-15 14:18:19 +01:00
Guillaume Gomez 0860fc14ae Add clippy into the known cfg list 2024-02-15 14:18:19 +01: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
yukang bd546fb20a add extra indent spaces for rust-playground link 2024-02-15 18:57:21 +08:00
David Wood b80fc5d4e8
errors: only eagerly translate subdiagnostics
Subdiagnostics don't need to be lazily translated, they can always be
eagerly translated. Eager translation is slightly more complex as we need
to have a `DiagCtxt` available to perform the translation, which involves
slightly more threading of that context.

This slight increase in complexity should enable later simplifications -
like passing `DiagCtxt` into `AddToDiagnostic` and moving Fluent messages
into the diagnostic structs rather than having them in separate files
(working on that was what led to this change).

Signed-off-by: David Wood <david@davidtw.co>
2024-02-15 10:34:41 +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 8443305015 Auto merge of #16559 - Wilfred:scip_documentation_field, r=lnicola
Set documentation field in SCIP from doc comment

Previously, the documentation field was the same as the text shown to users when they hover over that symbol. The documentation should really just be the doc comment, and as of #16179 the signature is already stored in the signatureDocumentation field.
2024-02-15 09:07:29 +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
Markus Reiter a90cc05233
Replace NonZero::<_>::new with NonZero::new. 2024-02-15 08:09:42 +01:00
Markus Reiter 746a58d435
Use generic NonZero internally. 2024-02-15 08:09:42 +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
Nicholas Nethercote ac47f6c666 Add suffixes to LitError.
To avoid some unwrapping.
2024-02-15 15:47:24 +11:00
Nicholas Nethercote 25ed6e43b0 Add ErrorGuaranteed to ast::LitKind::Err, token::LitKind::Err.
This mostly works well, and eliminates a couple of delayed bugs.

One annoying thing is that we should really also add an
`ErrorGuaranteed` to `proc_macro::bridge::LitKind::Err`. But that's
difficult because `proc_macro` doesn't have access to `ErrorGuaranteed`,
so we have to fake it.
2024-02-15 14:46:08 +11:00
Eric Huss 217e5e484d Fix SmallCStr conversion from CStr 2024-02-14 18:40:53 -08:00
DropDemBits 7cf4a8a3bf
fix: Place snippets correctly in multi-edit assists 2024-02-14 21:35:17 -05:00
DropDemBits 0d6024c021
Add tests for snippet range adjustment
Uses actual source for tests to easily confirm the results.
2024-02-14 21:33:05 -05:00
Nicholas Nethercote 332c57723a Make emit_unescape_error return Option<ErrorGuaranteed>.
And use the result in `cook_common` to decide whether to return an error
token.
2024-02-15 12:58:18 +11:00
Nicholas Nethercote a513bb20c3 Make report_lit_error return ErrorGuaranteed.
This will be helpful for subsequent commits.
2024-02-15 12:58:18 +11:00
Nicholas Nethercote 8b35f8e41e Remove LitError::LexerError.
`cook_lexer_literal` can emit an error about an invalid int literal but
then return a non-`Err` token. And then `integer_lit` has to account for
this to avoid printing a redundant error message.

This commit changes `cook_lexer_literal` to return `Err` in that case.
Then `integer_lit` doesn't need the special case, and
`LitError::LexerError` can be removed.
2024-02-15 12:58:18 +11: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
Tomasz Miąsko 5f4e4baddb Skip coroutines in jump threading to avoid query cycles 2024-02-15 00:00:00 +00:00
Wilfred Hughes dda641c62c Set documentation field in SCIP from doc comment
Previously, the documentation field was the same as the text shown to
users when they hover over that symbol. The documentation should
really just be the doc comment, and as of #16179 the signature is
already stored in the signatureDocumentation field.
2024-02-14 14:46:32 -08:00
Nicholas Nethercote 5233bc91da Add an ErrorGuaranteed to ast::TyKind::Err.
This makes it more like `hir::TyKind::Err`, and avoids a
`span_delayed_bug` call in `LoweringContext::lower_ty_direct`.

It also requires adding `ast::TyKind::Dummy`, now that
`ast::TyKind::Err` can't be used for that purpose in the absence of an
error emission.

There are a couple of cases that aren't as neat as I would have liked,
marked with `FIXME` comments.
2024-02-15 09:35:11 +11: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
Oli Scherer c1bb352c8b Continue compilation even if inherent impl checks fail 2024-02-14 21:04:51 +00:00
trevyn 220e8a7484 For E0038, suggest associated type if available 2024-02-14 12:42:32 -08:00
Esteban Küber 8d4d572e4d Fix msg for verbose suggestions with confusable capitalization
When encountering a verbose/multipart suggestion that has changes
that are only caused by different capitalization of ASCII letters that have
little differenciation, expand the message to highlight that fact (like we
already do for inline suggestions).

The logic to do this was already present, but implemented incorrectly.
2024-02-14 20:15:13 +00:00
Peter Hall 9cccf20899 Clarified docs on non-atomic oprations on owned/mut refs to atomics 2024-02-14 20:14:45 +00:00