Commit graph

161353 commits

Author SHA1 Message Date
flip1995 0fc3fda8e7
Merge commit '8d14c94b5c0a66241b4244f1c60ac5859cec1d97' into clippyup 2022-01-17 13:29:07 +01:00
bors 8d14c94b5c Auto merge of #8292 - marekdownar:8239, r=xFrednet
issue #8239: Printed hint for lint or_fun_call is cropped and does no…

fixes rust-lang/rust-clippy#8239

changelog: [`or_fun_call`]: if suggestion contains more lines than MAX_SUGGESTION_HIGHLIGHT_LINES it is stripped to one line
2022-01-17 12:08:30 +00:00
bors 72c59fda27 Auto merge of #8302 - xFrednet:0000-move-return-self-not-must-use, r=flip1995
Move `return_self_not_must_use` to `pedantic`

r? `@flip1995`

changelog: none
2022-01-17 11:35:58 +00:00
xFrednet 2d3eb5082a
Move return_self_not_must_use to pedantic 2022-01-17 12:35:19 +01:00
Marek Downar 69d78ceeba
removing unsafe from test fn's && renaming shrink to sugg_span 2022-01-17 12:34:03 +01:00
bors a34c079752 Auto merge of #92816 - tmiasko:rm-llvm-asm, r=Amanieu
Remove deprecated LLVM-style inline assembly

The `llvm_asm!` was deprecated back in #87590 1.56.0, with intention to remove
it once `asm!` was stabilized, which already happened in #91728 1.59.0. Now it
is time to remove `llvm_asm!` to avoid continued maintenance cost.

Closes #70173.
Closes #92794.
Closes #87612.
Closes #82065.

cc `@rust-lang/wg-inline-asm`

r? `@Amanieu`
2022-01-17 09:40:29 +00:00
bors d364d8ad5b Auto merge of #8299 - marekdownar:8214, r=Manishearth
#8214 cmp_owned suggestion flips the comparison

changelog: ``[`cmp_owned`]`` fixes #8214 so that the suggestion does not flip the comparison
2022-01-17 07:04:06 +00:00
bors 537a7f3e44 Auto merge of #8297 - Jarcho:if_same_then_else_7579, r=Manishearth
Don't lint `if_same_then_else` with `if let` conditions

fixes #7579

changelog: Don't lint `if_same_then_else` with `if let` conditions
2022-01-17 06:48:01 +00:00
woppopo e6aef256e6 Add ~const bound test for negative impls 2022-01-17 14:50:40 +09:00
bors 128417f40f Auto merge of #92996 - matthiaskrgr:rollup-50wpzva, r=matthiaskrgr
Rollup of 10 pull requests

Successful merges:

 - #92795 (Link sidebar "location" heading to top of page)
 - #92799 (Remove some unnecessary uses of `FieldDef::ident`)
 - #92808 (Fix `try wrapping expression in variant` suggestion with struct field shorthand)
 - #92819 (rustdoc: remove hand-rolled isatty)
 - #92876 (Fix suggesting turbofish with lifetime arguments)
 - #92921 (Rename Printer constructor from mk_printer() to Printer::new())
 - #92937 (rustdoc: Add missing dot separator)
 - #92953 (Copy an example to PartialOrd as well)
 - #92977 (Docs: recommend VecDeque instead of Vec::remove(0))
 - #92981 (fix const_ptr_offset_from tracking issue)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-01-17 05:46:53 +00:00
Matthias Krüger 9612038a7e
Rollup merge of #92981 - RalfJung:const_ptr_offset_from, r=dtolnay
fix const_ptr_offset_from tracking issue

The old tracking issue #41079 was for exposing those functions at all, and got closed when they were stabilized. We had nothing tracking their `const`ness so I opened a new tracking issue: https://github.com/rust-lang/rust/issues/92980.
2022-01-17 06:08:19 +01:00
Matthias Krüger 7bdd978c24
Rollup merge of #92977 - kornelski:popdoc, r=dtolnay
Docs: recommend VecDeque instead of Vec::remove(0)

