Commit Graph

303456 Commits

Author SHA1 Message Date
Esteban Küber
4438b3211f review comments and make test run-rustfix 2025-01-11 01:58:32 +00:00
Wilfred Hughes
442c4edb09 minor: Fix grammar in doc comments
"too" should be "to" here.
2025-01-10 17:38:14 -08:00
Esteban Küber
ec98df4bb6 On unused assign lint, detect mut arg: &Ty meant to be arg: &mut Ty
```
error: value assigned to `object` is never read
  --> $DIR/mut-arg-of-borrowed-type-meant-to-be-arg-of-mut-borrow.rs:11:5
   |
LL |     object = &object2;
   |     ^^^^^^
   |
note: the lint level is defined here
  --> $DIR/mut-arg-of-borrowed-type-meant-to-be-arg-of-mut-borrow.rs:1:9
   |
LL | #![deny(unused_assignments, unused_variables)]
   |         ^^^^^^^^^^^^^^^^^^
help: you might have meant to mutate the pointed at value being passed in, instead of changing the reference in the local binding
   |
LL ~ fn change_object2(object: &mut Object) {
LL |     let object2 = Object;
LL ~     *object = object2;
   |
```

This might be the first thing someone tries to write to mutate the value *behind* an argument, trying to avoid an E0308.
2025-01-11 01:34:23 +00:00
Esteban Küber
c2ae386c85 On E0308, detect mut arg: &Ty meant to be arg: &mut Ty
```
error[E0308]: mismatched types
  --> $DIR/mut-arg-of-borrowed-type-meant-to-be-arg-of-mut-borrow.rs:6:14
   |
LL | fn change_object(mut object: &Object) {
   |                              ------- expected due to this parameter type
LL |     let object2 = Object;
LL |     object = object2;
   |              ^^^^^^^ expected `&Object`, found `Object`
   |
help: you might have meant to mutate the pointed at value being passed in, instead of changing the reference in the local binding
   |
LL ~ fn change_object(object: &mut Object) {
LL |     let object2 = Object;
LL ~     *object = object2;
   |
```

This might be the first thing someone tries to write to mutate the value *behind* an argument. We avoid suggesting `object = &object2;`, as that is less likely to be what was intended.
2025-01-11 01:34:23 +00:00
Esteban Küber
57f9f8f883 Add test for mut arg: &Ty meant to be arg: &mut Ty
This is a mistake I've seen newcomers make where they want to express an "out" argument.
2025-01-11 01:34:23 +00:00
Esteban Küber
857918e9bc review comments
Replace tuple with struct and remove unnecessary early return.
2025-01-11 01:23:37 +00:00
Esteban Küber
919f672c3d Avoid unnecessary note when type has escaping bounds 2025-01-11 01:10:29 +00:00
Esteban Küber
91425d0ef8 Avoid duplicated note 2025-01-11 01:10:29 +00:00
Esteban Küber
05c39438e2 Account for for<'a> types when checking for non-structural type in constant as pattern
When we encounter a constant in a pattern, we check if it is non-structural. If so, we check if the type implements `PartialEq`, but for types with escaping bound vars the check would be incorrect as is, so we break early. This is ok because these types would be filtered anyways.

Fix #134764.
2025-01-11 01:10:29 +00:00
bors
7648efaf1a Auto merge of #135346 - weihanglo:update-cargo, r=weihanglo
Update cargo

