Commit Graph

266548 Commits

Author SHA1 Message Date
David Wood
207bc77e15
codegen_ssa: consolidate tied feature checking
`rustc_codegen_llvm` and `rustc_codegen_gcc` duplicated logic for
checking if tied target features were partially enabled. This commit
consolidates these checks into `rustc_codegen_ssa` in the
`codegen_fn_attrs` query, which also is run pre-monomorphisation for
each function, which ensures that this check is run for unused functions,
as would be expected.
2024-09-24 15:48:49 +01:00
David Wood
6edd86d58e
tests: add test for #105111
Enabling a tied feature should not enable the other feature
automatically. This was fixed by something in #128796, probably #128221
or #128679.
2024-09-24 15:42:15 +01:00
bors
11e760b7f4 Auto merge of #130738 - bjoernager:const-make-ascii, r=jhpratt
Mark `make_ascii_uppercase` and `make_ascii_lowercase` in `[u8]` and `str` as const.

Relevant tracking issue: #130698

This PR extends #130697 and #130713 to the similar methods in byte slices (`[u8]`) and string slices (`str`).

For the `str` methods, this simply requires adding the `const` specifier to the function signatures. The `[u8]` methods, however, require (at least a temporary) reimplementation due to the use of iterators and `for` loops.
2024-09-24 08:52:12 +00:00
Gabriel Bjørnager Jensen
e723fe1713 Mark and implement 'make_ascii_uppercase' and 'make_ascii_lowercase' in '[u8]' and 'str' as const; 2024-09-24 08:50:40 +02:00
bors
4cadeda932 Auto merge of #130768 - compiler-errors:rollup-8ncjy55, r=compiler-errors
Rollup of 7 pull requests

Successful merges:

 - #129545 (rustdoc: redesign toolbar and disclosure widgets)
 - #130618 (Skip query in get_parent_item when possible.)
 - #130727 (Check vtable projections for validity in miri)
 - #130750 (Add new Tier-3 target: `loongarch64-unknown-linux-ohos`)
 - #130758 (Revert "Add recursion limit to FFI safety lint")
 - #130759 (Update books)
 - #130762 (stabilize const_intrinsic_copy)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-09-24 06:02:43 +00:00
Michael Goulet
64aa4c6e25
Rollup merge of #130762 - RalfJung:const_intrinsic_copy, r=dtolnay
stabilize const_intrinsic_copy

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

This stabilizes
```rust
mod ptr {
    pub const unsafe fn copy_nonoverlapping<T>(src: *const T, dst: *mut T, count: usize);
    pub const unsafe fn copy<T>(src: *const T, dst: *mut T, count: usize);
}

impl *const T {
    pub const unsafe fn copy_to(self, dest: *mut T, count: usize);
    pub const unsafe fn copy_to_nonoverlapping(self, dest: *mut T, count: usize);
}

impl *mut T {
    pub const unsafe fn copy_to(self, dest: *mut T, count: usize);
    pub const unsafe fn copy_to_nonoverlapping(self, dest: *mut T, count: usize);

    pub const unsafe fn copy_from(self, src: *const T, count: usize);
    pub const unsafe fn copy_from_nonoverlapping(self, src: *const T, count: usize);
}

impl <T> NonNull<T> {
    pub const unsafe fn copy_to(self, dest: NonNull<T>, count: usize);
    pub const unsafe fn copy_to_nonoverlapping(self, dest: NonNull<T>, count: usize);

    pub const unsafe fn copy_from(self, src: NonNull<T>, count: usize);
    pub const unsafe fn copy_from_nonoverlapping(self, src: NonNull<T>, count: usize);
}
```
In particular, this reverts https://github.com/rust-lang/rust/pull/117905, which reverted https://github.com/rust-lang/rust/pull/97276.

The `NonNull` methods are not listed in the tracking issue, they were added to this feature gate in https://github.com/rust-lang/rust/pull/124498. The existing [FCP](https://github.com/rust-lang/rust/issues/80697#issuecomment-1022585839) does not cover them. They are however entirely identical to the `*mut` methods and already stable outside `const`. ``@rust-lang/libs-api`` please let me know if FCP will be required for the `NonNull` methods.
2024-09-23 23:49:14 -04:00
Michael Goulet
fdd4d644aa
Rollup merge of #130759 - rustbot:docs-update, r=ehuss
Update books

