Commit graph

142407 commits

Author SHA1 Message Date
hyd-dev
ac044e35aa
Do not ignore path segments in the middle in #[allow]/#[warn]/#[deny]/#[forbid] attributes 2021-04-17 18:11:07 +08:00
bors
03301ef1d8 Auto merge of #84246 - notriddle:rustdoc-path-printing-cleanup, r=jyn514
rustdoc: get rid of unused path printing code

The code for printing a raw path is only used in utils.rs, which only prints the alternative (non-HTML) format. Path has
a function that does the same thing without HTML support, so use that instead.
2021-04-17 09:58:27 +00:00
bors
080d30235f Auto merge of #84244 - ABouttefeux:closure-return-conflict-suggest, r=estebank
fix incomplete diagnostic notes when closure returns conflicting for genric type

fixes #84128
Correctly report the span on for conflicting return type in closures
2021-04-17 07:17:31 +00:00
bors
57e28ef86f Auto merge of #84243 - Soveu:fix-derive-macro-const-default, r=petrochenkov
Builtin derive macros: fix error with const generics default

This fixes a bug where builtin derive macros (like Clone, Debug) would basically copy-paste the default from a const generic, causing a compile error with very confusing message - it would say defaults are not allowed in impl blocks, while pointing at struct/enum/union definition.
2021-04-17 04:48:36 +00:00
bors
42e5621c53 Auto merge of #84113 - SNCPlay42:suggestion-extern-crate, r=petrochenkov
Detect when suggested paths enter extern crates more rigorously

When reporting resolution errors, the compiler tries to avoid suggesting importing inaccessible paths from other crates. However, the search for suggestions only recognized when it was entering a crate root directly, and so failed to recognize a path like `crate::module::private_item`, where `module` was imported from another crate with `use other_crate::module`, as entering another crate.

Fixes #80079
Fixes #84081
2021-04-17 02:23:10 +00:00
bors
84e93979e1 Auto merge of #84074 - notriddle:rustdoc-macro-visibility, r=jyn514
rustdoc: clean up and test macro visibility print

This fixes the overly-complex invariant mentioned in <https://github.com/rust-lang/rust/pull/83237#issuecomment-815346570>, where the macro source can't have any links in it only because the cache hasn't been populated yet.
2021-04-16 23:41:43 +00:00
JP Sugarbroad
8b5faf4ab0 Switch transmute_ptr_to_ptr to "pedantic" class.
Per discussion in https://github.com/rust-lang/rust-clippy/issues/6372, this lint has significant false positives.
2021-04-16 14:29:23 -07:00
bors
e441b33ba0 Auto merge of #7099 - ABouttefeux:master, r=llogiq
add type in help message of from_over_into

fixes #7088
changelog: add type in help message of from_over_into
2021-04-16 21:22:24 +00:00
Aaron Hill
4cfc7b3f73
Error when compiletest is passed duplicate revisions
Currently, we allow the user to write things like
'// revisions: rpass1 rpass1', which will not test what they were
intending to test.
2021-04-16 17:05:59 -04:00
Aaron Hill
169a221618
Mark has_global_allocator query as eval_always
Fixes #84252

This query reads from untracked global state in `CStore`.
2021-04-16 16:28:54 -04:00
Cameron Steffen
5af078ac1b Add flat_map_option lint 2021-04-16 15:23:49 -05:00
Josh Triplett
9aa4d068a1 Add documentation to help people find Ipv4Addr::UNSPECIFIED
People looking for `INADDR_ANY` don't always find
`Ipv4Addr::UNSPECIFIED`; add some documentation and an alias to help.
2021-04-16 13:18:04 -07:00
bors
831c15737c Auto merge of #7087 - Jarcho:allman_style_else, r=camsteffen
Allow allman style braces in `suspicious_else_formatting`

fixes: #3864

Indentation checks could be added as well, but the lint already doesn't check for it.

changelog: Allow allman style braces in `suspicious_else_formatting`
2021-04-16 20:16:52 +00:00
Trevor Spiteri
18955203d3 doc: use U+2212 for minus sign in floating-point -0.0 remarks
Also remove plus sign in `-0.0 == +0.0` to make it a valid expression.
2021-04-16 21:48:41 +02:00
bors
b0c818c5e0 Auto merge of #84249 - crlf0710:fix_miri, r=RalfJung
Update miri.

Fixes #84240.