18 commits in fd784878cfa843e3e29a6654ecf564c62fae6735..088d496082726091024f1689c124a0c3dccbd775
2025-01-03 20:06:26 +0000 to 2025-01-10 20:10:21 +0000
- docs(reference): Fix PkgIdSpec kind docs (rust-lang/cargo#15049)
- feat: Added warning when failing to update index cache (rust-lang/cargo#15014)
- docs(ref): Fix the inverted logic about MSRV (rust-lang/cargo#15044)
- chore(deps): update msrv (1 version) to v1.84 (rust-lang/cargo#15041)
- Remove unnecessary into conversions (rust-lang/cargo#15042)
- docs(contrib): Start guidelines for schema design (rust-lang/cargo#15037)
- fix: emit warnings as warnings when learning rust target info (rust-lang/cargo#15036)
- fix(schemas): Fix the `[lints]` JSON Schema (rust-lang/cargo#15035)
- fix(schemas): Fix 'metadata' JSON Schema (rust-lang/cargo#15033)
- shorten comment on Ord for SourceKind (rust-lang/cargo#15029)
- Make `"C"` explicit in `extern "C"`. (rust-lang/cargo#15034)
- simplify SourceID Ord/Eq (rust-lang/cargo#14980)
- Setup cargo environment for `cargo rustc --print` (rust-lang/cargo#15026)
- Avoid naming variables `str` (rust-lang/cargo#15025)
- Bump to 0.87.0; update changelog (rust-lang/cargo#15022)
- Update libgit2 to 1.9 (rust-lang/cargo#15018)
- Remove condition on RUSTUP_WINDOWS_PATH_ADD_BIN (rust-lang/cargo#15017)
- Fix https::self_signed_should_fail for macos (rust-lang/cargo#15016)
2025-01-11 00:53:22 +00:00
Alona Enraght-Moony
2a2b090d12 jsondoclint: Check that Path types exitst in Crate::paths. 2025-01-10 23:51:45 +00:00
Alona Enraght-Moony
1fe3331899 rustdoc-json: Include items in stripped modules in Crate::paths. 2025-01-10 23:51:45 +00:00
Alona Enraght-Moony
97ada592c0 jsondoclint: Support //@ !has <path> <value>.
This was removed for not being used [1], but now we need it.

[1]: https://github.com/rust-lang/rust/pull/133478#discussion_r1874358362
2025-01-10 23:51:45 +00:00
Samuel Tardieu
9ab77f1ccb Use NonNull::without_provenance within the standard library
This API removes the need for several `unsafe` blocks, and leads to
clearer code.
2025-01-10 23:23:10 +01:00
Weihang Lo
cd24a90493 Update cargo 2025-01-10 17:13:58 -05:00
bors
760b6f8de4 Auto merge of #135339 - joboet:ptr-is-zero, r=Noratrieb
alloc: remove unsound `IsZero` for raw pointers

Fixes #135338
2025-01-10 22:08:51 +00:00
Folkert de Vries
47573bf61e add -Zmin-function-alignment 2025-01-10 22:53:54 +01:00
Catherine Flores
ab55d3fc62 Correct version of literal_string_with_formatting_args (#13974)
It claims to be in 1.83 but in fact will not be until 1.85.

Evidence: <https://github.com/rust-lang/rust/pull/134788> is where it
was merged into rust-lang/rust, and has a milestone of 1.85.

changelog: none
2025-01-10 21:14:40 +00:00
Catherine Flores
64250a3360 Also deploy index.html file on release (#13971)
I noticed that this was missing bf482928 while doing the release. No
harm done, as it was updated on the next push to master.

changelog: none
2025-01-10 21:10:08 +00:00
Trevor Gross
a0c03b2537 Add tests against MPFR for remquo and remquof
Rug does not yet expose this function, but it is possible to use the
MPFR bindings directly.
2025-01-10 16:04:16 -05:00
Oli Scherer
a2c10e4514 Merge pull request #4132 from YohDeadfall/freebsd-thread-name-changes
Switched FreeBSD to pthread_setname_np
2025-01-10 20:15:14 +00:00
Alejandra González
579571d9cf New lint: manual_ok_err (#13740)
changelog: [`manual_ok_err`]: new lint

Detect manual implementations of `.ok()` or `.err()`, as in

```rust
let a = match func() {
    Ok(v) => Some(v),
    Err(_) => None,
};
let b = if let Err(v) = func() {
    Some(v)
} else {
    None
};
```

which can be replaced by

```rust
let a = func().ok();
let b = func().err();
```

This pattern was detected in the wild in the Rust reimplementation of
coreutils:
https://github.com/uutils/coreutils/pull/6886#pullrequestreview-2465160137
2025-01-10 19:19:58 +00:00
bors
b1a7dfb911 Auto merge of #134082 - davidtwco:forced-inlining, r=saethlin
mir_transform: implement `#[rustc_force_inline]`

Adds `#[rustc_force_inline]` which is similar to always inlining but reports an error if the inlining was not possible.

- `#[rustc_force_inline]` can only be applied to free functions to guarantee that the MIR inliner will be able to resolve calls.
- `rustc_mir_transform::inline::Inline` is refactored into two passes (`Inline` and `ForceInline`), sharing the vast majority of the implementation.
  - `rustc_mir_transform::inline::ForceInline` can't be disabled so annotated items are always inlined.
  - `rustc_mir_transform::inline::ForceInline` runs regardless of optimisation level.
- `#[rustc_force_inline]` won't inline unless target features match, as with normal inlining.
- MIR validation will ICE if a `#[rustc_force_inline]` isn't inlined, to guarantee that it will never be codegened independently. As a further guarantee, monomorphisation collection will always decide that `#[rustc_force_inline]` functions cannot be codegened locally.
- Like other intrinsics, `#[rustc_force_inline]` annotated functions cannot be cast to function pointers.
- As with other rustc attrs, this cannot be used by users, just within the compiler and standard library.
- This is only implemented within rustc, so should avoid any limitations of LLVM's inlining.

It is intended that this attribute be used with intrinsics that must be inlined for security reasons. For example, pointer authentication intrinsics would allow Rust users to make use of pointer authentication instructions, but if these intrinsic functions were in the binary then they could be used as gadgets with ROP attacks, defeating the point of introducing them. We don't have any intrinsics like this today, but I expect to upstream some once a force inlining mechanism such as this is available.

cc rust-lang/rust#131687 rust-lang/rfcs#3711 - this approach should resolve the concerns from these previous attempts

r? `@saethlin`
2025-01-10 19:04:26 +00:00
Yoh Deadfall
b0ac8c4039 Switched FreeBSD to pthread_setname_np 2025-01-10 21:51:26 +03:00
David Wood
cc9a9ecccb mir_build: check annotated functions w/out callers 2025-01-10 18:37:57 +00:00
David Wood
ce602acfc2 clarify target_feature + forced inlining 2025-01-10 18:37:57 +00:00
David Wood
3169a4493f don't collect #[rustc_force_inline] in eager mode 2025-01-10 18:37:57 +00:00
David Wood
dbec6bedf4 inline: move should inline check 2025-01-10 18:37:56 +00:00
David Wood
5f316f5e00 validator: move force inline check 2025-01-10 18:37:56 +00:00
David Wood
90066c0df3 inline: remove unnecessary promoted check 2025-01-10 18:37:55 +00:00
David Wood
e4bae91be1 inline: re-introduce some callee body checks 2025-01-10 18:37:55 +00:00
David Wood
450793923e inline: force inlining shims 2025-01-10 18:37:55 +00:00
David Wood
02d423cd24 codegen_attrs: force inlining takes precedence 2025-01-10 18:37:55 +00:00
David Wood
90ae2cf418 mir_transform: implement forced inlining
Adds `#[rustc_force_inline]` which is similar to always inlining but
reports an error if the inlining was not possible, and which always
attempts to inline annotated items, regardless of optimisation levels.
It can only be applied to free functions to guarantee that the MIR
inliner will be able to resolve calls.
2025-01-10 18:37:54 +00:00
David Wood
f86169a58f mir_transform: implement forced inlining
Adds `#[rustc_force_inline]` which is similar to always inlining but
reports an error if the inlining was not possible, and which always
attempts to inline annotated items, regardless of optimisation levels.
It can only be applied to free functions to guarantee that the MIR
inliner will be able to resolve calls.
2025-01-10 18:37:54 +00:00
joboet
4426e9a3c2 alloc: remove unsound IsZero for raw pointers
Fixes #135338
2025-01-10 18:48:48 +01:00
Philipp Krones
8678f9cdb6 CI: rerun the changelog check on PR synchronization (#13980)
Rerunning the PR checks when a PR is synchronized (new commits added, or
force-pushed) seems to remove the changelog checks from the UI while
keeping the PR mergeable from the maintainer's interface.

This PR reruns the cheap changelog check when a PR is synchronized.

changelog: none

r? @flip1995
2025-01-10 17:47:26 +00:00
Samuel Tardieu
4a69d0d4d8 New lint: manual_ok_err 2025-01-10 18:26:01 +01:00
Samuel Tardieu
1bdee5b6b3 CI: rerun the changelog check on PR synchronization
Rerunning the PR checks when a PR is synchronized (new commits added, or
force-pushed) seems to remove the changelog checks from the UI while
keeping the PR mergeable from the maintainer's interface.

This PR reruns the cheap changelog check when a PR is synchronized.
2025-01-10 18:17:55 +01:00
Philipp Krones
fc0e65d157 Use diagnostic item instead of path for core::fmt::Debug (#13949)
This removes the last call to `LateContext::match_def_path()` in
Clippy's code. The `LateContext::match_def_path()` in the compiler
sources was only kept for Clippy's usage.

Once this PR is merged and after the rustup, I will submit one to remove
`LateContext::match_def_path()` from the compiler.

changelog: none

r? @flip1995
2025-01-10 16:45:08 +00:00
许杰友 Jieyou Xu (Joe)
90e0127674 Merge pull request #2205 from ehuss/ci-config 2025-01-11 00:34:43 +08:00
许杰友 Jieyou Xu (Joe)
f53bce4c57 Merge pull request #2206 from ehuss/fix-matrix-link 2025-01-11 00:32:01 +08:00
Philipp Krones
cccb006cc0 CI: check the presence of the changelog line in every pull request (#13976)
Checking it only in the merge queue leads to deferred failures once the
decision to merge has been taken already.

- [X] Testing first without changelog line
- [x] Now that that has failed, adding the changelog line and
force-pushing

changelog: none
2025-01-10 16:31:50 +00:00
Eric Huss
43848beb68 Fix calculate-job-matrix.py link 2025-01-10 08:26:52 -08:00
Samuel Tardieu
7639e82939 CI: check the presence of the changelog line in every pull request
Checking it only in the merge queue leads to deferred failures once the
decision to merge has been taken already.
2025-01-10 17:23:10 +01:00
Eric Huss
fcbcc7411d Document how to find the configuration used in CI
This documents how to determine which settings are used in CI, since I
see this question come up regularly. We currently don't have a great way
to answer the question, but at least there is something.
2025-01-10 08:16:37 -08:00
Oli Scherer
65b01cb182 Use llvm.memset.p0i8.* to initialize all same-bytes arrays 2025-01-10 15:22:06 +00:00
Ralf Jung
1281915e27 Merge pull request #4131 from RalfJung/rustup
Rustup
2025-01-10 15:21:08 +00:00
Alejandra González
7611dbb047 Mention existing labels at CONTRIBUTING (#13978)
At CONTRIBUTING.md there are mentioned
[`l-crash`](https://github.com/rust-lang/rust-clippy/issues?q=is%3Aopen+label%3Al-crash)
and
[`l-bug`](https://github.com/rust-lang/rust-clippy/issues?q=is%3Aopen%20label%3Al-bug)
labels which are never used, so correct them to
[`I-ICE`](https://github.com/rust-lang/rust-clippy/issues?q=is%3Aopen%20label%3AI-ICE)
and
[`C-bug`](https://github.com/rust-lang/rust-clippy/issues?q=is%3Aopen%20label%3AC-bug)

changelog: none
2025-01-10 15:13:11 +00:00
Ralf Jung
ba44c88167 fix clippy warning 2025-01-10 15:55:48 +01:00