Commit Graph

1004 Commits

Author SHA1 Message Date
cui fliter 442f848d74 fix some typos in comments
Signed-off-by: cui fliter <imcusg@gmail.com>
2022-11-13 15:26:17 +08:00
bors 825f8edc2f Auto merge of #103530 - cjgillot:hir-lifetimes-direct, r=estebank
Resolve lifetimes independently for each item-like.

Now that the heavy-lifting is done on the AST and during lowering, we do not need to perform HIR lifetime resolution on a full item at once.  Instead, we can treat each item-like independently, and look at `generics_of` the parent exceptionally for associated items.
2022-11-12 05:22:17 +00:00
bors 42325c525b Auto merge of #104293 - Manishearth:rollup-xj92d0k, r=Manishearth
Rollup of 8 pull requests

Successful merges:

 - #95292 (Allow specialized const trait impls.)
 - #100386 (Make `Sized` coinductive, again)
 - #102215 (Implement the `+whole-archive` modifier for `wasm-ld`)
 - #103468 (Fix unused lint and parser caring about spaces to won't produce invalid code)
 - #103531 (Suggest calling the instance method of the same name when method not found)
 - #103960 (piece of diagnostic migrate)
 - #104051 (update Miri)
 - #104129 (rustdoc: use javascript to layout notable traits popups)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-11-11 20:11:07 +00:00
Manish Goregaokar fd5ff82f28
Rollup merge of #103468 - chenyukang:yukang/fix-103435-extra-parentheses, r=estebank
Fix unused lint and parser caring about spaces to won't produce invalid code

Fixes #103435
2022-11-11 12:12:29 -05:00
Camille GILLOT 0ff1d1e122 Tweak signatures in rustc_middle::hir::map. 2022-11-11 10:10:16 +00:00
Esteban Küber 8bd8484972 review comments 2022-11-10 18:06:59 -08:00
Esteban Küber 243496e129 Consider `#[must_use]` annotation on `async fn` as also affecting the `Future::Output`
No longer lint against `#[must_use] async fn foo()`.

When encountering a statement that awaits on a `Future`, check if the
`Future`'s parent item is annotated with `#[must_use]` and emit a lint
if so. This effectively makes `must_use` an annotation on the
`Future::Output` instead of only the `Future` itself.

Fix #78149.
2022-11-10 18:01:03 -08:00
Esteban Küber 50bb7a40e1 Tweak span for `#[must_use]`
Do not point at whole statement, only at the expression (skip pointing at `;`)
2022-11-10 18:01:02 -08:00
Rejyr ae5cc9c56e fix: lint against lint functions
fix: lint against the functions `LintContext::{lookup_with_diagnostics,lookup,struct_span_lint,lint}`, `TyCtxt::struct_lint_node`, `LintLevelsBuilder::struct_lint`.
2022-11-07 19:23:29 -05:00
Matthias Krüger ad01a37ca9
Rollup merge of #103868 - compiler-errors:trait-engine-less, r=jackh726
Use `TraitEngine` (by itself) less

Replace `TraitEngine` in favor of `ObligationCtxt` or `fully_solve_*`, improving code readability.
2022-11-05 00:02:04 +01:00
Michael Goulet 41e4218d2a Use TraitEngine less 2022-11-02 04:11:05 +00:00
Manish Goregaokar 69e705564d
Rollup merge of #103575 - Xiretza:suggestions-style-attr, r=davidtwco
Change #[suggestion_*] attributes to use style="..."

As discussed [on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/336883-i18n/topic/.23100717.20tool_only_span_suggestion), this changes `#[(multipart_)suggestion_{short,verbose,hidden}(...)]` attributes to plain `#[(multipart_)suggestion(...)]` attributes with a `style = "{short,verbose,hidden}"` parameter.

It also adds a new style, `tool-only`, that corresponds to `tool_only_span_suggestion`/`tool_only_multipart_suggestion` and causes the suggestion to not be shown in human-readable output at all.

Best reviewed commit-by-commit, there's a bit of noise in there.

