about summary refs log tree commit diff
path: root/compiler/rustc_lint/src
AgeCommit message (Collapse)AuthorLines
2022-12-02Eliminate four unnecessary lint macros.Nicholas Nethercote-40/+16
The lint definitions use macros heavily. This commit merges some of them that are split unnecessarily. I find the reduced indirection makes it easier to imagine what the generated code will look like.
2022-12-01rustc_ast_lowering: Stop lowering imports into multiple itemsVadim Petrochenkov-1/+1
Lower them into a single item with multiple resolutions instead. This also allows to remove additional `NodId`s and `DefId`s related to those additional items.
2022-12-01rustc_hir: Relax lifetime requirements on `Visitor::visit_path`Vadim Petrochenkov-3/+3
2022-11-30Update documentationOli Scherer-1/+1
2022-11-29Rebasemejrs-7/+2
2022-11-29Update trait checkmejrs-4/+7
2022-11-29Make `missing_copy_implementations` more cautiousmejrs-1/+33
2022-11-29Make inferred_outlives_crate return ClauseSantiago Pastorino-12/+8
2022-11-29Rollup merge of #104951 - Swatinem:async-kind, r=compiler-errorsMatthias Krüger-4/+1
Simplify checking for `GeneratorKind::Async` Adds a helper method around `generator_kind` that makes matching async constructs simpler.
2022-11-28Simplify checking for `GeneratorKind::Async`Arpad Borsos-4/+1
Adds a helper method around `generator_kind` that makes matching async constructs simpler.
2022-11-28Rename `NestedMetaItem::[Ll]iteral` as `NestedMetaItem::[Ll]it`.Nicholas Nethercote-2/+2
We already use a mix of `Literal` and `Lit`. The latter is better because it is shorter without causing any ambiguity.
2022-11-27Rollup merge of #104976 - WaffleLapkin:move_comments, r=cjgillotMatthias Krüger-1/+1
Prefer doc comments over `//`-comments in compiler Doc comments are generally nicer: they show up in the documentation, they are shown in IDEs when you hover other mentions of items, etc. Thus it makes sense to use them instead of `//`-comments.
2022-11-27Auto merge of #104048 - cjgillot:split-lifetime, r=compiler-errorsbors-6/+2
Separate lifetime ident from lifetime resolution in HIR Drive-by: change how suggested generic args are computed. Fixes https://github.com/rust-lang/rust/issues/103815 I recommend reviewing commit-by-commit.
2022-11-27Prefer doc comments over `//`-comments in compilerMaybe Waffle-1/+1
2022-11-27Auto merge of #103917 - oli-obk:layout_math, r=RalfJung,lcnrbors-63/+97
Various cleanups around scalar layout restrictions Pulled out of https://github.com/rust-lang/rust/pull/103724
2022-11-26Rollup merge of #104786 - WaffleLapkin:amp-mut-help, r=compiler-errorsGuillaume Gomez-2/+2
Use the power of adding helper function to simplify code w/ `Mutability` r? `@compiler-errors`
2022-11-25Use "must be init" instead of "must not be uninit" everywhereOli Scherer-5/+3
2022-11-25Add a `because` to errors derived from fieldsOli Scherer-22/+21
2022-11-25Don't show fields from other cratesOli Scherer-1/+3
2022-11-25Reinstate the previous compact form of "in this field" errorsOli Scherer-4/+12
2022-11-25Don't try to compute the layout of generic types.Oli Scherer-23/+23
2022-11-25Compute layout instead of manually procesisng the layout restriction attributesOli Scherer-31/+36
2022-11-25Print a trace through types to show how to get to the problematic typeOli Scherer-42/+64
2022-11-25Introduce PredicateKind::ClauseSantiago Pastorino-18/+26
2022-11-24Auto merge of #104845 - matthiaskrgr:rollup-tckj956, r=matthiaskrgrbors-0/+1
Rollup of 11 pull requests Successful merges: - #104514 (Use node_ty_opt to avoid ICE in visit_ty) - #104704 (Allow power10-vector feature in PowerPC) - #104747 (resolve: Don't use constructor def ids in the map for field names) - #104773 (OpaqueCast projections are always overlapping, they can't possibly be disjoint) - #104774 (Document split{_ascii,}_whitespace() for empty strings) - #104780 (make `error_reported` check for delayed bugs) - #104782 (Bump the const eval step limit) - #104792 (rustdoc: simplify `.search-results-title` CSS) - #104796 (lint: do not warn unused parens around higher-ranked function pointers) - #104820 (Remove normalize_projection_type) - #104822 (with_query_mode -> new) Failed merges: - #104716 (move 2 candidates into builtin candidate) - #104841 (Assert that we don't capture escaping bound vars in `Fn` trait selection) r? `@ghost` `@rustbot` modify labels: rollup
2022-11-24Rollup merge of #104796 - notriddle:notriddle/unused-issue-104397, r=oli-obkMatthias Krüger-0/+1
lint: do not warn unused parens around higher-ranked function pointers Fixes #104397
2022-11-24Auto merge of #103693 - HKalbasi:master, r=oli-obkbors-3/+5
Make rustc_target usable outside of rustc I'm working on showing type size in rust-analyzer (https://github.com/rust-lang/rust-analyzer/pull/13490) and I currently copied rustc code inside rust-analyzer, which works, but is bad. With this change, I would become able to use `rustc_target` and `rustc_index` directly in r-a, reducing the amount of copy needed. This PR contains some feature flag to put nightly features behind them to make crates buildable on the stable compiler + makes layout related types generic over index type + removes interning of nested layouts.
2022-11-24Fix rustc_pass_by_value.Camille GILLOT-1/+1
2022-11-24Auto merge of #104321 - Swatinem:async-gen, r=oli-obkbors-1/+14
Avoid `GenFuture` shim when compiling async constructs Previously, async constructs would be lowered to "normal" generators, with an additional `from_generator` / `GenFuture` shim in between to convert from `Generator` to `Future`. The compiler will now special-case these generators internally so that async constructs will *directly* implement `Future` without the need to go through the `from_generator` / `GenFuture` shim. The primary motivation for this change was hiding this implementation detail in stack traces and debuginfo, but it can in theory also help the optimizer as there is less abstractions to see through. --- Given this demo code: ```rust pub async fn a(arg: u32) -> Backtrace { let bt = b().await; let _arg = arg; bt } pub async fn b() -> Backtrace { Backtrace::force_capture() } ``` I would get the following with the latest stable compiler (on Windows): ``` 4: async_codegen::b::async_fn$0 at .\src\lib.rs:10 5: core::future::from_generator::impl$1::poll<enum2$<async_codegen::b::async_fn_env$0> > at /rustc/897e37553bba8b42751c67658967889d11ecd120\library\core\src\future\mod.rs:91 6: async_codegen::a::async_fn$0 at .\src\lib.rs:4 7: core::future::from_generator::impl$1::poll<enum2$<async_codegen::a::async_fn_env$0> > at /rustc/897e37553bba8b42751c67658967889d11ecd120\library\core\src\future\mod.rs:91 ``` whereas now I get a much cleaner stack trace: ``` 3: async_codegen::b::async_fn$0 at .\src\lib.rs:10 4: async_codegen::a::async_fn$0 at .\src\lib.rs:4 ```
2022-11-24move things from rustc_target::abi to rustc_abihkalbasi-1/+1
2022-11-24move some layout logic to rustc_target::abi::layouthkalbasi-2/+4
2022-11-24Avoid `GenFuture` shim when compiling async constructsArpad Borsos-1/+14
Previously, async constructs would be lowered to "normal" generators, with an additional `from_generator` / `GenFuture` shim in between to convert from `Generator` to `Future`. The compiler will now special-case these generators internally so that async constructs will *directly* implement `Future` without the need to go through the `from_generator` / `GenFuture` shim. The primary motivation for this change was hiding this implementation detail in stack traces and debuginfo, but it can in theory also help the optimizer as there is less abstractions to see through.
2022-11-23lint: do not warn unused parens around higher-ranked function pointersMichael Howell-0/+1
Fixes #104397
2022-11-23Depend on `Mutability` orderingMaybe Waffle-2/+2
2022-11-23Separate lifetime ident from resolution in HIR.Camille GILLOT-6/+2
2022-11-23Use nicer spans for `deref_into_dyn_supertrait`Maybe Waffle-3/+10
2022-11-23Make `deref_into_dyn_supertrait` lint the impl and not the usageMaybe Waffle-0/+88
2022-11-23Move `get_associated_type` from `clippy` to `rustc_lint`Maybe Waffle-0/+17
2022-11-22Rollup merge of #104359 - Nilstrieb:plus-one, r=fee1-deadManish Goregaokar-113/+203
Refactor must_use lint into two parts Before, the lint did the checking for `must_use` and pretty printing the types in a special format in one pass, causing quite complex and untranslatable code. Now the collection and printing is split in two. That should also make it easier to translate or extract the type pretty printing in the future. Also fixes an integer overflow in the array length pluralization calculation. fixes #104352
2022-11-22Rollup merge of #103488 - oli-obk:impl_trait_for_tait, r=lcnrManish Goregaokar-0/+1
Allow opaque types in trait impl headers and rely on coherence to reject unsound cases r? ````@lcnr```` fixes #99840
2022-11-22Auto merge of #103578 - petrochenkov:nofict, r=nagisabors-2/+2
Unreserve braced enum variants in value namespace With this PR braced enum variants (`enum E { V { /*...*/ } }`) no longer take a slot in value namespace, so the special case mentioned in the note in https://github.com/rust-lang/rfcs/blob/master/text/1506-adt-kinds.md#braced-structs is removed. Report - https://github.com/rust-lang/rust/pull/103578#issuecomment-1292594900.
2022-11-22Auto merge of #104696 - matthiaskrgr:rollup-gi1pdb0, r=matthiaskrgrbors-2/+2
Rollup of 11 pull requests Successful merges: - #103396 (Pin::new_unchecked: discuss pinning closure captures) - #104416 (Fix using `include_bytes` in pattern position) - #104557 (Add a test case for async dyn* traits) - #104559 (Split `MacArgs` in two.) - #104597 (Probe + better error messsage for `need_migrate_deref_output_trait_object`) - #104656 (Move tests) - #104657 (Do not check transmute if has non region infer) - #104663 (rustdoc: factor out common button CSS) - #104666 (Migrate alias search result to CSS variables) - #104674 (Make negative_impl and negative_impl_exists take the right types) - #104692 (Update test's cfg-if dependency to 1.0) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-11-22Split `MacArgs` in two.Nicholas Nethercote-2/+2
`MacArgs` is an enum with three variants: `Empty`, `Delimited`, and `Eq`. It's used in two ways: - For representing attribute macro arguments (e.g. in `AttrItem`), where all three variants are used. - For representing function-like macros (e.g. in `MacCall` and `MacroDef`), where only the `Delimited` variant is used. In other words, `MacArgs` is used in two quite different places due to them having partial overlap. I find this makes the code hard to read. It also leads to various unreachable code paths, and allows invalid values (such as accidentally using `MacArgs::Empty` in a `MacCall`). This commit splits `MacArgs` in two: - `DelimArgs` is a new struct just for the "delimited arguments" case. It is now used in `MacCall` and `MacroDef`. - `AttrArgs` is a renaming of the old `MacArgs` enum for the attribute macro case. Its `Delimited` variant now contains a `DelimArgs`. Various other related things are renamed as well. These changes make the code clearer, avoids several unreachable paths, and disallows the invalid values.
2022-11-21Stop passing the self-type as a separate argument.Oli Scherer-6/+10
2022-11-21Use ty::List instead of InternalSubstsOli Scherer-7/+2
2022-11-21Unreserve braced enum variants in value namespaceVadim Petrochenkov-2/+2
2022-11-21Add an always-ambiguous predicate to make sure that we don't accidentlally ↵Oli Scherer-0/+1
allow trait resolution to prove false things during coherence
2022-11-21Rollup merge of #104595 - compiler-errors:poly-existential-predicate, r=lcnrMatthias Krüger-1/+1
Add `PolyExistentialPredicate` type alias Wrapping `ExistentialPredicate`s in a binder is very common, and this alias already exists for the `PolyExistential{TraitRef,Projection}` types.
2022-11-20Change to Ty::is_inhabited_fromCameron Steffen-2/+2
2022-11-20Auto merge of #98914 - fee1-dead-contrib:min-deref-patterns, r=compiler-errorsbors-1/+1
Minimal implementation of implicit deref patterns for Strings cc `@compiler-errors` `@BoxyUwU` https://github.com/rust-lang/lang-team/issues/88 #87121 ~~I forgot to add a feature gate, will do so in a minute~~ Done