Commit graph

126257 commits

Author SHA1 Message Date
bors
2d86cc5a33 Auto merge of #5930 - ebroto:dev_newlint_fix_lt, r=matthiaskrgr
Fix cargo dev new_lint for late lint passes

Since 30c046ede4, `LateLintPass` has only one lifetime parameter.

I'm not sure how to easily test this, I think adding this kind of tests would be probably part of #5394

changelog: none
2020-08-23 10:59:53 +00:00
rail
91b200c62b Fix fp in borrow_interior_mutable_const
Fix false positive when referencing a field behind a pointer.
2020-08-23 22:49:08 +12:00
Ayush Kumar Mishra
18f47d81da Misleading documentation for derived Ord/PartialOrd implementation for enums #75620 2020-08-23 15:56:01 +05:30
bors
2342cc3333 Auto merge of #75789 - matthiaskrgr:clippy_compiletest, r=Dylan-DPC
compiletest: fix a couple clippy lint findings
2020-08-23 10:25:53 +00:00
Eduardo Broto
8776db9f6d Fix ICE in repeat_once lint 2020-08-23 12:05:34 +02:00
Lzu Tao
2c995d29f7 Prefer https link for wikipedia URLs 2020-08-23 10:02:42 +00:00
Eduardo Broto
eb8ede7f65 Improve documentation related to the sync process 2020-08-23 11:33:59 +02:00
bors
d5ba3efed1 Auto merge of #75465 - Aaron1011:feature/short-fn-def-span, r=estebank
Use smaller def span for functions

Currently, the def span of a function encompasses the entire function
signature and body. However, this is usually unnecessarily verbose - when we are
pointing at an entire function in a diagnostic, we almost always want to
point at the signature. The actual contents of the body tends to be
irrelevant to the diagnostic we are emitting, and just takes up
additional screen space.

This commit changes the `def_span` of all function items (freestanding
functions, `impl`-block methods, and `trait`-block methods) to be the
span of the signature. For example, the function

```rust
pub fn foo<T>(val: T) -> T { val }
```

now has a `def_span` corresponding to `pub fn foo<T>(val: T) -> T`
(everything before the opening curly brace).

Trait methods without a body have a `def_span` which includes the
trailing semicolon. For example:

```rust
trait Foo {
    fn bar();
}
```

the function definition `Foo::bar` has a `def_span` of `fn bar();`

This makes our diagnostic output much shorter, and emphasizes
information that is relevant to whatever diagnostic we are reporting.

We continue to use the full span (including the body) in a few of
places:

* MIR building uses the full span when building source scopes.
* 'Outlives suggestions' use the full span to sort the diagnostics being
  emitted.
* The `#[rustc_on_unimplemented(enclosing_scope="in this scope")]`
attribute points the entire scope body.

All of these cases work only with local items, so we don't need to
add anything extra to crate metadata.
2020-08-23 08:14:17 +00:00
Eduardo Broto
6dd65b8e6a Fix cargo dev new_lint for late lint passes 2020-08-23 10:14:09 +02:00
bors
d5abc8d3b2 Auto merge of #75813 - petrochenkov:feature/incr-def-path-table, r=Aaron1011
Lazy decoding of DefPathTable from crate metadata (non-incremental case)

The is the half of https://github.com/rust-lang/rust/pull/74967 that doesn't touch incremental-related structures.
We are still decoding def path hashes eagerly if we are in incremental mode.

The incremental part of https://github.com/rust-lang/rust/pull/74967 feels hacky, but I'm not qualified enough to suggest improvements. I'll reassign it so someone else once this PR lands.
@Aaron1011, I wasn't asking you to do this split because I wasn't sure that it's feasible (or simple to do).

r? @Aaron1011
2020-08-23 05:56:47 +00:00
Michael Wright
e8d33d73dc Fix let_and_return bad suggestion
Add a cast to the suggestion when the return expression has adjustments.
These adjustments are lost when the suggestion is applied.

This is similar to the problem in issue #4437.

