Commit Graph

1084 Commits

Author SHA1 Message Date
bors
e960b5e774 Auto merge of #104863 - nnethercote:reduce-lint-macros, r=cjgillot
Reduce macro usage for lints

r? `@cjgillot`
2022-12-02 15:31:15 +00:00
Nicholas Nethercote
406dace6f2 Inline and remove early_lint_node.
It has a single call site.
2022-12-02 15:24:01 +11:00
Nicholas Nethercote
a9b02af62b Merge builtins into EarlyLintPassObjects.
This avoids calling `early_lint_node` twice.

Note: one `early_lint_node` call had `!pre_expansion` for the second
argument and the other had `false`. The new single call just has
`!pre_expansion`. This results in a reduction of duplicate error
messages in some `ui-fulldeps` tests. The order of some `ui-fulldeps`
output also changes, but that doesn't matter.
2022-12-02 15:23:28 +11:00
Nicholas Nethercote
44cb4f70a8 Remove some unnecessary Send bounds.
Required to get the parallel compiler building again.
2022-12-02 13:59:28 +11:00
Nicholas Nethercote
357aee9320 Inline and remove late_lint_pass_crate.
It has a single call site.
2022-12-02 13:59:28 +11:00
Nicholas Nethercote
0e4f55d63f Inline and remove late_lint_mod_pass.
It has a single call site.
2022-12-02 13:59:28 +11:00
Nicholas Nethercote
890c5ead20 Merge builtins into LateLintPassObjects.
This avoids calling the `late_lint_{mod_pass,pass_crate}` twice.
2022-12-02 13:59:28 +11:00
Nicholas Nethercote
99e9c1ddb7 Remove six macros relating to lint definitions.
These were enabled by the removal of `-Zno-interleave-lints`.
2022-12-02 13:59:28 +11:00
Nicholas Nethercote
67cfe2cfbb Remove -Zno-interleave-lints.
Because it complicates lint implementation greatly.
2022-12-02 13:59:28 +11:00
Nicholas Nethercote
33faf01690 Eliminate four unnecessary lint macros.
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-02 13:59:28 +11:00
Vadim Petrochenkov
b32a4edb20 rustc_ast_lowering: Stop lowering imports into multiple items
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-01 18:51:20 +03:00
Vadim Petrochenkov
6cd4dd3091 rustc_hir: Relax lifetime requirements on Visitor::visit_path 2022-12-01 17:04:02 +03:00
Santiago Pastorino
537488efd6
Make inferred_outlives_crate return Clause 2022-11-29 12:01:58 -03:00
Matthias Krüger
c81605ca91
Rollup merge of #104951 - Swatinem:async-kind, r=compiler-errors
Simplify checking for `GeneratorKind::Async`

Adds a helper method around `generator_kind` that makes matching async constructs simpler.
2022-11-29 05:24:21 +01:00
Arpad Borsos
2db0dc3297
Simplify checking for GeneratorKind::Async
Adds a helper method around `generator_kind` that makes matching async constructs simpler.
2022-11-28 23:12:01 +01:00
Nicholas Nethercote
a60e337c88 Rename NestedMetaItem::[Ll]iteral as NestedMetaItem::[Ll]it.
We already use a mix of `Literal` and `Lit`. The latter is better
because it is shorter without causing any ambiguity.
2022-11-28 15:18:53 +11:00
Matthias Krüger
86304f5149
Rollup merge of #104976 - WaffleLapkin:move_comments, r=cjgillot
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-27 22:14:08 +01:00
bors
454784afba Auto merge of #104048 - cjgillot:split-lifetime, r=compiler-errors
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-27 14:30:19 +00:00
Maybe Waffle
1d42936b18 Prefer doc comments over //-comments in compiler 2022-11-27 11:19:04 +00:00
bors
df04d28163 Auto merge of #103917 - oli-obk:layout_math, r=RalfJung,lcnr
Various cleanups around scalar layout restrictions

Pulled out of https://github.com/rust-lang/rust/pull/103724
2022-11-27 10:35:00 +00:00
Guillaume Gomez
a2e485c25c
Rollup merge of #104786 - WaffleLapkin:amp-mut-help, r=compiler-errors
Use the power of adding helper function to simplify code w/ `Mutability`

