Commit Graph

247444 Commits

Author SHA1 Message Date
Nicholas Nethercote
8199632aa8 Rename DiagnosticArg{,Map,Name,Value} as DiagArg{,Map,Name,Value}. 2024-02-28 08:55:37 +11:00
Nicholas Nethercote
899cb40809 Rename DiagnosticBuilder as Diag.
Much better!

Note that this involves renaming (and updating the value of)
`DIAGNOSTIC_BUILDER` in clippy.
2024-02-28 08:55:35 +11:00
Nicholas Nethercote
4e1f9bd528 Rename SubDiagnostic as Subdiag.
Note the change of the `D` to `d`, to match all the other names that
have `Subdiag` in them, such as `SubdiagnosticMessage` and
`derive(Subdiagnostic)`.
2024-02-28 08:33:25 +11:00
Nicholas Nethercote
366536ba2b Rename DelayedDiagnostic as DelayedDiagInner. 2024-02-28 08:33:25 +11:00
Nicholas Nethercote
6588f5b749 Rename Diagnostic as DiagInner.
I started by changing it to `DiagData`, but that didn't feel right.
`DiagInner` felt much better.
2024-02-28 08:33:25 +11:00
bors
1e4f9e302c Auto merge of #121677 - flip1995:clippy-subtree-update, r=Manishearth
Clippy subtree update

r? `@Manishearth`
2024-02-27 18:28:06 +00:00
bors
8790c3cc7c Auto merge of #119636 - devnexen:linux_tcp_defer_accept, r=m-ou-se
os::net: expanding TcpStreamExt for Linux with `tcp_deferaccept`.

allows for socket to process only when there is data to process, the option sets a number of seconds until the data is ready.
2024-02-27 16:00:39 +00:00
Philipp Krones
f99056bd87
Update Cargo.lock 2024-02-27 15:50:23 +01:00
Philipp Krones
ad7513e874
Merge commit '10136170fe9ed01e46aeb4f4479175b79eb0e3c7' into clippy-subtree-update 2024-02-27 15:50:17 +01:00
bors
10136170fe Auto merge of #12363 - oli-obk:bump_ui_test, r=flip1995
lower `bstr` version requirement to `1.6.0`

test changes are due to https://github.com/oli-obk/ui_test/pull/201 (cc `@Jarcho)`

changelog: none
2024-02-27 13:46:14 +00:00
Oli Scherer
592fe89997 lower bstr version requirement to 1.6.0 2024-02-27 13:34:01 +00:00
bors
b6e4299415 Auto merge of #121548 - RalfJung:ffi-unwind-intrinsics, r=davidtwco
ffi_unwind_calls: treat RustIntrinsic like regular Rust calls

Also add some comments to `abi_can_unwind` to explain what happens.

r? `@nbdd0121`  Cc `@BatmanAoD`
2024-02-27 13:33:35 +00:00
Ralf Jung
f5c80dcd5a intrinsics.rs: add some notes on unwinding 2024-02-27 12:28:25 +01:00
Ralf Jung
bd3ea3e096 ffi_unwind_calls: treat RustIntrinsic like regular Rust calls 2024-02-27 12:28:25 +01:00
bors
9afdb8d1d5 Auto merge of #121285 - nnethercote:delayed_bug-audit, r=lcnr
Delayed bug audit

I went through all the calls to `delayed_bug` and `span_delayed_bug` and found a few places where they could be avoided.

r? `@compiler-errors`
2024-02-27 11:03:07 +00:00
bors
53ed660d47 Auto merge of #120411 - erikdesjardins:netbsdcall, r=Nilstrieb
i586_unknown_netbsd: use inline stack probes

This is one of the last two targets still using "call" stack probes.

I don't believe that this target uses call stack probes for any particular reason--inline stack probes are used on [`i686_unknown_netbsd`](b362939be1/compiler/rustc_target/src/spec/targets/i686_unknown_netbsd.rs (L8)), suggesting they work on netbsd; and on [`i586_unknown_linux_gnu`](b362939be1/compiler/rustc_target/src/spec/targets/i586_unknown_linux_gnu.rs (L4)) (via the base [`i686_unknown_linux_gnu`](b362939be1/compiler/rustc_target/src/spec/targets/i686_unknown_linux_gnu.rs (L9))), suggesting they work with `cpu = "pentium"`.

...although I don't have a netbsd system to test this on.