r? `@RalfJung`
2021-04-16 19:25:23 +00:00
Jason Newcomb
559deddb3b
Allow allman style braces in suspicious_else_formatting 2021-04-16 15:24:46 -04:00
bjorn3
21f13afafe Add comment 2021-04-16 20:55:51 +02:00
Ralf Jung
9aa6c1e0c9 fix 'const-stable since' for NonZeroU*::new_unchecked 2021-04-16 20:35:14 +02:00
bors
eaf0f3df15 Auto merge of #7075 - xFrednet:7054-fp-branches-sharing-code, r=camsteffen,flip1995
Fixing FPs for the `branches_sharing_code` lint

Fixes #7053
Fixes #7054
And an additional CSS adjustment to support dark mode for every inline code. It currently only works in paragraphs, which was an oversight on my part 😅. [Current Example](https://rust-lang.github.io/rust-clippy/master/index.html#blacklisted_name)

This also includes ~50 lines of doc comments and is therefor not as big as the changes would indicate. 🐧

---

changelog: none

All of these bugs were introduced in this dev version and are therefor not worth a change log entry.

r? `@phansch`
cc: `@camsteffen` since you have a pretty good overview of the `SpanlessEq` implementation 🙃
2021-04-16 18:33:45 +00:00
Joshua M. Clulow
4873271955 bootstrap: use bash on illumos to run install scripts
The default illumos shell ("sh" in the default PATH) is ksh93, rather
than bash, and does not support constructs like "local" that came from
bash.  The bootstrap function for invoking "install.sh" scripts should
use "bash" explicitly there to avoid issues.
2021-04-16 11:28:41 -07:00
Charles Lew
27c85295d9 Update miri. 2021-04-17 02:22:13 +08:00
Aliénore Bouttefeux
ccd0f0b4af added missing line in test ouput 2021-04-16 20:13:25 +02:00
Aliénore Bouttefeux
2d050f4b2f add type in help of from over Into 2021-04-16 19:38:01 +02:00
bors
28dbcd85c8 Auto merge of #7098 - camsteffen:cloned-copied, r=Manishearth
Add `cloned_instead_of_copied` lint

Don't go cloning all willy-nilly.

Featuring a new `get_iterator_item_ty` util!

changelog: Add cloned_instead_of_copied lint

Closes #3870
2021-04-16 17:32:13 +00:00
bors
7f2068cc2b Auto merge of #6568 - Jarcho:redundant_pattern_matching, r=flip1995
Fix: redundant_pattern_matching drop order

Fixes #5746

A note about the change in drop order is added when the scrutinee (or any temporary in the expression) isn't known to be safe to drop in any order (i.e. doesn't implement the `Drop` trait, or contain such a type). There is a whitelist for some `std` types, but it's incomplete. Currently just `Vec<_>`, `Box<_>`, `Rc<_>` and `Arc<_>`, but only if the contained type is also safe to drop in any order.

Another lint for when the drop order changes could be added as allowed by default, but the drop order requirement is pretty subtle in this case. I think the note added to the lint should be enough to make someone think before applying the change.

changelog: Added a note to `redundant_pattern_matching` when the change in drop order might matter
2021-04-16 16:45:59 +00:00
Cameron Steffen
b049c88fbe Eat dogfood 2021-04-16 11:39:31 -05:00
Cameron Steffen
0462666c70 Add cloned_instead_of_copied lint 2021-04-16 11:39:31 -05:00
bors
0cc00c48d2 Auto merge of #83416 - alexcrichton:const-thread-local, r=sfackler
std: Add a variant of thread locals with const init

This commit adds a variant of the `thread_local!` macro as a new
`thread_local_const_init!` macro which requires that the initialization
expression is constant (e.g. could be stuck into a `const` if so
desired). This form of thread local allows for a more efficient
implementation of `LocalKey::with` both if the value has a destructor
and if it doesn't. If the value doesn't have a destructor then `with`
should desugar to exactly as-if you use `#[thread_local]` given
sufficient inlining.

The purpose of this new form of thread locals is to precisely be
equivalent to `#[thread_local]` on platforms where possible for values
which fit the bill (those without destructors). This should help close
the gap in performance between `thread_local!`, which is safe, relative
to `#[thread_local]`, which is not easy to use in a portable fashion.
2021-04-16 16:36:46 +00:00
Alex Crichton
c6eea222a9 std: Add a variant of thread locals with const init
This commit adds a variant of the `thread_local!` macro as a new
`thread_local_const_init!` macro which requires that the initialization
expression is constant (e.g. could be stuck into a `const` if so
desired). This form of thread local allows for a more efficient
implementation of `LocalKey::with` both if the value has a destructor
and if it doesn't. If the value doesn't have a destructor then `with`
should desugar to exactly as-if you use `#[thread_local]` given
sufficient inlining.

