Commit Graph

277026 Commits

Author SHA1 Message Date
Flakebi
cde7e805ad
Cast allocas to default address space
Pointers for variables all need to be in the same address space for
correct compilation. Therefore ensure that even if an `alloca` is
created in a different address space, it is casted to the default
address space before its value is used.

This is necessary for the amdgpu target and others where the default
address space for `alloca`s is not 0.

For example the following code compiles incorrectly when not casting the
address space to the default one:

```rust
fn f(p: *const i8 /* addrspace(0) */) -> *const i8 /* addrspace(0) */ {
    let local = 0i8; /* addrspace(5) */
    let res = if cond { p } else { &raw const local };
    res
}
```

results in

```llvm
    %local = alloca addrspace(5) i8
    %res = alloca addrspace(5) ptr

if:
    ; Store 64-bit flat pointer
    store ptr %p, ptr addrspace(5) %res

else:
    ; Store 32-bit scratch pointer
    store ptr addrspace(5) %local, ptr addrspace(5) %res

ret:
    ; Load and return 64-bit flat pointer
    %res.load = load ptr, ptr addrspace(5) %res
    ret ptr %res.load
```

For amdgpu, `addrspace(0)` are 64-bit pointers, `addrspace(5)` are
32-bit pointers.
The above code may store a 32-bit pointer and read it back as a 64-bit
pointer, which is obviously wrong and cannot work. Instead, we need to
`addrspacecast %local to ptr addrspace(0)`, then we store and load the
correct type.
2025-02-10 21:38:44 +01:00
bors
bf6f8a4d32 Auto merge of - DiuDiu777:box-doc, r=jhpratt
Fix doc for missing Box allocator consistency

### Description:
This PR addresses missing document regarding consistency of `Box::from_raw` and `Box::from_raw_in`.