## rust-lang/book

5 commits in e7d217be2a75ef1753f0988d6ccaba4d7e376259..99cf75a5414fa8adbe3974bd0836661ca901708f
2024-09-23 16:18:39 UTC to 2024-09-11 18:38:03 UTC

- translations: remove broken link (rust-lang/book#4036)
- Update build instructions: include mdbook plugins (rust-lang/book#4032)
- Add `cargo init` usage suggestion to 1.3 (rust-lang/book#4025)
- Use immutable borrow of `TcpStream` when creating `BufReader` (rust-lang/book#4024)
- Upgrade to Rust 1.81 (rust-lang/book#4031)

## rust-lang/edition-guide

1 commits in b3ca7ade0f87d7e3fb538776defc5b2cc4188172..c7ebae25cb4801a31b6f05353f6d85bfa6feedd1
2024-09-22 08:47:02 UTC to 2024-09-22 08:47:02 UTC

- Update static_mut_refs now that it is a lint (rust-lang/edition-guide#322)

## rust-lang/reference

10 commits in 687faf9958c52116d003b41dfd29cc1cf44f5311..24fb2687cdbc54fa18ae4acf5d879cfceca77b2c
2024-09-22 09:07:12 UTC to 2024-09-10 19:24:17 UTC

- do not talk about the 'address of a constant' (rust-lang/reference#1624)
- Add spec identifier syntax to interior-mutability.md (rust-lang/reference#1585)
- Add spec identifier syntax to input-format.md (rust-lang/reference#1584)
- Document limitations on block doc comments (rust-lang/reference#1602)
- Places based on misaligned pointers: also mention 'static's as a possible base for place projections (rust-lang/reference#1606)
- type-layout: mention that call ABI compatibility is a separate concern (rust-lang/reference#1608)
- stabilize `const_extern_fn` (rust-lang/reference#1596)
- const_eval: update for const_mut_refs and const_refs_to_cell stabilization (rust-lang/reference#1590)
- fix: unclosed tag `sup` (rust-lang/reference#1612)
- Fix improper documentation on casting non_exhaustive enums (rust-lang/reference#1607)

## rust-lang/rustc-dev-guide

13 commits in 0ed9229f5b6f7824b333beabd7e3d5ba4b9bd971..555f3de2fa0d61c4294b74d245f1cbad6fcbf589
2024-09-23 12:51:33 UTC to 2024-09-10 07:32:10 UTC

- chore: add missing `.` (rust-lang/rustc-dev-guide#2074)
- Add remark on required free disk space (rust-lang/rustc-dev-guide#2073)
- fix broken links (rust-lang/rustc-dev-guide#2063)
- Add advice about submitting potentially hard-to-review PRs (rust-lang/rustc-dev-guide#2036)
- Edit a sentence for clarity (rust-lang/rustc-dev-guide#2071)
- Emphasize how to run a single tool test (rust-lang/rustc-dev-guide#2070)
- Remove chalk is owned by WG-traits (rust-lang/rustc-dev-guide#2068)
- Fix conditions lowering text for enums with no fields (rust-lang/rustc-dev-guide#2066)
- update proof tree chapter (rust-lang/rustc-dev-guide#2054)
- Add docs for JS tests (rust-lang/rustc-dev-guide#2048)
- Reflect `x.py test`'s `--rustc-args` option being renamed to `--compiletest-rustc-args` (rust-lang/rustc-dev-guide#2062)
- we standardized on this more reliable command (rust-lang/rustc-dev-guide#2061)
- Fix Typo and Remove Outdated Line About C Variadics (rust-lang/rustc-dev-guide#2060)
2024-09-23 23:49:13 -04:00
Michael Goulet
fa1bd9b06a
Rollup merge of #130758 - compiler-errors:ctype-recursion-limit, r=jieyouxu
Revert "Add recursion limit to FFI safety lint"

It's not necessarily clear if warning when we hit the recursion limit is the right thing to do, first of all.

**More importantly**, this PR was implemented incorrectly in the first place; it was not decrementing the recursion limit when stepping out of a type, so it would trigger when a ctype has more than RECURSION_LIMIT fields *anywhere* in the type's set of recursively reachable fields.

Reverts #130598
Reopens #130310
Fixes #130757
2024-09-23 23:49:13 -04:00
Michael Goulet
4d0b44ab5b
Rollup merge of #130750 - heiher:loong-linux-ohos-tier3, r=jieyouxu
Add new Tier-3 target: `loongarch64-unknown-linux-ohos`

MCP: https://github.com/rust-lang/compiler-team/issues/784
2024-09-23 23:49:12 -04:00
Michael Goulet
ec1ccff8ce
Rollup merge of #130727 - compiler-errors:objects, r=RalfJung
Check vtable projections for validity in miri

Currently, miri does not catch when we transmute `dyn Trait<Assoc = A>` to `dyn Trait<Assoc = B>`. This PR implements such a check, and fixes https://github.com/rust-lang/miri/issues/3905.

To do this, we modify `GlobalAlloc::VTable` to contain the *whole* list of `PolyExistentialPredicate`, and then modify `check_vtable_for_type` to validate the `PolyExistentialProjection`s of the vtable, along with the principal trait that was already being validated.

cc ``@RalfJung``
r? ``@lcnr`` or types

I also tweaked the diagnostics a bit.

---

**Open question:** We don't validate the auto traits. You can transmute `dyn Foo` into `dyn Foo + Send`. Should we check that? We currently have a test that *exercises* this as not being UB:

6c6d210089/src/tools/miri/tests/pass/dyn-upcast.rs (L14-L20)

I'm not actually sure if we ever decided that's actually UB or not 🤔

We could perhaps still check that the underlying type of the object (i.e. the concrete type that was unsized) implements the auto traits, to catch UB like:

```rust
fn main() {
    let x: &dyn Trait = &std::ptr::null_mut::<()>();
    let _: &(dyn Trait + Send) = std::mem::transmute(x);
    //~^ this vtable is not allocated for a type that is `Send`!
}
```
2024-09-23 23:49:12 -04:00
Michael Goulet
c0f1a69229
Rollup merge of #130618 - m-ou-se:skip-query, r=compiler-errors
Skip query in get_parent_item when possible.

For HirIds with a non-zero item local id, `self.parent_owner_iter(hir_id).next()` just returns the same HirId with the item local id set to 0, but also does a query to retrieve the Node which is ignored here, which seems wasteful.
2024-09-23 23:49:11 -04:00
Michael Goulet
0a0ea28f26
Rollup merge of #129545 - notriddle:notriddle/toolbar-v2, r=GuillaumeGomez
rustdoc: redesign toolbar and disclosure widgets

Fixes #77899
Fixes #90310

## Preview

| before | after
| ------ | -----
| ![image](https://github.com/user-attachments/assets/ebeec185-3a72-481d-921e-a9a885f348d9) | ![image](https://github.com/user-attachments/assets/08735a65-99d1-4523-ab77-ddb164c0a5db)
| ![image](https://github.com/user-attachments/assets/ae8e0f24-49cb-445d-b9bd-cec9c57b94e7) | ![image](https://github.com/user-attachments/assets/ba484f94-b031-41fc-b8a8-6cd81be8fb6b)
| ![image](https://github.com/user-attachments/assets/8c2cc041-a138-4950-a12e-3d529c8a5339) | ![image](https://github.com/user-attachments/assets/e7f010bd-19e2-4711-85bf-3fd00c3e5647)
| ![image](https://github.com/user-attachments/assets/e2b63785-971c-489e-b069-eb85f6a30620) | ![image](https://github.com/user-attachments/assets/b65eea16-d6a3-4aa3-8a27-6ded74009010)
| ![image](https://github.com/user-attachments/assets/1c7b0901-a61a-4325-9d01-9d8b14b476aa) | ![image](https://github.com/user-attachments/assets/d4a485db-d9f1-4a62-94bc-a3d125ea6dc1)
| N/A | ![image](https://github.com/user-attachments/assets/7add0a2a-7fd7-483d-87ee-51ee45a2fe5d)
| ![image](https://github.com/user-attachments/assets/334f50bc-9f8d-42d9-a7df-95058f7cdfd5) | ![image](https://github.com/user-attachments/assets/451fcc22-b034-453c-ae4b-b948fd6bd779)
| ![image](https://github.com/user-attachments/assets/132f720c-802a-466d-bd55-c7a4750acdc3) | ![image](https://github.com/user-attachments/assets/177b7921-06c5-467d-87d3-9cdf88c4e50b)

https://notriddle.com/rustdoc-html-demo-12/toolbar-v2/std/index.html

## Description

This adds labels to the icons and moves them away from the search box.

These changes are made together, because they work together, but are based on several complaints:

* The [+/-] thing are a Reddit-ism. They don't look like buttons, but look like syntax <https://rust-lang.zulipchat.com/#narrow/stream/266220-t-rustdoc/topic/More.20visual.20difference.20for.20the.20.2B.2F-.20.20Icons>, <https://github.com/rust-lang/rust/issues/59851> (some of these are laundry lists with more suggestions, but they all mention [+/-] looking wrong)

* The settings, help, and summary buttons are also too hard to recognize <https://lwn.net/Articles/987070/>, <https://github.com/rust-lang/rust/issues/90310>, <https://github.com/rust-lang/rust/issues/14475#issuecomment-274241997>, <https://internals.rust-lang.org/t/improve-rustdoc-design/12758> ("Not all functionality is self-explanatory, for example the [+] button in the top right corner, the theme picker or the settings button.")

The toggle-all and toggle-individual buttons both need done at once, since we want them to look like they go together. This changes them from both being [+/-] to both being arrows.

CC <https://github.com/rust-lang/rust/pull/113074#issuecomment-1677469680> and ``@jsha`` regarding the use of triangles for disclosure, which is what everyone wanted, but was pending a good toggle-all button. This PR adds a toggle-all button that should work.

Settings and Help are also migrated, so that the whole group can benefit from being described using actual words.

The breadcrumbs also get redesigned, so that they use less space, by shrinking the parent module path parts. This is done at the same time as the toolbar redesign because it's, effectively, moving space from the toolbar to the breadcrumbs.
This is aimed at avoiding any line wrapping at desktop sizes.

## Prior art

This style of toolbar, with explicit labels on the buttons, used to be more popular. It's not very common in web browsers nowadays, and for truly universal icons like ⬅️ I can understand why, but words are great when icons fail.

![image](https://github.com/user-attachments/assets/9a4a0498-232d-4d60-87b9-f601f4515254)
2024-09-23 23:49:11 -04:00
bors
f5cd2c5888 Auto merge of #127117 - Urgau:non_local_def-syntactic, r=BoxyUwU
Rework `non_local_definitions` lint to only use a syntactic heuristic

This PR reworks the `non_local_definitions` lint to only use a syntactic heuristic, i.e. not use a type-system logic for whenever an `impl` is local or not.

Instead the new logic wanted by T-lang in https://github.com/rust-lang/rust/issues/126768#issuecomment-2192634762, which is to consider every paths in `Self` and `Trait` and to no longer use the type-system inference trick.

`@rustbot` labels +L-non_local_definitions
Fixes #126768
2024-09-24 03:43:01 +00:00
Michael Goulet
702a644b74 Check vtable projections for validity in miri 2024-09-23 19:38:26 -04:00
bors
35daf8b8aa Auto merge of #130620 - onur-ozkan:update-make-prepare, r=Kobzol
remove workaround for make prepare and use dry-run build instead

Removes an annoying hard-coded logic.

try-job: x86_64-msvc
2024-09-23 22:19:24 +00:00
Ralf Jung
2787179f53 stabilize const_intrinsic_copy 2024-09-23 22:12:54 +02:00
bors
7042c269c1 Auto merge of #125645 - RalfJung:unclear_local_imports, r=nnethercote
add unqualified_local_imports lint

This lint helps deal with https://github.com/rust-lang/rustfmt/issues/4709 by having the compiler detect imports of local items that are not syntactically distinguishable from imports from other cates. Making them  syntactically distinguishable ensures rustfmt can consistently apply the desired import grouping.
2024-09-23 19:27:33 +00:00
rustbot
c3f57f3c50 Update books 2024-09-23 13:01:06 -04:00
Michael Goulet
9050b33745 Add a test 2024-09-23 12:55:56 -04:00
onur-ozkan
f6d3cd7345 invoke cmake check with run_always
Signed-off-by: onur-ozkan <work@onurozkan.dev>
2024-09-23 19:47:12 +03:00
Michael Goulet
de66639bbc Revert "Add recursion limit to FFI safety lint"
This reverts commit 716044751b.
2024-09-23 12:43:44 -04:00
bors
9d6039ccae Auto merge of #130755 - workingjubilee:rollup-zpja9b3, r=workingjubilee
Rollup of 7 pull requests

Successful merges:

 - #129201 (std: implement the `random` feature (alternative version))
 - #130536 (bootstrap: Set the dylib path when building books with rustdoc)
 - #130551 (Fix `break_last_token`.)
 - #130657 (Remove x86_64-fuchsia and aarch64-fuchsia target aliases)
 - #130721 (Add more test cases for block-no-opening-brace)
 - #130736 (Add rustfmt 2024 reformatting to git blame ignore)
 - #130746 (readd `@tgross35` and `@joboet` to the review rotation)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-09-23 16:40:39 +00:00
Michael Howell
cc3ffe4c91 Tweak breadcrumbs list 2024-09-23 09:21:39 -07:00
Michael Howell
e31a719cce Fix up standard library intro 2024-09-23 09:21:39 -07:00
Xiaotian Wu
9ab704612a Add new Tier-3 target: loongarch64-unknown-linux-ohos
MCP: https://github.com/rust-lang/compiler-team/issues/784

Co-authored-by: WANG Rui <wangrui@loongson.cn>
2024-09-23 23:06:14 +08:00
Jubilee
c7abc85181
Rollup merge of #130746 - joboet:hello_again, r=joboet
readd @tgross35 and @joboet to the review rotation

We're both (nearly) back from vacation.

CC ``@tgross35``
2024-09-23 07:54:46 -07:00
Jubilee
7ea391956f
Rollup merge of #130736 - Kobzol:rustfmt-2024-git-blame, r=compiler-errors
Add rustfmt 2024 reformatting to git blame ignore

https://github.com/rust-lang/rust/pull/130724 essentially reformatted the world, so we should add it to the git blame ignore list.

Tested with `git blame compiler/rustc_abi/src/lib.rs -L1137,1146`. I first thought that I have to ignore the merge commit, but it seems like the actual commit that did the reformatting should be ignored instead.

r? ``@compiler-errors``
2024-09-23 07:54:46 -07:00
Jubilee
6feefdb513
Rollup merge of #130721 - GrigorenkoPV:block-no-opening-brace, r=jieyouxu
Add more test cases for block-no-opening-brace

Also add FIXME's for #80931 & #78168
2024-09-23 07:54:45 -07:00
Jubilee
021ae2c7fd
Rollup merge of #130657 - arttet:fix/fuchsia, r=jieyouxu
Remove x86_64-fuchsia and aarch64-fuchsia target aliases

Closes #106649.
2024-09-23 07:54:45 -07:00
Jubilee
515bdcda01
Rollup merge of #130551 - nnethercote:fix-break-last-token, r=petrochenkov
Fix `break_last_token`.

It currently doesn't handle the three-char tokens `>>=` and `<<=` correctly. These can be broken twice, resulting in three individual tokens. This is a latent bug that currently doesn't cause any problems, but does cause problems for #124141, because that PR increases the usage of lazy token streams.

r? `@petrochenkov`
2024-09-23 07:54:44 -07:00
Jubilee
c58e3cb1e2
Rollup merge of #130536 - cuviper:rustbook-dylib-path, r=Mark-Simulacrum
bootstrap: Set the dylib path when building books with rustdoc

The library path is needed when the toolchain has been configured with
`[rust] rpath = false`. Otherwise, building the reference book will get
an error when it tries to run rustdoc, like:

    rustdoc: error while loading shared libraries: librustc_driver-2ec457c3b8826b72.so
2024-09-23 07:54:43 -07:00
Jubilee
1d369312e4
Rollup merge of #129201 - joboet:random_faster_sources, r=joshtriplett
std: implement the `random` feature (alternative version)

Implements the ACP rust-lang/libs-team#393.

This PR is an alternative version of #129120 that replaces `getentropy` with `CCRandomGenerateBytes` (on macOS) and `arc4random_buf` (other BSDs), since that function is not suited for generating large amounts of data and should only be used to seed other CPRNGs. `CCRandomGenerateBytes`/`arc4random_buf` on the other hand is (on modern platforms) just as secure and uses its own, very strong CPRNG (ChaCha20 on the BSDs, AES on macOS) periodically seeded with `getentropy`.
2024-09-23 07:54:43 -07:00
bors
648d024a78 Auto merge of #130716 - bjorn3:sync_cg_clif-2024-09-22, r=bjorn3
Subtree sync for rustc_codegen_cranelift

The main highlight this time is a fix for a miscompilation of RwLock on macOS. Also a Cranelift update and a couple of extra vendor intrinsics on arm64.

r? `@ghost`

`@rustbot` label +A-codegen +A-cranelift +T-compiler
2024-09-23 13:39:07 +00:00
joboet
b0c2c9372a
readd @tgross35 and @joboet to the review rotation 2024-09-23 13:37:52 +02:00
bjorn3
6b042f5b5d Rustfmt 2024-09-23 11:28:15 +00:00
bjorn3
9456ff13c9 Revert change to apply_patches to fix panic 2024-09-23 11:20:56 +00:00
bjorn3
b40fe1ee28 Merge commit '6d35b4c9a04580366fd800692a5b5db79d766530' into sync_cg_clif-2024-09-22 2024-09-23 11:20:46 +00:00
bjorn3
6d35b4c9a0 Rustup to rustc 1.83.0-nightly (6c6d21008 2024-09-22) 2024-09-23 11:11:08 +00:00
bjorn3
faeede3881 Merge branch 'sync_from_rust' 2024-09-23 11:04:43 +00:00
bors
c22a4215a0 Auto merge of #130641 - cuviper:llvm-19.1.0, r=nikic
Update to LLVM 19.1.0

This is a branch rebase of the submodule, now that LLVM 19.1.0 is final.
Our *only* extra patch right now is the one we're carrying for SGX unwind.
2024-09-23 10:54:29 +00:00
Ralf Jung
1eb51e717e fix unqualified_local_imports in rustc_const_eval 2024-09-23 11:57:32 +02:00
Ralf Jung
4c43757e43 fix unqualified_local_imports in Miri 2024-09-23 11:57:32 +02:00
Ralf Jung
584c5cf7ae add unqualified_local_imports lint 2024-09-23 11:57:28 +02:00
Mara Bos
c0c569f99d
Update compiler/rustc_middle/src/hir/map/mod.rs
Co-authored-by: Michael Goulet <michael@errs.io>
2024-09-23 09:36:17 +00:00
joboet
3ff09a05c8
update miri test 2024-09-23 10:36:17 +02:00
joboet
e94dd9b712
random: add tracking issue, address other comments 2024-09-23 10:36:16 +02:00
joboet
a21ff017f4
miri: shim CCRandomGenerateBytes 2024-09-23 10:36:16 +02:00
joboet
b9d47cfa9b
std: switch to faster random sources on macOS and most BSDs 2024-09-23 10:36:16 +02:00
joboet
5c1c725724
std: implement the random feature
Implements the ACP https://github.com/rust-lang/libs-team/issues/393.
2024-09-23 10:29:51 +02:00
Jakub Beránek
f7735f99cf
Add rustfmt 2024 reformatting to git blame ignore 2024-09-23 10:02:04 +02:00