Commit graph

8759 commits

Author SHA1 Message Date
Christiaan Dirkx
024a49aed1 Fix clippy test using ErrorKind 2021-04-18 09:29:24 +02:00
flip1995
f6d1f368db Merge commit 'b40ea209e7f14c8193ddfc98143967b6a2f4f5c9' into clippyup 2021-04-08 17:50:13 +02:00
Dylan DPC
cde58f7174 Rollup merge of #83916 - Amanieu:asm_anonconst, r=petrochenkov
Use AnonConst for asm! constants

This replaces the old system which used explicit promotion. See #83169 for more background.

The syntax for `const` operands is still the same as before: `const <expr>`.

Fixes #83169

Because the implementation is heavily based on inline consts, we suffer from the same issues:
- We lose the ability to use expressions derived from generics. See the deleted tests in `src/test/ui/asm/const.rs`.
- We are hitting the same ICEs as inline consts, for example #78174. It is unlikely that we will be able to stabilize this before inline consts are stabilized.
2021-04-07 13:07:14 +02:00
Amanieu d'Antras
879bfeca54 Use AnonConst for asm! constants 2021-04-06 12:35:41 +01:00
Dylan DPC
44e3ccb6dc Rollup merge of #83820 - petrochenkov:nolinkargs, r=nagisa
Remove attribute `#[link_args]`

Closes https://github.com/rust-lang/rust/issues/29596