- [from_raw](https://doc.rust-lang.org/nightly/std/boxed/struct.Box.html#method.from_raw): The document now misses the raw pointer passed to `Box::from_raw` must point to a block of memory allocated by the `Global Allocator` (specified in source code).

- [from_raw_in](https://doc.rust-lang.org/nightly/std/boxed/struct.Box.html#method.from_raw_in): The safety conditions don't include the allocator consistency.

Besides, [Boxed Memory Layout](https://doc.rust-lang.org/nightly/std/boxed/index.html#memory-layout) doesn't explicitly cover the allocator consistency issue.

This change builds upon the improvements made in [PR ](https://github.com/rust-lang/rust/pull/134496).
2025-01-02 06:56:57 +00:00
LemonJ
a5494a8e6c fix doc for missing Box allocator consistency 2025-01-02 11:12:31 +08:00
bors
c528b8c678 Auto merge of - Kobzol:rustc-dev-guide-josh, r=ehuss
Turn rustc-dev-guide into a Josh subtree

Discussed on [Zulip](https://rust-lang.zulipchat.com/#narrow/channel/196385-t-compiler.2Fwg-rustc-dev-guide/topic/a.20move.20to.20main.20repo.20.28rust-lang.2Frust.29).

Accompanying rustc-dev-guide PR: https://github.com/rust-lang/rustc-dev-guide/pull/2183

I didn't create a bootstrap step for rustc-dev-guide yet, because the rustc-dev-guide version that we currently use in this repo doesn't have linkcheck enabled and that fails tests.

The subtree starts with commit [ad93c5f1c49f2aeb45f7a4954017b1e607df9f5e](ad93c5f1c4).

What I did:
```
export DIR=src/doc/rustc-dev-guide

# Remove submodule
git submodule status ${DIR}
git submodule deinit ${DIR}
git rm -r --cached ${DIR}
rm -rf ${DIR}
# Remove rustc-dev-guide from .gitmodules
git commit -m"Removed `${DIR}` submodule"

# Import history with josh
git fetch https://github.com/rust-lang/rustc-dev-guide ad93c5f1c49f2aeb45f7a4954017b1e607df9f5e
josh-filter ':prefix=src/doc/rustc-dev-guide' FETCH_HEAD
git merge --allow-unrelated FILTERED_HEAD

# A few follow-up cleanup commits
```

r? ehuss
2025-01-02 03:05:42 +00:00
bors
504f4f5275 Auto merge of - EnzymeAD:enzyme-cg-llvm, r=oli-obk
Autodiff Upstreaming - rustc_codegen_llvm changes

Now that the autodiff/Enzyme backend is merged, this is an upstream PR for the `rustc_codegen_llvm` changes.
It also includes small changes to three files under `compiler/rustc_ast`, which overlap with my frontend PR (https://github.com/rust-lang/rust/pull/129458).
Here I only include minimal definitions of structs and enums to be able to build this backend code.
The same goes for minimal changes to `compiler/rustc_codegen_ssa`, the majority of changes there will be in another PR, once either this or the frontend gets merged.

We currently have 68 files left to merge, 19 in the frontend PR, 21 (+3 from the frontend) in this PR, and then ~30 in the middle-end.

This PR is large because it includes two of my three large files (~800 loc each). I could also first only upstream enzyme_ffi.rs, but I think people might want to see some use of these bindings in the same PR?

To already highlight the things which reviewers might want to discuss:

1) `enzyme_ffi.rs`: I do have a fallback module to make sure that we don't link rustc against Enzyme when we build rustc without autodiff support.

2) `add_panic_msg_to_global` was a pain to write and I currently can't even use it. Enzyme writes gradients into shadow memory. Pass in one float scalar? We'll allocate and return an extra float telling you how this float affected the output. Pass in a slice of floats? We'll let you allocate the vector and pass in a mutable reference to a float slice, we'll then write the gradient into that slice. It should be at least as large as your original slice, so we check that and panic if not. Currently we panic silently, but I already generate a nicer panic message with this function. I just don't know how to print it to the user. yet. I discussed this with a few rustc devs and the best we could come up with (for now), was to look for mangled panic calls in the IR and pick one, which works surprisingly reliably. If someone knows a good way to clean this up and print the panic message I'm all in, otherwise I can remove the code that writes the nicer panic message and keep the silent panic, since it's enough for soundness. Especially since this PR is already a bit larger.

3) `SanitizeHWAddress`: When differentiating C++, Enzyme can use TBAA to "understand" enums/unions, but for Rust we don't have this information. LLVM might to speculative loads which (without TBAA) confuse Enzyme, so we disable those with this attribute. This attribute is only set during the first opt run before Enzyme differentiates code. We then remove it again once we are done with autodiff and run the opt pipeline a second time. Since enums are everywhere in Rust, support for them is crucial, but if this looks too cursed I can remove these ~100 lines and keep them in my fork for now, we can then discuss them separately to make this PR simpler?

4) Duplicated llvm-opt runs: Differentiating already optimized code (and being able to do additional optimizations on the fly, e.g. for GPU code) is _the_ reason why Enzyme is so fast, so the compile time is acceptable for autodiff users:  https://enzyme.mit.edu/talks/Publications/ (There are also algorithmic issues in Enzyme core which are more serious than running opt twice).

5) I assume that if we merge these minimal cg_ssa changes here already, I also need to fix the other backends (GCC and cliff) to have dummy implementations, correct?

6) *I'm happy to split this PR up further if reviewers have recommendations on how to.*

For the full implementation, see: https://github.com/rust-lang/rust/pull/129175

Tracking:

- https://github.com/rust-lang/rust/issues/124509
2025-01-02 00:20:57 +00:00
bors
62b13a9019 Auto merge of - matthiaskrgr:rollup-5ubuitt, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 -  (handle submodules automatically on `doc` steps)
 -  (Fix typos)
 -  (`ObligationCause` construction tweaks in typeck)
 -  (Remove qualification of `std::cmp::Ordering` in `Ord` doc)
 -  (Fix ICE when opaque captures a duplicated/invalid lifetime)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-01-01 21:37:33 +00:00
Matthias Krüger
92dbfcc2c0
Rollup merge of - compiler-errors:opaque-captures-dupe, r=lqd
Fix ICE when opaque captures a duplicated/invalid lifetime

