Commit Graph

1869 Commits

Author SHA1 Message Date
Matthias Krüger
fdcd05178d
Rollup merge of #121860 - mu001999:master, r=Nilstrieb
Add a tidy check that checks whether the fluent slugs only appear once

As ``````@Nilstrieb`````` said in https://github.com/rust-lang/rust/pull/121828#issuecomment-1972622855:
> Might make sense to have a tidy check that checks whether the fluent slugs only appear once in the source code and lint for that
there's a tidy check already for sorting

We can get the tidy check error:
```
tidy check
tidy error: /path/to/rust/compiler/rustc_const_eval/messages.ftl: message `const_eval_invalid_align` is not used
tidy error: /path/to/rust/compiler/rustc_lint/messages.ftl: message `lint_trivial_untranslatable_diag` is not used
tidy error: /path/to/rust/compiler/rustc_parse/messages.ftl: message `parse_invalid_literal_suffix` is not used
tidy error: /path/to/rust/compiler/rustc_infer/messages.ftl: message `infer_need_type_info_in_coroutine` is not used
tidy error: /path/to/rust/compiler/rustc_passes/messages.ftl: message `passes_expr_not_allowed_in_context` is not used
tidy error: /path/to/rust/compiler/rustc_passes/messages.ftl: message `passes_layout` is not used
tidy error: /path/to/rust/compiler/rustc_parse/messages.ftl: message `parse_not_supported` is not used
```

r? ``````@Nilstrieb``````
2024-03-10 10:58:16 +01:00
Matthias Krüger
a979f971b4
Rollup merge of #121813 - Urgau:misc-non_local_defs-lint, r=cjgillot
Misc improvements to non local defs lint implementation

