Commit Graph

245839 Commits

Author SHA1 Message Date
long-long-float
1e59e66225 Fix to use for loop 2024-02-11 02:43:55 +09:00
long-long-float
44616e11d0 Add test for the issue 2024-02-11 02:43:44 +09:00
Ralf Jung
29db7890ba interpret/visitor: ensure we only see normalized types 2024-02-10 17:00:24 +01:00
bors
6cc4843512 Auto merge of #119614 - RalfJung:const-refs-to-static, r=oli-obk
unstably allow constants to refer to statics and read from immutable statics

I am not aware of any fundamental reason why we cannot allow constants to mention statics. What we really need is that constants do not *read from* statics that can change their value:
- This would break the principle that "constants behave as-if their expression was inlined everywhere and executed at runtime". This is enforced by halting const-eval interpretation when a read from a mutable global occurs.
- When building a valtree we want to be sure that the constant and everything it refers to is truly immutable. This is enforced by aborting valtree construction when a read from a mutable global occurs.

r? `@oli-obk` -- if you are okay with experimenting with this feature, I will create a tracking issue.
Based on and blocked on https://github.com/rust-lang/rust/pull/119044; only the last commit is new.
2024-02-10 15:52:24 +00:00
Lukas Wirth
5136705fad internal: Remove SELF_REF hack for self referential SyntaxContexts 2024-02-10 16:20:02 +01:00
Martin Nordholts
a4fbd01af2 tests/ui/lint/large_assignments: only-x86_64 -> only-64bit
So that devs on aarch64 can also bless tests.
2024-02-10 16:17:00 +01:00
Martin Nordholts
e2979a8b8c large_assignments: Allow moves into functions
Moves into functions are typically implemented with pointer passing
rather than memcpy's at the llvm-ir level, so allow moves into
functions.
2024-02-10 16:17:00 +01:00
Ralf Jung
4def37386c manually bless an aarch64 test 2024-02-10 16:13:48 +01:00
Ralf Jung
04bc624ea0 rebless after rebase 2024-02-10 16:13:48 +01:00
Ralf Jung
77f8c3caea detect consts that reference extern statics 2024-02-10 16:13:48 +01:00
Ralf Jung
9c0623fe8f validation: descend from consts into statics 2024-02-10 16:13:47 +01:00
Ralf Jung
4e77e368eb unstably allow constants to refer to statics and read from immutable statics 2024-02-10 16:12:55 +01:00
Ralf Jung
d56f3b6a5d interpret: rename ReadExternStatic → ExternStatic 2024-02-10 16:06:02 +01:00
bors
1c32387ce2 Auto merge of #16526 - Veykril:item-loc, r=Veykril
internal: Cleanup 🧹
2024-02-10 14:38:15 +00:00
Ralf Jung
18ed966ab5 interpret/write_discriminant: when encoding niched variant, ensure the stored value matches 2024-02-10 15:33:58 +01:00
Ralf Jung
1383657a46 add note on comparing vtables / function pointers 2024-02-10 14:58:37 +01:00
Lukas Wirth
36fb1409ed Cleanup visibility.rs 2024-02-10 13:50:45 +01:00
bors
5f40394baa Auto merge of #120877 - matthiaskrgr:rollup-j1b8mv6, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #117614 (static mut: allow mutable reference to arbitrary types, not just slices and arrays)
 - #120719 (Remove support for `associated_type_bound` nested in `dyn` types)
 - #120764 (Add documentation on `str::starts_with`)
 - #120823 (Clarify that atomic and regular integers can differ in alignment)
 - #120859 (Loosen an assertion to account for stashed errors.)
 - #120865 (Turn the "no saved object file in work product" ICE into a translatable fatal error)
 - #120866 (Remove unnecessary `#![feature(min_specialization)]`)
 - #120870 (Allow restricted trait impls under `#[allow_internal_unstable(min_specialization)]`)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-02-10 12:28:39 +00:00
onur-ozkan
ff6d296589 refactor use of Cargo and configure_linker in bootstrap
Signed-off-by: onur-ozkan <work@onurozkan.dev>
2024-02-10 15:24:33 +03:00
Matthias Krüger
55913368c5
Rollup merge of #120870 - Zalathar:allow-min-spec, r=oli-obk
Allow restricted trait impls under `#[allow_internal_unstable(min_specialization)]`

This is a follow-up to #119963 and a companion to #120866, though it can land independently from the latter.

---

We have several compiler crates that only enable `#[feature(min_specialization)]` because it is required by their expansions of `newtype_index!`, in order to implement traits marked with `#[rustc_specialization_trait]`.

This PR allows those traits to be implemented internally by macros with `#[allow_internal_unstable(min_specialization)]`, without needing specialization to be enabled in the enclosing crate.
2024-02-10 13:12:31 +01:00
Matthias Krüger
ed3b049a8b
Rollup merge of #120866 - Zalathar:no-min-spec, r=compiler-errors
Remove unnecessary `#![feature(min_specialization)]`

As of #119963 and #120676, we can now rely on `newtype_index!` having `#[allow_internal_unstable(min_specialization)]`, so there are a few compiler crates that no longer need to include min-spec in their own crate features.