See description on test.

Fixes 
Fixes 
Fixes 
2025-01-01 22:04:18 +01:00
Matthias Krüger
fac31a1398
Rollup merge of - mgsloan:remove-unnecessary-qualification-in-Ord-trait-docs, r=Noratrieb
Remove qualification of `std::cmp::Ordering` in `Ord` doc
2025-01-01 22:04:17 +01:00
Matthias Krüger
fa5acdc36f
Rollup merge of - compiler-errors:obligation-tweaks, r=lqd
`ObligationCause` construction tweaks in typeck

Mostly just consolidating the way we construct obligations in `FnCtxt`.
2025-01-01 22:04:17 +01:00
Matthias Krüger
92f56fc150
Rollup merge of - ericlehong:fix-typo, r=GuillaumeGomez
Fix typos

This PR fixes typos errors in comments and docs.

Thank you very much.
2025-01-01 22:04:16 +01:00
Matthias Krüger
afdb6270ef
Rollup merge of - onur-ozkan:auto-submodule-handler, r=jieyouxu
handle submodules automatically on `doc` steps

Helps to make `doc` macros less complicated.
2025-01-01 22:04:15 +01:00
Manuel Drehwald
d753cbf779 upstream rustc_codegen_llvm changes for enzyme/autodiff 2025-01-01 21:42:45 +01:00
Michael Goulet
d3c6067275 Fix ICE when opaque captures a duplicated/invalid lifetime 2025-01-01 19:32:51 +00:00
bors
45d11e51bb Auto merge of - kleisauke:avoid-lfs64-emscripten, r=Noratrieb
Avoid use of LFS64 symbols on Emscripten

Since Emscripten uses musl libc internally.

Non-functional change: all LFS64 symbols were aliased to their non-LFS64 counterparts in rust-lang/libc@7c952dceaa.
2025-01-01 18:55:10 +00:00
bors
372442fe5f Auto merge of - Kobzol:tidy-full-check, r=onur-ozkan
Run Python formatting check in tidy on CI

I don't think that there's a reason why we should ignore Python formatting on CI, when we already check Python lints and C++ formatting.

r? `@onur-ozkan`
2025-01-01 16:08:17 +00:00
Jakub Beránek
47e2baa1c9 Remove mention of rustc-dev-guide from toolstate 2025-01-01 17:06:58 +01:00
Jakub Beránek
1820e612d3 Modify rustc-dev-guide triagebot ping list 2025-01-01 17:06:27 +01:00
Jakub Beránek
5c0c0f41f4 Remove obsolete RustcGuide bootstrap step
It was not working for a long time.
2025-01-01 17:06:27 +01:00
Jakub Beránek
59d5328e0a Fix source code path in comment 2025-01-01 17:06:27 +01:00
Jakub Beránek
8decc04e75 Add rustc-dev-guide as a josh subtree 2025-01-01 17:06:11 +01:00
Jakub Beránek
ccee38a930 Removed rustc-dev-guide as a submodule 2025-01-01 17:05:53 +01:00
Kleis Auke Wolthuizen
b6af0c4836 std::fs::DirEntry.metadata(): prefer use of lstat() on Emscripten
Align it with musl, which also prefers using lstat() here.
2025-01-01 13:21:19 +01:00
Kleis Auke Wolthuizen
ef58e8b989 Avoid use of LFS64 symbols on Emscripten
Since Emscripten uses musl libc internally.

Non-functional change: all LFS64 symbols were aliased to their non-LFS64
counterparts in rust-lang/libc@7c952dceaa.
2025-01-01 13:21:19 +01:00
bors
eeeff9a66c Auto merge of - Marcondiro:master, r=jhpratt,programmerjake
char to_digit: avoid unnecessary casts to u64

Hello,
in the `char::to_digit` method there are a few `as u64` casts that are not strictly necessary.
I assume that the reason behind these casts is to avoid possible overflows in the `+ 10` add.

This PR removes the aforementioned casts, avoiding the overflow issue by slightly modifying the ASCII letter to int mapping.