This PR is a collection of small improvements I found when I [needlessly tried](https://www.github.com/rust-lang/rust/pull/120393#issuecomment-1971787475) to fix a "perf-regression" in the lint implementation.

I recommend looking at each commit individually.
2024-03-09 16:21:15 +01:00
Matthias Krüger
a08a5d4292
Rollup merge of #122181 - chenyukang:yukang-fix-late-lint-crash, r=oli-obk
Fix crash in internal late lint checking

Fixes #122177
2024-03-08 13:22:28 +01:00
Matthias Krüger
3e634f8c5c
Rollup merge of #121563 - Jarcho:use_cf, r=petrochenkov
Use `ControlFlow` in visitors.

Follow up to #121256

This does have a few small behaviour changes in some diagnostic output where the visitor will now find the first match rather than the last match. The change in `find_anon_types.rs` has the only affected test. I don't see this being an issue as the last occurrence isn't any better of a choice than the first.
2024-03-08 13:22:26 +01:00
yukang
c81521ae54 Fix crash in late internal checking 2024-03-08 19:00:53 +08:00
Urgau
98dbe9abac Use was_invoked_from_cargo method instead of hand-written one 2024-03-07 07:54:15 +01:00
Urgau
6c4eadd747 Add early-return when checking if a path is local 2024-03-07 07:54:15 +01:00
Urgau
20200f65ca Remove useless smallvec dependency in rustc_lint::non_local_def 2024-03-07 07:54:15 +01:00
bors
aa029ce4d8 Auto merge of #122113 - matthiaskrgr:rollup-5d1jnwi, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #121958 (Fix redundant import errors for preload extern crate)
 - #121976 (Add an option to have an external download/bootstrap cache)
 - #122022 (loongarch: add frecipe and relax target feature)
 - #122026 (Do not try to format removed files)
 - #122027 (Uplift some feeding out of `associated_type_for_impl_trait_in_impl` and into queries)
 - #122063 (Make the lowering of `thir::ExprKind::If` easier to follow)
 - #122074 (Add missing PartialOrd trait implementation doc for array)
 - #122082 (remove outdated fixme comment)
 - #122091 (Note why we're using a new thread in `test_get_os_named_thread`)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-03-07 02:30:40 +00:00
Matthias Krüger
1d4360a621
Rollup merge of #122107 - Urgau:non_local_def-allow, r=WaffleLapkin
Temporarily make allow-by-default the `non_local_definitions` lint

T-lang [decided in their triage meeting](https://hackmd.io/U-CKiZx_RKiaANAPXtWf7g#non_local_definitions-common-issues-impl-for-ampLocal-FromltLocalgt-for-Global-%E2%80%A6-rust121621) to try to use a [better logic](https://github.com/rust-lang/rust/issues/121621#issuecomment-1976826895) for detecting non-local `impl` definitions given the [numerous reports](https://github.com/rust-lang/rust/issues/121621) we got.

Until that is done and also because the beta cut is next week, switch the lint to allow-by-default until it's implemented.

r? `@WaffleLapkin`
2024-03-07 00:57:42 +01:00
Urgau
6fc45b84ac Temporarily make allow-by-default the non_local_definitions lint 2024-03-06 22:24:25 +01:00
Matthias Krüger
efe9deace8
Rollup merge of #121382 - nnethercote:rework-untranslatable_diagnostic-lint, r=davidtwco
Rework `untranslatable_diagnostic` lint

Currently it only checks calls to functions marked with `#[rustc_lint_diagnostics]`. This PR changes it to check calls to any function with an `impl Into<{D,Subd}iagnosticMessage>` parameter. This greatly improves its coverage and doesn't rely on people remembering to add `#[rustc_lint_diagnostics]`. It also lets us add `#[rustc_lint_diagnostics]` to a number of functions that don't have an `impl Into<{D,Subd}iagnosticMessage>`, such as `Diag::span`.

r? ``@davidtwco``
2024-03-06 22:02:46 +01:00
yukang
5a4ff2779e Fix redundant import errors for preload extern crate 2024-03-06 21:29:33 +08:00
Nicholas Nethercote
b7d58eef4b Rewrite the untranslatable_diagnostic lint.
Currently it only checks calls to functions marked with
`#[rustc_lint_diagnostics]`. This commit changes it to check calls to
any function with an `impl Into<{D,Subd}iagMessage>` parameter. This
greatly improves its coverage and doesn't rely on people remembering to
add `#[rustc_lint_diagnostics]`.

The commit also adds `#[allow(rustc::untranslatable_diagnostic)`]
attributes to places that need it that are caught by the improved lint.
These places that might be easy to convert to translatable diagnostics.

Finally, it also:
- Expands and corrects some comments.
- Does some minor formatting improvements.
- Adds missing `DecorateLint` cases to
  `tests/ui-fulldeps/internal-lints/diagnostics.rs`.
2024-03-06 14:19:01 +11:00
bors
62415e2a95 Auto merge of #122041 - matthiaskrgr:rollup-imsmdke, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #121202 (Limit the number of names and values in check-cfg diagnostics)
 - #121301 (errors: share `SilentEmitter` between rustc and rustfmt)
 - #121658 (Hint user to update nightly on ICEs produced from outdated nightly)
 - #121846 (only compare ambiguity item that have hard error)
 - #121961 (add test for #78894 #71450)
 - #121975 (hir_analysis: enums return `None` in `find_field`)
 - #121978 (Fix duplicated path in the "not found dylib" error)
 - #121991 (Merge impl_trait_in_assoc_types_defined_by query back into `opaque_types_defined_by`)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-03-06 00:03:50 +00:00
Jason Newcomb
e760c44063 Use ControlFlow in AST visitors. 2024-03-05 19:03:20 -05:00
Jason Newcomb
be9b125d41 Convert TypeVisitor and DefIdVisitor to use VisitorResult 2024-03-05 13:28:15 -05:00
Jason Newcomb
5abfb3775d Move visitor utils to rustc_ast_ir 2024-03-05 12:38:03 -05:00
Urgau
9d9b26bca9 Limit the number of names and values in check-cfg diagnostics 2024-03-05 07:54:04 +01:00
bors
1547c076bf Auto merge of #121780 - nnethercote:diag-renaming2, r=davidtwco
Diagnostic renaming 2

A sequel to #121489.

r? `@davidtwco`
2024-03-05 02:58:34 +00:00
Nicholas Nethercote
7aa0eea19c Rename BuiltinLintDiagnostics as BuiltinLintDiag.
Not the dropping of the trailing `s` -- this type describes a single
diagnostic and its name should be singular.
2024-03-05 12:15:10 +11:00
Nicholas Nethercote
573267cf3c Rename SubdiagnosticMessageOp as SubdiagMessageOp. 2024-03-05 12:14:49 +11:00
Nicholas Nethercote
60ea6e2831 Rename SubdiagnosticMessage as SubdiagMessage. 2024-03-05 12:14:49 +11:00
Nicholas Nethercote
18715c98c6 Rename DiagnosticMessage as DiagMessage. 2024-03-05 12:14:49 +11:00
bors
2eeff462b7 Auto merge of #120675 - oli-obk:intrinsics3.0, r=pnkfelix
Add a scheme for moving away from `extern "rust-intrinsic"` entirely

All `rust-intrinsic`s can become free functions now, either with a fallback body, or with a dummy body and an attribute, requiring backends to actually implement the intrinsic.

This PR demonstrates the dummy-body scheme with the `vtable_size` intrinsic.

cc https://github.com/rust-lang/rust/issues/63585

follow-up to #120500

MCP at https://github.com/rust-lang/compiler-team/issues/720
2024-03-05 00:13:01 +00:00
Matthias Krüger
13b971209a
Rollup merge of #121969 - nnethercote:ParseSess-cleanups, r=wesleywiser
`ParseSess` cleanups

The main change here is to rename all `ParseSess` values as `psess`. Plus a few other small cleanups.

r? `@wesleywiser`
2024-03-04 22:16:33 +01:00
Nicholas Nethercote
80d2bdb619 Rename all ParseSess variables/fields/lifetimes as psess.
Existing names for values of this type are `sess`, `parse_sess`,
`parse_session`, and `ps`. `sess` is particularly annoying because
that's also used for `Session` values, which are often co-located, and
it can be difficult to know which type a value named `sess` refers to.
(That annoyance is the main motivation for this change.) `psess` is nice
and short, which is good for a name used this much.

The commit also renames some `parse_sess_created` values as
`psess_created`.
2024-03-05 08:11:45 +11:00
Oli Scherer
aa2ae6b491 Add is_intrinsic helper 2024-03-04 16:13:50 +00:00
Matthias Krüger
10234fc246
Rollup merge of #121749 - jieyouxu:issue-45127-fix, r=petrochenkov
Don't lint on executable crates with `non_snake_case` names

Revives #111130, cc `@GilShoshan94.`
Closes #45127.
2024-03-03 22:56:13 +01:00
r0cky
d88c7ffc62 Remove unused fluent messages 2024-03-03 00:57:45 +08:00
许杰友 Jieyou Xu (Joe)
d363db71f8
Hoist only-executables check above producing crate ident 2024-03-01 19:16:02 +00:00
Matthias Krüger
58825b4ea9
Rollup merge of #121580 - Suyashtnt:issue-121502-fix, r=michaelwoerister
make unused_imports less assertive in test modules

closes #121502

This is a fairly small change and I used the fix suggested in the example expected error message.
Not sure if I should've rather used the alternatives but this one seems the most descriptive.

Some alternatives:
- if this is meant to be a test module, add `#[cfg(test)]` to the containing module
- try adding #[cfg(test)] to this test module
- consider adding #[allow(unused_imports)] if you want to silent the lint on the unused import
- consider removing the unused import
2024-03-01 17:51:29 +01:00
bors
6cbf0926d5 Auto merge of #121728 - tgross35:f16-f128-step1-ty-updates, r=compiler-errors
Add stubs in IR and ABI for `f16` and `f128`

This is the very first step toward the changes in https://github.com/rust-lang/rust/pull/114607 and the [`f16` and `f128` RFC](https://rust-lang.github.io/rfcs/3453-f16-and-f128.html). It adds the types to `rustc_type_ir::FloatTy` and `rustc_abi::Primitive`, and just propagates those out as `unimplemented!` stubs where necessary.

These types do not parse yet so there is no feature gate, and it should be okay to use `unimplemented!`.

The next steps will probably be AST support with parsing and the feature gate.

r? `@compiler-errors`
cc `@Nilstrieb` suggested breaking the PR up in https://github.com/rust-lang/rust/pull/120645#issuecomment-1925900572
2024-03-01 03:36:11 +00:00
Matthias Krüger
dd4ecd1cf4
Rollup merge of #121326 - fmease:detect-empty-leading-where-clauses-on-ty-aliases, r=compiler-errors
Detect empty leading where clauses on type aliases

1. commit: refactor the AST of type alias where clauses
   * I could no longer bear the look of `.0.1` and `.1.0`
   * Arguably moving `split` out of `TyAlias` into a substruct might not make that much sense from a semantic standpoint since it reprs an index into `TyAlias.predicates` but it's alright and it cleans up the usage sites of `TyAlias`
2. commit: fix an oversight: An empty leading where clause is still a leading where clause
   * semantically reject empty leading where clauses on lazy type aliases
     * e.g., on `#![feature(lazy_type_alias)] type X where = ();`
   * make empty leading where clauses on assoc types trigger lint `deprecated_where_clause_location`
     * e.g., `impl Trait for () { type X where = (); }`
2024-02-29 20:50:02 +01:00
León Orell Valerian Liehr
cce81289e6
Detect empty leading where-clauses on type aliases 2024-02-29 17:20:04 +01:00
Nicholas Nethercote
b4e9f93eb4 Mark some once-again-unreachable paths as unreachable.
This undoes the changes from #121482 and #121586, now that stashed errors
will trigger more early aborts.
2024-02-29 11:08:29 +11:00
bors
c475e2303b Auto merge of #121489 - nnethercote:diag-renaming, r=davidtwco
Diagnostic renaming

Renaming various diagnostic types from `Diagnostic*` to `Diag*`. Part of https://github.com/rust-lang/compiler-team/issues/722. There are more to do but this is enough for one PR.

r? `@davidtwco`
2024-02-28 20:39:38 +00:00
Trevor Gross
e3f63d9375 Add f16 and f128 to rustc_type_ir::FloatTy and rustc_abi::Primitive
Make changes necessary to support these types in the compiler.
2024-02-28 12:58:32 -05:00
Gil Shoshan
bf8756d2dd
Don't lint snake-case on executable crate name
Co-authored-by: Jieyou Xu <jieyouxu@outlook.com>
2024-02-28 16:55:00 +00:00
Nicholas Nethercote
5e29e26b96 Remove the UntranslatableDiagnosticTrivial lint.
It's a specialized form of the `UntranslatableDiagnostic` lint that is
deny-by-default.

Now that `UntranslatableDiagnostic` has been changed from
allow-by-default to deny-by-default, the trivial variant is no longer
needed.
2024-02-28 10:53:04 +11:00
Nicholas Nethercote
9b3520e876 Rename DiagnosticStyledString as DiagStyledString. 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
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
bors
b79db437dc Auto merge of #120586 - ShE3py:exprkind-err, r=fmease
Add `ErrorGuaranteed` to `ast::ExprKind::Err`

See #119967 for context
```
      \
       \
          _~^~^~_
      \) /  o o  \ (/
        '_   -   _'
        / '-----' \
```

r? fmease
2024-02-26 14:43:15 +00:00
Guillaume Gomez
91d337dfa8
Rollup merge of #120840 - HTGAzureX1212:HTGAzureX1212/unicode-identifier-types, r=fmease,Manishearth
Split Diagnostics for Uncommon Codepoints: Add Individual Identifier Types

This pull request further modifies the `uncommon_codepoints` lint, adding the individual identifier types of `Technical`, `Not_NFKC`, `Exclusion` and `Limited_Use` to the diagnostic message.

Example rendered diagnostic:
```
error: identifier contains a Unicode codepoint that is not used in normalized strings: 'ij'
  --> $DIR/lint-uncommon-codepoints.rs:6:4
   |
LL | fn dijkstra() {}
   |    ^^^^^^^
   = note: this character is included in the Not_NFKC Unicode general security profile
```

Second step of #120228.
2024-02-26 10:27:41 +01:00
HTGAzureX1212.
8bccceb8fc separate messages for individual categories 2024-02-26 10:09:03 +08:00
Lieselotte
c440a5b814
Add ErrorGuaranteed to ast::ExprKind::Err 2024-02-25 22:24:31 +01:00
bors
b0d3e04ca9 Auto merge of #120393 - Urgau:rfc3373-non-local-defs, r=WaffleLapkin
Implement RFC 3373: Avoid non-local definitions in functions

This PR implements [RFC 3373: Avoid non-local definitions in functions](https://github.com/rust-lang/rust/issues/120363).
2024-02-25 19:11:06 +00:00
Matthias Krüger
a4423884c1
Rollup merge of #121586 - gurry:121532-ice-unwrap-on-none, r=cjgillot
Don't use `unwrap()` in `ArrayIntoIter` lint when typeck fails

Fixes #121532
2024-02-25 17:05:23 +01:00
Matthias Krüger
7c88ea2842
Rollup merge of #121060 - clubby789:bool-newtypes, r=cjgillot
Add newtypes for bool fields/params/return types

Fixed all the cases of this found with some simple searches for `*/ bool` and `bool /*`; probably many more
2024-02-25 17:05:20 +01:00