r? `@compiler-errors`
2022-11-26 17:47:23 +01:00
Oli Scherer
208bb933e7 Use "must be init" instead of "must not be uninit" everywhere 2022-11-25 08:40:27 +00:00
Oli Scherer
5446a52b4b Add a because to errors derived from fields 2022-11-25 08:40:03 +00:00
Oli Scherer
fcb1f1874f Don't show fields from other crates 2022-11-25 08:12:16 +00:00
Oli Scherer
98c550ecc8 Reinstate the previous compact form of "in this field" errors 2022-11-25 08:11:29 +00:00
Oli Scherer
ccaa28bf69 Don't try to compute the layout of generic types. 2022-11-25 08:10:52 +00:00
Oli Scherer
2bed079103 Compute layout instead of manually procesisng the layout restriction attributes 2022-11-25 08:10:29 +00:00
Oli Scherer
5cbf172909 Print a trace through types to show how to get to the problematic type 2022-11-25 08:09:52 +00:00
Santiago Pastorino
974e2837bb
Introduce PredicateKind::Clause 2022-11-25 00:04:54 -03:00
bors
65a6e22668 Auto merge of #104845 - matthiaskrgr:rollup-tckj956, r=matthiaskrgr
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-24 23:45:32 +00:00
Matthias Krüger
83d1aab9ff
Rollup merge of #104796 - notriddle:notriddle/unused-issue-104397, r=oli-obk
lint: do not warn unused parens around higher-ranked function pointers

Fixes #104397
2022-11-24 21:34:56 +01:00
bors
b3bc6bf312 Auto merge of #103693 - HKalbasi:master, r=oli-obk
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-24 20:29:13 +00:00
Camille GILLOT
5de9c84140 Fix rustc_pass_by_value. 2022-11-24 17:49:42 +00:00
bors
5dfb4b0afa Auto merge of #104321 - Swatinem:async-gen, r=oli-obk
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:🅱️:async_fn$0
             at .\src\lib.rs:10
   5: core::future::from_generator::impl$1::poll<enum2$<async_codegen:🅱️:async_fn_env$0> >
             at /rustc/897e37553bba8b42751c67658967889d11ecd120\library\core\src\future\mod.rs:91
   6: async_codegen:🅰️:async_fn$0
             at .\src\lib.rs:4
   7: core::future::from_generator::impl$1::poll<enum2$<async_codegen:🅰️: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:🅱️:async_fn$0
             at .\src\lib.rs:10
   4: async_codegen:🅰️:async_fn$0
             at .\src\lib.rs:4
```
2022-11-24 17:14:42 +00:00
hkalbasi
390a637e29 move things from rustc_target::abi to rustc_abi 2022-11-24 16:26:13 +03:30
hkalbasi
27fb904d68 move some layout logic to rustc_target::abi::layout 2022-11-24 16:26:12 +03:30
Arpad Borsos
9f36f988ad
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.
2022-11-24 10:04:27 +01:00
Michael Howell
97d95d48e2 lint: do not warn unused parens around higher-ranked function pointers
Fixes #104397
2022-11-23 17:57:11 -07:00
Maybe Waffle
9b9c7d0ecc Depend on Mutability ordering 2022-11-23 20:26:31 +00:00
Camille GILLOT
fb7d25e978 Separate lifetime ident from resolution in HIR. 2022-11-23 19:33:06 +00:00
Maybe Waffle
20f3de5ab1 Use nicer spans for deref_into_dyn_supertrait 2022-11-23 16:12:51 +00:00
Maybe Waffle
0d4a5c725a Make deref_into_dyn_supertrait lint the impl and not the usage 2022-11-23 15:40:27 +00:00
Maybe Waffle
11a5386256 Move get_associated_type from clippy to rustc_lint 2022-11-23 15:40:27 +00:00
Manish Goregaokar
a673364c54
Rollup merge of #104359 - Nilstrieb:plus-one, r=fee1-dead
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-22 22:54:39 -05:00
Manish Goregaokar
53eab246db
Rollup merge of #103488 - oli-obk:impl_trait_for_tait, r=lcnr
Allow opaque types in trait impl headers and rely on coherence to reject unsound cases

r? ````@lcnr````

fixes #99840
2022-11-22 22:54:38 -05:00
bors
b7463e8bdb Auto merge of #103578 - petrochenkov:nofict, r=nagisa
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-22 10:17:09 +00:00
bors
0f7d81754d Auto merge of #104696 - matthiaskrgr:rollup-gi1pdb0, r=matthiaskrgr
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-22 01:35:57 +00:00
Nicholas Nethercote
3e3a4192d8 Split MacArgs in two.
`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-22 09:04:15 +11:00
Oli Scherer
7658e0fccf Stop passing the self-type as a separate argument. 2022-11-21 20:39:46 +00:00
Oli Scherer
48ff6a95b5 Use ty::List instead of InternalSubsts 2022-11-21 20:31:11 +00:00