The purpose of this new form of thread locals is to precisely be
equivalent to `#[thread_local]` on platforms where possible for values
which fit the bill (those without destructors). This should help close
the gap in performance between `thread_local!`, which is safe, relative
to `#[thread_local]`, which is not easy to use in a portable fashion.
2021-04-16 09:21:38 -07:00
Michael Howell
6109cee35c rustdoc: get rid of unused path printing code
The code for printing a raw path is only used in utils.rs,
which only prints the alternative (non-HTML) format. Path has
a function that does the same thing without HTML support,
so use that instead.
2021-04-16 08:46:47 -07:00
Aliénore Bouttefeux
af90cac0e1 fix reporting return type in some cases 2021-04-16 17:06:19 +02:00
Soveu
9ecfae44d7 builtin derive macros: fix error with const generics default 2021-04-16 16:29:11 +02:00
Yawara ISHIDA
61230f4cb8 Fixed incosistent_struct_constructor triggers in macro-generated code 2021-04-16 22:50:04 +09:00
bors
2faef12b65 Auto merge of #84241 - Dylan-DPC:rollup-jk9nt6k, r=Dylan-DPC
Rollup of 4 pull requests

Successful merges:

 - #83337 (rustdoc: Hide item contents, not items)
 - #83944 (Fix a couple resolve bugs from binder refactor)
 - #84145 (Address comments for vecdeque_binary_search #78021)
 - #84172 (Compiler error messages: reduce assertiveness of message E0384)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-04-16 13:46:01 +00:00
bors
1e0a3ff55c Auto merge of #6937 - Jarcho:map_entry_suggestion, r=giraffate
Improve `map_entry` suggestion

fixes: #5176
fixes: #4674
fixes: #4664
fixes: #1450

Still need to handle the value returned by `insert` correctly.

changelog: Improve `map_entry` suggestion. Will now suggest `or_insert`, `insert_with` or `match _.entry(_)` as appopriate.
changelog: Fix `map_entry` false positives where the entry api can't be used. e.g. when the map is used for multiple things.
2021-04-16 13:23:23 +00:00
Dylan DPC
c7c59d7c3b
Rollup merge of #84172 - jayaddison:compiler/E0384-reduce-assertiveness, r=petrochenkov
Compiler error messages: reduce assertiveness of message E0384

This message is emitted as guidance by the compiler when a developer attempts to reassign a value to an immutable variable.  Following the message will always currently work, but it may not always be the best course of action; following the 'consider ...' messaging pattern provides a hint to the developer that it could be wise to explore other alternatives.

Resolves #84144
2021-04-16 14:08:33 +02:00
Dylan DPC
a5ec5cf72a
Rollup merge of #84145 - vojtechkral:vecdeque-binary-search, r=m-ou-se
Address comments for vecdeque_binary_search #78021
2021-04-16 14:08:32 +02:00
Dylan DPC
8853aaeefc
Rollup merge of #83944 - jackh726:binder-refactor-fix2, r=lcnr
Fix a couple resolve bugs from binder refactor

Fixes #83753
Fixes #83907
2021-04-16 14:08:31 +02:00
Dylan DPC
a5c68d7908
Rollup merge of #83337 - Manishearth:item-hide, r=GuillaumeGomez
rustdoc: Hide item contents, not items

This tweaks rustdoc to hide item contents instead of items, and only when there are too many of them.

This means that users will _always_ see the type parameters, and will _often_ see fields/etc as long as they are small. Traits have some heuristics for hiding only the methods or only the methods and the consts, since the associated types are super important.

I'm happy to play around with the heuristics here; we could potentially make it so that structs/enums/etc are always hidden but traits will try really hard to show type aliases.

This needs a test, but you can see it rendered at https://manishearth.net/sand/doc_render/bar/

<details>

<summary> Code example </summary>