cc #100717 `@compiler-errors`
r? `@davidtwco`
2022-11-01 20:00:38 -04:00
Dylan DPC 5ee0fb1c68
Rollup merge of #103338 - l4l:enum-unreachable-pub, r=nagisa
Fix unreachable_pub suggestion for enum with fields

Resolves #103317
2022-10-31 14:52:55 +05:30
Guillaume Gomez 2414a4c31a
Rollup merge of #103625 - WaffleLapkin:no_tyctxt_dogs_allowed, r=compiler-errors
Accept `TyCtxt` instead of `TyCtxtAt` in `Ty::is_*` functions

Functions in answer:

- `Ty::is_freeze`
- `Ty::is_sized`
- `Ty::is_unpin`
- `Ty::is_copy_modulo_regions`

This allows to remove a lot of useless `.at(DUMMY_SP)`, making the code a bit nicer :3

r? `@compiler-errors`
2022-10-29 14:18:03 +02:00
Nicholas Nethercote c8c25ce5a1 Rename some `OwnerId` fields.
spastorino noticed some silly expressions like `item_id.def_id.def_id`.

This commit renames several `def_id: OwnerId` fields as `owner_id`, so
those expressions become `item_id.owner_id.def_id`.

`item_id.owner_id.local_def_id` would be even clearer, but the use of
`def_id` for values of type `LocalDefId` is *very* widespread, so I left
that alone.
2022-10-29 20:28:38 +11:00
Maybe Waffle a17ccfa621 Accept `TyCtxt` instead of `TyCtxtAt` in `Ty::is_*` functions
Functions in answer:

- `Ty::is_freeze`
- `Ty::is_sized`
- `Ty::is_unpin`
- `Ty::is_copy_modulo_regions`
2022-10-27 15:06:08 +04:00
Xiretza cd621be782 Convert all #[suggestion_*] attributes to #[suggestion(style = "...")]
Using the following command:

find compiler/ -type f -name '*.rs' -exec perl -i -gpe \
    's/(#\[\w*suggestion)_(short|verbose|hidden)\(\s*(\S+,)?/\1(\3style = "\2",/g' \
    '{}' +
2022-10-26 15:04:09 +02:00
Vadim Petrochenkov 34eb73c72d privacy: Rename "accessibility levels" to "effective visibilities"
And a couple of other naming tweaks

Related to https://github.com/rust-lang/rust/issues/48054
2022-10-26 16:34:53 +04:00
yukang a46af18cb1 fix parentheses surrounding spacing issue in parser 2022-10-24 18:24:10 +08:00
yukang c0447b489b fix #103435, unused lint won't produce invalid code 2022-10-24 16:51:31 +08:00
Michael Howell 9f06fbd1ad
Rollup merge of #103402 - joshtriplett:niche-wrap-fix, r=oli-obk
Fix wrapped valid-range handling in ty_find_init_error

Rust's niche handling allows for wrapping valid ranges with end < start;
for instance, a valid range with start=43 and end=41 means a niche of
42. Most places in the compiler handle this correctly, but
`ty_find_init_error` assumed that `lo > 0` means the type cannot contain a
zero.

Fix it to handle wrapping ranges.
2022-10-23 14:48:17 -07:00
bors e64f1110c0 Auto merge of #103345 - Nilstrieb:diag-flat, r=compiler-errors
Flatten diagnostic slug modules

This makes it easier to grep for the slugs in the code.

See https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Localization.20infra.20interferes.20with.20grepping.20for.20error for more discussion about it.

This was mostly done with a few regexes and a bunch of manual work. This also exposes a pretty annoying inconsistency for the extra labels. Some of the extra labels are defined as additional properties in the fluent message (which makes them not prefixed with the crate name) and some of them are new fluent messages themselves (which makes them prefixed with the crate name). I don't know whether we want to clean this up at some point but it's useful to know.