Suggestion based on a [discussion](https://internals.rust-lang.org/t/should-vec-have-a-try-remove-mut-self-usize-option-t-function/15964/9?u=kornel) where user needlessly struggled with `remove(0)` and accidentally created a quadratic cost.
2022-01-17 06:08:18 +01:00
Matthias Krüger 775fe37ca9
Rollup merge of #92953 - azdavis:azdavis-copy-example, r=dtolnay
Copy an example to PartialOrd as well

In https://github.com/rust-lang/rust/pull/88202 I added an example for deriving PartialOrd on enums, but only later did I realize that I actually put the example on Ord.

This copies the example to PartialOrd as well, which is where I intended for it to be.

We could also delete the example on Ord, but I see there's already some highly similar examples shared between Ord and PartialOrd, so I figured we could leave it.

I also changed some type annotations in an example from `x : T` to the more common style (in Rust) of `x: T`.
2022-01-17 06:08:17 +01:00
Matthias Krüger 0aae1ec9ff
Rollup merge of #92937 - GuillaumeGomez:dot-separator, r=jsha
rustdoc: Add missing dot separator

Fixes #92901.

![Screenshot from 2022-01-15 17-47-18](https://user-images.githubusercontent.com/3050060/149631249-e2c0c3a4-9ed8-48e2-92cc-79a5bb347b35.png)

r? ``@jsha``
2022-01-17 06:08:17 +01:00
Matthias Krüger 216ce7c519
Rollup merge of #92921 - dtolnay:printernew, r=wesleywiser
Rename Printer constructor from mk_printer() to Printer::new()

The original naming is left over from 2011 which was before impl blocks and associated functions existed.

21313d623a/src/comp/pretty/pp.rs
2022-01-17 06:08:16 +01:00
Matthias Krüger c6ff4be011
Rollup merge of #92876 - compiler-errors:fix-turbofish-lifetime-suggestion, r=nagisa
Fix suggesting turbofish with lifetime arguments

Now we suggest turbofish correctly given exprs like `foo<'_>`.

Also fix suggestion when we have `let x = foo<bar, baz>;` which was broken.
2022-01-17 06:08:15 +01:00
Matthias Krüger 681271e045
Rollup merge of #92819 - euclio:atty, r=CraftSpider
rustdoc: remove hand-rolled isatty

This PR replaces bindings to the platform-specific isatty APIs with the `isatty` crate, as done elsewhere in the repository.
2022-01-17 06:08:14 +01:00
Matthias Krüger ff1b653cdb
Rollup merge of #92808 - compiler-errors:wrap-struct-shorthand-field-in-variant, r=davidtwco
Fix `try wrapping expression in variant` suggestion with struct field shorthand

Fixes a broken suggestion: [playground](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=83fe2dbfe1485f8cfca1aef2a6582e77)

before:
```
error[E0308]: mismatched types
 --> src/main.rs:7:19
  |
7 |     let x = Foo { bar };
  |                   ^^^ expected enum `Option`, found integer
  |
  = note: expected enum `Option<i32>`
             found type `{integer}`
help: try wrapping the expression in `Some`
  |
7 |     let x = Foo { Some(bar) };
  |                   +++++   +
```

after:
```
error[E0308]: mismatched types
 --> src/main.rs:7:19
  |
7 |     let x = Foo { bar };
  |                   ^^^ expected enum `Option`, found integer
  |
  = note: expected enum `Option<i32>`
             found type `{integer}`
help: try wrapping the expression in `Some`
  |
7 |     let x = Foo { bar: Some(bar) };
  |                   ~~~~~~~~~~~~~~
```

r? ``@m-ou-se``
since you touched the code last in #91080
2022-01-17 06:08:13 +01:00
Matthias Krüger 3de7276689
Rollup merge of #92799 - rust-lang:followup-from-92533, r=Aaron1011
Remove some unnecessary uses of `FieldDef::ident`

Followup from #92533.

cc ``@Aaron1011`` ``@petrochenkov``
2022-01-17 06:08:11 +01:00
Matthias Krüger 869b7bc5e7
Rollup merge of #92795 - jsha:link-to-top, r=GuillaumeGomez
Link sidebar "location" heading to top of page

This makes it easy, when you are scrolled far down in a page, to jump back to the top.

Demo: https://rustdoc.crud.net/jsha/link-to-top/std/string/struct.String.html

r? ``@GuillaumeGomez``
2022-01-17 06:08:10 +01:00
bors fd20513f52 Auto merge of #92473 - petrochenkov:ltrattr2, r=Aaron1011
expand: Pick `cfg`s and `cfg_attrs` one by one, like other attributes

This is a rebase of https://github.com/rust-lang/rust/pull/83354, but without any language-changing parts ~(except for https://github.com/rust-lang/rust/pull/84110)~, i.e. the attribute expansion order is the same.

This is a pre-requisite for any other changes making cfg attributes closer to regular macro attributes
- Possibly changing their expansion order (https://github.com/rust-lang/rust/issues/83331)
- Keeping macro backtraces for cfg attributes, or otherwise making them visible after expansion without keeping them in place literally (https://github.com/rust-lang/rust/pull/84110).

Two exceptions to the "one by one" behavior are:
- cfgs eagerly expanded by `derive` and `cfg_eval`, they are still expanded in a batch, that's by design.
- cfgs at the crate root, they are currently expanded not during the main expansion pass, but before that, during `#![feature]` collection. I'll try to disentangle that logic later in a separate PR.

r? `@Aaron1011`
2022-01-17 02:06:54 +00:00
Jason Newcomb 5461ed670e Don't lint if_same_then_else with if let conditions 2022-01-16 18:39:46 -05:00
bors 1fbd6aedb3 Auto merge of #92935 - Xanewok:update-rls, r=pietroalbini
Update RLS and drop rustc-ap-packages

Closes #91543

r? `@pietroalbini`

cc `@calebcartwright` `@flip1995`
2022-01-16 23:03:33 +00:00
Cameron Steffen be6d6934b6 Fix Visitor::NestedFilter in Clippy 2022-01-16 16:02:36 -06:00
Cameron Steffen 1a6312ee0f Format clippy 2022-01-16 16:02:36 -06:00
Cameron Steffen 45db716902 Replace NestedVisitorMap with NestedFilter 2022-01-16 16:02:36 -06:00
Ralf Jung bb1423e019 fix const_ptr_offset_from tracking issue 2022-01-16 15:21:42 -05:00
bors 93cad4a94d Auto merge of #8203 - pmnoxx:piotr-next-lint, r=llogiq
New lint: `iter_overeager_cloned`

Closes #8202

changelog: New lint: [`iter_overeager_cloned`]
2022-01-16 20:02:28 +00:00
Marek Downar 5b6ec8c57d
#8214 cmp_owned suggestion flips the comparison 2022-01-16 20:27:00 +01:00
Piotr Mikulski 36396c6b97 Fix tests 2022-01-16 10:33:30 -08:00
Piotr Mikulski d48d247309 Fix clippy warnings 2022-01-16 10:19:48 -08:00
Piotr Mikulski 1c9b31d350 New line: cloned_next 2022-01-16 09:59:29 -08:00
Kornel 361ef2aadc Docs: recommend VecDeque instead of Vec::remove(0) 2022-01-16 17:53:05 +00:00
bors bd3cb52565 Auto merge of #92970 - matthiaskrgr:rollup-tcx7cfb, r=matthiaskrgr
Rollup of 10 pull requests

Successful merges:

 - #92487 (Fix unclosed boxes in pretty printing of TraitAlias)
 - #92581 (ARMv6K Horizon - Enable default libraries)
 - #92619 (Add diagnostic items for macros)
 - #92635 (rustdoc: Yet more intra-doc links cleanup)
 - #92646 (feat: rustc_pass_by_value lint attribute)
 - #92706 (Clarify explicitly that BTree{Map,Set} are ordered.)
 - #92710 (Include Projections when elaborating TypeOutlives)
 - #92746 (Parse `Ty?` as `Option<Ty>` and provide structured suggestion)
 - #92792 (rustdoc: fix intra-link for generic trait impls)
 - #92814 (remove unused FIXME)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-01-16 17:22:57 +00:00
Matthias Krüger 2b6b49e1d7
Rollup merge of #92814 - lcnr:unused-fixme, r=Mark-Simulacrum
remove unused FIXME

#56935 seems to be fixed.
2022-01-16 16:58:20 +01:00
Matthias Krüger 682ad02b49
Rollup merge of #92792 - mdibaiee:92662/fix-intra-doc-generics, r=camelid
rustdoc: fix intra-link for generic trait impls

fixes #92662

r? `````@camelid`````
2022-01-16 16:58:19 +01:00
Matthias Krüger 9323a0d1be
Rollup merge of #92746 - estebank:question-mark-in-type, r=davidtwco
Parse `Ty?` as `Option<Ty>` and provide structured suggestion

Swift has specific syntax that desugars to `Option<T>` similar to our
`?` operator, which means that people might try to use it in Rust. Parse
it and gracefully recover.
2022-01-16 16:58:18 +01:00
Matthias Krüger 9835b90c91
Rollup merge of #92710 - jackh726:issue-92280, r=nikomatsakis
Include Projections when elaborating TypeOutlives

Fixes #92280

In `Elaborator`, we elaborate that `Foo<<Bar as Baz>::Assoc>: 'a` -> `<Bar as Baz>::Assoc: 'a`. This is the same rule that would be applied to any other `Param`. If there are escaping vars, we continue to do nothing.

r? `@nikomatsakis`
2022-01-16 16:58:17 +01:00
Matthias Krüger 039d6dc289
Rollup merge of #92706 - umanwizard:btree, r=dtolnay
Clarify explicitly that BTree{Map,Set} are ordered.

One of the main reasons one would want to use a BTree{Map,Set} rather than a Hash{Map,Set} is because they maintain their keys in sorted order; but this was never explicitly stated in the top-level docs (it was only indirectly alluded to there, and stated explicitly in the docs for `iter`, `values`, etc.)

This PR states the ordering guarantee more prominently.
2022-01-16 16:58:16 +01:00
Matthias Krüger c5041f88ea
Rollup merge of #92646 - mdibaiee:76935/pass-by-value, r=lcnr
feat: rustc_pass_by_value lint attribute

Useful for thin wrapper attributes that are best passed as value instead
of reference.

Fixes #76935
2022-01-16 16:58:15 +01:00
Matthias Krüger e1b943991f
Rollup merge of #92635 - camelid:yet-more-cleanup, r=Manishearth
rustdoc: Yet more intra-doc links cleanup

r? `@Manishearth`
2022-01-16 16:58:14 +01:00
Matthias Krüger cf4549c920
Rollup merge of #92619 - Alexendoo:macro-diagnostic-items, r=matthewjasper
Add diagnostic items for macros

For use in Clippy, it adds diagnostic items to all the stable public macros

Clippy has lints that look for almost all of these (currently by name or path), but there are a few that aren't currently part of any lint, I could remove those if it's preferred to add them as needed rather than ahead of time
2022-01-16 16:58:14 +01:00
Matthias Krüger 391b66ccff
Rollup merge of #92581 - Meziu:armv6k-3ds-target, r=nagisa
ARMv6K Horizon - Enable default libraries

Due to the nature of the external gcc linker, default libraries are required, even for `no_std` programs.
2022-01-16 16:58:12 +01:00
Matthias Krüger 9527533408
Rollup merge of #92487 - dtolnay:traitalias, r=matthewjasper
Fix unclosed boxes in pretty printing of TraitAlias

This was causing trait aliases to not even render at all in stringified / pretty printed output.

```rust
macro_rules! repro {
    ($item:item) => {
        stringify!($item)
    };
}

fn main() {
    println!("{:?}", repro!(pub trait Trait<T> = Sized where T: 'a;));
}
```

Before:&ensp;`""`
After:&ensp;`"pub trait Trait<T> = Sized where T: 'a;"`

The fix is copied from how `head`/`end` for `ItemKind::Use`, `ItemKind::ExternCrate`, and `ItemKind::Mod` are all done in the pretty printer:

dd3ac41495/compiler/rustc_ast_pretty/src/pprust/state.rs (L1178-L1184)
2022-01-16 16:58:10 +01:00
Igor Matuszewski 69c3b723d2 Use new Racer from crates.io 2022-01-16 15:30:47 +01:00
Igor Matuszewski 7f04877b1e Drop duplicate checks for now missing rustc_ast dep in tidy 2022-01-16 15:30:47 +01:00
Igor Matuszewski d83c44a03b Update RLS and drop rustc-ap-packages 2022-01-16 15:30:46 +01:00
bors 48e89b00ca Auto merge of #92245 - petrochenkov:cmrval, r=nagisa
rustc_metadata: Switch all decoder methods from vectors to iterators

To avoid allocations in some cases.

Also remove unnecessary `is_proc_macro_crate` checks from decoder, currently the general strategy is to shift all the work to the encoder and assume that all the encoded data is correct and can be decoded unconditionally in the decoder.
2022-01-16 14:25:25 +00:00
bors 0d27bd846c Auto merge of #8295 - Jarcho:useless_format_8290, r=giraffate
Handle implicit named arguments in `useless_format`

fixes #8290

Ideally this would fix the macro parsing code to handle this, but this is a smaller change and easier to back port.

changelog: Handle implicit named arguments in `useless_format`
2022-01-16 13:24:08 +00:00
bors d61f798aac Auto merge of #8284 - xFrednet:0000-update-copyright-year-i-am-procrastinating, r=giraffate
Update copyright year for Clippy (2022 edition)

At this point, I'm just searching for small things to do instead of sleeping or working on my bachelor thesis. 😅  Taking one day off will be fine 🙃

changelog: none
2022-01-16 12:33:08 +00:00