Commit Graph

255560 Commits

Author SHA1 Message Date
León Orell Valerian Liehr 06bc4fc671
Remove `LintDiagnostic::msg`
* instead simply set the primary message inside the lint decorator functions
* it used to be this way before [#]101986 which introduced `msg` to prevent
  good path delayed bugs (which no longer exist) from firing under certain
  circumstances when lints were suppressed / silenced
* this is no longer necessary for various reasons I presume
* it shaves off complexity and makes further changes easier to implement
2024-05-23 04:08:35 +02:00
León Orell Valerian Liehr 366ef95407
Slightly clean up some lint infra code
* inline `LintBuffer::add_lint`, it only had a single use
* update a lint infra example code snippet
  * it used the wrong API (the snippet isn't tested)
  * presumably the arguments were updated from builder to diag struct style
    at some point without updating the method
2024-05-23 03:21:12 +02:00
bors b54dd08a84 Auto merge of #125326 - weiznich:move/do_not_recommend_to_diganostic_namespace, r=compiler-errors
Move `#[do_not_recommend]` to the `#[diagnostic]` namespace

This commit moves the `#[do_not_recommend]` attribute to the `#[diagnostic]` namespace. It still requires
`#![feature(do_not_recommend)]` to work.

r? `@compiler-errors`
2024-05-22 04:14:08 +00:00
bors 54cdc13542 Auto merge of #125387 - weihanglo:update-cargo, r=weihanglo
Update cargo

9 commits in 0de7f2ec6c39d68022e6b97a39559d2f4dbf3930..84dc5dc11a9007a08f27170454da6097265e510e
2024-05-17 16:54:54 +0000 to 2024-05-20 18:57:08 +0000
- Fix warning about unused Permissions (rust-lang/cargo#13938)
- fix: support IPv6-only network for cargo fix (rust-lang/cargo#13907)
- Load `libsecret` by its `SONAME`, `libsecret-1.so.0` (rust-lang/cargo#13927)
- docs(ref): Simplify check-cfg build.rs docs (rust-lang/cargo#13937)
- Make `git::use_the_cli` test truly locale independent (rust-lang/cargo#13935)
- Silence warnings running embedded unittests. (rust-lang/cargo#13929)
- Fix warning output in build_with_symlink_to_path_dependency_with_build_script_in_git (rust-lang/cargo#13930)
- Fix:  Make path dependencies with the same name stays locked (rust-lang/cargo#13572)
- Temporarily fix standard_lib tests on linux. (rust-lang/cargo#13931)

r? ghost
2024-05-22 02:03:23 +00:00
bors 72d8d8d9f9 Auto merge of #125202 - flip1995:clippy-subtree-update, r=Manishearth
Clippy subtree update

r? `@Manishearth`
2024-05-21 23:55:52 +00:00
Weihang Lo 09f1a90bf8
Update cargo 2024-05-21 18:53:54 -04:00
bors 791adf759c Auto merge of #124417 - Xiretza:translate-early-lints, r=fmease
Make early lints translatable

<del>Requires https://github.com/projectfluent/fluent-rs/pull/353.</del> 5134a04eaa

r? diagnostics
2024-05-21 21:36:09 +00:00
Xiretza 98dd6c7e8f Rename buffer_lint_with_diagnostic to buffer_lint 2024-05-21 20:16:39 +00:00
Xiretza c4f6502c6d Fix typo in deprecation lint message 2024-05-21 20:16:39 +00:00
Xiretza 8004e6a379 Make early lints translatable 2024-05-21 20:16:39 +00:00
Xiretza b7abf014ec Convert uses of BuiltinLintDiag::Normal to custom variants
This ensures all diagnostic messages are created at diagnostic emission
time, making them translatable.
2024-05-21 20:16:39 +00:00
Xiretza 41a20b4c56 Port DeprecatedMacro to diag structs 2024-05-21 20:16:39 +00:00
Xiretza c227f35a9c Generate lint diagnostic message from BuiltinLintDiag
Translation of the lint message happens when the actual diagnostic is
created, not when the lint is buffered. Generating the message from
BuiltinLintDiag ensures that all required data to construct the message
is preserved in the LintBuffer, eventually allowing the messages to be
moved to fluent.

Remove the `msg` field from BufferedEarlyLint, it is either generated
from the data in the BuiltinLintDiag or stored inside
BuiltinLintDiag::Normal.
2024-05-21 20:16:39 +00:00
Xiretza 2482f3c17c Convert unexpected_cfg_{name,value} to struct diagnostics 2024-05-21 20:16:39 +00:00
Xiretza bac6b6248b Convert NAMED_ASM_LABELS lint to diag struct 2024-05-21 20:11:42 +00:00
Xiretza 36902fbcf6 Fix subdiagnostic-only enum variants not generating code 2024-05-21 20:11:42 +00:00
Xiretza eee14e9adf Add note_once/help_once to diagnostic derives 2024-05-21 20:11:42 +00:00
Xiretza 56bca95875 Implement IntoDiagArg for RustcVersion 2024-05-21 20:11:42 +00:00
Xiretza 3b979aebfe Implement IntoDiagArg for hir Namespace 2024-05-21 20:11:42 +00:00
bors 39e02f1bd1 Auto merge of #125379 - matthiaskrgr:rollup-6149w01, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #123122 (Fix incorrect suggestion for undeclared hrtb lifetimes in where clauses.)
 - #123492 (add pull request template asking for relevant tracking issues)
 - #125276 (Fix parsing of erroneously placed semicolons)
 - #125310 (Move ~100 tests from tests/ui to subdirs)
 - #125357 (Migrate `run-make/rustdoc-scrape-examples-multiple` to `rmake.rs`)
 - #125369 (Don't do cc detection for synthetic targets)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-05-21 19:29:59 +00:00
Matthias Krüger d04e2e2858
Rollup merge of #125369 - saethlin:synthetic-targets-dont-cc, r=onur-ozkan
Don't do cc detection for synthetic targets

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

Synthetic targets only exist for mir-opt tests, and the mir-opt test suite is in general designed to avoid any use of a C compiler. We don't need to do CC detection. It's unclear to me how this code didn't cause issues before.
2024-05-21 20:28:49 +02:00
Matthias Krüger 639853fea5
Rollup merge of #125357 - GuillaumeGomez:migrate-rustdoc-scrape-examples-multiple, r=jieyouxu
Migrate `run-make/rustdoc-scrape-examples-multiple` to `rmake.rs`

Part of https://github.com/rust-lang/rust/issues/121876.

r? ```@jieyouxu```
2024-05-21 20:28:49 +02:00
Matthias Krüger 1b57ef3207
Rollup merge of #125310 - workingjubilee:muck-out-the-test-stables, r=Nilstrieb
Move ~100 tests from tests/ui to subdirs

new dirs for some, the rest in old
sweep tests up before they turn cold
to stop our code from growing mold
2024-05-21 20:28:48 +02:00
Matthias Krüger bfa98d318f
Rollup merge of #125276 - dev-ardi:no-main-diag, r=fmease
Fix parsing of erroneously placed semicolons

This closes https://github.com/rust-lang/rust/issues/124935, is a continuation of https://github.com/rust-lang/rust/pull/125245 after rebasing https://github.com/rust-lang/rust/pull/125117.

Thanks ```@gurry``` for your code and sorry for making it confusing :P

r? fmease
2024-05-21 20:28:47 +02:00
Matthias Krüger 7a90db7fb1
Rollup merge of #123492 - lcnr:master, r=davidtwco
add pull request template asking for relevant tracking issues

As mentioned at RustNation, I would like to remind PR authors to link to relevant tracking issues when opening PRs as it is otherwise very easy to forget doing so.

There's a certain amount of conflict between making the template as small as possible while still being clear for new contributors. I am very much open to changes here but really want to try this out.

Also unsure how much formal buy-in we need here. Maybe merge this pinging t-compiler and t-libs, and then ask how people feel about this on zulip in a few weeks?

r? `@davidtwco`
2024-05-21 20:28:47 +02:00
Matthias Krüger 6009cb776a
Rollup merge of #123122 - surechen:fix_122714, r=fmease
Fix incorrect suggestion for undeclared hrtb lifetimes in where clauses.

For poly-trait-ref like `for<'a> Trait<T>`   in  `T: for<'a> Trait<T> + 'b { }`.
We should merge the hrtb lifetimes: existed `for<'a>` and suggestion `for<'b>` or will get err: [E0316] nested quantification of lifetimes

fixes #122714
2024-05-21 20:28:46 +02:00
Philipp Krones bb1481a72a
Merge commit '2efebd2f0c03dabbe5c3ad7b4ebfbd99238d1fb2' into clippy-subtree-update 2024-05-21 10:39:30 -07:00
bors 506512391b Auto merge of #124676 - djkoloski:relax_multiple_sanitizers, r=cuviper,rcvalle
Relax restrictions on multiple sanitizers

Most combinations of LLVM sanitizers are legal-enough to enable simultaneously. This change will allow simultaneously enabling ASAN and shadow call stacks on supported platforms.

I used this python script to generate the mutually-exclusive sanitizer combinations:

```python
#!/usr/bin/python3

import subprocess

flags = [
    ["-fsanitize=address"],
    ["-fsanitize=leak"],
    ["-fsanitize=memory"],
    ["-fsanitize=thread"],
    ["-fsanitize=hwaddress"],
    ["-fsanitize=cfi", "-flto", "-fvisibility=hidden"],
    ["-fsanitize=memtag", "--target=aarch64-linux-android", "-march=armv8a+memtag"],
    ["-fsanitize=shadow-call-stack"],
    ["-fsanitize=kcfi", "-flto", "-fvisibility=hidden"],
    ["-fsanitize=kernel-address"],
    ["-fsanitize=safe-stack"],
    ["-fsanitize=dataflow"],
]

for i in range(len(flags)):
    for j in range(i):
        command = ["clang++"] + flags[i] + flags[j] + ["-o", "main.o", "-c", "main.cpp"]
        completed = subprocess.run(command, stderr=subprocess.DEVNULL)
        if completed.returncode != 0:
            first = flags[i][0][11:].replace('-', '').upper()
            second = flags[j][0][11:].replace('-', '').upper()
            print(f"(SanitizerSet::{first}, SanitizerSet::{second}),")
```
2024-05-21 15:35:29 +00:00
Ben Kimock 51cf3815ce Don't do cc detection for synthetic targets 2024-05-21 11:24:19 -04:00
bors 6715446db6 Auto merge of #125358 - matthiaskrgr:rollup-mx841tg, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #124570 (Miscellaneous cleanups)
 - #124772 (Refactor documentation for Apple targets)
 - #125011 (Add opt-for-size core lib feature flag)
 - #125218 (Migrate `run-make/no-intermediate-extras` to new `rmake.rs`)
 - #125225 (Use functions from `crt_externs.h` on iOS/tvOS/watchOS/visionOS)
 - #125266 (compiler: add simd_ctpop intrinsic)
 - #125348 (Small fixes to `std::path::absolute` docs)

Failed merges:

 - #125296 (Fix `unexpected_cfgs` lint on std)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-05-21 12:50:09 +00:00
bors 2efebd2f0c Auto merge of #12765 - yusufraji:while-float, r=llogiq
Add new lint `while_float`

This PR adds a nursery lint that checks for while loops comparing floating point values.

changelog:
```
changelog: [`while_float`]: Checks for while loops comparing floating point values.
```

Fixes #758
2024-05-21 11:36:31 +00:00
Georg Semmler 2cff3e90bc
Move `#[do_not_recommend]` to the `#[diagnostic]` namespace
This commit moves the `#[do_not_recommend]` attribute to the
`#[diagnostic]` namespace. It still requires
`#![feature(do_not_recommend)]` to work.
2024-05-21 13:14:41 +02:00
Matthias Krüger e6e05d51ec
Rollup merge of #125348 - tbu-:pr_doc_path_absolute, r=jhpratt
Small fixes to `std::path::absolute` docs
2024-05-21 12:47:07 +02:00
Matthias Krüger fd975f75fa
Rollup merge of #125266 - workingjubilee:stream-plastic-love, r=RalfJung,nikic
compiler: add simd_ctpop intrinsic

Fairly straightforward addition.

cc `@rust-lang/opsem` new (extremely boring) intrinsic
2024-05-21 12:47:06 +02:00
Matthias Krüger a8ee8d5086
Rollup merge of #125225 - madsmtm:ios-crt_externs.h, r=workingjubilee
Use functions from `crt_externs.h` on iOS/tvOS/watchOS/visionOS

Use `_NSGetEnviron`, `_NSGetArgc` and `_NSGetArgv` on iOS/tvOS/watchOS/visionOS, see each commit and the code comments for details. This allows us to unify more code with the macOS implementation, as well as avoiding linking to the `Foundation` framework (which is good for startup performance).

The biggest problem with doing this would be if it lead to App Store rejections. After doing a bunch of research on this, while [it did happen once in 2009](https://blog.unity.com/engine-platform/unity-app-store-submissions-problem-solved), I find it fairly unlikely to happen nowadays, especially considering that Apple has later _added_ `crt_externs.h` to the iOS/tvOS/watchOS/visionOS SDKs, strongly signifying the functions therein is indeed supported on those platforms (even though they lack an availability attribute).

That we've been overly cautious here has also been noted by `@thomcc` in https://github.com/rust-lang/rust/pull/117910#issuecomment-1903372350.

r? `@workingjubilee`

`@rustbot` label O-apple
2024-05-21 12:47:05 +02:00
Matthias Krüger 7ef533bce6
Rollup merge of #125218 - Oneirical:easy-test-the-third, r=jieyouxu
Migrate `run-make/no-intermediate-extras` to new `rmake.rs`

Part of #121876 and the associated [Google Summer of Code project](https://blog.rust-lang.org/2024/05/01/gsoc-2024-selected-projects.html).
2024-05-21 12:47:05 +02:00
Matthias Krüger 4abf179b14
Rollup merge of #125011 - diondokter:opt-for-size, r=Amanieu,kobzol
Add opt-for-size core lib feature flag

Adds a feature flag to the core library that enables the possibility to have smaller implementations for certain algorithms.

So far, the core lib has traded performance for binary size. This is likely what most people want since they have big simd-capable machines. However, people on small machines, like embedded devices, don't enjoy the potential speedup of the bigger algorithms, but do have to pay for them. These microcontrollers often only have 16-1024kB of flash memory.

This PR is the result of some talks with project members like `@Amanieu` at RustNL.
There are some open questions of how this is eventually stabilized, but it's a similar question as with the existing `panic_immediate_abort` feature.

Speaking as someone from the embedded side, we'd rather have this unstable for a while as opposed to not having it at all. In the meantime we can try to use it and also add additional PRs to the core lib that uses the feature flag in areas where we find benefit.

Open questions from my side:
- Is this a good feature name?
  - `panic_immediate_abort` is fairly verbose, so I went with something equally verbose
  - It's easy to refactor later
- I've added the feature to `std` and `alloc` as well as they might benefit too. Do we agree?
  - I expect these to get less usage out of the flag since most size-constraint projects don't use these libraries often.
2024-05-21 12:47:04 +02:00
Matthias Krüger 4a4883bfb7
Rollup merge of #124772 - madsmtm:apple-platform-support-docs, r=oli-obk
Refactor documentation for Apple targets

Refactor the documentation for Apple targets in `rustc`'s platform support page to make it clear what the supported OS version is and which environment variables are being read (`*_DEPLOYMENT_TARGET` and `SDKROOT`). This fixes https://github.com/rust-lang/rust/issues/124215.

Note that I've expanded the `aarch64-apple-ios-sim` maintainers `@badboy` and `@deg4uss3r` to include being maintainer of all `*-apple-ios-*` targets. If you do not wish to be so, please state that, then I'll explicitly note that in the docs.

Additionally, I've added myself as co-maintainer of most of these targets.

r? `@thomcc`

I think the documentation you've previously written on tvOS is great, have mostly modified it to have a more consistent formatting with the rest of the Apple target.

I recognize that there's quite a few changes here, feel free to ask about any of them!

---

CC `@simlay` `@Nilstrieb`

`@rustbot` label O-apple
2024-05-21 12:47:04 +02:00
Matthias Krüger df59800b08
Rollup merge of #124570 - nnethercote:misc-cleanups, r=michaelwoerister
Miscellaneous cleanups

A mix of small cleanups made while looking at various things.

r? `@wesleywiser`
2024-05-21 12:47:03 +02:00
bors e8fbd99128 Auto merge of #124097 - compiler-errors:box-into-iter, r=WaffleLapkin
Add `IntoIterator` for `Box<[T]>` + edition 2024-specific lints

* Adds a similar method probe opt-out mechanism to the `[T;N]: IntoIterator` implementation for edition 2021.
* Adjusts the relevant lints (shadowed `.into_iter()` calls, new source of method ambiguity).
* Adds some tests.
* Took the liberty to rework the logic in the `ARRAY_INTO_ITER` lint, since it was kind of confusing.

Based mostly off of #116607.

ACP: rust-lang/libs-team#263
References #59878
Tracking for Rust 2024: https://github.com/rust-lang/rust/issues/123759

Crater run was done here: https://github.com/rust-lang/rust/pull/116607#issuecomment-1770293013
Consensus afaict was that there is too much breakage, so let's do this in an edition-dependent way much like `[T; N]: IntoIterator`.
2024-05-21 10:13:53 +00:00
Guillaume Gomez f8c992f8b4 Migrate `run-make/rustdoc-scrape-examples-multiple` to `rmake.rs` 2024-05-21 12:11:17 +02:00
bors e875391458 Auto merge of #123812 - compiler-errors:additional-fixes, r=fmease
Follow-up fixes to `report_return_mismatched_types`

Some renames, simplifications, fixes, etc. Follow-ups to #123804. I don't think it totally disentangles this code, but it does remove some of the worst offenders on the "I am so confused" scale (e.g. `get_node_fn_decl`).
2024-05-21 08:06:41 +00:00
bors 1d0e4afd4c Auto merge of #125298 - tesuji:arrcmp, r=nikic
Add codegen test for array comparision opt

Fixed since rust 1.55
closes #62531
2024-05-21 05:55:39 +00:00
Nicholas Nethercote 3ac816a1ca Sort `rustc_middle` attributes.
As is already done in several other crates, such as `rustc_errors`.
2024-05-21 14:56:57 +10:00
Nicholas Nethercote ac847b2583 Remove unused features from `rustc_middle`. 2024-05-21 14:56:57 +10:00
Nicholas Nethercote c1d5b6a480 Remove erroneous comment.
The comment was originally in `src/librustc_mir/lib.rs`, but now that
it's in `compiler/rustc_const_eval/src/lib.rs` it's no longer
appropriate.
2024-05-21 14:56:57 +10:00
Nicholas Nethercote ce222328d7 Minor `pub` and whitespace cleanups. 2024-05-21 14:56:57 +10:00
Nicholas Nethercote d8ea468994 Reorder some `use` items. 2024-05-21 14:55:37 +10:00
Nicholas Nethercote eb10eb2b45 Reorder top-level attributes.
And remove an unnecessary `feature(try_blocks)`.
2024-05-21 14:55:37 +10:00
Jubilee Young d89500843c Move 100 entries from tests/ui into subdirs
- Move super-fast-paren-parsing test into ui/parser
- Move stmt_expr_attrs test into ui/feature-gates
- Move macro tests into ui/macros
- Move global_asm tests into ui/asm
- Move env tests into ui/process
- Move xcrate tests into ui/cross-crate
- Move unop tests into ui/unop
- Move backtrace tests into ui/backtrace
- Move check-static tests into ui/statics
- Move expr tests into ui/expr
- Move optimization fuel tests into ui/fuel
- Move ffi attribute tests into ui/ffi-attrs
- Move suggestion tests into ui/suggestions
- Move main tests into ui/fn-main
- Move lint tests into ui/lint
- Move repr tests into ui/repr
- Move intrinsics tests into ui/intrinsics
- Move tool lint tests into ui/tool-attributes
- Move return tests into ui/return
- Move pattern tests into ui/patttern
- Move range tests into ui/range
- Move foreign-fn tests into ui/foreign
- Move orphan-check tests into ui/coherence
- Move inference tests into ui/inference
- Reduce ROOT_ENTRY_LIMIT
2024-05-20 19:55:59 -07:00