r? `@davidtwco`
2022-10-23 09:06:39 +00:00
Nilstrieb c65ebae221
Migrate all diagnostics 2022-10-23 10:09:44 +02:00
bors faab68eb29 Auto merge of #103426 - matthiaskrgr:rollup-n6dqdy8, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #103123 (Introduce `subst_iter` and `subst_iter_copied` on `EarlyBinder` )
 - #103328 (Do not suggest trivially false const predicates)
 - #103354 (Escape string literals when fixing overlong char literal)
 - #103355 (Handle return-position `impl Trait` in traits properly in `register_hidden_type`)
 - #103368 (Delay ambiguity span bug in normalize query iff not rustdoc)
 - #103388 (rustdoc: remove unused CSS class `.result-description`)
 - #103399 (Change `unknown_lint` applicability to `MaybeIncorrect`)
 - #103401 (Use functions for headings rustdoc GUI test)
 - #103412 (Fix typo in docs of `String::leak`.)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-10-23 06:20:24 +00:00
Matthias Krüger 6be917a748
Rollup merge of #103399 - smoelius:unknown-lint-maybe-incorrect, r=fee1-dead
Change `unknown_lint` applicability to `MaybeIncorrect`

This small PR changes the applicability of `unknown_lint` to `MaybeIncorrect`, because the suggested lint might not be the correct one.

Here is one example where the current applicability causes a problem. Clippy has a set of internal lints guarded by a feature called `internal`. If the feature is not enabled, then the internal lints are "unknown." In that case, running `cargo clippy --fix ...` on `clippy_utils` causes lines such as the followig
26c96e3416/src/tools/clippy/clippy_utils/src/paths.rs (L51-L52)
to be changed to
```rust
 #[expect(clippy::invalid_regex)] // internal lints do not know about all external crates
 pub const FUTURES_IO_ASYNCREADEXT: [&str; 3] = ["futures_util", "io", "AsyncReadExt"];
```
which is not correct.
2022-10-23 08:14:33 +02:00
Matthias Krüger 5290d5e321
Rollup merge of #103123 - compiler-errors:early-binder-iter, r=cjgillot
Introduce `subst_iter` and `subst_iter_copied` on `EarlyBinder`

Makes working with bounds lists a bit easier, which I seem to do a lot.

