Commit Graph

267763 Commits

Author SHA1 Message Date
dacian
3b2be4457d grammar fix 2024-10-06 20:37:10 +03:00
bors
373971abe4 Auto merge of #131259 - ismailarilik:handle-potential-query-instability-lint-for-librustdoc, r=notriddle
Handle `librustdoc` cases of `rustc::potential_query_instability` lint

This PR removes `#![allow(rustc::potential_query_instability)]` line from [`src/librustdoc/lib.rs`](https://github.com/rust-lang/rust/blob/master/src/librustdoc/lib.rs#L23) and converts `FxHash{Map,Set}` types into `FxIndex{Map,Set}` to suppress lint errors.

A somewhat tracking issue: https://github.com/rust-lang/rust/issues/84447

r? `@compiler-errors`
2024-10-06 14:04:21 +00:00
bors
96d9d8aa7d Auto merge of #131320 - matthiaskrgr:rollup-tom15b3, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #129392 (Do not consider match/let/ref of place that evaluates to `!` to diverge, disallow coercions from them too)
 - #131279 (update "build/host" symlink comment)
 - #131312 (On function and method calls in patterns, link to the book)
 - #131315 (bootstrap: add `std_features` config)
 - #131316 (Fix typo in primitive_docs.rs)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-10-06 11:43:07 +00:00
Matthias Krüger
dd09e9c742
Rollup merge of #131316 - programmerjake:patch-4, r=Noratrieb
Fix typo in primitive_docs.rs

typo introduced in #129559
2024-10-06 11:06:59 +02:00
Matthias Krüger
3c4bc7d763
Rollup merge of #131315 - shrirambalaji:issue-129599-fix-shrirambalaji, r=onur-ozkan
bootstrap: add `std_features` config

Adding support for a std-features config under the rust section in config.toml during bootstrap. This allows rustc devs to build with specific feature flags for local development.
2024-10-06 11:06:58 +02:00
Matthias Krüger
11c41ff165
Rollup merge of #131312 - estebank:fn-in-pattern, r=compiler-errors
On function and method calls in patterns, link to the book

```
error: expected a pattern, found an expression
 --> f889.rs:3:13
  |
3 |     let (x, y.drop()) = (1, 2);
  |             ^^^^^^^^ not a pattern
  |
  = note: arbitrary expressions are not allowed in patterns: <https://doc.rust-lang.org/book/ch18-00-patterns.html>

error[E0532]: expected a pattern, found a function call
 --> f889.rs:2:13
  |
2 |     let (x, drop(y)) = (1, 2);
  |             ^^^^ not a tuple struct or tuple variant
  |
  = note: function calls are not allowed in patterns: <https://doc.rust-lang.org/book/ch18-00-patterns.html>
```

Fix #97200.
2024-10-06 11:06:58 +02:00
Matthias Krüger
aa546f9a73
Rollup merge of #131279 - onur-ozkan:remove-host-symlink, r=Noratrieb
update "build/host" symlink comment

It's needed and can't be removed, so make it clear where it's needed.
2024-10-06 11:06:57 +02:00
Matthias Krüger
9aaebd481a
Rollup merge of #129392 - compiler-errors:raw-ref-op-doesnt-diverge-but-more, r=lcnr
Do not consider match/let/ref of place that evaluates to `!` to diverge, disallow coercions from them too

Fixes #117288.

This PR implements a heuristic which disables two things that are currently being performed on the HIR when we have **expressions that involve place-like expressions that point to `!`**. Specifically, it will (in certain cases explained below):

### (1.) Disable the `NeverToAny` coercion we implicitly insert for `!`.

Which fixes this inadvertent, sneaky unsoundness:

```
unsafe {
    let x: *const ! = &0 as *const u8 as *const !;
    let _: () = *x;
}
```

which is UB because currently rust emits an *implicit* NeverToAny coercion even though we really shouldn't be, since there's no read of the value pointed by `x`.

### (2.) Disable the logic which considers expression which evaluate to `!` to diverge, which affects the type returned by the containing block.

Which fixes this unsoundness:

```
fn make_up_a_value<T>() -> T {
    unsafe {
        let x: *const ! = &0 as *const u8 as *const !;
        let _ = *x;
    }
}
```

We disable these two operations **if** the expression is a place-like expression (locals, statics, field projections, index operations, and deref operations), and if the parent expression is either:
(1.) the LHS of an assignment
(2.) AddrOf
(3.) A match or let **unless** all of the *patterns consitute a read*, which is explained below:

And finally, a pattern currently is considered to constitute a read **unless** it is a wildcard, or an OR pattern. An OR pattern is considered to constitute a read if all of its subpatterns constitute a read, to remain as conservative as possible in cases like `_ | subpat` or `subpat | _`.

All other patterns are considered currently to constitute a read. Specifically, because `NeverToAny` is a coercion performed on a *value* and not a *place*, `Struct { .. }` on a `!` type must be a coercion currently, and we currently rely on this behavior to allow us to perform coercions like `let _: i32 = x;` where `x: !`.

This is already considered UB by [miri](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=daf3a2246433fe43fdc07d1389c276c9), but also means it does not affect the preexisting UB in this case:

```
let Struct { .. } = *never_ptr;
```

Even though it's likely up for debate since we're not actually reading any data out of the struct, it almost certainly causes inference changes which I do *NOT* want to fix in this PR.
2024-10-06 11:06:57 +02:00
bors
68301a6a96 Auto merge of #131075 - mrkajetanp:bootstrap-editors, r=Kobzol
bootstrap: Consolidate editor setup into ./x setup editor & add support for vim, emacs & helix

Add support for automatically setting up the recommended
LSP config for Vim (coc-nvim), Emacs (eglot) and Helix.

Additionally, refactor setup.rs to make it easier to add support
for more editors in the future.

As suggested,
r? `@jieyouxu`
2024-10-06 07:43:53 +00:00
ismailarilik
e0a20b484d Handle librustdoc cases of rustc::potential_query_instability lint 2024-10-06 10:39:03 +03:00
bors
7d53688b25 Auto merge of #131314 - tgross35:update-builtins, r=tgross35
Update `compiler-builtins` to 0.1.133

This includes [1], which should help resolve an infinite recusion issue on WASM and SPARC (possibly other platforms). See [2] and [3] for further details.

[1]: https://github.com/rust-lang/compiler-builtins/pull/708
[2]: https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/sparc-unknown-none-elf.20regresssion.20between.20compiler-built.2E.2E.2E
[3]: https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/.5Bwasm32.5D.20Infinite.20recursion.20.60compiler-builtins.60.20.60__multi3.60
2024-10-06 05:15:51 +00:00
Jacob Lifshay
002afd1ae9
Fix typo in primitive_docs.rs 2024-10-05 22:01:02 -07:00
Shriram Balaji
8b968764f1 bootstrap: add std_features config
bootstrap: add std_features  to config.example

fix: use BTreeSet for std-features; add unit tests

* fix formatting of string in front of std_features
* rename `std_features` to `std-features` in config.toml

fix: remove space before std-features in config.toml

fix: remove explicit .into_iter conversion

bootstrap: add details for rust.std-features in config.example.toml

Co-authored-by: Onur Özkan <onurozkan.dev@outlook.com>

fix: remove `Option<T>` from `rust_std_features`

fix: move default rust_std_features to config

fix: make std_features CI rustc incompatible
2024-10-06 09:59:10 +05:30
bors
daebce4247 Auto merge of #130540 - veera-sivarajan:fix-87525, r=estebank
Add a Lint for Pointer to Integer Transmutes in Consts

Fixes #87525

This PR adds a MirLint for pointer to integer transmutes in const functions and associated consts. The implementation closely follows this comment: https://github.com/rust-lang/rust/pull/85769#issuecomment-880969112. More details about the implementation can be found in the comments.

Note: This could break some sound code as mentioned by RalfJung in https://github.com/rust-lang/rust/pull/85769#issuecomment-886491680:

> ... technically const-code could transmute/cast an int to a ptr and then transmute it back and that would be correct -- so the lint will deny some sound code. Does not seem terribly likely though.

References:
1. https://doc.rust-lang.org/std/mem/fn.transmute.html
2. https://doc.rust-lang.org/reference/items/associated-items.html#associated-constants
2024-10-06 02:39:23 +00:00
Trevor Gross
7c0c511933 Update compiler-builtins to 0.1.133
This includes [1], which should help resolve an infinite recusion issue
on WASM and SPARC (possibly other platforms). See [2] and [3] for
further details.

[1]: https://github.com/rust-lang/compiler-builtins/pull/708
[2]: https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/sparc-unknown-none-elf.20regresssion.20between.20compiler-built.2E.2E.2E
[3]: https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/.5Bwasm32.5D.20Infinite.20recursion.20.60compiler-builtins.60.20.60__multi3.60
2024-10-05 21:34:51 -05:00
Esteban Küber
7f5548fa8b On function and method calls in patterns, link to the book
```
error: expected a pattern, found an expression
 --> f889.rs:3:13
  |
3 |     let (x, y.drop()) = (1, 2); //~ ERROR
  |             ^^^^^^^^ not a pattern
  |
  = note: arbitrary expressions are not allowed in patterns: <https://doc.rust-lang.org/book/ch18-00-patterns.html>

error[E0532]: expected a pattern, found a function call
 --> f889.rs:2:13
  |
2 |     let (x, drop(y)) = (1, 2); //~ ERROR
  |             ^^^^ not a tuple struct or tuple variant
  |
  = note: function calls are not allowed in patterns: <https://doc.rust-lang.org/book/ch18-00-patterns.html>
```

Fix #97200.
2024-10-06 01:44:59 +00:00
Michael Goulet
e8d5eb2a2b Be far more strict about what we consider to be a read of never 2024-10-05 19:10:47 -04:00
Michael Goulet
d2bd018dad Be more thorough in expr_constitutes_read 2024-10-05 19:10:47 -04:00
bors
85e2f55d82 Auto merge of #131293 - DianQK:llvm-19.1.1, r=nikic
Update to LLVM 19.1.1

No known issues are fixed this time.

r? `@rust-lang/wg-llvm`
2024-10-05 22:42:04 +00:00
Michael Goulet
515b93297f Document things a bit more carefully, also account for coercion in check_expr_has_type_or_error 2024-10-05 18:36:47 -04:00
Michael Goulet
73d49f8c69 Fix up tests 2024-10-05 18:36:47 -04:00
Michael Goulet
5193c211ea Do not coerce places if they do not constitute reads 2024-10-05 18:36:47 -04:00
Michael Goulet
6371ef6e96 Evaluating place expr that is never read from does not diverge 2024-10-05 18:36:47 -04:00
onur-ozkan
4f50efd132 update "build/host" symlink comment
Signed-off-by: onur-ozkan <work@onurozkan.dev>
2024-10-05 22:48:55 +03:00
bors
9096f4fafa Auto merge of #131302 - matthiaskrgr:rollup-56kbpzx, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #130555 ( Initial support for riscv32{e|em|emc}_unknown_none_elf)
 - #131280 (Handle `rustc_interface` cases of `rustc::potential_query_instability` lint)
 - #131281 (make Cell unstably const)
 - #131285 (clarify semantics of ConstantIndex MIR projection)
 - #131299 (fix typo in 'lang item with track_caller' message)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-10-05 19:32:38 +00:00
Matthias Krüger
6a85c32f55
Rollup merge of #131299 - RalfJung:lang-item-track-caller, r=compiler-errors
fix typo in 'lang item with track_caller' message

Revival of https://github.com/rust-lang/rust/pull/124912
2024-10-05 19:07:55 +02:00
Matthias Krüger
c45f902723
Rollup merge of #131285 - RalfJung:mir-projection-sem, r=cjgillot
clarify semantics of ConstantIndex MIR projection

This documents what Miri does:
c4ce8c114b/compiler/rustc_const_eval/src/interpret/projection.rs (L272-L275)

I am not sure what exactly the purpose of this `min_length` field is, TBH... but this seems like the most obvious meaning it could have?
2024-10-05 19:07:55 +02:00
Matthias Krüger
388c10b2ac
Rollup merge of #131281 - RalfJung:const-cell, r=Amanieu
make Cell unstably const

Now that we can do interior mutability in `const`, most of the Cell API can be `const fn`. :)  The main exception is `set`, because it drops the old value. So from const context one has to use `replace`, which delegates the responsibility for dropping to the caller.