---

Some of the expansions of `newtype_index!` still appear to require min-spec in the crate features. I think this is because `#[orderable]` causes the expansion to include an implementation of `TrustedStep`, which is flagged with `#[rustc_specialization_trait]`, and for whatever reason that isn't permitted by allow-internal-unstable. So this PR only touches the crates where that isn't the case.
2024-02-10 13:12:31 +01:00
Matthias Krüger
9a8958f2bb
Rollup merge of #120865 - saethlin:missing-o-files, r=nnethercote
Turn the "no saved object file in work product" ICE into a translatable fatal error

I don't know if it's fair to say this fixes https://github.com/rust-lang/rust/issues/120854 but it surely makes the error reporting better and should encourage people with good instincts like ```@CinchBlue.```
2024-02-10 13:12:31 +01:00
Matthias Krüger
2dbc9f55f7
Rollup merge of #120859 - nnethercote:fix-120856, r=oli-obk
Loosen an assertion to account for stashed errors.

The meaning of this assertion changed in #120828 when the meaning of `has_errors` changed to exclude stashed errors. Evidently the new meaning is too restrictive.

Fixes #120856.

r? ```@oli-obk```
2024-02-10 13:12:30 +01:00
Matthias Krüger
83544703f5
Rollup merge of #120823 - LegionMammal978:clarify-atomic-align, r=RalfJung
Clarify that atomic and regular integers can differ in alignment

The documentation for atomic integers says that they have the "same in-memory representation" as their underlying integers. This might be misconstrued as implying that they have the same layout. Therefore, clarify that atomic integers' alignment is equal to their size.
2024-02-10 13:12:29 +01:00
Matthias Krüger
2eda0c7b2e
Rollup merge of #120764 - Alfriadox:master, r=m-ou-se
Add documentation on `str::starts_with`

Add documentation about a current footgun of `str::starts_with`
2024-02-10 13:12:29 +01:00
Matthias Krüger
e11e4446da
Rollup merge of #120719 - compiler-errors:no-dyn-atb, r=lcnr
Remove support for `associated_type_bound` nested in `dyn` types

These necessarily desugar to `impl Trait`, which is inconsistent with the `associated_type_bound` feature after #120584.

This PR keeps the `is_in_dyn_type` hack, which kind of makes me sad. Ideally, we'd be validating that no object types have associated type bounds somewhere else. Unfortunately, we can't do this later during astconv (i think?), nor can we do it earlier during ast validation (i think?) because of the feature gating of ATB being a *warning* rather than an *error*. Let me know if you have thoughts about this.

r? lcnr
2024-02-10 13:12:28 +01:00
Matthias Krüger
0b7f0ff230
Rollup merge of #117614 - RalfJung:static-mut-refs, r=davidtwco,oli-obk
static mut: allow mutable reference to arbitrary types, not just slices and arrays

For historical reasons, we allow this:
```rust
static mut ARRAY: &'static mut [isize] = &mut [1];
```
However, we do not allow this:
```rust
static mut INT: &'static mut isize = &mut 1;
```

