Commit Graph

244244 Commits

Author SHA1 Message Date
Rowan S-L
30b8b44990 use /usr/bin/env bash instead of /bin/bash 2024-01-21 12:43:09 -05:00
bors
ef71f1047e Auto merge of #120198 - lnicola:sync-from-ra, r=lnicola
Subtree update of `rust-analyzer`

r? `@ghost`
2024-01-21 16:14:51 +00:00
trevyn
b58a8a98cd maybe_lint_impl_trait: separate is_downgradable from is_object_safe 2024-01-21 20:04:39 +04:00
Noritada Kobayashi
ff02662d44 Correct the anchor of an URL in an error message 2024-01-22 01:02:20 +09:00
Markus Reiter
0e3035b512
Manually implement derived NonZero traits. 2024-01-21 16:28:50 +01:00
onur-ozkan
1afd216f76 use u64 to represent file size
This increases the maximum supported file size (previously limited to 4GB)
and avoids potential issues with u32 to u64 conversions, which are no longer
needed.

Signed-off-by: onur-ozkan <work@onurozkan.dev>
2024-01-21 18:16:22 +03:00
Laurențiu Nicola
595b4c3c32 Merge commit 'a9116523604c998e7781f60d3b5a6f586e0414a9' into sync-from-ra 2024-01-21 16:53:06 +02:00
bors
d9d89fd53d Auto merge of #119807 - Emilgardis:track_caller_from_impl_into, r=Nilstrieb
Add `#[track_caller]` to the "From implies Into" impl

This pr implements what was mentioned in https://github.com/rust-lang/rust/issues/77474#issuecomment-1074480790

This follows from my URLO https://users.rust-lang.org/t/104497

```rust
#![allow(warnings)]
fn main() {
    // Gives a good location
    let _: Result<(), Loc> = dbg!(Err::<(), _>(()).map_err(|e| e.into()));

    // still doesn't work, gives location of `FnOnce::call_once()`
    let _: Result<(), Loc> = dbg!(Err::<(), _>(()).map_err(Into::into));
}

#[derive(Debug)]
pub struct Loc {
    pub l: &'static std::panic::Location<'static>,
}

impl From<()> for Loc {
    #[track_caller]
    fn from(_: ()) -> Self {
        Loc {
            l: std::panic::Location::caller(),
        }
    }
}
```
2024-01-21 14:17:25 +00:00
Jaro Fietz
98f59817c2
Rename function in weird-exprs.rs for clarity 2024-01-21 13:47:45 +01:00
bohan
9c3091e9cf exclude unexported macro bindings from extern crate 2024-01-21 20:24:40 +08:00
Zalathar
6d7e80c5bc Add #[coverage(off)] to closures introduced by #[test]/#[bench] 2024-01-21 23:17:00 +11:00
Zalathar
bdfc64ac98 coverage: Add a test that uses #[bench] 2024-01-21 23:17:00 +11:00
Matthias Krüger
3eb7fe32a1
Rollup merge of #120180 - Zalathar:vec-split-off-alternatives, r=dtolnay
Document some alternatives to `Vec::split_off`

One of the discussion points that came up in #119917 is that some people use `Vec::split_off` in cases where they probably shouldn't, because the alternatives (like `mem::take`) are hard to discover.

This PR adds some suggestions to the documentation of `split_off` that should point people towards alternatives that might be more appropriate for their use-case.

I've deliberately tried to keep these changes as simple and uncontroversial as possible, so that they don't depend on how the team decides to handle the concerns raised in #119917. That's why I haven't touched the existing documentation for `split_off`, and haven't added links to `split_off` to the documentation of other methods.
2024-01-21 12:28:55 +01:00
Matthias Krüger
1229d4cde3
Rollup merge of #120174 - Mark-Simulacrum:link-libs-policy, r=dtolnay
Warn users about limited review for tier 2 and 3 code

Needs https://github.com/rust-lang/std-dev-guide/pull/61
2024-01-21 12:28:55 +01:00
Matthias Krüger
ac713695f3
Rollup merge of #120167 - dtolnay:bootstrap, r=clubby789
Capture the rationale for `-Zallow-features=` in bootstrap.py

Based on the discussion in https://github.com/rust-lang/rust/pull/120096.
2024-01-21 12:28:54 +01:00
Matthias Krüger
e59a6fe63f
Rollup merge of #120158 - jubnzv:120130-mirdf-exports, r=nnethercote
`rustc_mir_dataflow`: Restore removed exports