```rust
pub struct PubStruct {
    pub a: usize,
    pub b: usize,
}

pub struct BigPubStruct {
    pub a: usize,
    pub b: usize,
    pub c: usize,
    pub d: usize,
    pub e: usize,
    pub f: usize,
}

pub union BigUnion {
    pub a: usize,
    pub b: usize,
    pub c: usize,
    pub d: usize,
    pub e: usize,
    pub f: usize,
}

pub union Union {
    pub a: usize,
    pub b: usize,
    pub c: usize,
}

pub struct PrivStruct {
    a: usize,
    b: usize,
}

pub enum Enum {
    A, B, C,
    D {
        a: u8,
        b: u8
    }
}

pub enum LargeEnum {
    A, B, C, D, E, F, G, H, I, J
}

pub trait Trait {
    type A;
    #[must_use]
    fn foo();
    fn bar();
}

pub trait GinormousTrait {
    type A;
    type B;
    type C;
    type D;
    type E;
    type F;
    const N: usize = 1;
    #[must_use]
    fn foo();
    fn bar();
}

pub trait HugeTrait {
    type A;
    const M: usize = 1;
    const N: usize = 1;
    const O: usize = 1;
    const P: usize = 1;
    const Q: usize = 1;
    #[must_use]
    fn foo();
    fn bar();
}

pub trait BigTrait {
    type A;
    #[must_use]
    fn foo();
    fn bar();
    fn baz();
    fn quux();
    fn frob();
    fn greeble();
}

#[macro_export]
macro_rules! foo {
    (a) => {a};
}
```

</details>

Fixes https://github.com/rust-lang/rust/issues/82114
2021-04-16 14:08:30 +02:00
bors
3833636446 Auto merge of #84230 - cuviper:llvm-12, r=nikic
Update to LLVM 12.0.0 final
2021-04-16 10:55:43 +00:00
bors
d4bc912c48 Auto merge of #84217 - crlf0710:remove_main_attr_pure, r=petrochenkov
Remove #[main] attribute.

This removes the #[main] attribute support from the compiler according to the decisions within #29634. For existing use cases within test harness generation, replaced it with a newly-introduced internal attribute `#[rustc_main]`.

This is first part extracted from #84062 .

Closes #29634.

r? `@petrochenkov`
2021-04-16 08:01:45 +00:00
bors
ddc2598230 Auto merge of #7093 - Jarcho:single_match_fp, r=llogiq
Fix `single_match`

fixes: #7038
changelog: Don't suggest an equality check for types which don't implement `PartialEq` in `single_match`
2021-04-16 06:44:26 +00:00
bors
710da44e22 Auto merge of #84228 - SkiFire13:fix-84213, r=estebank
Suggest to borrow after failing to cast from T to *const/mut T

Fixes #84213
2021-04-16 05:13:43 +00:00
Charles Lew
696562d22d Remove #[main] attribute. 2021-04-16 13:04:02 +08:00
Charles Lew
fc357039f9 Remove #[main] attribute. 2021-04-16 13:04:02 +08:00
bors
faa97568a0 Auto merge of #7085 - Jarcho:manual_map_autoderef, r=giraffate
Don't allow adjustments for `manual_map`

fixes: #7077

The other option here would be to add the return type to the closure. It would be fine for simple types, but longer types can be rather unwieldy. Could also implement the adjustment manually.

changelog: Don't lint `manual_map` when type adjustments are added. e.g. autoderef
2021-04-16 03:05:52 +00:00
bors
5e7bebad1d Auto merge of #84220 - gpluscb:weak_doc, r=jyn514
Correct outdated documentation for rc::Weak

This was overlooked in ~~#50357~~ #51901
2021-04-16 02:31:15 +00:00
Jason Newcomb
9a55c0c176
Fix single_match
Check for `PartialEq` in addition to `StructuralPartialEq` before suggesting `==`
2021-04-15 22:09:20 -04:00
Jason Newcomb
c02baba1dc
redundant_pattern_matching fix inverted boolean when missing Drop trait # Please enter the commit message for your changes. Lines starting # with '#' will be ignored, and an empty message aborts the commit. # # Date: Fri Apr 2 19:04:45 2021 -0400 # # On branch redundant_pattern_matching # Your branch is ahead of 'origin/redundant_pattern_matching' by 1 commit. # (use "git push" to publish your local commits) # # Changes to be committed: # modified: clippy_lints/src/matches.rs # # Please enter the commit message for your changes. Lines starting # with '#' will be ignored, and an empty message aborts the commit. # # Date: Fri Apr 2 19:04:45 2021 -0400 # # interactive rebase in progress; onto ebc64690d # Last commands done (6 commands done): # pick 25d211ad8 Code cleanup and additional std types checked # r 0c71ce56f redundant_pattern_matching fix inverted boolean when missing Drop trait # No commands remaining. # You are currently editing a commit while rebasing branch 'redundant_pattern_matching' on 'ebc64690d'. # # Changes to be committed: # modified: clippy_lints/src/matches.rs # 2021-04-15 20:37:20 -04:00
Jason Newcomb
b6581636bd
Improve redundant_pattern_matching
Add a note when the drop order change may result in different behaviour.
2021-04-15 20:37:15 -04:00