I think that's terribly inconsistent. I don't care much for `static mut`, but we have to keep it around for backwards compatibility and so we have to keep supporting it properly in the compiler. In recent refactors of how we deal with mutability of data in `static` and `const`, I almost made a fatal mistake since I tested `static mut INT: &'static mut isize = &mut 1` and concluded that we don't allow such `'static` mutable references even inside `static mut`. After all, nobody would expect this to be allowed only for arrays and slices, right?!?? So for the sake of our own sanity, and of whoever else reverse engineers these rules in the future to understand what the Rust compiler accepts or does not accept, I propose that we accept this for all types, not just arrays and slices.
2024-02-10 13:12:28 +01:00
Lukas Wirth
dc69255b83 Re-organize hir-def/lib.rs 2024-02-10 12:40:23 +01:00
Lukas Wirth
74eb3ecbc1 Move ChildbySource and HasSource impls to their corresponding modules 2024-02-10 12:09:12 +01:00
bors
0878cdef2a Auto merge of #16524 - evertedsphere:swann/trait-bound-dyn, r=Veykril
minor: test that flip_trait_bound works with trait objects

Closes https://github.com/rust-lang/rust-analyzer/issues/16522.
2024-02-10 10:59:46 +00:00
bors
1ef7a2329b Auto merge of #16525 - Veykril:item-loc, r=Veykril
Abstract more over ItemTreeLoc-like structs

Allows reducing some code duplication by using functions generic over said structs. The diff isn't negative due to me adding some additional impls for completeness.
2024-02-10 10:47:37 +00:00
Lukas Wirth
00303c3b67 Abstract over ItemTreeLoc 2024-02-10 11:37:59 +01:00
Gurinder Singh
0815067796 Take empty where into account when suggesting predicates 2024-02-10 16:05:39 +05:30
Soham Chowdhury
dcdfc35fce test that flip_trait_bound works with trait objects 2024-02-10 11:06:07 +01:00
bors
232919c33a Auto merge of #120771 - oli-obk:useless_non_ensure_query_call, r=davidtwco
Use `ensure` when the result of the query is not needed beyond its `Result`ness

while I would like to just remove the `tcx` methods for ensure-only queries, that is hard to do without another query annotation or by turning the `define_callbacks` macro into a proc macro to get more control

should fix perf regression of https://github.com/rust-lang/rust/pull/120558
2024-02-10 09:27:14 +00:00
Vadim Petrochenkov
b07283815b hir: Remove hir::Map::{opt_parent_id,parent_id,get_parent,find_parent} 2024-02-10 12:24:46 +03:00
Vadim Petrochenkov
e46e3e7107 hir: Introduce TyCtxt::parent_hir_{id,node}
Remove the FIXME and keep `CRATE_HIR_ID` being its own parent.
This scheme turned out to be more practical than having an `Option` on closer inspection.

Also make `hir_owner_parent` more readable.
2024-02-10 12:23:11 +03:00
Ralf Jung
3bc490d814 various docs tweaks 2024-02-10 10:19:57 +01:00
Ralf Jung
aa64c73f14 simd_scatter: mention left-to-right order 2024-02-10 10:13:15 +01:00
Ralf Jung
5219af6ae0 add more missing simd intrinsics 2024-02-10 10:13:14 +01:00
Ralf Jung
d96f0c382f simd intrinsics: add simd_shuffle_generic 2024-02-10 10:13:14 +01:00
bors
aa97edb214 Auto merge of #16497 - evertedsphere:swann/fix-inline-for-macro-generated-method, r=Veykril
Fix incorrect inlining of functions that come from MBE macros

Partial fix for https://github.com/rust-lang/rust-analyzer/issues/16471.

As a reminder, there are two issues there:
1. missing whitespace in parameter types (the first test)
2. the `self` parameter not being replaced by `this` in the function body (the second test)

The first part is fixed in this PR. See [this comment](https://github.com/rust-lang/rust-analyzer/pull/16497#issuecomment-1934243409) for the second.
2024-02-10 08:59:51 +00:00
bors
7e9265506d Auto merge of #16521 - tetsuharuohzeki:experiment-enable-str_to_string, r=lnicola
internal: Enable str_to_string Clippy rule

This fix [the FIXME comment](bb0de88f24/Cargo.toml (L183-L184))
2024-02-10 08:15:39 +00:00
bors
757b8efed4 Auto merge of #120712 - compiler-errors:async-closures-harmonize, r=oli-obk
Harmonize `AsyncFn` implementations, make async closures conditionally impl `Fn*` traits

This PR implements several changes to the built-in and libcore-provided implementations of `Fn*` and `AsyncFn*` to address two problems:
1. async closures do not implement the `Fn*` family traits, leading to breakage: https://crater-reports.s3.amazonaws.com/pr-120361/index.html
2. *references* to async closures do not implement `AsyncFn*`, as a consequence of the existing blanket impls of the shape `AsyncFn for F where F: Fn, F::Output: Future`.

In order to fix (1.), we implement `Fn` traits appropriately for async closures. It turns out that async closures can:
* always implement `FnOnce`, meaning that they're drop-in compatible with `FnOnce`-bound combinators like `Option::map`.
* conditionally implement `Fn`/`FnMut` if they have no captures, which means that existing usages of async closures should *probably* work without breakage (crater checking this: https://github.com/rust-lang/rust/pull/120712#issuecomment-1930587805).

In order to fix (2.), we make all of the built-in callables implement `AsyncFn*` via built-in impls, and instead adjust the blanket impls for `AsyncFn*` provided by libcore to match the blanket impls for `Fn*`.
2024-02-10 07:15:15 +00:00
Zalathar
a2479a4ae7 Remove unnecessary min_specialization after bootstrap
These crates all needed specialization for `newtype_index!`, which will no
longer be necessary when the current nightly eventually becomes the next
bootstrap compiler.
2024-02-10 18:15:11 +11:00
Zalathar
7b73e4fd44 Allow restricted trait impls in macros with min_specialization
Implementing traits marked with `#[rustc_specialization_trait]` normally
requires (min-)specialization to be enabled for the enclosing crate.

With this change, that permission can also be granted by an
`allow_internal_unstable` attribute on the macro that generates the impl.
2024-02-10 18:14:02 +11:00
bors
68125c72d3 Auto merge of #120721 - onur-ozkan:incorrect-llvm-path-on-cross-target, r=albertlarsan68
fix `llvm_out` to use the correct LLVM root

When `download-ci-llvm` is enabled, `llvm_out` ends up with the
error below due to an incorrect path on cross-compilations. This change fixes that.

```sh
failed to execute command: "/rust/build/x86_64-unknown-linux-gnu/llvm/build/bin/llvm-config" "--version"
ERROR: No such file or directory (os error 2)
```
2024-02-10 04:12:51 +00:00
Michael Goulet
e6f5af9671 Remove unused fn 2024-02-10 03:52:13 +00:00
Michael Goulet
fde695a2d1 Add a helpful suggestion 2024-02-10 03:31:34 +00:00
Venus Xeon-Blonde
d7263d7aad
Change wording 2024-02-09 22:24:57 -05:00