Tracking issue: https://github.com/rust-lang/rust/issues/131283

`as_array_of_cells` is itself still unstable to I added the const-ness to the feature gate for that function and not to `const_cell`, Cc #88248.

r? libs-api
2024-10-05 19:07:54 +02:00
Matthias Krüger
2e80beb36c
Rollup merge of #131280 - ismailarilik:handle-potential-query-instability-lint-for-rustc-interface, r=cjgillot
Handle `rustc_interface` cases of `rustc::potential_query_instability` lint

This PR removes `#![allow(rustc::potential_query_instability)]` occurrences from [`compiler/rustc_interface/`](https://github.com/rust-lang/rust/blob/master/compiler/rustc_interface/) <s>and converts `FxHash{Map,Set}` types into `FxIndex{Map,Set}` to suppress lint errors</s> (was not necessary for this PR).

A somewhat tracking issue: https://github.com/rust-lang/rust/issues/84447

r? `@compiler-errors`
2024-10-05 19:07:54 +02:00
Matthias Krüger
8e31e98ff9
Rollup merge of #130555 - hegza:rv32e, r=workingjubilee
Initial support for riscv32{e|em|emc}_unknown_none_elf

We have a research prototype of an RV32EMC target and have been successfully running the e, em, emc programs on it. I'm hoping upstreaming this configuration would make the target maintenance slightly easier.

Configuration is based on the respective {i, im, imc} variants. As defined in RISC-V Unprivileged Spec. 20191213, the only change in RVE wrt. RVI is to reduce the number of integer registers to 16 (x0-x15), which also implies

- 2 callee saved registers instead of 12
- 32-bit / 4-byte stack alignment instead of 128 bits / 16 bytes

My initial presumption is that this will not impact how the target is defined for the compiler but only becomes relevant at the runtime level. I am willing to investigate, though.

EDIT: LLVM is now told about the presumed 32-bit stack alignment.

`@Disasm` `@romancardenas`
2024-10-05 19:07:53 +02:00
bors
2b21f90d5e Auto merge of #131221 - XrXr:bump-compiler-builtins, r=tgross35
Update compiler-builtins to 0.1.132

This commit updates compiler-builtins from 0.1.130 to 0.1.132.

PRs in the delta:
 - rust-lang/compiler-builtins#698
 - rust-lang/compiler-builtins#699
 - rust-lang/compiler-builtins#701
 - rust-lang/compiler-builtins#704
 - rust-lang/compiler-builtins#627
 - rust-lang/compiler-builtins#706
2024-10-05 17:07:21 +00:00
Ralf Jung
8faf3722ac fix typo in 'lang item with track_caller' message 2024-10-05 17:12:46 +02:00
bors
e561499e90 Auto merge of #131188 - Kobzol:remove-libstd-so-from-sysroot, r=onur-ozkan
Do not copy libstd dynamic library to sysroot

Since https://github.com/rust-lang/rust/pull/122362, rustc links statically to libstd.[so|dll]. Which means that the libstd.[so|dll] file no longer has to be in the rustc sysroot. However, we are currently still shipping this file, in every new release of Rust, for no reason, it's just wasted bytes.

This PR removes the dynamic library file from the built sysroot.

However, it is not yet performed on Windows, because stage0 incremental tests start failing there (see description of the issue [here](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Failing.20incr.20tests.20on.20Windows.20when.20std.2Edll.20is.20missing/near/474507064)).

This is an extended version of https://github.com/rust-lang/rust/pull/128986.
CC `@Zoxc`
2024-10-05 14:05:05 +00:00
DianQK
70260dbeca
Update to LLVM 19.1.1 2024-10-05 21:10:04 +08:00
Veera
ab8673501c Add a Lint for Pointer to Integer Transmutes in Consts 2024-10-05 12:48:02 +00:00
bors
f559d61888 Auto merge of #131288 - matthiaskrgr:rollup-h0t0v2h, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #130428 (Stabilize `const_slice_split_at_mut` and `const_slice_first_last_chunk`)
 - #131094 (std: replace `LazyBox` with `OnceBox`)
 - #131256 (move f16/f128 const fn under f16/f128 feature gate)
 - #131278 (remove outdated contribution direction)
 - #131286 (Miri subtree update)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-10-05 11:28:48 +00:00
Matthias Krüger
72acacf60f
Rollup merge of #131286 - RalfJung:miri-sync, r=RalfJung
Miri subtree update

r? `@ghost`
2024-10-05 13:15:59 +02:00
Matthias Krüger
1bd61bbeac
Rollup merge of #131278 - onur-ozkan:update-outdated-doc, r=Kobzol
remove outdated contribution direction
2024-10-05 13:15:59 +02:00
Matthias Krüger
cb5bb13ea9
Rollup merge of #131256 - RalfJung:f16-f128-const, r=ibraheemdev
move f16/f128 const fn under f16/f128 feature gate

The `*_const` features were added to work around https://github.com/rust-lang/rust/issues/129656, which should not be needed any more.
2024-10-05 13:15:58 +02:00
Matthias Krüger
92beb42f64
Rollup merge of #131094 - joboet:lazy_once_box, r=ibraheemdev
std: replace `LazyBox` with `OnceBox`

This PR replaces the `LazyBox` wrapper used to allocate the pthread primitives with `OnceBox`, which has a more familiar API mirroring that of `OnceLock`. This cleans up the code in preparation for larger changes like #128184 (from which this PR was split) and allows some neat optimizations, like avoid an acquire-load of the allocation pointer in `Mutex::unlock`, where the initialization of the allocation must have already been observed.

Additionally, I've gotten rid of the TEEOS `Condvar` code, it's just a duplicate of the pthread one anyway and I didn't want to repeat myself.
2024-10-05 13:15:57 +02:00
Matthias Krüger
386a0baecb
Rollup merge of #130428 - ink-feather-org:stabilize-const-split-at-mut, r=RalfJung
Stabilize `const_slice_split_at_mut` and `const_slice_first_last_chunk`

Stabilizes #101804 and the remainder of #111774.

FCP proposed in the tracking issue.

Requires #130403 (or it would need a rustc_allow_const_fn_unstable for it)

Stabilized const API:
```rust
// slice
impl [T] {
    pub const fn split_at_mut(&mut self, mid: usize) -> (&mut [T], &mut [T]);
    pub const fn split_at_mut_unchecked(&mut self, mid: usize) -> (&mut [T], &mut [T]);
    pub const fn split_at_mut_checked(&mut self, mid: usize) -> Option<(&mut [T], &mut [T])>;

    pub const fn first_chunk_mut<const N: usize>(&mut self) -> Option<&mut [T; N]>;
    pub const fn last_chunk_mut<const N: usize>(&mut self) -> Option<&mut [T; N]>;
    pub const fn split_first_chunk_mut<const N: usize>(&mut self) -> Option<(&mut [T; N], &mut [T])>;
    pub const fn split_last_chunk_mut<const N: usize>(&mut self) -> Option<(&mut [T; N], &mut [T])>;
}
```

Closes #101804
Closes #111774

cc `@RalfJung`
2024-10-05 13:15:56 +02:00
Ralf Jung
f0ddc7b472 clarify semantics of ConstantIndex MIR projection 2024-10-05 12:19:14 +02:00
bors
3b418b1485 Auto merge of #3940 - rust-lang:refutable_slice, r=RalfJung
Prefer refutable slice patterns over len check + index op

Just something I noticed while reviewing other PRs

We do it for shim arguments almost everywhere, but when the size is not statically known, we didn't use the helpers as they rely on array ops. But we can avoid a len check followed by several index ops by just using a refutable slice pattern with `let else`.

The pattern is so common, it seems almost worth a dedicated macro
2024-10-05 09:39:25 +00:00
Henri Lunnikivi
6edd0b356f Add platform support doc for rv32e 2024-10-05 12:19:21 +03:00
Henri Lunnikivi
346afc7017 Add UI test to verify invalid loads are not generated 2024-10-05 12:19:20 +03:00
Henri Lunnikivi
fe658e1fe4 Add assembly tests to satisfy 'tidy' 2024-10-05 12:14:35 +03:00
Henri Lunnikivi
66b3d0b36a Work around the stage0 sanity check
Add rv32e-targets to 'stage0 missing targets'. This prevents the error
"no such target exists in the target list".
2024-10-05 12:14:35 +03:00
Henri Lunnikivi
f3037823de doc: platform-support.md: Document port 2024-10-05 12:14:35 +03:00
Henri Lunnikivi
04099b663c Update target fns to latest main 2024-10-05 12:14:35 +03:00
Henri Lunnikivi
7a0bac49c8 Add comment: data_layout 2024-10-05 12:14:35 +03:00