Added back previously available exports:

* `Forward`/`Backward`: used when implementing `AnalysisDomain`
* `Engine`: used in user's code to solve the dataflow problem
* `SwitchIntEdgeEffects`: used when implementing functions of the `Analysis` trait
* `graphviz`: potentially useful for debugging purposes

Closes #120130
2024-01-21 12:28:53 +01:00
Matthias Krüger
4a941d384d
Rollup merge of #120145 - the8472:fix-inplace-dest-drop, r=cuviper
fix: Drop guard was deallocating with the incorrect size

InPlaceDstBufDrop holds onto the allocation before the shrinking happens which means it must deallocate the destination elements but the source allocation.

Thanks `@cuviper` for spotting this.
2024-01-21 12:28:53 +01:00
Matthias Krüger
a72d6c114b
Rollup merge of #120128 - oli-obk:smir_internal_lift, r=celinval
Make stable_mir::with_tables sound

See the first commit for the actual soundness fix. The rest is just fallout from that and is entirely safe code. Includes most of #120120

The major difference to #120120 is that we don't need an unsafe trait, as we can now rely on the type system (the only unsafe part, and the actual source of the unsoundness was in `with_tables`)

r? `@celinval`
2024-01-21 12:28:52 +01:00
Matthias Krüger
092d62734a
Rollup merge of #120045 - scottmcm:unhide-repeat-n, r=Mark-Simulacrum
Un-hide `iter::repeat_n`

ACP accepted in https://github.com/rust-lang/libs-team/issues/120#issuecomment-1894144403
2024-01-21 12:28:52 +01:00
Matthias Krüger
7119ca15ff
Rollup merge of #120005 - atouchet:rd3, r=Mark-Simulacrum
Update Readme

A couple minor formatting fixes and re-add missing "Installing from Source" section to the table of contents.
2024-01-21 12:28:51 +01:00
bors
fa404339c9 Auto merge of #85528 - the8472:iter-markers, r=dtolnay
Implement iterator specialization traits on more adapters

This adds

* `TrustedLen` to `Skip` and `StepBy`
* `TrustedRandomAccess` to `Skip`
* `InPlaceIterable` and `SourceIter` to  `Copied` and `Cloned`

The first two might improve performance in the compiler itself since `skip` is used in several places. Constellations that would exercise the last point are probably rare since it would require an owning iterator that has references as Items somewhere in its iterator pipeline.

Improvements for `Skip`:

```
# old
test iter::bench_skip_trusted_random_access                     ... bench:       8,335 ns/iter (+/- 90)

# new
test iter::bench_skip_trusted_random_access                     ... bench:       2,753 ns/iter (+/- 27)
```
2024-01-21 11:17:46 +00:00
HTGAzureX1212
1821bfaa09
chore: suggest wrapping in an assert!() instead
This shortens the `#[must_use]` diagnostics displayed, in light of the [review comment](https://github.com/rust-lang/rust/pull/62431/files#r300819839) on when this was originally added.
2024-01-21 18:39:09 +08:00
bors
cb25c5bc3d Auto merge of #120187 - Nadrieril:rollup-xfwrb0c, r=Nadrieril
Rollup of 8 pull requests

Successful merges:

 - #116090 (Implement strict integer operations that panic on overflow)
 - #118811 (Use `bool` instead of `PartiolOrd` as return value of the comparison closure in `{slice,Iteraotr}::is_sorted_by`)
 - #119081 (Add Ipv6Addr::is_ipv4_mapped)
 - #119461 (Use an interpreter in MIR jump threading)
 - #119996 (Move OS String implementation into `sys`)
 - #120015 (coverage: Format all coverage tests with `rustfmt`)
 - #120027 (pattern_analysis: Remove `Ty: Copy` bound)
 - #120084 (fix(rust-analyzer): use new pkgid spec to compare)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-01-21 09:18:48 +00:00
Nadrieril
01669d27d2
Rollup merge of #120084 - weihanglo:pkgid-spec, r=Mark-Simulacrum
fix(rust-analyzer): use new pkgid spec to compare

Starting from rust-lang/cargo#13311, Cargo's compiler artifact message
uses Package ID specification as package's identifier format.

Zulip topic: https://rust-lang.zulipchat.com/#narrow/stream/246057-t-cargo/topic/proc-macro-test.20bootstrap.20and.20pkgid.20JSON

cc `@ehuss`
2024-01-21 06:38:38 +01:00
Nadrieril
e7f3dc76f5
Rollup merge of #120027 - Nadrieril:remove-ty-copy-bound, r=compiler-errors
pattern_analysis: Remove `Ty: Copy` bound

To make it compatible with rust-analyzer's `Ty` which isn't `Copy` (it's an `Arc`).

r? ``@compiler-errors``
2024-01-21 06:38:38 +01:00
Nadrieril
e8678b1030
Rollup merge of #120015 - Zalathar:format, r=dtolnay
coverage: Format all coverage tests with `rustfmt`

As suggested by <https://github.com/rust-lang/rust/pull/119984#discussion_r1452856806>.

Test files in `tests/` are normally ignored by `x fmt`, but sometimes those files end up being run through `rustfmt` anyway, either by `rust-analyzer` or by hand.

When that happens, it's annoying to have to manually revert formatting changes that are unrelated to the actual changes being made. So it's helpful for the tests in the repository to already have standard formatting beforehand.

However, there are several coverage tests that deliberately use non-standard formatting, so that line counts reveal more information about where code regions begin and end. In those cases, we can use `#[rustfmt::skip]` to prevent that code from being disturbed.

``@rustbot`` label +A-code-coverage
2024-01-21 06:38:37 +01:00
Nadrieril
a1b41a9048
Rollup merge of #119996 - joboet:move_pal_os_str, r=ChrisDenton
Move OS String implementation into `sys`

Part of #117276. The new structure is really useful here, since we can easily eliminate a number of ugly `#[path]`-based imports.

In the future, it might be good to move the WTF-8 implementation directly to the OS string implementation, I cannot see it being used anywhere else. That is a story for another PR, however.
2024-01-21 06:38:37 +01:00
Nadrieril
203cc6930e
Rollup merge of #119461 - cjgillot:jump-threading-interp, r=tmiasko
Use an interpreter in MIR jump threading

This allows to understand assignments of aggregate constants. This case appears more frequently with GVN promoting aggregates to constants.
2024-01-21 06:38:36 +01:00
Nadrieril
3cd378cc15
Rollup merge of #119081 - jstasiak:is-ipv4-mapped, r=dtolnay
Add Ipv6Addr::is_ipv4_mapped

This change consists of cherry-picking the content from the original PR[1], which got closed due to inactivity, and applying the following changes:

* Resolving merge conflicts (obviously)
* Linked to to_ipv4_mapped instead of to_ipv4 in the documentation (seems more appropriate)
* Added the must_use and rustc_const_unstable attributes the original didn't have

I think it's a reasonably useful method to have.

[1] https://github.com/rust-lang/rust/pull/86490
2024-01-21 06:38:35 +01:00
Nadrieril
e8d1c2ef9c
Rollup merge of #118811 - EbbDrop:is-sorted-by-bool, r=Mark-Simulacrum
Use `bool` instead of `PartiolOrd` as return value of the comparison closure in `{slice,Iteraotr}::is_sorted_by`

Changes the function signature of the closure given to `{slice,Iteraotr}::is_sorted_by` to return a `bool` instead of a `PartiolOrd` as suggested by the libs-api team here: https://github.com/rust-lang/rust/issues/53485#issuecomment-1766411980.

This means these functions now return true if the closure returns true for all the pairs of values.
2024-01-21 06:38:35 +01:00
Nadrieril
b661cd6c57
Rollup merge of #116090 - rmehri01:strict_integer_ops, r=m-ou-se
Implement strict integer operations that panic on overflow

This PR implements the first part of the ACP for adding panic on overflow style arithmetic operations (https://github.com/rust-lang/libs-team/issues/270), mentioned in #116064.

It adds the following operations on both signed and unsigned integers:

- `strict_add`
- `strict_sub`
- `strict_mul`
- `strict_div`
- `strict_div_euclid`
- `strict_rem`
- `strict_rem_euclid`
- `strict_neg`
- `strict_shl`
- `strict_shr`
- `strict_pow`

Additionally, signed integers have:

- `strict_add_unsigned`
- `strict_sub_unsigned`
- `strict_abs`

And unsigned integers have:

- `strict_add_signed`

The `div` and `rem` operations are the same as normal division and remainder but are added for completeness similar to the corresponding `wrapping_*` operations.

I'm not sure if I missed any operations, I basically found them from the `wrapping_*` and `checked_*` operations on both integer types.
2024-01-21 06:38:34 +01:00
David Tolnay
c43344e839
Add test of thread_local containing multiline const block
Before making thread_local accept statements inside the const block,
this test would fail to compile as follows:

    error: no rules expected the token `let`
       --> library/std/tests/thread.rs:26:13
        |
    26  |             let value = 1;
        |             ^^^ no rules expected this token in macro call
        |
    note: while trying to match meta-variable `$init:expr`
       --> library/std/src/thread/local.rs:189:69
        |
    189 |     ($(#[$attr:meta])* $vis:vis static $name:ident: $t:ty = const { $init:expr }; $($rest:tt)*) => (
        |                                                                     ^^^^^^^^^^
2024-01-20 19:00:27 -08:00
David Tolnay
f52b88e91f
Revert example change from PR 116392 2024-01-20 18:39:48 -08:00
Nikolai Vazquez
fc75a4e146
Allow any expression blocks in thread_local! 2024-01-20 18:39:16 -08:00
yukang
3ed96e35c4 Suggest arry::from_fn for array initialization 2024-01-21 09:57:26 +08:00
Zalathar
6f1944d394 Document some alternatives to Vec::split_off 2024-01-21 11:56:55 +11:00
bors
867d39cdf6 Auto merge of #120100 - oli-obk:astconv_lifetimes, r=BoxyUwU
Don't forget that the lifetime on hir types is `'tcx`

This PR just tracks the `'tcx` lifetime to wherever the original objects actually have that lifetime. This code is needed for https://github.com/rust-lang/rust/pull/107606 (now #120131) so that `ast_ty_to_ty` can invoke `lit_to_const` on an argument passed to it. Currently the argument is `&hir::Ty<'_>`, but after this PR it is `&'tcx hir::Ty<'tcx>`.
2024-01-21 00:33:43 +00:00
Camille GILLOT
ad25f0eb2c Make MIR pass name a compile-time constant. 2024-01-21 00:21:33 +00:00
bors
4cb17b4e78 Auto merge of #111803 - scottmcm:simple-swap-alternative, r=Mark-Simulacrum
Tweak the threshold for chunked swapping

Thanks to `@AngelicosPhosphoros` for the tests here, which I copied from #98892.

This is an experiment as a simple alternative to that PR that just tweaks the existing threshold, since that PR showed that 3×Align (like `String`) currently doesn't work as well as it could.
2024-01-20 21:54:44 +00:00
Mark Rousskov
cc8e56b1e9 Warn users about limited review for tier 2 and 3 code 2024-01-20 16:22:46 -05:00
EbbDrop
606eeb84ad Use bool instead of PartiolOrd in is_sorted_by 2024-01-20 21:38:34 +01:00
bors
038d115cd8 Auto merge of #120170 - GuillaumeGomez:rollup-edqdf30, r=GuillaumeGomez
Rollup of 6 pull requests

Successful merges:

 - #119997 (Fix impl stripped in rustdoc HTML whereas it should not be in case the impl is implemented on a type alias)
 - #120000 (Ensure `callee_id`s are body owners)
 - #120063 (Remove special handling of `box` expressions from parser)
 - #120116 (Remove alignment-changing in-place collect)
 - #120138 (Increase vscode settings.json `git.detectSubmodulesLimit`)
 - #120169 (Spelling fix)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-01-20 19:55:26 +00:00
Georgiy Komarov
7842043b99
Add a warning comment 2024-01-20 16:52:18 -03:00
Guillaume Gomez
774cd3afd5
Rollup merge of #120169 - sunrosa:patch-1, r=ChrisDenton
Spelling fix

"It's" expands to "it is". "It is use..." doesn't make sense.

"Its" is the possessive form, and the intended form here.
2024-01-20 20:06:36 +01:00
Guillaume Gomez
dfd62cc3af
Rollup merge of #120138 - trevyn:detect-submodules-limit, r=albertlarsan68
Increase vscode settings.json `git.detectSubmodulesLimit`

The default vscode git integration throws a warning on the rust repository because it has more than the default limit of 10 submodules. This adds an increase to 20 to the settings.json that x.py offers to install on setup.

<img width="461" alt="Screen Shot 2024-01-19 at 11 47 47 PM" src="https://github.com/rust-lang/rust/assets/230691/440dfa4e-32e3-41f7-b8c6-5a07ade7aa14">

Also reported at https://stackoverflow.com/questions/60917209/disable-vs-code-warning-submodules-which-wont-be-opened-automatically
2024-01-20 20:06:35 +01:00
Guillaume Gomez
b917753d79
Rollup merge of #120116 - the8472:only-same-alignments, r=cuviper
Remove alignment-changing in-place collect

This removes the alignment-changing in-place collect optimization introduced in #110353
Currently stable users can't benefit from the optimization because GlobaAlloc doesn't support alignment-changing realloc and neither do most posix allocators. So in practice it has a negative impact on performance.

Explanation from https://github.com/rust-lang/rust/issues/120091#issuecomment-1899071681:

> > You mention that in case of alignment mismatch -- when the new alignment is less than the old -- the implementation calls `mremap`.
>
> I was trying to note that this isn't really the case in practice, due to the semantics of Rust's allocator APIs. The only use of the allocator within the `in_place_collect` implementation itself is [a call to `Allocator::shrink()`](db7125f008/library/alloc/src/vec/in_place_collect.rs (L299-L303)), which per its documentation [allows decreasing the required alignment](https://doc.rust-lang.org/1.75.0/core/alloc/trait.Allocator.html). However, in stable Rust, the only available `Allocator` is [`Global`](https://doc.rust-lang.org/1.75.0/alloc/alloc/struct.Global.html), which delegates to the registered `GlobalAlloc`. Since `GlobalAlloc::realloc()` [cannot change the required alignment](https://doc.rust-lang.org/1.75.0/core/alloc/trait.GlobalAlloc.html#method.realloc), the implementation of [`<Global as Allocator>::shrink()`](db7125f008/library/alloc/src/alloc.rs (L280-L321)) must fall back to creating a brand-new allocation, `memcpy`ing the data into it, and freeing the old allocation, whenever the alignment doesn't remain exactly the same.
>
> Therefore, the underlying allocator, provided by libc or some other source, has no opportunity to internally `mremap()` the data when the alignment is changed, since it has no way of knowing that the allocation is the same.
2024-01-20 20:06:35 +01:00
Guillaume Gomez
8f5f967031
Rollup merge of #120063 - clubby789:remove-box-handling, r=Nilstrieb
Remove special handling of `box` expressions from parser

#108471 added a temporary hack to parse `box expr`. It's been almost a year since then, so I think it's safe to remove the special handling.

As a drive-by cleanup, move `parser/removed-syntax*` tests to their own directory.
2024-01-20 20:06:34 +01:00
Guillaume Gomez
71cef76894
Rollup merge of #120000 - smoelius:fix-clippy, r=fee1-dead
Ensure `callee_id`s are body owners

This PR makes the `callee_id` argument of Clippy's `implements_trait_with_env` optional, and when it is passed, ensures it is a body owner.

#118661 added the `callee_id` parameter to alleviate an ICE. Specifically, the `callee_id` is used to determine an "effect arg" in certain situations.

Frankly, I [do not completely understand](https://github.com/rust-lang/rust/pull/118661#discussion_r1449013176) what an "effect arg" is. But the code that determines it seems to require that `callee_id` is a body owner:
- 1ead4761e9/src/tools/clippy/clippy_utils/src/ty.rs (L286-L288)
- 1ead4761e9/compiler/rustc_middle/src/ty/util.rs (L834)
- 1ead4761e9/compiler/rustc_middle/src/hir/map/mod.rs (L372)

In the current head, some def ids passed as `callee_id`s are not body owners. This PR fixes that.

cc ``@rust-lang/clippy``

r? ``@fee1-dead``
2024-01-20 20:06:34 +01:00
Guillaume Gomez
1236fa2102
Rollup merge of #119997 - GuillaumeGomez:fix-stripped-impl-on-ty-alias, r=notriddle
Fix impl stripped in rustdoc HTML whereas it should not be in case the impl is implemented on a type alias

Fixes #119015.

I talked about it a bit with ```@petrochenkov.``` They might change what `EffectiveVisibilities` return for impl items like this one and make them not only reachable but also re-exported, which would fix this case. It could also potentially break other things, so it'll be done whenever they can and then we can check together.

Surprisingly, this fix is making rustdoc even closer to rustc in term of errors (the CI currently fails because currently accepted broken codes aren't working anymore with this change). Not sure exactly why though. This is linked to https://github.com/rust-lang/rust/pull/110631 from what I could find.

So either I'm missing something here, or we consider it's ok and we consider the failing tests as "should fail" and I'll update `rustdoc-ui` ones.

r? ```@notriddle```
2024-01-20 20:06:33 +01:00
sunrosa
0e96840e7e
Spelling fix
"It's" expands to "it is". "Its" is the possessive form.
2024-01-20 18:27:55 +00:00