Thanks,
Happy new year.
2025-01-01 10:54:12 +00:00
bors
bc3e3015b6 Auto merge of - Zalathar:rollup-pldy5w6, r=Zalathar
Rollup of 6 pull requests

Successful merges:

 -  (Remove allowing static_mut_refs lint)
 -  (E0277: suggest dereferencing function arguments in more cases)
 -  (add suggestion for wrongly ordered format parameters)
 -  (Some small nits to the borrowck suggestions for mutating a map through index)
 -  (bootstrap: Overhaul and simplify the `tool_check_step!` macro)
 -  (Provide structured suggestion for `impl Default` of type where all fields have defaults)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-01-01 08:10:15 +00:00
Stuart Cook
65cb7c66d0
Rollup merge of - estebank:default-lint-sugg, r=compiler-errors
Provide structured suggestion for `impl Default` of type where all fields have defaults

```
error: `Default` impl doesn't use the declared default field values
  --> $DIR/manual-default-impl-could-be-derived.rs:28:1
   |
LL | / impl Default for B {
LL | |     fn default() -> Self {
LL | |         B {
LL | |             x: s(),
   | |                --- this field has a default value
LL | |             y: 0,
   | |                - this field has a default value
...  |
LL | | }
   | |_^
   |
help: to avoid divergence in behavior between `Struct { .. }` and `<Struct as Default>::default()`, derive the `Default`
   |
LL ~ #[derive(Default)] struct B {
   |
```

Note that above the structured suggestion also includes completely removing the manual `impl`, but the rendering doesn't.
2025-01-01 16:35:32 +11:00
Stuart Cook
cf7d7f5096
Rollup merge of - Zalathar:tool-check-step, r=jieyouxu
bootstrap: Overhaul and simplify the `tool_check_step!` macro

Main changes:

- Pull most of `run` out of the macro and into a regular helper function
- Reduce the number of redundant/unnecessary macro arguments
- Switch to struct-like syntax so that optional arguments are clearer, and so that rustfmt is happy

~~The one “functional” change is that the `-check.stamp` files now get their name from the final path segment, instead of the struct name; in practice this means that they now contain more hyphens in some cases. As far as I'm aware, the exact filename doesn't matter so this should be fine.~~ (that change has been removed from this PR)
2025-01-01 16:35:31 +11:00
Stuart Cook
f91bfd97bf
Rollup merge of - compiler-errors:map-mutate-nits, r=estebank
Some small nits to the borrowck suggestions for mutating a map through index

1. Suggesting users to either use `.insert` or `.get_mut` (which do totally different things) can be a bit of a footgun, so let's make that a bit more nuanced.
2. I find the suggestion of `.get_mut(|val| { *val = whatever; })` to be a bit awkward. I changed this to be an if-let instead.
3. Fix a bug which was suppressing the structured suggestion for some mutations via the index operator on `HashMap`/`BTreeMap`.

r? estebank or reassign
2025-01-01 16:35:31 +11:00
Stuart Cook
1ea1db5b08
Rollup merge of - DavisRayM:129966-format-string-help-message, r=estebank
add suggestion for wrongly ordered format parameters

Add suggestion for wrongly ordered format parameters like `?#`.

Supersedes 
Fix 
2025-01-01 16:35:30 +11:00
Stuart Cook
0204259780
Rollup merge of - dianne:e0277-suggest-deref, r=estebank
E0277: suggest dereferencing function arguments in more cases

This unifies and generalizes some of the logic in `TypeErrCtxt::suggest_dereferences` so that it will suggest dereferencing arguments to function/method calls in order to satisfy trait bounds in more cases.

Previously it would only fire on reference types, and it had two separate cases (one specifically to get through custom `Deref` impls when passing by-reference, and one specifically to catch ). I've based the new checks loosely on what's done for `E0308` in `FnCtxt::suggest_deref_or_ref`: it will suggest dereferences to satisfy trait bounds whenever the referent is `Copy`, is boxed (& so can be moved out of the boxes), or is being passed by reference.