Closes #5729
2020-08-23 07:50:59 +02:00
JR Heard
69d3334adf
Fix typo in documentation of i32 wrapping_abs() 2020-08-22 22:21:03 -07:00
bors
7ce71c362b Auto merge of #73526 - cuviper:rust-llvm11, r=nikic
Upgrade to LLVM 11 (rc2)

This builds on #73525 to try actually moving rust-lang/llvm-project to LLVM 11.
2020-08-23 04:02:41 +00:00
Camelid
637659be6a Add missing links 2020-08-22 20:23:50 -07:00
bors
e482c86b9d Auto merge of #73084 - Aaron1011:feature/new-recursive-expand, r=petrochenkov
Re-land PR #72388:  Recursively expand `TokenKind::Interpolated` in `probably_equal_for_proc_macro`

PR #72388 allowed us to preserve the original `TokenStream` in more cases during proc-macro expansion, but had to be reverted due to a large number of regressions (See #72545 and #72622). These regressions fell into two categories

1. Missing handling for `Group`s with `Delimiter::None`, which are inserted during `macro_rules!` expansion (but are lost during stringification and re-parsing). A large number of these regressions were due to `syn` and `proc-macro-hack`, but several crates needed changes to their own proc-macro code.
2. Legitimate hygiene issues that were previously being masked by stringification. Some of these were relatively benign (e.g. [a compiliation error](https://github.com/paritytech/parity-scale-codec/pull/210) caused by misusing `quote_spanned!`). However, two crates had intentionally written unhygenic `macro_rules!` macros, which were able to access identifiers that were not passed as arguments (see https://github.com/rust-lang/rust/issues/72622#issuecomment-636402573).

All but one of the Crater regressions have now been fixed upstream (see https://hackmd.io/ItrXWRaSSquVwoJATPx3PQ?both). The remaining crate (which has a PR pending at https://github.com/sammhicks/face-generator/pull/1) is not on `crates.io`, and is a Yew application that seems unlikely to have any reverse dependencies.

As @petrochenkov mentioned in https://github.com/rust-lang/rust/issues/72545#issuecomment-638632434, not re-landing PR #72388 allows more crates to write unhygenic `macro_rules!` macros, which will eventually stop compiling. Since there is only one Crater regression remaining, since additional crates could write unhygenic `macro_rules!` macros in the time it takes that PR to be merged.
2020-08-23 01:44:36 +00:00
Camelid
becf5ec4ea Add missing intra-doc link 2020-08-22 17:41:40 -07:00
Camelid
5d32786b4f Switch to intra-doc links in std::macros
Also:
* Fix typo in module docs
* Link to `std::io::stderr` instead of `std::io::Stderr` to match the
  link text
* Link to `std::io::stdout`
2020-08-22 15:44:00 -07:00
Aaron Hill
e3cd43eb00
Use smaller def span for functions
Currently, the def span of a funtion encompasses the entire function
signature and body. However, this is usually unnecessarily verbose - when we are
pointing at an entire function in a diagnostic, we almost always want to
point at the signature. The actual contents of the body tends to be
irrelevant to the diagnostic we are emitting, and just takes up
additional screen space.

This commit changes the `def_span` of all function items (freestanding
functions, `impl`-block methods, and `trait`-block methods) to be the
span of the signature. For example, the function

```rust
pub fn foo<T>(val: T) -> T { val }
```

now has a `def_span` corresponding to `pub fn foo<T>(val: T) -> T`
(everything before the opening curly brace).

Trait methods without a body have a `def_span` which includes the
trailing semicolon. For example:

```rust
trait Foo {
    fn bar();
}```

the function definition `Foo::bar` has a `def_span` of `fn bar();`

This makes our diagnostic output much shorter, and emphasizes
information that is relevant to whatever diagnostic we are reporting.

We continue to use the full span (including the body) in a few of
places:

* MIR building uses the full span when building source scopes.
* 'Outlives suggestions' use the full span to sort the diagnostics being
  emitted.
* The `#[rustc_on_unimplemented(enclosing_scope="in this scope")]`
attribute points the entire scope body.
* The 'unconditional recursion' lint uses the full span to show
  additional context for the recursive call.

All of these cases work only with local items, so we don't need to
add anything extra to crate metadata.
2020-08-22 18:41:49 -04:00
Aaron Hill
0fcad9cd29
Add backwards-compat hack for certain '$name' tokens
See issue #74616
2020-08-22 17:31:47 -04:00
Aaron Hill
cd24aee8e6
Recursively expand TokenKind::Interpolated (take 2)
Fixes #68430

This is a re-attempt of PR #72388, which was previously reverted due to
a large number of breakages. All of the known breakages should now be
patched upstream.
2020-08-22 17:18:26 -04:00
Oliver Middleton
57e7e2875b Update docs for SystemTime Windows implementation
Windows now uses `GetSystemTimePreciseAsFileTime` on versions of Windows that support it.
2020-08-22 22:00:33 +01:00
Josh Stone
b450c0c86c Write coverage filenames in Version3 format 2020-08-22 13:44:54 -07:00
Josh Stone
fb05be00df Match scalar-pair-bool more flexibly for LLVM 11
LLVM 11 started using `phi` and `select` for `fn pair_i32_bool`, which
is still valid, but harder to match than the simple instructions we were
getting before. We'll just check that the unpacked args are directly
referenced in any way, and call it good.
2020-08-22 13:44:54 -07:00
Josh Stone
5c87749a27 Apply suggestions from code review
Flatten the INC definition to one line.

Co-authored-by: lzutao <taolzu@gmail.com>
2020-08-22 13:44:54 -07:00
Josh Stone
a210a29303 Expand RISCV pseudo-instructions to match LLVM 11 2020-08-22 13:44:54 -07:00
Josh Stone
636ca7a412 Upgrade to LLVM 11 (rc2) 2020-08-22 13:44:54 -07:00
Josh Stone
df4bafc360 Don't make clang use gcc's include-fixed
This was breaking `#include_next <limits.h>`, such that we weren't
getting definitions of `PATH_MAX` and `_POSIX_ARG_MAX`.
2020-08-22 13:44:53 -07:00
Dylan MacKenzie
b65daa7688 Test new floating point bit casts 2020-08-22 13:35:30 -07:00
LeSeulArtichaut
c3e3b7f119 Use intra-doc link in proc_macro 2020-08-22 22:29:43 +02:00
LeSeulArtichaut
c8a372ecff Use intra-doc-links in core::{raw, ffi, pin} 2020-08-22 22:25:27 +02:00
Dylan MacKenzie
23e08e223b Add #![feature(const_float_classify)] for f64::classify and friends 2020-08-22 12:28:31 -07:00
Dylan MacKenzie
3cd450ec5d Add #![feature(const_float_bits_conv)] for f64::to_bits and friends 2020-08-22 12:28:31 -07:00
bors
663d2f5cd3 Auto merge of #75171 - amosonn:new_zeroed_slice, r=Amanieu
New zeroed slice

Add to #63291 the methods

```rust
impl<T> Box<[T]> { pub fn new_zeroed_slice(len: usize) -> Box<[MaybeUninit<T>]> {…} }
impl<T> Rc<[T]> { pub fn new_zeroed_slice(len: usize) -> Rc<[MaybeUninit<T>]> {…} }
impl<T> Arc<[T]> { pub fn new_zeroed_slice(len: usize) -> Arc<[MaybeUninit<T>]> {…} }
```

as suggested in https://github.com/rust-lang/rust/issues/63291#issuecomment-605511675 .

Also optimize `{Rc, Arc}::new_zeroed` to use `alloc_zeroed`, otherwise they are no more efficient than using `new_uninit` and zeroing the memory manually (which was the original implementation).
2020-08-22 18:46:42 +00:00
Vadim Petrochenkov
6a5e6572cb rustc_metadata: Move some code around to merge impls of CrateMetadataRef 2020-08-22 21:38:56 +03:00
Vadim Petrochenkov
15643d5d90 Do not forget capacity when collecting def path hashes 2020-08-22 21:36:34 +03:00
bors
dd07860b83 Auto merge of #5941 - ThibsG:InlineInCopyPassByRef, r=yaahc
Don't lint if it has always inline attribute

Don't trigger the lint `trivially_copy_pass_by_ref` if it has `#[inline(always)]` attribute.

Note: I am not particularly familiar with `inline` impacts, so I implemented this the way that if only `#[inline]` attribute is here (without `always`), the lint will still trigger. Also, it will still trigger if it has `#[inline(never)]`.
Just tell me if it sounds too much conservative.

Fixes: #5876

changelog: none
2020-08-22 18:30:39 +00:00
Aaron Hill
df57e28685 Lazy decoding of DefPathTable from crate metadata (non-incremental case) 2020-08-22 21:19:47 +03:00
Dylan MacKenzie
e2326a1eec Treat a NULL return from dlsym as an error on illumos
This works around behavior observed on illumos in #74469, in which
foreign code (libc according to the OP) was racing with rustc to check
`dlerror`.
2020-08-22 11:14:07 -07:00
Dylan MacKenzie
766fcb0b01 Refactor dynamic library error checking on *nix
The old code was checking `dlerror` more often than necessary, since the
return value of `dlopen` indicates whether an error occurred.
2020-08-22 11:14:07 -07:00
bors
5528caf914 Auto merge of #74566 - lzutao:guard, r=petrochenkov
Gate if-let guard feature

Enhanced on #74315. That PR is in crater queue so I don't want to push to it.

Close  #74232
cc #51114
2020-08-22 15:38:13 +00:00
bors
527a685e40 Auto merge of #75783 - denisvasilik:intra-doc-links-core-alloc, r=jyn514
Move to intra-doc links for library/core/src/alloc/{layout, global, mod}.rs

Helps with #75080. The files already contained intra-doc links, so there are only minor changes.

@rustbot modify labels: T-doc, A-intra-doc-links, T-rustdoc

Known issues:

* [`handle_alloc_error`]: Link from `core` to `alloc` could not be resolved.
* [`slice`]: slice is a primitive type, but could not be resolved; had to use [`crate::slice`] instead.
2020-08-22 13:21:24 +00:00
Ralf Jung
9a12d9a243 fix dead links to wrapping_offset_from 2020-08-22 15:07:34 +02:00
Ralf Jung
4f92f0d31b remove feature gate from tests 2020-08-22 15:07:32 +02:00
bors
f21d10b970 Auto merge of #5929 - stchris:issues/5917, r=ebroto
Widen understanding of prelude import

Prelude imports are exempt from wildcard import warnings. Until now only
imports of the form

```
use ...::prelude::*;
```

were considered. This change makes it so that the segment `prelude` can
show up anywhere, for instance:

```
use ...::prelude::v1::*;
```

Fixes #5917

changelog: Allow `prelude` to appear in any segment of the import path in [`wildcard_imports`]
2020-08-22 12:50:22 +00:00
Ralf Jung
0e4f335e63 stabilize ptr_offset_from 2020-08-22 14:37:10 +02:00
Ralf Jung
7ad4369ba6 remove deprecated wrapping_offset_from 2020-08-22 14:37:08 +02:00
Ralf Jung
1241f1927e offset_from: also document same-provenance requirement 2020-08-22 14:37:06 +02:00
Christian Stefanescu
e615a26ae4 Use more elegant way to check for prelude string 2020-08-22 14:22:02 +02:00
Christian Stefanescu
53508aeb65 Run sh tests/ui/update-all-references.sh 2020-08-22 14:22:02 +02:00
Christian Stefanescu
5b07b9ed61 Widen understanding of prelude import
Prelude imports are exempt from wildcard import warnings. Until now only
imports of the form

```
use ...::prelude::*;
```

were considered. This change makes it so that the segment `prelude` can
show up anywhere, for instance:

```
use ...::prelude::v1::*;
```

Fixes #5917
2020-08-22 14:22:02 +02:00