Specifically, means that we don't need to do `.transpose_iter().map(|(pred, _)| *pred)` every time we want to iterate through an `EarlyBinder<&'tcx [(Predicate, Span)]>` (and even then, still have to call `subst` later), which was a very awkward idiom imo.
2022-10-23 08:14:30 +02:00
bors 6c9c2d862d Auto merge of #102660 - camsteffen:uninhabited-perf, r=oli-obk
Remove ParamEnv from uninhabited query
2022-10-23 03:39:43 +00:00
Josh Triplett 36662dfc83 Fix wrapped valid-range handling in ty_find_init_error
Rust's niche handling allows for wrapping valid ranges with end < start;
for instance, a valid range with start=43 and end=41 means a niche of
42. Most places in the compiler handle this correctly, but
ty_find_init_error assumed that `lo > 0` means the type cannot contain a
zero.

Fix it to handle wrapping ranges.

Add a test to cover this case.
2022-10-23 00:33:06 +01:00
Cameron Steffen 2928e9ef2c Introduce InhabitedPredicate 2022-10-22 13:20:06 -05:00
Samuel Moelius 62b65b5ede Change `unknown_lint` applicability to `MaybeIncorrect` 2022-10-22 07:17:36 -04:00
Dylan DPC 16c3b64794
Rollup merge of #102602 - WaffleLapkin:linty_action, r=estebank
Slightly tweak comments wrt `lint_overflowing_range_endpoint`

From the review: https://github.com/rust-lang/rust/pull/101986#discussion_r975610611

It _seemed_ that the lint was not emitted when the `if` check failed, but _actually_ this happens already in a special case and the lint is emitted outside of this function, if this function doesn't. I've cleared up the code/comments a bit, so it's more obvious :)

r? ```@estebank```
2022-10-22 16:28:07 +05:30
Michael Goulet aa8931c612 Introduce subst_iter and subst_iter_copied on EarlyBinder 2022-10-22 06:52:12 +00:00
Dylan DPC 3055eb9b26
Rollup merge of #103260 - cuviper:needs-asm-support, r=fee1-dead
Fixup a few tests needing asm support
2022-10-21 17:29:59 +05:30
Dylan DPC e11511dfa6
Rollup merge of #103051 - davidtwco:translation-tidying-up, r=compiler-errors
translation: doc comments with derives, subdiagnostic-less enum variants, more derive use

- Adds support for `doc` attributes in the diagnostic derives so that documentation comments don't result in the derive failing.
- Adds support for enum variants in the subdiagnostic derive to not actually correspond to an addition to a diagnostic.
- Made use of the derive in more places in the `rustc_ast_lowering`, `rustc_ast_passes`, `rustc_lint`, `rustc_session`, `rustc_infer` - taking advantage of recent additions like eager subdiagnostics, multispan suggestions, etc.

cc #100717
2022-10-21 17:29:58 +05:30
Kitsu 6a065f78c4 Fix unreachable_pub suggestion for enum with fields 2022-10-21 12:56:12 +03:00
Michael Goulet 8509819aef Elaborate supertrait bounds when triggering unused_must_use on impl Trait 2022-10-20 17:31:01 +00:00
Josh Stone f8e157b33f Fixup a few tests needing asm support 2022-10-19 11:34:00 -07:00
David Wood 21d3bbd8b6 lint: use derive more
Signed-off-by: David Wood <david.wood@huawei.com>
2022-10-17 09:54:24 +01:00
Matthias Krüger d6506cc0be
Rollup merge of #102953 - WaffleLapkin:better_docs_for_decorate_param, r=RalfJung
Improve docs for `struct_lint_level` function.

r? ``@RalfJung``

Does this answer your questions?
2022-10-16 17:51:31 +02:00
Rageking8 7122abaddf more dupe word typos 2022-10-14 12:57:56 +08:00
Maybe Waffle c5de3ecec3 link lint function with `decorate` function param to `struct_lint_level` 2022-10-12 14:16:24 +00:00
David Wood b4ac26289f errors: `AddToDiagnostic::add_to_diagnostic_with`
`AddToDiagnostic::add_to_diagnostic_with` is similar to the previous
`AddToDiagnostic::add_to_diagnostic` but takes a function that can be
used by the caller to modify diagnostic messages originating from the
subdiagnostic (such as performing translation eagerly).

`add_to_diagnostic` now just calls `add_to_diagnostic_with` with an
empty closure.

Signed-off-by: David Wood <david.wood@huawei.com>
2022-10-10 14:20:16 +01:00
Dylan DPC 81b9d0b1d1
Rollup merge of #102868 - compiler-errors:rename-assoc-tyalias-to-ty, r=TaKO8Ki
Rename `AssocItemKind::TyAlias` to `AssocItemKind::Type`

Thanks `@camsteffen` for catching this in ast too, cc https://github.com/rust-lang/rust/pull/102829#issuecomment-1272649247
2022-10-10 13:43:43 +05:30
Michael Goulet d3bd6beb97 Rename AssocItemKind::TyAlias to AssocItemKind::Type 2022-10-10 02:31:37 +00:00
Maybe Waffle 9d4edff1b0 adopt to building infcx 2022-10-09 13:07:21 +00:00
Maybe Waffle 40f36fac49 adopt to new rustc lint api 2022-10-09 13:07:21 +00:00
Maybe Waffle 7434b9f0d1 fixup lint name 2022-10-09 13:07:21 +00:00
Maybe Waffle 98e0c4df73 fix `for_loop_over_fallibles` lint docs 2022-10-09 13:07:21 +00:00
Maybe Waffle 6766113c87 remove an infinite loop 2022-10-09 13:07:21 +00:00
Maybe Waffle b9b2059e84 Edit documentation for `for_loop_over_fallibles` lint 2022-10-09 13:07:20 +00:00