This doesn't make the suggestion fire in contexts other than function arguments or binary operators (which are in a separate case that this doesn't touch), and doesn't make it suggest a combination of `&`-removal and dereferences. Those would require a bit more restructuring, so I figured just doing this would be a decent first step.

Closes 
2025-01-01 16:35:30 +11:00
Stuart Cook
f4db757cb5
Rollup merge of - mu001999-contrib:cleanup/static-mut, r=estebank
Remove allowing static_mut_refs lint
2025-01-01 16:35:29 +11:00
bors
a8953d83cf Auto merge of - rustbot:docs-update, r=ehuss
Update books

## rust-lang/book

13 commits in ad2011d3bcad9f152d034faf7635c22506839d58..04d06dfe541607e6419f3d028c3f9b245f3be4d9
2024-12-20 22:44:11 UTC to 2024-12-16 18:18:21 UTC

- Update section name ()
- Update text to reflect the change from '&str' to 'char' in example ()
- Update figure number in text and file name ()
- Fix chapter number ()
- Delete unused reference ()
- Remove orphaned half-sentence ()
- Fix chapter number ()
- A better phrasing for generic methods. ()
- Fix minor grammatical error ()
- Update appendix-06-translation.md to add another Chinese translation. ()
- Change Korean translation repo to newer ()
- Clarify/improve readability in Ch. 02 discussion of `Result` variants ()
- Ch. 20: conclude §01 with a reference to the Rustonomicon ()

## rust-lang/nomicon

1 commits in 97e84a38c94bf9362b11284c20b2cb4adaa1e868..7ef05b9777c94836bc92f50f23e6e00981521a89
2024-12-30 10:38:10 UTC to 2024-12-30 10:38:10 UTC

- Fix URL fragment to MutexGuard's negative impl of Send ()

## rust-lang/reference

3 commits in 9f41bc11342d46544ae0732caf14ec0bcaf27376..acd6794e712d5e2ef6f5c84fb95688d32a69b816
2024-12-18 23:04:30 +0000 to 2024-12-30 22:12:57 +0000

- Revert "`coverage` attribute" ()
- Document Rust 2024 match ergonomics reservations ()
- Add documentation for `#[diagnostic::do_not_recommend]` ()

## rust-lang/edition-guide

5 commits in bc4ce51e1d4dacb9350a92e95f6159a42de2f8c6..d56e0f3a0656b7702ca466d4b191e16c28262b82
2024-12-18 05:34:59 +0000 to 2024-12-31 20:04:52 +0000

- 2024: Document rustfmt overflow_delimited_expr ()
- 2024: Document rustfmt fixes ()
- Update the transitioning steps ()
- Revert "2024: Assignment operator RHS indentation" ()
- Revert "2024: Add chapter on single-line `where` clauses" ()

## rust-lang/rust-by-example

1 commits in 76406337f4131253443aea0ed7e7f451b464117c..093397535b48ae13ec76bc526b7e6eb8c096a85c
2024-12-18 17:29:56 UTC to 2024-12-18 17:29:56 UTC

- Mention that you're not allowed to partially move Drop types ()

## rust-lang/rustc-dev-guide

18 commits in 7f7ba48f04abc2ad25e52f30b5e2bffa286b019f..ad93c5f1c49f2aeb45f7a4954017b1e607df9f5e
2024-12-30 09:22:22 UTC to 2024-12-17 17:00:38 UTC

- Opt into, rather than out of, linkcheck ()
- Remove stale implementation details of coverage instrumentation ()
- Remove properly tracked config file from .gitignore & add support for skipping of link-checking ()
- Add a couple of linkcheck exceptions: ()
- Add missing link for [Node] ()
- Fix 403 received for HEAD request ()
- Start using mdbook-linkcheck2 ()
- Document `x test --no-capture` ()
- Remove the `-test` suffix from normalize directives ()
- Rework the driver docs ()
- Document `forbid-output` for UI tests ()
- completions: Zsh is now supported ()
- region-outlives propagation ()
- compiletest: Document the `--debugger` flag ()
- document the public ci dashboard ()
- Fix trivial typo of "query-fied" ()
- Fix some typos ()
- Add suggestion for `--keep-stage 0` ()
2025-01-01 05:25:45 +00:00
bors
2085bce154 Auto merge of - tgross35:rollup-s59bx7c, r=tgross35
Rollup of 8 pull requests