The attribute could always be replaced with `-C link-arg`, but cargo didn't provide a reasonable way to pass such flags to rustc.
Now cargo supports `cargo:rustc-link-arg*` directives in build scripts (https://doc.rust-lang.org/cargo/reference/unstable.html#extra-link-arg), so this attribute can be removed.
2021-04-05 00:24:33 +02:00
Vadim Petrochenkov
c7264483e7 Remove attribute #[link_args] 2021-04-03 21:25:53 +03:00
Roxane
2ca5368628 fix clippy error 2021-04-02 19:11:51 -04:00
Jack Huey
b438e30fa6 Track bound vars 2021-03-31 10:15:27 -04:00
Camille GILLOT
d121b34e99 Remove hir::CrateItem. 2021-03-30 20:31:06 +02:00
Joshua Nelson
a57a8c3058 Remove (lots of) dead code
Found with https://github.com/est31/warnalyzer.

Dubious changes:
- Is anyone else using rustc_apfloat? I feel weird completely deleting
  x87 support.
- Maybe some of the dead code in rustc_data_structures, in case someone
  wants to use it in the future?
- Don't change rustc_serialize

  I plan to scrap most of the json module in the near future (see
  https://github.com/rust-lang/compiler-team/issues/418) and fixing the
  tests needed more work than I expected.

TODO: check if any of the comments on the deleted code should be kept.
2021-03-27 22:16:33 -04:00
Dylan DPC
b094bb1bd7 Rollup merge of #82917 - cuviper:iter-zip, r=m-ou-se
Add function core::iter::zip

This makes it a little easier to `zip` iterators:

```rust
for (x, y) in zip(xs, ys) {}
// vs.
for (x, y) in xs.into_iter().zip(ys) {}
```

You can `zip(&mut xs, &ys)` for the conventional `iter_mut()` and
`iter()`, respectively. This can also support arbitrary nesting, where
it's easier to see the item layout than with arbitrary `zip` chains:

```rust
for ((x, y), z) in zip(zip(xs, ys), zs) {}
for (x, (y, z)) in zip(xs, zip(ys, zs)) {}
// vs.
for ((x, y), z) in xs.into_iter().zip(ys).zip(xz) {}
for (x, (y, z)) in xs.into_iter().zip((ys.into_iter().zip(xz)) {}
```

It may also format more nicely, especially when the first iterator is a
longer chain of methods -- for example:

```rust
    iter::zip(
        trait_ref.substs.types().skip(1),
        impl_trait_ref.substs.types().skip(1),
    )
    // vs.
    trait_ref
        .substs
        .types()
        .skip(1)
        .zip(impl_trait_ref.substs.types().skip(1))
```

This replaces the tuple-pair `IntoIterator` in #78204.
There is prior art for the utility of this in [`itertools::zip`].

[`itertools::zip`]: https://docs.rs/itertools/0.10.0/itertools/fn.zip.html
2021-03-27 20:37:07 +01:00
Ömer Sinan Ağacan
ce4e668e39 format macro argument parsing fix
When the character next to `{}` is "shifted" (when mapping a byte index
in the format string to span) we should avoid shifting the span end
index, so first map the index of `}` to span, then bump the span,
instead of first mapping the next byte index to a span (which causes
bumping the end span too much).

Regression test added.

Fixes #83344
2021-03-27 13:06:36 +03:00
Josh Stone
0dddfbf9bf Use iter::zip in src/tools/clippy/ 2021-03-26 09:33:38 -07:00
flip1995
9f6b5de7de Merge commit '0e87918536b9833bbc6c683d1f9d51ee2bf03ef1' into clippyup 2021-03-25 19:29:11 +01:00
kadmin
e06731bb28 Add has_default to GenericParamDefKind::Const
This currently creates a field which is always false on GenericParamDefKind for future use when
consts are permitted to have defaults

Update const_generics:default locations

Previously just ignored them, now actually do something about them.

Fix using type check instead of value

Add parsing

This adds all the necessary changes to lower const-generics defaults from parsing.

Change P<Expr> to AnonConst

This matches the arguments passed to instantiations of const generics, and makes it specific to
just anonymous constants.

Attempt to fix lowering bugs
2021-03-23 17:16:20 +00:00
bors
2bc180e888 Auto merge of #79278 - mark-i-m:stabilize-or-pattern, r=nikomatsakis
Stabilize or_patterns (RFC 2535, 2530, 2175)

closes #54883

This PR stabilizes the or_patterns feature in Rust 1.53.

This is blocked on the following (in order):
- [x] The crater run in https://github.com/rust-lang/rust/pull/78935#issuecomment-731564021
- [x] The resolution of the unresolved questions and a second crater run (https://github.com/rust-lang/rust/pull/78935#issuecomment-735412705)
    - It looks like we will need to pursue some sort of edition-based transition for `:pat`.
- [x] Nomination and discussion by T-lang
- [x] Implement new behavior for `:pat` based on consensus (https://github.com/rust-lang/rust/pull/80100).
- [ ] An FCP on stabilization

EDIT: Stabilization report is in https://github.com/rust-lang/rust/pull/79278#issuecomment-772815177
2021-03-22 19:48:27 +00:00
lcnr
731c98b16b update const_eval_resolve 2021-03-20 17:22:24 +01:00
mark
d2f0b27f0a clippy: stabilize or_patterns lint 2021-03-19 19:45:42 -05:00
Vadim Petrochenkov
2c4570c958 hir: Preserve used syntax in TyKind::TraitObject 2021-03-18 03:02:32 +03:00
bors
b62694b08f Auto merge of #82122 - bstrie:dep4real, r=dtolnay
Deprecate `intrinsics::drop_in_place` and `collections::Bound`, which accidentally weren't deprecated

Fixes #82080.

I've taken the liberty of updating the `since` values to 1.52, since an unobservable deprecation isn't much of a deprecation (even the detailed release notes never bothered to mention these deprecations).

As mentioned in the issue I'm *pretty* sure that using a type alias for `Bound` is semantically equivalent to the re-export; [the reference implies](https://doc.rust-lang.org/reference/items/type-aliases.html) that type aliases only observably differ from types when used on unit structs or tuple structs, whereas `Bound` is an enum.
2021-03-17 19:39:03 +00:00
bors
56138ad789 Auto merge of #83188 - petrochenkov:field, r=lcnr
ast/hir: Rename field-related structures

I always forget what `ast::Field` and `ast::StructField` mean despite working with AST for long time, so this PR changes the naming to less confusing and more consistent.

- `StructField` -> `FieldDef` ("field definition")
- `Field` -> `ExprField` ("expression field", not "field expression")
- `FieldPat` -> `PatField` ("pattern field", not "field pattern")

Various visiting and other methods working with the fields are renamed correspondingly too.

The second commit reduces the size of `ExprKind` by boxing fields of `ExprKind::Struct` in preparation for https://github.com/rust-lang/rust/pull/80080.
2021-03-17 16:49:46 +00:00
Yuki Okushi
5476382dda Rollup merge of #83092 - petrochenkov:qspan, r=estebank
More precise spans for HIR paths

`Ty::assoc_item` is lowered to `<Ty>::assoc_item` in HIR, but `Ty` got span from the whole path.
This PR fixes that, and adjusts some diagnostic code that relied on `Ty` having the whole path span.

This is a pre-requisite for https://github.com/rust-lang/rust/pull/82868 (we cannot report suggestions like `Tr::assoc` -> `<dyn Tr>::assoc` with the current imprecise spans).
r? ````@estebank````
2021-03-17 15:20:54 +09:00
bors
846d4f0613 Auto merge of #82536 - sexxi-goose:handle-patterns-take-2, r=nikomatsakis
2229: Handle patterns within closures correctly when `capture_disjoint_fields` is enabled

This PR fixes several issues related to handling patterns within closures when `capture_disjoint_fields` is enabled.
1. Matching is always considered a use of the place, even with `_` patterns
2. Compiler ICE when capturing fields in closures through `let` assignments

To do so, we

- Introduced new Fake Reads
- Delayed use of `Place` in favor of `PlaceBuilder`
- Ensured that `PlaceBuilder` can be resolved before attempting to extract `Place` in any of the pattern matching code

Closes rust-lang/project-rfc-2229/issues/27
Closes rust-lang/project-rfc-2229/issues/24
r? `@nikomatsakis`
2021-03-16 19:19:06 +00:00
Vadim Petrochenkov
e72d28352c ast: Reduce size of ExprKind by boxing fields of ExprKind::Struct 2021-03-16 11:41:24 +03:00
Vadim Petrochenkov
35e8be7407 ast/hir: Rename field-related structures
StructField -> FieldDef ("field definition")
Field -> ExprField ("expression field", not "field expression")
FieldPat -> PatField ("pattern field", not "field pattern")

Also rename visiting and other methods working on them.
2021-03-16 11:41:24 +03:00
Vadim Petrochenkov
09a9ea69bf Update clippy tests 2021-03-16 00:12:38 +03:00
Roxane
9d5daa6f45 Fix error after rebase 2021-03-15 13:16:18 -04:00
Roxane
7926664876 Add comments with examples and tests 2021-03-15 13:16:04 -04:00
hyd-dev
1d57c3e1fb Use rustc_interface::interface::Config::parse_sess_created in Clippy 2021-03-15 18:25:04 +08:00
Roxane
0ab2bcd182 Add fake_read() to clippy 2021-03-14 19:45:24 -04:00
flip1995
a189df12bd Clippy: HACK! Fix bootstrap error
This will be removed in the next sync, once beta is at 1.52. Until then
this hack avoids to put `cfg(bootstrap)` into Clippy.
2021-03-12 15:32:35 +01:00
flip1995
f2f2a005b4 Merge commit '6ed6f1e6a1a8f414ba7e6d9b8222e7e5a1686e42' into clippyup 2021-03-12 15:30:50 +01:00
bors
36a27ecaac Auto merge of #79519 - cjgillot:noattr, r=wesleywiser
Store HIR attributes in a side table

Same idea as #72015 but for attributes.
The objective is to reduce incr-comp invalidations due to modified attributes.
Notably, those due to modified doc comments.

Implementation:
- collect attributes during AST->HIR lowering, in `LocalDefId -> ItemLocalId -> &[Attributes]` nested tables;
- access the attributes through a `hir_owner_attrs` query;
- local refactorings to use this access;
- remove `attrs` from HIR data structures one-by-one.

Change in behaviour:
- the HIR visitor traverses all attributes at once instead of parent-by-parent;
- attribute arrays are sometimes duplicated: for statements and variant constructors;
- as a consequence, attributes are marked as used after unused-attribute lint emission to avoid duplicate lints.

~~Current bug: the lint level is not correctly applied in `std::backtrace_rs`, triggering an unused attribute warning on `#![no_std]`. I welcome suggestions.~~
2021-03-10 08:40:51 +00:00
bstrie
7406c12885 Deprecate items that accidentally weren't deprecated
Fixes #82080
2021-03-09 19:09:20 -05:00
Camille GILLOT
6c668266c0 Remove hir::Expr::attrs. 2021-03-09 19:27:58 +01:00
Camille GILLOT
dc9560cfd2 Remove hir::Item::attrs. 2021-03-09 19:27:50 +01:00
Camille GILLOT
49835d8abf Remove hir::ImplItem::attrs. 2021-03-09 19:23:08 +01:00
Camille GILLOT
dd2af148cc Remove hir::TraitItem::attrs. 2021-03-09 19:23:08 +01:00
Camille GILLOT
c3a17dba6c Remove hir::StructField::attrs. 2021-03-09 19:23:07 +01:00
Camille GILLOT
55f68ead6b Remove hir::Variant::attrs. 2021-03-09 19:23:06 +01:00
Camille GILLOT
04496071e4 Remove hir::Arm::attrs. 2021-03-09 19:23:05 +01:00
Camille GILLOT
b32cffe493 Remove hir::Crate::attrs. 2021-03-09 19:22:55 +01:00
Camille GILLOT
acd6014b80 Remove hir::Local::attrs. 2021-03-09 19:09:35 +01:00
Camille GILLOT
3e721b1445 Remove hir::StmtKind::attrs. 2021-03-09 19:09:35 +01:00
Camille GILLOT
476c5283d5 Do not store attrs in FnKind. 2021-03-09 19:09:33 +01:00
Camille GILLOT
8d5e0f512f Simplify clippy author. 2021-03-09 19:09:32 +01:00
kadmin
cb8bc0b6e6 Switch to changing cp_non_overlap in tform
It was suggested to lower this in MIR instead of ssa, so do that instead.
2021-03-09 16:54:14 +00:00
kadmin
fb4dc5845b Update cranelift 2021-03-09 16:54:14 +00:00
kadmin
6f60dd884e Update match branches
This updates all places where match branches check on StatementKind or UseContext.
This doesn't properly implement them, but adds TODOs where they are, and also adds some best
guesses to what they should be in some cases.
2021-03-09 16:54:13 +00:00
Mara Bos
824662d78a Rollup merge of #82048 - mark-i-m:or-pat-type-ascription, r=petrochenkov
or-patterns: disallow in `let` bindings

~~Blocked on https://github.com/rust-lang/rust/pull/81869~~

Disallows top-level or-patterns before type ascription. We want to reserve this syntactic space for possible future generalized type ascription.

r? ``@petrochenkov``
2021-03-09 09:05:20 +00:00