(cc `@he32)`
2024-02-27 08:35:56 +00:00
bors
1c28a2c1b0 Auto merge of #121667 - pitaj:diag_items-legacy_numeric_constants, r=Nilstrieb
syms for legacy numeric constants diag items

Missed these in #121272 and #121361, woops.

For https://github.com/rust-lang/rust-clippy/pull/12312

r? `@Nilstrieb`
2024-02-27 06:04:54 +00:00
Nicholas Nethercote
a8a486c846 Refactor take_for_recovery call sites.
To make them more concise and similar to each other.
2024-02-27 16:40:15 +11:00
Nicholas Nethercote
62b4e55112 Avoid a span_delayed_bug in compute_regions.
By storing error guarantees in `RegionErrors`.
2024-02-27 16:40:13 +11:00
Nicholas Nethercote
9f82563718 Avoid a span_delayed_bug in TypeErrCtxt::report_region_errors.
By returning error guarantees from a few functions it relies on.
2024-02-27 16:40:11 +11:00
bors
e33cba523a Auto merge of #12126 - teor2345:patch-1, r=llogiq
Fix sign-handling bugs and false negatives in `cast_sign_loss`

**Note: anyone should feel free to move this PR forward, I might not see notifications from reviewers.**

changelog: [`cast_sign_loss`]: Fix sign-handling bugs and false negatives

This PR fixes some arithmetic bugs and false negatives in PR #11883 (and maybe earlier PRs).
Cc `@J-ZhengLi`

I haven't updated the tests yet. I was hoping for some initial feedback before adding tests to cover the cases listed below.

Here are the issues I've attempted to fix:

#### `abs()` can return a negative value in release builds

Example:
```rust
i32::MIN.abs()
```
https://play.rust-lang.org/?version=stable&mode=release&edition=2021&gist=022d200f9ef6ee72f629c0c9c1af11b8

Docs: https://doc.rust-lang.org/std/primitive.i32.html#method.abs

Other overflows that produce negative values could cause false negatives (and underflows could produce false positives), but they're harder to detect.

#### Values with uncertain signs can be positive or negative

Any number of values with uncertain signs cause the whole expression to have an uncertain sign, because an uncertain sign can be positive or negative.

Example (from UI tests):
```rust
fn main() {
    foo(a: i32, b: i32, c: i32) -> u32 {
        (a * b * c * c) as u32
        //~^ ERROR: casting `i32` to `u32` may lose the sign of the value
    }

    println!("{}", foo(1, -1, 1));
}
```
https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=165d2e2676ee8343b1b9fe60db32aadd

#### Handle `expect()` the same way as `unwrap()`

Since we're ignoring `unwrap()` we might as well do the same with `expect()`.

This doesn't seem to have tests but I'm happy to add some like `Some(existing_test).unwrap() as u32`.

#### A negative base to an odd exponent is guaranteed to be negative

An integer `pow()`'s sign is only uncertain when its operants are uncertain. (Ignoring overflow.)

Example:
```rust
((-2_i32).pow(3) * -2) as u32
```

This offsets some of the false positives created by one or more uncertain signs producing an uncertain sign. (Rather than just an odd number of uncertain signs.)

#### Both sides of a multiply or divide should be peeled recursively

I'm not sure why the lhs was peeled recursively, and the rhs was left intact. But the sign of any sequence of multiplies and divides is determined by the signs of its operands. (Ignoring overflow.)

I'm not sure what to use as an example here, because most expressions I want to use are const-evaluable.

But if `p()` is [a non-const function that returns a positive value](https://doc.rust-lang.org/std/primitive.i32.html#method.isqrt), and if the lint handles unary negation, these should all lint:
```rust
fn peel_all(x: i32) {
    (-p(x) * -p(x) * -p(x)) as u32;
    ((-p(x) * -p(x)) * -p(x)) as u32;
    (-p(x) * (-p(x) * -p(x))) as u32;
}
```

#### The right hand side of a Rem doesn't change the sign

Unlike Mul and Div,
> Given remainder = dividend % divisor, the remainder will have the same sign as the dividend.
https://doc.rust-lang.org/reference/expressions/operator-expr.html#arithmetic-and-logical-binary-operators

I'm not sure what to use as an example here, because most expressions I want to use are const-evaluable.

But if `p()` is [a non-const function that returns a positive value](https://doc.rust-lang.org/std/primitive.i32.html#method.isqrt), and if the lint handles unary negation, only the first six expressions should lint.

The expressions that start with a constant should lint (or not lint) regardless of whether the lint supports `p()` or unary negation, because only the dividend's sign matters.

Example:
```rust
fn rem_lhs(x: i32) {
    (-p(x) % -1) as u32;
    (-p(x) % 1) as u32;
    (-1 % -p(x)) as u32;
    (-1 % p(x)) as u32;
    (-1 % -x) as u32;
    (-1 % x) as u32;
    // These shouldn't lint:
    (p(x) % -1) as u32;
    (p(x) % 1) as u32;
    (1 % -p(x)) as u32;
    (1 % p(x)) as u32;
    (1 % -x) as u32;
    (1 % x) as u32;
}
```

#### There's no need to bail on other expressions

When peeling, any other operators or expressions can be left intact and sent to the constant evaluator.

If these expressions can be evaluated, this offsets some of the false positives created by one or more uncertain signs producing an uncertain sign. If not, they end up marked as having uncertain sign.
2024-02-27 05:38:40 +00:00
Nicholas Nethercote
b2d1d6f6ff Avoid span_delayed_bug on one path in AdtDef::eval_explicit_discr.
Also change its return type to `Result`.
2024-02-27 16:31:45 +11:00
Nicholas Nethercote
d0267cb26b Remove an unnecessary span_delayed_bug in Resolver::valid_res_from_ribs.
`Resolver::report_error` always emits (this commit makes that clearer),
so the `span_delayed_bug` is unnecessary.
2024-02-27 16:31:40 +11:00
Nicholas Nethercote
c743e4a855 Refactor LoweringContext::get_delegation_sig_id.
I find the function much easier to read this way. Thanks to @kadiwa4 for
the suggestion.
2024-02-27 16:09:20 +11:00
Nicholas Nethercote
2fc94cefc5 Remove an unnecessary span_delayed_bug call.
The existing code calls a function that returns `Result<_,
ErrorGuaranteed>`, and then calls `span_delayed_bug` pointlessly in the
`Err` case.
2024-02-27 16:09:14 +11:00
bors
fb060815b3 Auto merge of #11136 - y21:enhance_read_line_without_trim, r=dswij
[`read_line_without_trim`]: detect string literal comparison and `.ends_with()` calls

This lint now also realizes that a comparison like `s == "foo"` and calls such as `s.ends_with("foo")` will fail if `s` was initialized by a call to `Stdin::read_line` (because of the trailing newline).

changelog: [`read_line_without_trim`]: detect string literal comparison and `.ends_with()` calls

r? `@giraffate` assigning you because you reviewed #10970 that added this lint, so this is kinda a followup PR ^^
2024-02-27 03:36:12 +00:00
bors
91cae1dcdc Auto merge of #121635 - 823984418:remove_archive_builder_lifetime_a, r=nnethercote
Remove useless lifetime of ArchiveBuilder

`trait ArchiveBuilder<'a>` has a seemingly useless lifetime a, so I remove it. If this is intentional, please reject this PR.

```rust
pub trait ArchiveBuilder<'a> {
    fn add_file(&mut self, path: &Path);

    fn add_archive(
        &mut self,
        archive: &Path,
        skip: Box<dyn FnMut(&str) -> bool + 'static>,
    ) -> io::Result<()>;

    fn build(self: Box<Self>, output: &Path) -> bool;
}
```
2024-02-27 03:27:48 +00:00
bors
71ffdf7ff7 Auto merge of #121655 - matthiaskrgr:rollup-qpx3kks, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 - #121598 (rename 'try' intrinsic to 'catch_unwind')
 - #121639 (Update books)
 - #121648 (Update Vec and String `{from,into}_raw_parts`-family docs)
 - #121651 (Properly emit `expected ;` on `#[attr] expr`)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-02-27 00:55:14 +00:00
Peter Jaszkowiak
2ea33225c2 syms for legacy numeric constants diag items 2024-02-26 17:37:12 -07:00
Matthias Krüger
ec5c5b7da8
Rollup merge of #121651 - ShE3py:issue-121647, r=estebank
Properly emit `expected ;` on `#[attr] expr`

Fixes #121647

See #118182, #120586

---
r? estebank
2024-02-27 00:40:01 +01:00
Matthias Krüger
94609dbb03
Rollup merge of #121648 - jieyouxu:from-into-raw-parts-docs, r=Nilstrieb
Update Vec and String `{from,into}_raw_parts`-family docs

- Fix documentation argument order to match the code argument order for consistency.
- Add return argument description for `{Vec,String}::into_raw_parts` to match their `from*` counterparts.
2024-02-27 00:40:01 +01:00
Matthias Krüger
e47d814a33
Rollup merge of #121639 - rustbot:docs-update, r=ehuss
Update books

## rust-lang/book

1 commits in 71352deb20727b4dda9ebfe8182709d5bf17dfea..19c40bfd2d57641d962f3119a1c343355f1b3c5e
2024-02-19 20:39:35 UTC to 2024-02-19 20:39:35 UTC

- Rust upgrades (rust-lang/book#3844)

## rust-lang/edition-guide

3 commits in 76bd48a273a0e0413a3bf22c699112d41497b99e..e1eead1181a691e56299294d5f1d62fe7a26d317
2024-02-24 21:15:28 UTC to 2024-02-17 21:44:36 UTC

- Rename static_mut_refs (rust-lang/edition-guide#293)
- Add 2024 prelude (rust-lang/edition-guide#292)
- Add some more initial stub docs for 2024. (rust-lang/edition-guide#291)

## rust-lang/reference

5 commits in 8227666de13f6e7bb32dea9dc42e841adb5ce4b7..3417f866932cb1c09c6be0f31d2a02ee01b4b95d
2024-02-25 19:37:14 UTC to 2024-02-15 13:28:59 UTC

- Document `target_abi` (rust-lang/reference#1446)
- Add `rust-toolchain.toml` and revise README (rust-lang/reference#1474)
- Clarify semantics of the various pointer to pointer casts (rust-lang/reference#1451)
- Update aarch64 target feature docs to match LLVM (rust-lang/reference#1470)
- Fix grammar for TypePathFn (rust-lang/reference#1281)

## rust-lang/rust-by-example

4 commits in e188d5d466f7f3ff9f1d518393235f4fe951be46..57f1e708f5d5850562bc385aaf610e6af14d6ec8
2024-02-24 18:31:19 UTC to 2024-02-14 13:06:53 UTC

- bug: fix typo (rust-lang/rust-by-example#1822)
- Fix typo in attribute.md (rust-lang/rust-by-example#1818)
- Add Japanese translation (rust-lang/rust-by-example#1794)
- Remove unused .travis.yml file (rust-lang/rust-by-example#1816)

## rust-lang/rustc-dev-guide

9 commits in 1f30cc7cca9a3433bc1872abdc98960b36c21ca0..7b0ef5b0bea5e3ce3b9764aa5754a60e2cc05c52
2024-02-22 19:15:52 UTC to 2024-02-13 12:13:06 UTC

- Update compiletest directives to be in `ui_test` style `//`@`` (rust-lang/rustc-dev-guide#1895)
- Add notes on tweak rust-analyzer.check.overrideCommand (rust-lang/rustc-dev-guide#1890)
- Fix more links (rust-lang/rustc-dev-guide#1884)
- Remove references to -Z ast-json and -Z ast-json-noexpand (rust-lang/rustc-dev-guide#1893)
- Specify ui test suite directives and add note on ignore-tidy directives (rust-lang/rustc-dev-guide#1892)
- Update docs about ui tests now using `//`@`` headers (rust-lang/rustc-dev-guide#1885)
- Make git rebase commands more bulletproof (rust-lang/rustc-dev-guide#1889)
- updating-llvm.md: command does not work (rust-lang/rustc-dev-guide#1887)
- fix update llvm build command (rust-lang/rustc-dev-guide#1886)
2024-02-27 00:40:00 +01:00
Matthias Krüger
d95c321062
Rollup merge of #121598 - RalfJung:catch_unwind, r=oli-obk
rename 'try' intrinsic to 'catch_unwind'

The intrinsic has nothing to do with `try` blocks, and corresponds to the stable `catch_unwind` function, so this makes a lot more sense IMO.

Also rename Miri's special function while we are at it, to reflect the level of abstraction it works on: it's an unwinding mechanism, on which Rust implements panics.
2024-02-27 00:40:00 +01:00
bors
d12b53e481 Auto merge of #12116 - J-ZhengLi:issue12101, r=Alexendoo
fix suggestion error in [`useless_vec`]

fixes: #12101

---

changelog: fix suggestion error in [`useless_vec`]

r+ `@matthiaskrgr` since they opened the issue?
2024-02-26 22:38:24 +00:00
bors
5c786a7fe3 Auto merge of #121516 - RalfJung:platform-intrinsics-begone, r=oli-obk
remove platform-intrinsics ABI; make SIMD intrinsics be regular intrinsics

`@Amanieu` `@workingjubilee` I don't think there is any reason these need to be "special"? The [original RFC](https://rust-lang.github.io/rfcs/1199-simd-infrastructure.html) indicated eventually making them stable, but I think that is no longer the plan, so seems to me like we can clean this up a bit.

Blocked on https://github.com/rust-lang/stdarch/pull/1538, https://github.com/rust-lang/rust/pull/121542.
2024-02-26 22:24:16 +00:00
teor
1e3c55eea2
Remove redundant uncertain_counts 2024-02-27 07:34:18 +10:00
Lieselotte
1658ca082a
Properly emit expected ; on #[attr] expr 2024-02-26 21:47:10 +01:00
bors
fc3800f657 Auto merge of #121646 - ibraheemdev:patch-17, r=ChrisDenton
Fix race between block initialization and receiver disconnection

Port of https://github.com/crossbeam-rs/crossbeam/pull/1084. Closes https://github.com/rust-lang/rust/issues/121582.
2024-02-26 19:46:01 +00:00
许杰友 Jieyou Xu (Joe)
bfeea294cc
Document args returned from String::into_raw_parts 2024-02-26 19:32:32 +00:00
许杰友 Jieyou Xu (Joe)
dd24a462d5
Document args returned from Vec::into_raw_parts{,_with_alloc} 2024-02-26 19:32:32 +00:00
许杰友 Jieyou Xu (Joe)
26bdf2900a
Rearrange String::from_raw_parts doc argument order to match code argument order 2024-02-26 19:32:26 +00:00
许杰友 Jieyou Xu (Joe)
a1b93e8fed
Rearrange Vec::from_raw_parts{,_in} doc argument order to match code argument order 2024-02-26 19:32:17 +00:00
y21
fd85db3636 restructure lint code, update description, more cases 2024-02-26 20:24:46 +01:00
y21
cfddd91c91 [read_line_without_trim]: catch string eq checks 2024-02-26 20:19:15 +01:00
Ibraheem Ahmed
580b003edd
fix race between block initialization and receiver disconnection 2024-02-26 13:53:35 -05:00
bors
1c5094878b Auto merge of #12342 - lucarlig:empty-docs, r=llogiq
Empty docs

Fixes https://github.com/rust-lang/rust-clippy/issues/9931

changelog: [`empty_doc`]: Detects documentation that is empty.
changelog: Doc comment lints now trigger for struct field and enum variant documentation
2024-02-26 18:03:13 +00:00
bors
d71899573a Auto merge of #12355 - Ethiraric:fix-11927, r=Alexendoo
[`box_default`]: Preserve required path segments

When encountering code such as:
```rs
Box::new(outer::Inner::default())
```
clippy would suggest replacing with `Box::<Inner>::default()`, dropping the `outer::` segment. This behavior is incorrect and that commit fixes it.

What it does is it checks the contents of the `Box::new` and, if it is of the form `A::B::default`, does a text replacement, inserting `A::B` in the `Box`'s quickfix generic list.
If the source does not match that pattern (including `Vec::from(..)` or other `T::new()` calls), we then fallback to the original code.

Fixes #11927

*Please write a short comment explaining your change (or "none" for internal only changes)*

changelog: [`box_default`]: Preserve required path segments
2024-02-26 17:25:43 +00:00
bors
829308e9af Auto merge of #121636 - matthiaskrgr:rollup-1tt2o5n, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #121389 (llvm-wrapper: fix few warnings)
 - #121493 (By changing some attributes to only_local, reducing encoding attributes in the crate metadate.)
 - #121615 (Move `emit_stashed_diagnostic` call in rustfmt.)
 - #121617 (Actually use the right closure kind when checking async Fn goals)
 - #121628 (Do not const prop unions)
 - #121629 (fix some references to no-longer-existing ReprOptions.layout_seed)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-02-26 17:14:13 +00:00
rustbot
67bd410cac Update books 2024-02-26 12:00:42 -05:00
Ethiraric
97dc4b22c6 [box_default]: Preserve required path segments
When encountering code such as:
```
Box::new(outer::Inner::default())
```
clippy would suggest replacing with `Box::<Inner>::default()`, dropping
the `outer::` segment. This behavior is incorrect and that commit fixes
it.

What it does is it checks the contents of the `Box::new` and, if it is
of the form `A::B::default`, does a text replacement, inserting `A::B`
in the `Box`'s quickfix generic list.
If the source does not match that pattern (including `Vec::from(..)`
or other `T::new()` calls), we then fallback to the original code.

Fixes #11927
2024-02-26 17:39:00 +01:00