Successful merges:

 -  (Add more mailmap entries)
 -  (borrowck diagnostics: make `add_move_error_suggestions` use the HIR rather than `SourceMap`)
 -  (Add GUI test for item info elements color)
 -  (Print how to rebless Python formatting in tidy)
 -  (chore: fix typos)
 -  (add .mailmap entry for myself)
 -  (Revert  single line where clause style guide)
 -  (Revert style guide rhs break)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-01-01 01:34:29 +00:00
Trevor Gross
9472d32842
Rollup merge of - ehuss:revert-style-guide-rhs-break, r=compiler-errors
Revert style guide rhs break

This reverts https://github.com/rust-lang/rust/pull/132369 and https://github.com/rust-lang/rust/pull/119838. The style-guide change for indentation of rhs was not implemented in time for the 2024 style edition.
See tracking issue https://github.com/rust-lang/rust/issues/132380.

cc  for the other style guide change in 2024.

r? ``@compiler-errors``
2024-12-31 18:42:26 -05:00
Trevor Gross
fee79a2900
Rollup merge of - ehuss:revert-single-line-where, r=compiler-errors
Revert  single line where clause style guide

This did not get implemented for the style edition in 2024, so this PR removes it from the documentation.
See tracking issue https://github.com/rust-lang/rust/issues/132381.

This can be added back in the next edition if it gets implemented. I'm a little unclear on what the style team intends for how future changes are documented. For example, the current style-guide documented behavior that rustfmt does not support. I'm not sure who the audience for this document is, or how this is intended to stay in sync with rustfmt. For example, if I read this and assume this is how it is supposed to work, and then rustfmt breaks that, it seems like that is confusing. Similarly, if I'm staying on an older edition, this documentation would be incorrect for my crate.

Perhaps changes like this could be "teed-up" in a PR, but not merged until the edition is stabilized (similar to how the reference works)? And include notes for parts that are edition-specific (so if I am using an older edition, I can see that something is different). In general, I'm a little confused on how this is intended to work.

Reverts:

- https://github.com/rust-lang/rust/pull/119515
2024-12-31 18:42:25 -05:00
Trevor Gross
8a2979c18f
Rollup merge of - Skgland:master, r=Noratrieb
add .mailmap entry for myself

Seeing  in the bors queue I decided to check myself and noticed I was listed four times.
This fixed that by cannonicalizing all entries to use my username and the github no-reply email address, rather than some combination of name or username and different email addresses.
2024-12-31 18:42:25 -05:00
Trevor Gross
ac4546c9fd
Rollup merge of - dxsullivan:fix-typo, r=lqd
chore: fix typos

I hope my typo corrections will help you. Thank you for your work.
2024-12-31 18:42:24 -05:00
Trevor Gross
53b99dee15
Rollup merge of - Kobzol:tidy-bless-log, r=Noratrieb
Print how to rebless Python formatting in tidy

Suggested [here](https://github.com/rust-lang/rust/pull/134964#discussion_r1900124882).

r? ``@Noratrieb``
2024-12-31 18:42:24 -05:00
Trevor Gross
63d5b72482
Rollup merge of - GuillaumeGomez:item-info-colors, r=fmease
Add GUI test for item info elements color

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

r? ``@fmease``
2024-12-31 18:42:23 -05:00
Trevor Gross
3d3d898a2e
Rollup merge of - dianne:fix-move-error-suggestion, r=estebank
borrowck diagnostics: make `add_move_error_suggestions` use the HIR rather than `SourceMap`

This PR aims to fix  by rewriting `add_move_error_suggestions`[^1]. Previously, it manually scanned the source text to find a leading `&`, which isn't always going to produce a correct result (see: that issue). Admittedly, the HIR visitor in this PR introduces a lot of boilerplate, but hopefully the logic at its core isn't too complicated (I go over it in the comments). I also tried a simpler version that didn't use a HIR visitor and suggested adding `ref` always, but the `&ref x` suggestions really didn't look good. As a bonus for the added complexity though, it's now able to produce nice `&`-removing suggestions in more cases.

I tried to do this such that it avoids edition-dependent checks and its suggestions can be applied together with those from the match ergonomics 2024 migration lint. I haven't added tests for that since the details of match ergonomics 2024 are still being sorted out, but I can try if desired once that's finalized.

[^1]: In brief, it fires on patterns where users try to bind by-value in such a way that moves out of a reference to a non-Copy type (including slice references with non-copy elements). The suggestions are to change the binding's mode to be by-reference, either by removing[^2] an enclosing `&`/`&mut` or adding `ref` to the binding.

[^2]: Incidentally, I find the terminology of "consider removing the borrow" a bit confusing for a suggestion to remove a `&` pattern in order to make bindings borrow rather than move. I'm not sure what a good, concise way to explain that would be though, and that should go in a separate PR anyway.
2024-12-31 18:42:23 -05:00
Trevor Gross
ecfb85b3e1
Rollup merge of - Noratrieb:lots-of-mailmapping-round-2, r=Mark-Simulacrum
Add more mailmap entries

If you have been pinged: I'm adding a mailmap entry for you to keep thanks.rust-lang.org working properly.

**I have picked the canonical address mostly arbitrarily. If you want a different one as the canonical address, please tell me here**.

<details>
<summary>more details on the change</summary>

builds on top of , this containing the less obvious changes that add new canonical email addresses instead of just adding new current ones.

The people updated in this commit have contributed under different email
addresses than the ones they have used in rust-lang/team.
https://github.com/rust-lang/thanks/pull/53 will use team data for thanks reviewers, which requires this to be in
sync.
Therefore, I have updated many of the people that I've noticed being
duplicated after the change.

</details>

I'm adding a novel entry for you: ``@apiraino`` ``@KodrAus`` ``@cramertj`` ``@sunfishcode`` ``@Eh2406`` ``@skade`` ``@huonw`` ``@jsha`` ``@shepmaster`` ``@workingjubilee`` ``@rbtcollins``  ``@nrc`` ``@fitzgen`` ``@sophiajt`` ``@tmiasko`` ``@notriddle`` ``@TimNN`` ``@WaffleLapkin``
2024-12-31 18:42:22 -05:00
bors
4e59b1da80 Auto merge of - weihanglo:update-cargo, r=weihanglo
Update cargo

5 commits in c86f4b3a1b153218e6e50861214b0b4b4e695f23..d73d2caf9e41a39daf2a8d6ce60ec80bf354d2a7
2024-12-24 17:49:48 +0000 to 2024-12-31 20:51:21 +0000
- fix(package): warn if symlinks checked out as plain text files ()
- test: track caller for `.crate` file publish verification ()
- test: relax panic output assertion ()
- test: relax `bad_crate_type` to only match error message prefix ()
- refactor(package): split `cargo_package` to modules ()

r? ghost
2024-12-31 22:37:20 +00:00
Weihang Lo
acb38ec197
Update cargo 2024-12-31 17:05:16 -05:00
Michael Sloan
cdd55bfda2 Remove qualification of std::cmp::Ordering in Ord doc 2024-12-31 14:29:03 -07:00
Michael Goulet
1638948890 Obligation tweaks 2024-12-31 20:46:06 +00:00
Eric Huss
40b2cd9dde Update reference, edition-guide 2024-12-31 12:29:50 -08:00
bors
d117b7f211 Auto merge of - clarfonthey:bigint-mul, r=scottmcm
Tidy up bigint multiplication methods

This tidies up the library version of the bigint multiplication methods after the addition of the intrinsics in . It follows [this summary](https://github.com/rust-lang/rust/issues/85532#issuecomment-2403442775) of what's desired for these methods.

Note that, if `2H = N`, then `uH::MAX * uH::MAX + uH::MAX + uH::MAX` is `uN::MAX`, and that we can effectively add two "carry" values without overflowing.

For ease of terminology, the "low-order" or "least significant" or "wrapping" half of multiplication will be called the low part, and the "high-order" or "most significant" or "overflowing" half of multiplication will be called the high part. In all cases, the return convention is `(low, high)` and left unchanged by this PR, to be litigated later.

## API Changes

The original API:

```rust
impl uN {
    // computes self * rhs
    pub const fn widening_mul(self, rhs: uN) -> (uN, uN);

    // computes self * rhs + carry
    pub const fn carrying_mul(self, rhs: uN, carry: uN) -> (uN, uN);
}
```

The added API:

```rust
impl uN {
    // computes self * rhs + carry1 + carry2
    pub const fn carrying2_mul(self, rhs: uN, carry: uN, add: uN) -> (uN, uN);
}
impl iN {
    // note that the low part is unsigned
    pub const fn widening_mul(self, rhs: iN) -> (uN, iN);
    pub const fn carrying_mul(self, rhs: iN, carry: iN) -> (uN, iN);
    pub const fn carrying_mul_add(self, rhs: iN, carry: iN, add: iN) -> (uN, iN);
}
```

Additionally, a naive implementation has been added for `u128` and `i128` since there are no double-wide types for those. Eventually, an intrinsic will be added to make these more efficient, but rather than doing this all at once, the library changes are added first.

## Justifications for API

The unsigned parts are done to ensure consistency with overflowing addition: for a two's complement integer, you want to have unsigned overflow semantics for all parts of the integer except the highest one. This is because overflow for unsigned integers happens on the highest bit (from `MAX` to zero), whereas overflow for signed integers happens on the second highest bit (from `MAX` to `MIN`). Since the sign information only matters in the highest part, we use unsigned overflow for everything but that part.

There is still discussion on the merits of signed bigint *addition* methods, since getting the behaviour right is very subtle, but at least for signed bigint *multiplication*, the sign of the operands does make a difference. So, it feels appropriate that at least until we've nailed down the final API, there should be an option to do signed versions of these methods.

Additionally, while it's unclear whether we need all three versions of bigint multiplication (widening, carrying-1, and carrying-2), since it's possible to have up to two carries without overflow, there should at least be a method to allow that. We could potentially only offer the carry-2 method and expect that adding zero carries afterword will optimise correctly, but again, this can be litigated before stabilisation.

## Note on documentation

While a lot of care was put into the documentation for the `widening_mul` and `carrying_mul` methods on unsigned integers, I have not taken this same care for `carrying_mul_add` or the signed versions. While I have updated the doc tests to be more appropriate, there will likely be many documentation changes done before stabilisation.

## Note on tests

Alongside this change, I've added several tests to ensure that these methods work as expected. These are alongside the codegen tests for the intrinsics.
2024-12-31 18:49:36 +00:00
Esteban Küber
2b2ea9e875 Provide structured suggestion for impl Default of type where all fields have defaults
```
error: `Default` impl doesn't use the declared default field values
  --> $DIR/manual-default-impl-could-be-derived.rs:28:1
   |
LL | / impl Default for B {
LL | |     fn default() -> Self {
LL | |         B {
LL | |             x: s(),
   | |                --- this field has a default value
LL | |             y: 0,
   | |                - this field has a default value
...  |
LL | | }
   | |_^
   |
help: to avoid divergence in behavior between `Struct { .. }` and `<Struct as Default>::default()`, derive the `Default`
   |
LL ~ #[derive(Default)] struct B {
   |
```

Note that above the structured suggestion also includes completely removing the manual `impl`, but the rendering doesn't.
2024-12-31 18:06:01 +00:00
Eric Huss
7a46c7b112 Revert "Rollup merge of - joshtriplett:style-guide-binop-indent, r=compiler-errors"
This reverts commit 36287830a2, reversing
changes made to 31026b7fe3.
2024-12-31 08:50:28 -08:00
Eric Huss
a6ba04ae6a Revert "Rollup merge of - joshtriplett:style-guide-binop-heuristic-assignment-only, r=calebcartwright"
This reverts commit 348d28052b, reversing
changes made to 526c67f37b.
2024-12-31 08:50:04 -08:00