Commit Graph

38409 Commits

Author SHA1 Message Date
Yuki Okushi
b17de50a41
Rollup merge of #90803 - TaKO8Ki:suggest-chars-on-attempt-to-iter, r=estebank
Suggest `&str.chars()` on attempt to `&str.iter()`

closes #90786
2021-11-16 15:59:39 +09:00
Yuki Okushi
21bff4a4c1
Rollup merge of #90801 - b-naber:missing_normalization_equate_inputs_output, r=jackh726
Normalize both arguments of `equate_normalized_input_or_output`

Fixes https://github.com/rust-lang/rust/issues/90638
Fixes https://github.com/rust-lang/rust/issues/90612

Temporary fix for a more complex underlying problem stemming from an inability to normalize closure substs during typecheck.

r? ````@jackh726````
2021-11-16 15:59:39 +09:00
Yuki Okushi
ebef3ce25b
Rollup merge of #86455 - tlyu:check-where-before-suggesting-unsized, r=estebank
check where-clause for explicit `Sized` before suggesting `?Sized`

Fixes #85945.

Based on #86454.

``@rustbot`` label +A-diagnostics +A-traits +A-typesystem +D-papercut +T-compiler
2021-11-16 15:59:38 +09:00
Taylor Yu
c9fcbda389 check where clause before suggesting unsized 2021-11-15 22:31:55 -06:00
Yuki Okushi
894c0e4190
Add a regression test for #80772 2021-11-16 09:38:43 +09:00
Yuki Okushi
fff9055afb
Rollup merge of #90892 - RalfJung:miri-partial-ptr-copy, r=oli-obk
fix ICE on Miri/CTFE copy of half a pointer

Fixes https://github.com/rust-lang/miri/issues/1910
r? `````@oli-obk`````
2021-11-16 09:14:22 +09:00
Yuki Okushi
12d5297418
Rollup merge of #90837 - c410-f3r:testsssssss, r=petrochenkov
Move some tests to more reasonable directories - 9

cc #73494
r? `@petrochenkov`
2021-11-16 09:14:20 +09:00
bors
891ca5f63c Auto merge of #90821 - scottmcm:new-slice-reverse, r=Mark-Simulacrum
MIRI says `reverse` is UB, so replace it with something LLVM can vectorize

For small types with padding, the current implementation is UB because it does integer operations on uninit values.
```
error: Undefined Behavior: using uninitialized data, but this operation requires initialized memory
   --> /playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/num/mod.rs:836:5
    |
836 | /     uint_impl! { u32, u32, i32, 32, 4294967295, 8, "0x10000b3", "0xb301", "0x12345678",
837 | |     "0x78563412", "0x1e6a2c48", "[0x78, 0x56, 0x34, 0x12]", "[0x12, 0x34, 0x56, 0x78]", "", "" }
    | |________________________________________________________________________________________________^ using uninitialized data, but this operation requires initialized memory
    |
    = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
    = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information

    = note: inside `core::num::<impl u32>::rotate_left` at /playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/num/uint_macros.rs:211:13
    = note: inside `core::slice::<impl [Foo]>::reverse` at /playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/slice/mod.rs:701:58
```
<https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=340739f22ca5b457e1da6f361768edc6>

But LLVM has gotten smarter since I wrote the previous implementation in 2017, so this PR removes all the manual magic and just writes it in such a way that LLVM will vectorize.  This code is much simpler and has very little `unsafe`, and is actually faster to boot!

If you're curious to see the codegen: <https://rust.godbolt.org/z/Pcn13Y9E3>

Before:
```
running 7 tests
test slice::reverse_simd_f64x4                           ... bench:      17,940 ns/iter (+/- 481) = 58448 MB/s
test slice::reverse_u128                                 ... bench:      17,758 ns/iter (+/- 205) = 59048 MB/s
test slice::reverse_u16                                  ... bench:     158,234 ns/iter (+/- 6,876) = 6626 MB/s
test slice::reverse_u32                                  ... bench:      62,047 ns/iter (+/- 1,117) = 16899 MB/s
test slice::reverse_u64                                  ... bench:      31,582 ns/iter (+/- 552) = 33201 MB/s
test slice::reverse_u8                                   ... bench:      81,253 ns/iter (+/- 1,510) = 12905 MB/s
test slice::reverse_u8x3                                 ... bench:     270,615 ns/iter (+/- 11,463) = 3874 MB/s
```

After:
```
running 7 tests
test slice::reverse_simd_f64x4                           ... bench:      17,731 ns/iter (+/- 306) = 59137 MB/s
test slice::reverse_u128                                 ... bench:      17,919 ns/iter (+/- 239) = 58517 MB/s
test slice::reverse_u16                                  ... bench:      43,160 ns/iter (+/- 607) = 24295 MB/s
test slice::reverse_u32                                  ... bench:      21,065 ns/iter (+/- 371) = 49778 MB/s
test slice::reverse_u64                                  ... bench:      21,118 ns/iter (+/- 482) = 49653 MB/s
test slice::reverse_u8                                   ... bench:      76,878 ns/iter (+/- 1,688) = 13639 MB/s
test slice::reverse_u8x3                                 ... bench:     264,723 ns/iter (+/- 5,544) = 3961 MB/s
```

Those are the existing benches, <14a2fd640e/library/alloc/benches/slice.rs (L322-L346)>
2021-11-15 20:19:23 +00:00
Nilstrieb
d64aea65ad Fix non-constant value ICE (#90878)
This also fixes the same suggestion, which was kind of broken, because it just searched for the last occurence of `const` to replace with a `let`. This works great in some cases, but when there is no const and a leading space to the file, it doesn't work and panic with overflow because it thought that it had found a const.

I also changed the suggestion to only trigger if the `const` and the non-constant value are on the same line, because if they aren't, the suggestion is very likely to be wrong.

Also don't trigger the suggestion if the found `const` is on line 0, because that triggers the ICE.
2021-11-15 20:40:29 +01:00
bors
c26746af5a Auto merge of #90473 - joshtriplett:stabilize-format-args-capture, r=Mark-Simulacrum
stabilize format args capture

Works as expected, and there are widespread reports of success with it, as well as interest in it.

RFC: rust-lang/rfcs#2795
Tracking issue: https://github.com/rust-lang/rust/issues/67984

Addressing items from the tracking issue:

- We don't support capturing arguments from a non-literal format string like `format_args!(concat!(...))`. We could add that in a future enhancement, or we can decide that it isn't supported (as suggested in https://github.com/rust-lang/rust/issues/67984#issuecomment-801394736 ).
- I've updated the documentation.
- `panic!` now supports capture as well.
- There are potentially opportunities to further improve diagnostics for invalid usage, such as if it looks like the user tried to use an expression rather than a variable. However, such cases are all already caught and provide reasonable syntax errors now, and we can always provided even friendlier diagnostics in the future.
2021-11-15 16:10:19 +00:00
Josh Triplett
afa719e2ee Update test output 2021-11-15 10:14:33 +01:00
Josh Triplett
8c9bfaa5f3 Stabilize format_args_capture
Works as expected, and there are widespread reports of success with it,
as well as interest in it.
2021-11-15 10:14:29 +01:00
bors
d5a0c7cb03 Auto merge of #90645 - terrarier2111:master, r=estebank
Implement diagnostic for String conversion

This is my first real contribution to rustc, any feedback is highly appreciated.
This should fix https://github.com/rust-lang/rust/issues/89856

Thanks to `@estebank` for guiding me.
2021-11-15 06:55:01 +00:00
Lucas Kent
62acf7f96d feedback 2021-11-15 14:51:56 +11:00
Takayuki Maeda
d562f487c9 suggest &str.chars() on attempt to &str.iter()
check if `String` or `&String` or `&str`

Update compiler/rustc_typeck/src/check/method/suggest.rs

Co-authored-by: Esteban Kuber <estebank@users.noreply.github.com>

remove some trailing whitespace
2021-11-15 12:37:01 +09:00
Gary Guo
6ad626fb5c Add regression test for issue 90320 2021-11-15 02:14:54 +00:00
Scott McMurray
f541dd13f1 Don't run the codegen test when debug_assert is enabled 2021-11-14 16:24:31 -08:00
Ralf Jung
9ec88626ea
expand comment 2021-11-14 19:03:32 -05:00
Ralf Jung
eebf676bf8 fix getting the discriminant of a zero-variant enum 2021-11-14 13:29:21 -05:00
Caio
ab5434f9b8 Move some tests to more reasonable directories 2021-11-14 14:38:42 -03:00
Lucas Kent
f980f813e1 Improve ManuallyDrop suggestion 2021-11-15 00:04:34 +11:00
Nilstrieb
24acf86029 Fix span for non-satisfied trivial trait bounds
The spans for "trait bound not satisfied" errors in trivial trait bounds referenced the entire item (fn, impl, struct) before.
Now they only reference the obligation itself (`String: Copy`)

Address #90869
2021-11-14 11:38:52 +01:00
Ralf Jung
94ca0b392d fix ICE on Miri/CTFE copy of half a pointer 2021-11-13 20:56:01 -05:00
Lucas Kent
130b9e9e3b Improve diagnostics when a static lifetime is expected 2021-11-14 12:04:39 +11:00
Matthias Krüger
e273fab434
Rollup merge of #90840 - BoxyUwU:lolripme, r=jackh726
relate lifetime in `TypeOutlives` bounds on drop impls

Fixes #90838
2021-11-13 22:35:04 +01:00
Matthias Krüger
b35af0d04d
Rollup merge of #90771 - asterycs:fix/trait-object-error-code, r=michaelwoerister
Fix trait object error code

closes #90768

I `grep`:d and changed the occurrences that seemed relevant. Please let me know what you think and if anything is missing!
2021-11-13 22:35:03 +01:00
Jakob Degen
d58d52a397 Fix handling of substitutions and binders when deciding whether to suggest references
When suggesting references, substitutions were being forgotten and some types were misused. This led to at
least one ICE and other incorrectly emitted diagnostics. This has been fixed; in some cases this leads to
diagnostics changing, and tests have been adjusted.
2021-11-13 16:28:41 -05:00
Dylan MacKenzie
22d937ddfc Sanity check for move from an uninit variable whose address is taken 2021-11-13 11:30:52 -08:00
Dylan MacKenzie
ece0e6ae6d Add raw pointer variant of #90752 with incorrect behavior 2021-11-13 11:16:57 -08:00
Dylan MacKenzie
d846fe0522 Add regression test for #90752 2021-11-13 11:16:57 -08:00
bors
d212d902ae Auto merge of #89551 - jhpratt:stabilize-const_raw_ptr_deref, r=oli-obk
Stabilize `const_raw_ptr_deref` for `*const T`

This stabilizes dereferencing immutable raw pointers in const contexts.
It does not stabilize `*mut T` dereferencing. This is behind the
same feature gate as mutable references.

closes https://github.com/rust-lang/rust/issues/51911
2021-11-13 17:10:15 +00:00
threadexception
829a5288ec Implement diagnostic for String conversion
Co-authored-by: Esteban Kuber <estebank@users.noreply.github.com>
2021-11-13 15:17:44 +01:00
bors
3e018ce194 Auto merge of #87264 - mystor:expand_literal, r=petrochenkov
proc_macro: Add an expand_expr method to TokenStream

This feature is aimed at giving proc macros access to powers similar to those used by builtin macros such as `format_args!` or `concat!`. These macros are able to accept macros in place of string literal parameters, such as the format string, as they perform recursive macro expansion while being expanded.

This can be especially useful in many cases thanks to helper macros like `concat!`, `stringify!` and `include_str!` which are often used to construct string literals at compile-time in user code.

For now, this method only allows expanding macros which produce literals, although more expressions will be supported before the method is stabilized.

In earlier versions of this PR, this method exclusively returned `Literal`, and spans on returned literals were stripped of expansion context before being returned to be as conservative as possible about permission leakage. The method's naming has been generalized to eventually support arbitrary expressions, and the context stripping has been removed (https://github.com/rust-lang/rust/pull/87264#discussion_r674863279), which should allow for more general APIs like "format_args_implicits" (https://github.com/rust-lang/rust/issues/67984) to be supported as well.

## API Surface

```rust
impl TokenStream {
    pub fn expand_expr(&self) -> Result<TokenStream, ExpandError>;
}

#[non_exhaustive]
pub struct ExpandError;

impl Debug for ExpandError { ... }
impl Display for ExpandError { ... }
impl Error for ExpandError {}
impl !Send for ExpandError {}
impl !Sync for ExpandError {}
```
2021-11-13 08:22:52 +00:00
bors
032dfe4360 Auto merge of #89167 - workingjubilee:use-simd, r=MarkSimulacrum
pub use core::simd;

A portable abstraction over SIMD has been a major pursuit in recent years for several programming languages. In Rust, `std::arch` offers explicit SIMD acceleration via compiler intrinsics, but it does so at the cost of having to individually maintain each and every single such API, and is almost completely `unsafe` to use.  `core::simd` offers safe abstractions that are resolved to the appropriate SIMD instructions by LLVM during compilation, including scalar instructions if that is all that is available.

`core::simd` is enabled by the `#![portable_simd]` nightly feature tracked in https://github.com/rust-lang/rust/issues/86656 and is introduced here by pulling in the https://github.com/rust-lang/portable-simd repository as a subtree. We built the repository out-of-tree to allow faster compilation and a stochastic test suite backed by the proptest crate to verify that different targets, features, and optimizations produce the same result, so that using this library does not introduce any surprises. As these tests are technically non-deterministic, and thus can introduce overly interesting Heisenbugs if included in the rustc CI, they are visible in the commit history of the subtree but do nothing here. Some tests **are** introduced via the documentation, but these use deterministic asserts.

There are multiple unsolved problems with the library at the current moment, including a want for better documentation, technical issues with LLVM scalarizing and lowering to libm, room for improvement for the APIs, and so far I have not added the necessary plumbing for allowing the more experimental or libm-dependent APIs to be used. However, I thought it would be prudent to open this for review in its current condition, as it is both usable and it is likely I am going to learn something else needs to be fixed when bors tries this out.

The major types are
- `core::simd::Simd<T, N>`
- `core::simd::Mask<T, N>`

There is also the `LaneCount` struct, which, together with the SimdElement and SupportedLaneCount traits, limit the implementation's maximum support to vectors we know will actually compile and provide supporting logic for bitmasks. I'm hoping to simplify at least some of these out of the way as the compiler and library evolve.
2021-11-13 02:17:20 +00:00
Jubilee Young
7c3d72d069 Test core::simd works
These tests just verify some basic APIs of core::simd function, and
guarantees that attempting to access the wrong things doesn't work.
The majority of tests are stochastic, and so remain upstream, but
a few deterministic tests arrive in the subtree as doc tests.
2021-11-12 16:58:47 -08:00
Jubilee Young
39cb863253 Expose portable-simd as core::simd
This enables programmers to use a safe alternative to the current
`extern "platform-intrinsics"` API for writing portable SIMD code.
This is `#![feature(portable_simd)]` as tracked in #86656
2021-11-12 16:58:39 -08:00
b-naber
7a4aa65810 add tests 2021-11-12 23:39:16 +01:00
Ellen
875024ca6b oops... 2021-11-12 20:50:25 +00:00
Nika Layzell
3e4d3d2a29 proc_macro: Add an expand_expr method to TokenStream
This feature is aimed at giving proc macros access to powers similar to
those used by builtin macros such as `format_args!` or `concat!`. These
macros are able to accept macros in place of string literal parameters,
such as the format string, as they perform recursive macro expansion
while being expanded.

This can be especially useful in many cases thanks to helper macros like
`concat!`, `stringify!` and `include_str!` which are often used to
construct string literals at compile-time in user code.

For now, this method only allows expanding macros which produce
literals, although more expresisons will be supported before the method
is stabilized.
2021-11-12 15:41:40 -05:00
pierwill
1642fdfea0 Add -Zassert-incr-state to assert state of incremental cache 2021-11-12 13:41:46 -06:00
bors
e90c5fbbc5 Auto merge of #90836 - matthiaskrgr:rollup-ou6yrlw, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #90589 (rustc_llvm: update PassWrapper for recent LLVM)
 - #90644 (Extend the const swap feature)
 - #90704 (Unix ExitStatus comments and a tiny docs fix)
 - #90761 (Shorten Span of unused macro lints)
 - #90795 (Add more comments to explain the code to generate the search index)
 - #90798 (Document `unreachable!` custom panic message)
 - #90826 (rustc_feature: Convert `BuiltinAttribute` from tuple to a struct)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-11-12 19:28:04 +00:00
Matthias Krüger
640f365bff
Rollup merge of #90761 - hellow554:macro_span, r=estebank
Shorten Span of unused macro lints

The span has been reduced to the actual ident of the macro, instead of linting the
*whole* macro.

Closes #90745

r? ``@estebank``
2021-11-12 19:17:31 +01:00
bors
220ed09b26 Auto merge of #89316 - asquared31415:multiple-clobber-abi, r=Amanieu
Add support for specifying multiple clobber_abi in `asm!`

r? `@Amanieu`
cc #72016
`@rustbot` label: +A-inline-assembly +F-asm
2021-11-12 16:29:25 +00:00
asquared31415
e80f3008e0 fix aarch test error annotations 2021-11-12 10:30:20 -05:00
Scott McMurray
71f5cfb21f MIRI says reverse is UB, so replace it with an implementation that LLVM can vectorize
For small types with padding, the current implementation is UB because it does integer operations on uninit values.  But LLVM has gotten smarter since I wrote the previous implementation in 2017, so remove all the manual magic and just write it in such a way that LLVM will vectorize.  This code is much simpler (albeit nuanced) and has very little `unsafe`, and is actually faster to boot!
2021-11-11 20:32:18 -08:00
bors
14a2fd640e Auto merge of #90489 - jyn514:load-all-extern-crates, r=petrochenkov
rustdoc: Go back to loading all external crates unconditionally

This *continues* to cause regressions. This code will be unnecessary
once access to the resolver happens fully before creating the tyctxt
(#83761), so load all crates unconditionally for now. To minimize churn, this leaves in the code for loading crates selectively.

"Fixes" https://github.com/rust-lang/rust/issues/84738. Previously: https://github.com/rust-lang/rust/pull/83738, https://github.com/rust-lang/rust/pull/85749, https://github.com/rust-lang/rust/pull/88215

r? `@petrochenkov` cc `@camelid` (this should fix the "index out of bounds" error you had while looking up `crate_name`).
2021-11-11 22:00:53 +00:00
bors
62efba8a05 Auto merge of #90755 - scottmcm:spec-array-clone, r=jackh726
Specialize array cloning for Copy types

Because after PR 86041, the optimizer no longer load-merges at the LLVM IR level, which might be part of the perf loss.  (I'll run perf and see if this makes a difference.)

Also I added a codegen test so this hopefully won't regress in future -- it passes on stable and with my change here, but not on the 2021-11-09 nightly.

Example on current nightly: <https://play.rust-lang.org/?version=nightly&mode=release&edition=2021&gist=1f52d46fb8fc3ca3ac9f097390085ffa>
```rust
type T = u8;
const N: usize = 3;

pub fn demo_clone(x: &[T; N]) -> [T; N] {
    x.clone()
}

pub fn demo_copy(x: &[T; N]) -> [T; N] {
    *x
}
```
```llvm-ir
; playground::demo_clone
; Function Attrs: mustprogress nofree nosync nounwind nonlazybind uwtable willreturn
define i24 `@_ZN10playground10demo_clone17h98a4f11453d1a753E([3` x i8]* noalias nocapture readonly align 1 dereferenceable(3) %x) unnamed_addr #0 personality i32 (i32, i32, i64, %"unwind::libunwind::_Unwind_Exception"*, %"unwind::libunwind::_Unwind_Context"*)* `@rust_eh_personality` {
start:
  %0 = getelementptr [3 x i8], [3 x i8]* %x, i64 0, i64 0
  %1 = getelementptr inbounds [3 x i8], [3 x i8]* %x, i64 0, i64 1
  %.val.i.i.i.i.i.i.i.i.i = load i8, i8* %0, align 1, !alias.scope !2, !noalias !9
  %2 = getelementptr inbounds [3 x i8], [3 x i8]* %x, i64 0, i64 2
  %.val.i.i.i.i.i.1.i.i.i.i = load i8, i8* %1, align 1, !alias.scope !2, !noalias !20
  %.val.i.i.i.i.i.2.i.i.i.i = load i8, i8* %2, align 1, !alias.scope !2, !noalias !23
  %array.sroa.6.0.insert.ext.i.i.i.i = zext i8 %.val.i.i.i.i.i.2.i.i.i.i to i32
  %array.sroa.6.0.insert.shift.i.i.i.i = shl nuw nsw i32 %array.sroa.6.0.insert.ext.i.i.i.i, 16
  %array.sroa.5.0.insert.ext.i.i.i.i = zext i8 %.val.i.i.i.i.i.1.i.i.i.i to i32
  %array.sroa.5.0.insert.shift.i.i.i.i = shl nuw nsw i32 %array.sroa.5.0.insert.ext.i.i.i.i, 8
  %array.sroa.0.0.insert.ext.i.i.i.i = zext i8 %.val.i.i.i.i.i.i.i.i.i to i32
  %array.sroa.5.0.insert.insert.i.i.i.i = or i32 %array.sroa.5.0.insert.shift.i.i.i.i, %array.sroa.0.0.insert.ext.i.i.i.i
  %array.sroa.0.0.insert.insert.i.i.i.i = or i32 %array.sroa.5.0.insert.insert.i.i.i.i, %array.sroa.6.0.insert.shift.i.i.i.i
  %.sroa.4.0.extract.trunc.i.i.i.i = trunc i32 %array.sroa.0.0.insert.insert.i.i.i.i to i24
  ret i24 %.sroa.4.0.extract.trunc.i.i.i.i
}

; playground::demo_copy
; Function Attrs: mustprogress nofree norecurse nosync nounwind nonlazybind readonly uwtable willreturn
define i24 `@_ZN10playground9demo_copy17h7817453f9291d746E([3` x i8]* noalias nocapture readonly align 1 dereferenceable(3) %x) unnamed_addr #1 {
start:
  %.sroa.0.0..sroa_cast = bitcast [3 x i8]* %x to i24*
  %.sroa.0.0.copyload = load i24, i24* %.sroa.0.0..sroa_cast, align 1
  ret i24 %.sroa.0.0.copyload
}
```
2021-11-11 09:13:22 +00:00
Marcel Hellwig
9f6ca7482c Shorten Span of unused macro lints
The span has been recuded to the actual ident, instead of linting the
*whole* macro.
2021-11-11 08:04:02 +01:00
bors
1d34cb4efc Auto merge of #89550 - lcnr:coherence-specialization, r=nikomatsakis
do not emit overlap errors for impls failing the orphan check

this should finally allow us to merge #86986, see https://github.com/rust-lang/rust/pull/86986#discussion_r716059345 for more details.

r? `@nikomatsakis` cc `@eddyb`
2021-11-11 05:47:37 +00:00
bors
9dbbbb12c0 Auto merge of #83846 - torhovland:issue-10971, r=davidtwco
Added the --temps-dir option

Fixes #10971.

The new `--temps-dir` option puts intermediate files in a user-specified directory. This provides a fix for the issue where parallel invocations of rustc would overwrite each other's intermediate files.

No files are kept in the intermediate directory unless `-C save-temps=yes`.

If additional files are specifically requested using `--emit asm,llvm-bc,llvm-ir,obj,metadata,link,dep-info,mir`, these will be put in the output directory rather than the intermediate directory.

This is a backward-compatible change, i.e. if `--temps-dir` is not specified, the behavior is the same as before.
2021-11-11 02:52:32 +00:00
bors
8e0293137f Auto merge of #90784 - matthiaskrgr:rollup-car8g12, r=matthiaskrgr
Rollup of 3 pull requests

Successful merges:

 - #89930 (Only use `clone3` when needed for pidfd)
 - #90736 (adjust documented inline-asm register constraints)
 - #90783 (Update Miri)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-11-10 23:13:06 +00:00
Matthias Krüger
a09115f3b4
Rollup merge of #89930 - cuviper:avoid-clone3, r=joshtriplett
Only use `clone3` when needed for pidfd

In #89522 we learned that `clone3` is interacting poorly with Gentoo's
`sandbox` tool. We only need that for the unstable pidfd extensions, so
otherwise avoid that and use a normal `fork`.

This is a re-application of beta #89924, now that we're aware that we need
more than just a temporary release fix. I also reverted 12fbabd27f, as
that was just fallout from using `clone3` instead of `fork`.

r? `@Mark-Simulacrum`
cc `@joshtriplett`
2021-11-10 23:04:25 +01:00
Matthias Krüger
858fea410d
Rollup merge of #88868 - calebzulawski:feature/simd_bitmask, r=workingjubilee
Allow simd_bitmask to return byte arrays

cc `@rust-lang/project-portable-simd` `@workingjubilee`
2021-11-10 18:52:27 +01:00
Jimmy Envall
fc9624c673 Fix trait object error code 2021-11-10 18:49:30 +01:00
lcnr
1296719c06 no overlap errors after failing the orphan check 2021-11-10 15:10:19 +01:00
Tor Hovland
1793a7acc7 Changing cdylib to staticlib, as the former doesn't work with arm-none-eabi-gcc. 2021-11-10 08:25:35 +01:00
asquared31415
3e799e4963 add missing sym feature 2021-11-10 01:35:39 -05:00
asquared31415
f3e42cb160 Fix aarch tests 2021-11-10 01:06:03 -05:00
asquared31415
b233d3b5da Add support for specifying multiple clobber_abi in asm!
Allow multiple clobber_abi in asm

Update docs
Fix aarch64 test
Combine abis
Emit duplicate ABI error, empty ABI list error
multiple clobber_abi
2021-11-10 01:06:03 -05:00
Scott McMurray
cc7d8014d7 Specialize array cloning for Copy types
Because after PR 86041, the optimizer no longer load-merges at the LLVM IR level, which might be part of the perf loss.  (I'll run perf and see if this makes a difference.)

Also I added a codegen test so this hopefully won't regress in future -- it passes on stable and with my change here, but not on the 2021-11-09 nightly.
2021-11-09 21:43:20 -08:00
bors
8b09ba6a5d Auto merge of #90734 - matthiaskrgr:rollup-e1euotp, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #89561 (Type inference for inline consts)
 - #90035 (implement rfc-2528 type_changing-struct-update)
 - #90613 (Allow to run a specific rustdoc-js* test)
 - #90683 (Make `compiler-docs` only control the default instead of being a hard off-switch)
 - #90685 (x.py: remove fixme by deleting code)
 - #90701 (Record more artifact sizes during self-profiling.)
 - #90723 (Better document `Box` and `alloc::alloc::box_free` connection)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-11-09 20:09:53 +00:00
Matthias Krüger
610b4e503c
Rollup merge of #90035 - SparrowLii:rfc2528, r=jackh726
implement rfc-2528 type_changing-struct-update

This PR implement rfc2528-type_changing-struct-update.
The main change process is as follows:
1. Move the processing part of `base_expr` into `check_expr_struct_fields` to avoid returning `remaining_fields` (a relatively complex hash table)
2. Before performing the type consistency check(`check_expr_has_type_or_error`), if the `type_changing_struct_update` feature is set, enter a different processing flow, otherwise keep the original flow
3. In the case of the same structure definition, check each field in `remaining_fields`. If the field in `base_expr` is not the suptype of the field in `adt_ty`, an error(`FeildMisMatch`) will be reported.

The MIR part does not need to be changed, because only the items contained in `remaining_fields` will be extracted from `base_expr` when MIR is generated. This means that fields with different types in `base_expr` will not be used
Updates #86618
cc `@nikomatsakis`
2021-11-09 19:00:41 +01:00
Matthias Krüger
fd74c93403
Rollup merge of #89561 - nbdd0121:const_typeck, r=nikomatsakis
Type inference for inline consts

Fixes #78132
Fixes #78174
Fixes #81857
Fixes #89964

Perform type checking/inference of inline consts in the same context as the outer def, similar to what is currently done to closure.

Doing so would require `closure_base_def_id` of the inline const to return the outer def, and since `closure_base_def_id` can be called on non-local crate (and thus have no HIR available), a new `DefKind` is created for inline consts.

The type of the generated anon const can capture lifetime of outer def, so we couldn't just use the typeck result as the type of the inline const's def. Closure has a similar issue, and it uses extra type params `CK, CS, U` to capture closure kind, input/output signature and upvars. I use a similar approach for inline consts, letting it have an extra type param `R`, and then `typeof(InlineConst<[paremt generics], R>)` would just be `R`. In borrowck region requirements are also propagated to the outer MIR body just like it's currently done for closure.

With this PR, inline consts in expression position are quitely usable now; however the usage in pattern position is still incomplete -- since those does not remain in the MIR borrowck couldn't verify the lifetime there. I have left an ignored test as a FIXME.

Some disucssions can be found on [this Zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/260443-project-const-generics/topic/inline.20consts.20typeck).
cc `````@spastorino````` `````@lcnr`````
r? `````@nikomatsakis`````

`````@rustbot````` label A-inference F-inline_const T-compiler
2021-11-09 19:00:40 +01:00
bors
d6082292a6 Auto merge of #86041 - bstrie:unmagic-array-copy, r=jackh726
Replace Copy/Clone compiler magic on arrays with library impls

With const generics the compiler no longer needs to fake these impls.
2021-11-09 17:13:44 +00:00
Yuki Okushi
f1fef6be7f
Rollup merge of #90708 - NieDzejkob:feature-note, r=jackh726
Add a note about feature(explicit_generic_args_with_impl_trait) to the relevant error message

Fixes #90615
2021-11-09 22:02:25 +09:00
Yuki Okushi
c2f095a37b
Rollup merge of #90678 - JohnTitor:add-some-gats-tests, r=jackh726
Add some GATs-related regression tests

Closes #88595, closes #90014
r? `@jackh726`
2021-11-09 22:02:23 +09:00
Yuki Okushi
6e39d27a82
Rollup merge of #90591 - richlowe:illumos-ui-target, r=Mark-Simulacrum
treat illumos like solaris in failing ui tests which need it

Just adding the right cfg target for tests which fail because they don't know illumos is a thing.

(cc `````@jclulow)`````
2021-11-09 22:02:22 +09:00
bors
214cd1f228 Auto merge of #87337 - jyn514:lint-error, r=oli-obk,flip1995
Don't abort compilation after giving a lint error

The only reason to use `abort_if_errors` is when the program is so broken that either:
1. later passes get confused and ICE
2. any diagnostics from later passes would be noise

This is never the case for lints, because the compiler has to be able to deal with `allow`-ed lints.
So it can continue to lint and compile even if there are lint errors.

Closes https://github.com/rust-lang/rust/issues/82761. This is a WIP because I have a feeling it will exit with 0 even if there were lint errors; I don't have a computer that can build rustc locally at the moment.
2021-11-09 08:21:10 +00:00
bors
60952bc3da Auto merge of #90485 - camsteffen:fmt-args-less-bind, r=m-ou-se
Don't destructure args tuple in format_args!

This allows Clippy to parse the HIR more simply since `arg0` is changed to `_args.0`. (cc rust-lang/rust-clippy#7843). From rustc's perspective, I think this is something between a lateral move and a tiny improvement since there are fewer bindings.

r? `@m-ou-se`
2021-11-09 05:33:16 +00:00
Yuki Okushi
ebd401bc36
Add some GATs-related regression tests 2021-11-09 08:04:39 +09:00
Gus Wynn
958de5a938 warn on must_use use on async fn's 2021-11-08 14:38:41 -08:00
Jacob Pratt
6d2f8af1db
Permit const assertions in stdlib 2021-11-08 17:06:00 -05:00
Jakub Kądziołka
048e1c942d
Add a note about feature(explicit_generic_args_with_impl_trait) to the relevant error message 2021-11-08 19:49:41 +01:00
bstrie
ce1143e94d impl Copy/Clone for arrays in std, not in compiler 2021-11-08 13:11:58 -05:00
Guillaume Gomez
d9fc7d1041
Rollup merge of #90657 - GuillaumeGomez:one-char-last-line-removed, r=jyn514
Fix bug with `#[doc]` string single-character last lines

Fixes #90618.

This is because `.iter().all(|c| c == '*')` returns `true` if there is no character checked. And in case the last line has only one character, it simply returns `true`, making the last line behind removed.
2021-11-08 15:15:24 +01:00
Joshua Nelson
cdafe99539 Add more missing methods to IntraLinkCrateLoader
This helps with (but does not fix)
https://github.com/rust-lang/rust/issues/84738. I tested on
edcee7b812
and still hit ICEs.
2021-11-08 02:27:21 +00:00
bors
43192ca3d7 Auto merge of #89488 - c410-f3r:testsssssss, r=petrochenkov
Move some tests to more reasonable directories - 8

cc #73494
r? `@petrochenkov`
2021-11-08 02:04:31 +00:00
Joshua Nelson
0ac13bd430 Don't abort compilation after giving a lint error
The only reason to use `abort_if_errors` is when the program is so broken that either:
1. later passes get confused and ICE
2. any diagnostics from later passes would be noise

This is never the case for lints, because the compiler has to be able to deal with `allow`-ed lints.
So it can continue to lint and compile even if there are lint errors.
2021-11-08 01:22:28 +00:00
bors
5fa94f3c57 Auto merge of #88368 - jyn514:metadata-error, r=petrochenkov
Improve error when an .rlib can't be parsed

This usually describes either an error in the compiler itself or some
sort of IO error. Either way, we should report it to the user rather
than just saying "crate not found".

This only gives an error if the crate couldn't be loaded at all - if the
compiler finds another .rlib or .rmeta file which was valid, it will
continue to compile the crate.

Example output:
```
error[E0785]: found invalid metadata files for crate `foo`
 --> bar.rs:3:24
  |
3 |         println!("{}", foo::FOO_11_49[0]);
  |                        ^^^
  |
  = warning: failed to parse rlib '/home/joshua/test-rustdoc/libfoo.rlib': Invalid archive extended name offset
```

cc `@ehuss`
2021-11-07 23:03:55 +00:00
Tor Hovland
13dbdc6ad3 There is a -Clinker='arm-none-eabi-gcc' that seems to be causing trouble. 2021-11-07 20:08:42 +01:00
Tor Hovland
27464fa501 Almost all the other tests use '-include', so we'll do too. 2021-11-07 20:06:22 +01:00
Joshua Nelson
257ac1b498 Improve error when an .rlib can't be parsed
This usually describes either an error in the compiler itself or some
sort of IO error. Either way, we should report it to the user rather
than just saying "crate not found".

This only gives an error if the crate couldn't be loaded at all - if the
compiler finds another .rlib or .rmeta file which was valid, it will
continue to compile the crate.

Example output:
```
error[E0785]: found invalid metadata files for crate `foo`
 --> bar.rs:3:24
  |
3 |         println!("{}", foo::FOO_11_49[0]);
  |                        ^^^
  |
  = warning: failed to parse rlib '/home/joshua/test-rustdoc/libfoo.rlib': Invalid archive extended name offset
```
2021-11-07 15:03:40 +00:00
Vadim Petrochenkov
2834f57c45 ast: Fix naming conventions in AST structures
TraitKind -> Trait
TyAliasKind -> TyAlias
ImplKind -> Impl
FnKind -> Fn

All `*Kind`s in AST are supposed to be enums.

Tuple structs are converted to braced structs for the types above, and fields are reordered in syntactic order.

Also, mutable AST visitor now correctly visit spans in defaultness, unsafety, impl polarity and constness.
2021-11-07 21:38:17 +08:00
Tor Hovland
ede76c40d1 Made temps-dir an unstable option. 2021-11-07 09:32:05 +01:00
bors
90a273b785 Auto merge of #90348 - Amanieu:asm_feature_gates, r=joshtriplett
Add features gates for experimental asm features

This PR splits off parts of `asm!` into separate features because they are not ready for stabilization.

Specifically this adds:
- `asm_const` for `const` operands.
- `asm_sym` for `sym` operands.
- `asm_experimental_arch` for architectures other than x86, x86_64, arm, aarch64 and riscv.

r? `@nagisa`
2021-11-07 04:59:42 +00:00
Gary Guo
4060ed7eff Add a FIXME note about what's missing 2021-11-07 04:00:34 +00:00
Gary Guo
ff055e2135 Ensure closure requirements are proven for inline const 2021-11-07 04:00:34 +00:00
Gary Guo
1d32b20170 Add unit test for issue 78174 2021-11-07 04:00:34 +00:00
Gary Guo
4acef9ac19 Add unit test for issue 78132 2021-11-07 04:00:34 +00:00
Amanieu d'Antras
87d0d64b78 Restrict tests that use needs-asm-support to non-experimental
architectures
2021-11-07 03:44:42 +00:00
Amanieu d'Antras
eb32c00216 Add features gates for experimental asm features 2021-11-07 01:23:53 +00:00
Matthias Krüger
ec471de865
Rollup merge of #90649 - cjgillot:reveal-all-2, r=lcnr
Run reveal_all on MIR when inlining is activated.

Fix logic error in https://github.com/rust-lang/rust/pull/85254 which prevented the pass from running when needed.
Fixes https://github.com/rust-lang/rust/issues/78442
r? ``@lcnr``
2021-11-06 23:12:06 +01:00
Matthias Krüger
43fee0e0a9
Rollup merge of #90646 - BoxyUwU:funky_ice, r=estebank
type error go brrrrrrrr

Fixes #90444

when we relate something like:
`fn(fn((), (), u32))` with `fn(fn((), (), ()))`
we relate the inner fn ptrs:
`fn((), (), u32)` with `fn((), (), ())`
yielding a `TypeError::ArgumentSorts(_, 2)` which we then use as the `TypeError` for the `fn(fn(..))` which later causes the ICE as the `2` does not correspond to any input or output types in `fn(_)`

r? `@estebank`
2021-11-06 23:12:06 +01:00
Matthias Krüger
1d9fe9cd06
Rollup merge of #90627 - camelid:suggest-box-deref, r=davidtwco
Suggest dereference of `Box` when inner type is expected

For example:

    enum Ty {
        Unit,
        List(Box<Ty>),
    }

    fn foo(x: Ty) -> Ty {
        match x {
            Ty::Unit => Ty::Unit,
            Ty::List(elem) => foo(elem),
        }
    }

Before, the only suggestion was to rewrap `inner` with `Ty::Wrapper`,
which is unhelpful and confusing:

    error[E0308]: mismatched types
     --> src/test/ui/suggestions/boxed-variant-field.rs:9:31
      |
    9 |         Ty::List(elem) => foo(elem),
      |                               ^^^^
      |                               |
      |                               expected enum `Ty`, found struct `Box`
      |                               help: try using a variant of the expected enum: `Ty::List(elem)`
      |
      = note: expected enum `Ty`
               found struct `Box<Ty>`

Now, rustc will first suggest dereferencing the `Box`, which is most
likely what the user intended:

    error[E0308]: mismatched types
     --> src/test/ui/suggestions/boxed-variant-field.rs:9:31
      |
    9 |         Ty::List(elem) => foo(elem),
      |                               ^^^^ expected enum `Ty`, found struct `Box`
      |
      = note: expected enum `Ty`
               found struct `Box<Ty>`
    help: try dereferencing the `Box`
      |
    9 |         Ty::List(elem) => foo(*elem),
      |                               +
    help: try using a variant of the expected enum
      |
    9 |         Ty::List(elem) => foo(Ty::List(elem)),
      |                               ~~~~~~~~~~~~~~

r? ``@davidtwco``
2021-11-06 23:12:04 +01:00
Matthias Krüger
4c49db35fc
Rollup merge of #90508 - nbdd0121:issue-90483, r=davidtwco
Apply adjustments for field expression even if inaccessible

The adjustments are used later by ExprUseVisitor to build Place projections and without adjustments it can produce invalid result.

Fix #90483

``@rustbot`` label: T-compiler
2021-11-06 23:12:03 +01:00
Jacob Pratt
0cdbeaa2a3
Stabilize const_raw_ptr_deref for *const T
This stabilizes dereferencing immutable raw pointers in const contexts.
It does not stabilize `*mut T` dereferencing. This is placed behind the
`const_raw_mut_ptr_deref` feature gate.
2021-11-06 17:05:15 -04:00
Cameron Steffen
a9a24d5106 Don't destructure args tuple in format_args! 2021-11-06 14:28:08 -05:00
Guillaume Gomez
aa6f6f47cd Add test for removed one character last line in rustdoc 2021-11-06 20:21:29 +01:00
Caio
7fd15f0900 Move some tests to more reasonable directories 2021-11-06 15:35:20 -03:00
Noah Lev
d93f7f93c4 Suggest dereference of Box when inner type is expected
For example:

    enum Ty {
        Unit,
        List(Box<Ty>),
    }

    fn foo(x: Ty) -> Ty {
        match x {
            Ty::Unit => Ty::Unit,
            Ty::List(elem) => foo(elem),
        }
    }

Before, the only suggestion was to rewrap `elem` with `Ty::List`,
which is unhelpful and confusing:

    error[E0308]: mismatched types
     --> src/test/ui/suggestions/boxed-variant-field.rs:9:31
      |
    9 |         Ty::List(elem) => foo(elem),
      |                               ^^^^
      |                               |
      |                               expected enum `Ty`, found struct `Box`
      |                               help: try using a variant of the expected enum: `Ty::List(elem)`
      |
      = note: expected enum `Ty`
               found struct `Box<Ty>`

Now, rustc will first suggest dereferencing the `Box`, which is most
likely what the user intended:

    error[E0308]: mismatched types
     --> src/test/ui/suggestions/boxed-variant-field.rs:9:31
      |
    9 |         Ty::List(elem) => foo(elem),
      |                               ^^^^ expected enum `Ty`, found struct `Box`
      |
      = note: expected enum `Ty`
               found struct `Box<Ty>`
    help: try dereferencing the `Box`
      |
    9 |         Ty::List(elem) => foo(*elem),
      |                               +
    help: try using a variant of the expected enum
      |
    9 |         Ty::List(elem) => foo(Ty::List(elem)),
      |                               ~~~~~~~~~~~~~~
2021-11-06 11:06:17 -07:00
Camille GILLOT
a3776d99cc Run reveal_all on MIR more often. 2021-11-06 15:56:29 +01:00
Ellen
abb9a9853b type error go brrrrrrrr 2021-11-06 10:39:11 +00:00
bors
7276a6a117 Auto merge of #90297 - dtolnay:dotzero, r=petrochenkov
Append .0 to unsuffixed float if it would otherwise become int token

Previously the unsuffixed f32/f64 constructors of `proc_macro::Literal` would create literal tokens that are definitely not a float:

```rust
Literal::f32_unsuffixed(10.0)  // 10
Literal::f32_suffixed(10.0)    // 10f32
Literal::f64_unsuffixed(10.0)  // 10
Literal::f64_suffixed(10.0)    // 10f64
```

Notice that the `10` are actually integer tokens if you were to reparse them, not float tokens.

This diff updates `Literal::f32_unsuffixed` and `Literal::f64_unsuffixed` to produce tokens that unambiguously parse as a float. This matches longstanding behavior of the proc-macro2 crate's implementation of these APIs dating back at least 3.5 years, so it's likely an unobjectionable behavior.

```rust
Literal::f32_unsuffixed(10.0)  // 10.0
Literal::f32_suffixed(10.0)    // 10f32
Literal::f64_unsuffixed(10.0)  // 10.0
Literal::f64_suffixed(10.0)    // 10f64
```

Fixes https://github.com/dtolnay/syn/issues/1085.
2021-11-06 07:15:05 +00:00
bors
9d39f6ab7d Auto merge of #89970 - jackh726:gats_diagnostics, r=nikomatsakis
Implementation of GATs outlives lint

See #87479 for background. Closes #87479

The basic premise of this lint/error is to require the user to write where clauses on a GAT when those bounds can be implied or proven from any function on the trait returning that GAT.

## Intuitive Explanation (Attempt) ##
Let's take this trait definition as an example:
```rust
trait Iterable {
    type Item<'x>;
    fn iter<'a>(&'a self) -> Self::Item<'a>;
}
```
Let's focus on the `iter` function. The first thing to realize is that we know that `Self: 'a` because of `&'a self`. If an impl wants `Self::Item` to contain any data with references, then those references must be derived from `&'a self`. Thus, they must live only as long as `'a`. Furthermore, because of the `Self: 'a` implied bound, they must live only as long as `Self`. Since it's `'a` is used in place of `'x`, it is reasonable to assume that any value of `Self::Item<'x>`, and thus `'x`, will only be able to live as long as `Self`. Therefore, we require this bound on `Item` in the trait.

As another example:
```rust
trait Deserializer<T> {
    type Out<'x>;
    fn deserialize<'a>(&self, input: &'a T) -> Self::Out<'a>;
}
```
The intuition is similar here, except rather than a `Self: 'a` implied bound, we have a `T: 'a` implied bound. Thus, the data on `Self::Out<'a>` is derived from `&'a T`, and thus it is reasonable to expect that the lifetime `'x` will always be less than `T`.

## Implementation Algorithm ##
* Given a GAT `<P0 as Trait<P1..Pi>>::G<Pi...Pn>` declared as `trait T<A1..Ai> for A0 { type G<Ai...An>; }` used in return type of one associated function `F`
* Given env `E` (including implied bounds) for `F`
* For each lifetime parameter `'a` in `P0...Pn`:
    * For each other type parameter `Pi != 'a` in `P0...Pn`: // FIXME: this include of lifetime parameters too
        * If `E => (P: 'a)`:
            * Require where clause `Ai: 'a`

## Follow-up questions ##
* What should we do when we don't pass params exactly?
For this example:
```rust
trait Des {
    type Out<'x, D>;
    fn des<'z, T>(&self, data: &'z Wrap<T>) -> Self::Out<'z, Wrap<T>>;
}
```
Should we be requiring a `D: 'x` clause? We pass `Wrap<T>` as `D` and `'z` as `'x`, and should be able to prove that `Wrap<T>: 'z`.

r? `@nikomatsakis`
2021-11-06 04:15:22 +00:00
Caleb Zulawski
1e1886908f Disable bitmask test on big endian 2021-11-06 02:29:03 +00:00
Caleb Zulawski
3981ca076c Allow simd_select_bitmask to take byte arrays 2021-11-06 02:12:14 +00:00
Caleb Zulawski
7964942515 Allow simd_bitmask to return byte arrays 2021-11-06 02:08:09 +00:00
jackh726
b6edcbd7b5 Review comments 2021-11-05 21:33:14 -04:00
bors
18cae2680f Auto merge of #88441 - jackh726:closure_norm, r=nikomatsakis
Normalize obligations for closure confirmation

Based on #90017

Fixes #74261
Fixes #71955
Fixes #88459

r? `@nikomatsakis`
2021-11-06 01:12:39 +00:00
bors
d32993afe8 Auto merge of #90631 - matthiaskrgr:rollup-a5tzjh3, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #89942 (Reorder `widening_impl`s to make the doc clearer)
 - #90569 (Fix tests using `only-i686` to use the correct `only-x86` directive)
 - #90597 (Warn for variables that are no longer captured)
 - #90623 (Remove more checks for LLVM < 12)
 - #90626 (Properly register text_direction_codepoint_in_comment lint.)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-11-05 22:12:31 +00:00
Josh Stone
e96a0a8681 Revert "Do not call getpid wrapper after fork in tests"
This reverts commit 12fbabd27f.

It was only needed because of using raw `clone3` instead of `fork`, but
we only do that now when a pidfd is requested.
2021-11-05 14:49:26 -07:00
Matthias Krüger
f5f6f73faf
Rollup merge of #90626 - rusticstuff:be-more-accepting, r=jyn514
Properly register text_direction_codepoint_in_comment lint.

This makes it known to the compiler so it can be configured like with `#![allow(text_direction_codepoint_in_comment)]`.

Fixes #90614.
2021-11-05 21:12:31 +01:00
Matthias Krüger
4b1cb73f1d
Rollup merge of #90597 - nikomatsakis:issue-90465, r=wesleywiser
Warn for variables that are no longer captured

r? `@wesleywiser`

cc `@rust-lang/wg-rfc-2229`

Fixes #90465
2021-11-05 21:12:29 +01:00
Matthias Krüger
cd24ffb266
Rollup merge of #90569 - wesleywiser:fix_only_i686_tests, r=Mark-Simulacrum
Fix tests using `only-i686` to use the correct `only-x86` directive

We translate `i686` to `x86` which means tests marked as `only-i686`
never ran. Update those tests to use `only-x86`.

We parse the `only-` architecture directive here

27143a9094/src/tools/compiletest/src/util.rs (L160-L168)

and we translate `i686` to `x86` here

27143a9094/src/tools/compiletest/src/util.rs (L56)
2021-11-05 21:12:28 +01:00
Hans Kratz
9db9811ddf Properly register text_direction_codepoint_in_comment lint. 2021-11-05 20:12:40 +01:00
David Tolnay
1f9807799c
Add test to confirm fnn_unsuffixed does not emit exponent notation 2021-11-05 12:06:49 -07:00
bors
0d1754e8bf Auto merge of #90583 - willcrichton:example-analyzer, r=jyn514
Fix ICE when rustdoc is scraping examples inside of a proc macro

This PR provides a clearer semantics for how --scrape-examples interacts with macros. If an expression's span AND it's enclosing item's span both are not `from_expansion`, then the example will be scraped. The added test case `rustdoc-scrape-examples-macros` shows a variety of situations.

* A macro-rules macro that takes a function call as input: good
* A macro-rules macro that generates a function call as output: bad
* A proc-macro that generates a function call as output: bad
* An attribute macro that generates a function call as output: bad
* An attribute macro that takes a function call as input: good, if the proc macro is designed to propagate the input spans

I ran this updated rustdoc on pyo3 and confirmed that it successfully scrapes examples from inside a proc macro, eg

<img width="1013" alt="Screen Shot 2021-11-04 at 1 11 28 PM" src="https://user-images.githubusercontent.com/663326/140412691-81a3bb6b-a448-4a1b-a293-f7a795553634.png">

(cc `@mejrs)`

Additionally, this PR fixes an ordering bug in the highlighting logic.

Fixes https://github.com/rust-lang/rust/issues/90567.

r? `@jyn514`
2021-11-05 19:05:36 +00:00
Niko Matsakis
4154e8acf0 apply suggestions from code review 2021-11-05 12:43:42 -04:00
Will Crichton
82b23be3c1 Fix rustdoc-scrape-examples-macros test not being cross-platform 2021-11-05 09:32:04 -07:00
Tor Hovland
d4bcee9638 Added a regression test. 2021-11-05 08:46:29 +01:00
Will Crichton
c62817bfe2 Move rustdoc-scrape-examples-macros test to run-make-fulldeps 2021-11-04 18:52:59 -07:00
Yuki Okushi
3821ab231b
Rollup merge of #90571 - GuillaumeGomez:missing-bottom-border-sidebar, r=jsha
Fix missing bottom border for headings in sidebar

Fixes #90568.

r? ```@jsha```
2021-11-05 10:32:47 +09:00
Yuki Okushi
7ee926a852
Rollup merge of #90554 - ehuss:unstable-options-cleanup, r=joshtriplett
Clean up some `-Z unstable-options` in tests.

Several of these tests were for features that have been stabilized, or otherwise don't need `-Z unstable-options`.
2021-11-05 10:32:45 +09:00
Yuki Okushi
987797bfe1
Rollup merge of #90507 - TaKO8Ki:suggest-extern-crate-alloc, r=jackh726
Suggest `extern crate alloc` when using undeclared module `alloc`

closes #90136
2021-11-05 10:32:39 +09:00
SparrowLii
926892ddc0 Add feature trigger and enable is_struct check 2021-11-05 09:30:49 +08:00
Niko Matsakis
fc8113d04e handle case of a variable not captured 2021-11-04 21:26:47 -04:00
Niko Matsakis
76bc02715e rework diagnostic reporting to be more structured 2021-11-04 20:32:44 -04:00
Richard Lowe
dbc3bf48c4 treat illumos like solaris in failing ui tests which need it 2021-11-04 17:00:19 -05:00
bors
2cff30b17a Auto merge of #90536 - crlf0710:fix_vtable_hrtb, r=jackh726
Erase regions within `vtable_trait_first_method_offset`

Fixes #90177 .

r? `@jackh726`
2021-11-04 21:52:21 +00:00
Will Crichton
4846d102e2 Fix ICE when rustdoc is scraping examples inside of a proc macro 2021-11-04 13:57:39 -07:00
Will Crichton
3ad6d12827 Sort scraped call locations before serializing 2021-11-04 13:57:09 -07:00
Guillaume Gomez
aa17e1c47f Fix missing bottom border for headings in sidebar 2021-11-04 20:07:24 +01:00
Wesley Wiser
8c56ef0878 Fix tests using only-i686 to use the correct only-x86 directive
We translate `i686` to `x86` which means tests marked as `only-i686`
never ran. Update those tests to use `only-x86`.
2021-11-04 10:39:15 -04:00
Eric Huss
754455e4f2 Clean up some -Z unstable-options in tests. 2021-11-03 20:00:00 -07:00
bors
e60e19bc65 Auto merge of #90179 - Nilstrieb:lifetime-elision-mismatch-hint, r=estebank
Add beginner friendly lifetime elision hint to E0623

Address #90170

Suggest adding a new lifetime parameter when two elided lifetimes should match up but don't.

Example:

```
error[E0623]: lifetime mismatch
  --> $DIR/issue-90170-elision-mismatch.rs:2:35
   |
LL | fn foo(slice_a: &mut [u8], slice_b: &mut [u8]) {
   |                 ---------           --------- these two types are declared with different lifetimes...
LL |     core::mem::swap(&mut slice_a, &mut slice_b);
   |                                   ^^^^^^^^^^^^ ...but data from `slice_b` flows into `slice_a` here
   |
   = note: each elided lifetime in input position becomes a distinct lifetime
help: explicitly declare a lifetime and assign it to both
   |
LL | fn foo<'a>(slice_a: &'a mut [u8], slice_b: &'a mut [u8]) {
   |       ++++           ++                     ++

```

for

```rust
fn foo(slice_a: &mut [u8], slice_b: &mut [u8]) {
    core::mem::swap(&mut slice_a, &mut slice_b);
}
```
2021-11-04 00:39:21 +00:00
Nilstrieb
4b9e4606cb Add beginner friendly lifetime elision hint to E0623
Suggest adding a new lifetime parameter when two elided lifetimes should match up but don't

Issue #90170

This also changes the tests introduced by the previous commits because of another rustc issue (#90258)
2021-11-03 20:10:44 +01:00
Charles Lew
8841204cc6 Erase regions within vtable_trait_first_method_offset. 2021-11-04 00:53:54 +08:00
Tomasz Miąsko
bc4931ed7e addr_of! grants mutable access, maybe?
The exact set of permissions granted when forming a raw reference is
currently undecided https://github.com/rust-lang/rust/issues/56604.

To avoid presupposing any particular outcome, adjust the const
qualification to be compatible with decision where raw reference
constructed from `addr_of!` grants mutable access.
2021-11-03 16:43:12 +01:00
Tomasz Miąsko
b285e0c5d8 Remove MaybeMutBorrowedLocals 2021-11-03 16:43:12 +01:00
Takayuki Maeda
6c1e194534 fix message 2021-11-03 13:53:57 +09:00
Matthias Krüger
e38844a9d8
Rollup merge of #90502 - GuillaumeGomez:split-doc-cfg-feature, r=jyn514
Split doc_cfg and doc_auto_cfg features

Part of #90497.

With this feature, `doc_cfg` won't pick up items automatically anymore.

cc `@Mark-Simulacrum`
r? `@jyn514`
2021-11-02 23:48:50 +01:00
Matthias Krüger
bc487f7dd2
Rollup merge of #90417 - lcnr:stabilize-relaxed-struct-unsizing, r=wesleywiser
stabilize `relaxed_struct_unsize`

closes #81793

the fcp is already complete.
2021-11-02 23:48:47 +01:00
Tor Hovland
0b378f008b Fix test. 2021-11-02 22:43:49 +01:00
Gary Guo
f556075459 Apply adjustments for field expression even if inaccessible
The adjustments are used later by ExprUseVisitor to build Place projections
and without adjustments it can produce invalid result.
2021-11-02 17:22:12 +00:00
Takayuki Maeda
acb9f9ba38 add a suggestion about undeclared alloc module 2021-11-03 01:44:01 +09:00
Guillaume Gomez
d50a4753b8 Split doc_cfg and doc_auto_cfg features 2021-11-02 16:55:50 +01:00
bors
db062de72b Auto merge of #90406 - nbdd0121:panic, r=cjgillot
Collect `panic/panic_bounds_check` during monomorphization

This would prevent link time errors if these functions are `#[inline]` (e.g. when `panic_immediate_abort` is used).

Fix #90405
Fix rust-lang/cargo#10019

`@rustbot` label: T-compiler A-codegen
2021-11-01 17:18:57 +00:00
bors
e9b0d99259 Auto merge of #90463 - matthiaskrgr:rollup-eljk9vo, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #89826 (Feature gate + make must_not_suspend allow-by-default)
 - #89929 (Handling submodule update failures more gracefully from x.py)
 - #90333 (rustdoc: remove flicker during page load)
 - #90349 (Fix rare ICE during typeck in rustdoc scrape_examples)
 - #90398 (Document `doc(keyword)` unstable attribute)
 - #90441 (Test that promotion follows references when looking for drop)
 - #90450 (Remove `rustc_hir::hir_id::HirIdVec`)
 - #90452 (Remove unnecessary `Option` from `promote_candidate` return type)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-11-01 14:00:08 +00:00
bors
db14a17e69 Auto merge of #90462 - pietroalbini:bidi-master, r=nikomatsakis,pietroalbini
[master] Fix CVE-2021-42574

This PR implements new lints to mitigate the impact of [CVE-2021-42574], caused by the presence of bidirectional-override Unicode codepoints in the compiled source code. [See the advisory][advisory] for more information about the vulnerability.

The changes in this PR will be released in tomorrow's nightly release.

[CVE-2021-42574]: https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-42574
[advisory]: https://blog.rust-lang.org/2021/11/01/cve-2021-42574.html
2021-11-01 10:53:49 +00:00
Matthias Krüger
365483a35b
Rollup merge of #90441 - tmiasko:test-promotion-needs-drop, r=Mark-Simulacrum
Test that promotion follows references when looking for drop

Noticed that this wasn't covered by any of existing tests.

The const checking and const qualification, which currently shares the
implementation with promotion, will likely need a different behaviour
here (see issue #90193).
2021-11-01 03:33:09 +01:00
Matthias Krüger
3730485a24
Rollup merge of #90349 - willcrichton:example-analyzer, r=jyn514
Fix rare ICE during typeck in rustdoc scrape_examples

While testing the `--scrape-examples` extension on the [wasmtime](https://github.com/bytecodealliance/wasmtime) repository, I found some additional edge cases. Specifically, when asking to typecheck a body containing a function call, I would sometimes get an ICE if:
* The body doesn't exist
* The function's HIR node didn't have a type

This adds checks for both of those conditions.

(Also this updates a test to check that the sources of a reverse-dependency are correctly generated and linked.)

r? `@jyn514`
2021-11-01 03:33:07 +01:00
Matthias Krüger
bb6901d32b
Rollup merge of #90333 - jsha:flashy-searchbar, r=GuillaumeGomez
rustdoc: remove flicker during page load

The search bar has a `:disabled` style that makes it grey, which creates a distracting flicker from grey to white when the page finishes loading. The search bar should stay the same color throughout page load.

A blank white search bar might create an incorrect impression for users with JS turned off. Since they can't use the search functionality, I've hidden the search bar in noscript.css.

Fixes #90246
r? `@GuillaumeGomez`

Demo: https://rustdoc.crud.net/jsha/flashy-searchbar/std/string/struct.String.html
2021-11-01 03:33:06 +01:00
jackh726
18421b1f08 Add lint for region pairs too 2021-10-31 21:53:26 -04:00
jackh726
b84044acff Review comments and more tests 2021-10-31 21:36:04 -04:00
Gus Wynn
185fa56256 Feature gate and make must_not_suspend allow-by-default
This lint is not yet ready for stable use, primarily due to false positives in edge
cases; we want to test it out more before stabilizing.
2021-10-31 21:22:17 -04:00
Jacob Hoffman-Andrews
a4fe76ff7c Hide search bar in noscript.css
Also, remove the highlighting of the search bar in disabled state. This
reduces flicker when loading a page.
2021-10-31 12:41:06 -07:00
Tomasz Miąsko
fadb9cc521 Test that promotion follows references when looking for drop
Noticed that this wasn't covered by any of existing tests.

The const checking and const qualification, which currently shares the
implementation with promotion, will likely need a different behaviour
here (see issue #90193).
2021-10-31 18:33:29 +01:00
Matthias Krüger
26f505c433
Rollup merge of #90430 - jkugelman:must-use-std-a-through-n, r=joshtriplett
Add #[must_use] to remaining std functions (A-N)

I've run out of compelling reasons to group functions together across crates so I'm just going to go module-by-module. This is half of the remaining items from the `std` crate, from A-N.

I added these functions myself. Clippy predictably ignored the `mut` ones, but I don't know why the rest weren't flagged. Check them closely, please? Maybe I overlooked good reasons.

```rust
std::backtrace::Backtrace                                   const fn disabled() -> Backtrace;
std::backtrace::Backtrace<'a>                               fn frames(&'a self) -> &'a [BacktraceFrame];
std::collections::hash_map::RawOccupiedEntryMut<'a, K, V>   fn key_mut(&mut self) -> &mut K;
std::collections::hash_map::RawOccupiedEntryMut<'a, K, V>   fn get_mut(&mut self) -> &mut V;
std::collections::hash_map::RawOccupiedEntryMut<'a, K, V>   fn get_key_value(&mut self) -> (&K, &V);
std::collections::hash_map::RawOccupiedEntryMut<'a, K, V>   fn get_key_value_mut(&mut self) -> (&mut K, &mut V);
std::env                                                    fn var_os<K: AsRef<OsStr>>(key: K) -> Option<OsString>;
std::env                                                    fn split_paths<T: AsRef<OsStr> + ?Sized>(unparsed: &T) -> SplitPaths<'_>;
std::io::Error                                              fn get_mut(&mut self) -> Option<&mut (dyn error::Error + Send + Sync + 'static)>;
```

Parent issue: #89692

r? `@joshtriplett`
2021-10-31 13:20:06 +01:00
Matthias Krüger
6c5aa765fb
Rollup merge of #89068 - bjorn3:restructure_rt2, r=joshtriplett
Restructure std::rt (part 2)

A couple more cleanups on top of https://github.com/rust-lang/rust/pull/89011

Blocked on #89011
2021-10-31 13:20:04 +01:00
Esteban Küber
c0b134582a
Lint against RTL unicode codepoints in literals and comments
Address CVE-2021-42574.
2021-10-31 13:14:04 +01:00
Matthias Krüger
e79e9f5e2a
Rollup merge of #89839 - jkugelman:must-use-mem-ptr-functions, r=joshtriplett
Add #[must_use] to mem/ptr functions

There's a lot of low-level / unsafe stuff here. Are there legit use cases for ignoring any of these return values?

* No regressions in `./x.py test --stage 1 library/std src/tools/clippy`.
* One regression in `./x.py test --stage 1 src/test/ui`. Fixed.
* I am unable to run `./x.py doc` on my machine so I'll need to wait for the CI to verify doctests pass. I eyeballed all the adjacent tests and they all look okay.

Parent issue: #89692

r? ```@joshtriplett```
2021-10-31 09:20:25 +01:00
John Kugelman
e129d49f88 Add #[must_use] to remaining std functions (A-N) 2021-10-30 23:44:02 -04:00
Jacob Hoffman-Andrews
69df43b041 Improve display of enum variants
Use h3 and h4 for the variant name and the "Fields" subheading.
Remove the "of T" part of the "Fields" subheading.
Remove border-bottom from "Fields" subheading.
Move docblock below "Fields" listing.
2021-10-30 16:35:26 -07:00
John Kugelman
887503ad14 Add #[must_use] to mem/ptr functions 2021-10-30 18:54:48 -04:00
bors
e249ce6b23 Auto merge of #90422 - GuillaumeGomez:rollup-s1mdag0, r=GuillaumeGomez
Rollup of 5 pull requests

Successful merges:

 - #90156 (Remove underlines from non-top docblocks.)
 - #90183 (Show all Deref implementations recursively)
 - #90202 (Improve and test cross-crate hygiene)
 - #90375 (Use `is_global` in `candidate_should_be_dropped_in_favor_of`)
 - #90399 (Skipping verbose diagnostic suggestions when calling .as_ref() on type not implementing AsRef)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-10-30 19:31:47 +00:00
Guillaume Gomez
197da45e18
Rollup merge of #90399 - yuvaldolev:as-ref-overly-verbose-diagnostic, r=estebank
Skipping verbose diagnostic suggestions when calling .as_ref() on type not implementing AsRef

Addresses #89806

Skipping suggestions when calling `.as_ref()` for types that do not implement the `AsRef` trait.

r? `@estebank`
2021-10-30 20:30:28 +02:00
Guillaume Gomez
06bb1ff1b5
Rollup merge of #90375 - yanok:master, r=lcnr
Use `is_global` in `candidate_should_be_dropped_in_favor_of`

This manifistated in #90195 with compiler being unable to keep
one candidate for a trait impl, if where is a global impl and more
than one trait bound in the where clause.

Before #87280 `candidate_should_be_dropped_in_favor_of` was using
`TypeFoldable::is_global()` that was enough to discard the two
`ParamCandidate`s. But #87280 changed it to use
`TypeFoldable::is_known_global()` instead, which is pessimistic, so
now the compiler drops the global impl instead (because
`is_known_global` is not sure) and then can't decide between the
two `ParamCandidate`s.

Switching it to use `is_global` again solves the issue.

Fixes #90195.
2021-10-30 20:30:27 +02:00
Guillaume Gomez
1a1f525bb0
Rollup merge of #90202 - matthewjasper:xcrate-hygiene, r=petrochenkov
Improve and test cross-crate hygiene

- Decode the parent expansion for traits and enums in `rustc_resolve`, this was already being used for resolution in typeck
- Avoid suggesting importing names with def-site hygiene, since it's often not useful
- Add more tests

r? `@petrochenkov`
2021-10-30 20:30:27 +02:00
Guillaume Gomez
73494404e9
Rollup merge of #90183 - GuillaumeGomez:recurse-deref, r=jyn514
Show all Deref implementations recursively

Fixes #87783.

This is a re-implementation of #80653, so taking the original PR comment:

This changes `rustdoc` to recursively follow `Deref` targets so that methods from all levels are added to the rendered output. This implementation displays the methods from all levels in the expanded state with separate sections for each level.

![image](https://user-images.githubusercontent.com/279572/103482863-46723b00-4ddb-11eb-972b-c463351a425c.png)

cc `@camelid`
r? `@jyn514`
2021-10-30 20:30:26 +02:00
Guillaume Gomez
ec83b95ab9
Rollup merge of #90156 - jsha:less-border-bottom-2, r=GuillaumeGomez
Remove underlines from non-top docblocks.

We still had a number of places where underlined section headings would
show up, like under Implementations.

Follow-up to #89506 (thanks `@yaymukund!)` and #90036. Related to #59829.

r? `@camelid`

Demo:

[Before](https://doc.rust-lang.org/nightly/std/string/struct.String.html#trait-implementations):

[![image](https://user-images.githubusercontent.com/220205/138402555-b0c0a3ea-ff50-4aad-bb74-6f9e57323807.png)](https://jacob.hoffman-andrews.com/rust/less-border-bottom-2/std/string/struct.String.html#trait-implementations)

[After](https://jacob.hoffman-andrews.com/rust/less-border-bottom-2/std/string/struct.String.html#trait-implementations):

[![image](https://user-images.githubusercontent.com/220205/138402669-d0835bd9-8813-4f0c-8697-f86e9759acec.png)](https://jacob.hoffman-andrews.com/rust/less-border-bottom-2/std/string/struct.String.html#trait-implementations)
2021-10-30 20:30:25 +02:00
Gary Guo
94e940dd30 Collect panic/panic_bounds_check during monomorphization 2021-10-30 18:21:44 +01:00
bors
2609fab8e4 Auto merge of #90205 - mati865:link-modifiers-in-rustc, r=petrochenkov
Repace use of `static_nobundle` with `native_link_modifiers` within Rust codebase

This fixes warnings when building Rust and running tests:
```
warning: library kind `static-nobundle` has been superseded by specifying `-bundle` on library kind `static`. Try `static:-bundle`
warning: `rustc_llvm` (lib) generated 2 warnings (1 duplicate)
```
2021-10-30 16:22:49 +00:00
Jacob Hoffman-Andrews
a65c98fefb Remove underlines from non-top docblocks.
We still had a number of places where underlined section headings would
show up, like under Implementations.
2021-10-30 09:22:28 -07:00
Guillaume Gomez
78b604569b Document tests a bit more 2021-10-30 16:30:14 +02:00
lcnr
b40aa64e48 stabilize relaxed_struct_unsize 2021-10-30 15:56:02 +02:00
Matthias Krüger
d99dc7abfa
Rollup merge of #90396 - b-naber:type_flags_ices_default_anon_consts, r=lcnr
Prevent type flags assertions being thrown in default_anon_const_substs if errors occurred

Fixes https://github.com/rust-lang/rust/issues/90364
Fixes https://github.com/rust-lang/rust/issues/88997

r? ``@lcnr``
2021-10-30 14:37:03 +02:00
Matthias Krüger
88e0bea7ca
Rollup merge of #90395 - b-naber:const-expr-type-relation, r=oli-obk
Restrict liveness of mutable borrow of inner infcx in ConstInferUnifier::consts

Fixes https://github.com/rust-lang/rust/issues/89304

r? ``@oli-obk``
2021-10-30 14:37:02 +02:00
Matthias Krüger
a213740abe
Rollup merge of #90374 - GuillaumeGomez:unify-rustdoc-book-titles, r=camelid
Unify titles in rustdoc book doc attributes chapter

As discussed in https://github.com/rust-lang/rust/pull/90339.

I wasn't able to find out where the link to the titles was used so let's see if the CI fails. :)

r? ``@camelid``
2021-10-30 14:37:00 +02:00
bors
22f1ad75e9 Auto merge of #88268 - GuillaumeGomez:generics-search-index, r=notriddle,camelid,jyn514
rustdoc: Fix generics generation in search index

The generics were not added to the search index as they should, instead they were added as arguments. I used this opportunity to allow generics to have generics themselves (will come in very handy for my current rewrite of the search engine!).

r? `@jyn514`
2021-10-30 04:12:40 +00:00
Cameron Steffen
4cfb7add77 Fix a format_args span to be expansion 2021-10-29 17:13:15 -05:00
Will Crichton
b8ecc9fefa Fix rare ICE during typeck in rustdoc scrape_examples 2021-10-29 13:21:50 -07:00
Guillaume Gomez
0c70831171 Unify titles in rustdoc book doc attributes chapter 2021-10-29 21:27:44 +02:00
Guillaume Gomez
355e6eddfe Fix invalid handling of generics 2021-10-29 20:54:15 +02:00
Yuval Dolev
cad2d21cb6 Explicitly skipping suggestions for 'Pin' as it does not implement the 'AsRef' trait 2021-10-29 15:49:55 +03:00
Yuval Dolev
e2151497bf Skip suggestions for the AsRef trait 2021-10-29 15:49:55 +03:00
Guillaume Gomez
dd68d207a5 Don't display "Methods from Deref<...>" if no method is display (the ones which don't have self argument) 2021-10-29 14:37:01 +02:00
Guillaume Gomez
0c38f31bf2 Add tests for recursive deref 2021-10-29 14:25:15 +02:00
bors
9ed5b94b28 Auto merge of #90373 - tmiasko:union-qualification, r=oli-obk
Use type based qualification for unions

Union field access is currently qualified based on the qualification of
a value previously assigned to the union. At the same time, every union
access transmutes the content of the union, which might result in a
different qualification.

For example, consider constants A and B as defined below, under the
current rules neither contains interior mutability, since a value used
in the initial assignment did not contain `UnsafeCell` constructor.

```rust
#![feature(untagged_unions)]

union U { i: u32, c: std::cell::Cell<u32> }
const A: U = U { i: 0 };
const B: std::cell::Cell<u32> = unsafe { U { i: 0 }.c };
```

To avoid the issue, the changes here propose to consider the content of
a union as opaque and use type based qualification for union types.

Fixes #90268.

`@rust-lang/wg-const-eval`
2021-10-29 12:21:09 +00:00
SparrowLii
1ab2616b4d Add feature trigger and correct is_struct check 2021-10-29 20:08:30 +08:00
b-naber
87fbf3c5aa ignore type flags insertion in default_anon_const_substs if error occurred 2021-10-29 13:47:53 +02:00
b-naber
a39c50b64c add test 2021-10-29 12:38:28 +02:00
bors
37f70a0e1e Auto merge of #90214 - tmiasko:indirect-mutation-qualif, r=ecstatic-morse,oli-obk
Consider indirect mutation during const qualification dataflow

Previously a local would be qualified if either one of two separate data
flow computations indicated so. First determined if a local could
contain the qualif, but ignored any forms of indirect mutation. Second
determined if a local could be mutably borrowed (and so indirectly
mutated), but which in turn ignored the qualif.

The end result was incorrect because the effect of indirect mutation was
effectivelly ignored in the all but the final stage of computation.

In the new implementation the indirect mutation is directly incorporated
into the qualif data flow. The local variable becomes immediately
qualified once it is mutably borrowed and borrowed place type can
contain the qualif.

In general we will now reject additional programs, program that were
prevously unintentionally accepted.

There are also some cases which are now accepted but were previously
rejected, because previous implementation didn't consider whether
borrowed place could have the qualif under the consideration.

Fixes #90124.

r? `@ecstatic-morse`
2021-10-29 08:38:39 +00:00
bors
88a5a984fe Auto merge of #90380 - Mark-Simulacrum:revert-89558-query-stable-lint, r=lcnr
Revert "Add rustc lint, warning when iterating over hashmaps"

Fixes perf regressions introduced in https://github.com/rust-lang/rust/pull/90235 by temporarily reverting the relevant PR.
2021-10-29 04:55:51 +00:00
SparrowLii
f3679bc23e move the processing part of base_expr into check_expr_struct_fields 2021-10-29 11:16:28 +08:00
Mateusz Mikuła
533247c1c8 Add -Zunstable-options instead of feature 2021-10-28 23:38:21 +02:00
Matthew Jasper
a76a2d4ef9 Add comments to hygiene tests 2021-10-28 21:48:39 +01:00
bors
85c0558d03 Auto merge of #90218 - JakobDegen:adt_significant_drop_fix, r=nikomatsakis
Fixes incorrect handling of ADT's drop requirements

Fixes #90024 and a bunch of duplicates.

The main issue was just that the contract of `NeedsDropTypes::adt_components` was inconsistent; the list of types it might return were the generic parameters themselves or the fields of the ADT, depending on the nature of the drop impl. This meant that the caller could not determine whether a `.subst()` call was still needed on those types; it called `.subst()` in all cases, and this led to ICEs when the returned types were the generic params.

First contribution of more than a few lines, so feedback definitely appreciated.
2021-10-28 16:03:13 +00:00
Mark Rousskov
3215eeb99f
Revert "Add rustc lint, warning when iterating over hashmaps" 2021-10-28 11:01:42 -04:00
Ilya Yanok
9a0a622a04 Add test cases 2021-10-28 14:25:46 +00:00
SparrowLii
7bde18a0f3 implement type-changing-struct-update
put the test dir in test/ui/rfcs
2021-10-28 14:17:15 +08:00
Tomasz Miąsko
3f778f31b6 Use type based qualification for unions
Union field access is currently qualified based on the qualification of
a value previously assigned to the union. At the same time, every union
access transmutes the content of the union, which might result in a
different qualification.

For example, consider constants A and B as defined below, under the
current rules neither contains interior mutability, since a value used
in the initial assignment did not contain `UnsafeCell` constructor.

```rust
#![feature(untagged_unions)]

union U { i: u32, c: std::cell::Cell<u32> }
const A: U = U { i: 0 };
const B: std::cell::Cell<u32> = unsafe { U { i: 0 }.c };
```

To avoid the issue, the changes here propose to consider the content of
a union as opaque and use type based qualification for union types.
2021-10-28 00:00:00 +00:00
Matthias Krüger
f32c09b82a
Rollup merge of #90304 - vandenheuvel:test_issue_75961, r=Mark-Simulacrum
Add regression test for #75961

Closes #75961.
Closes #21203.
2021-10-27 18:25:46 +02:00
Matthias Krüger
83d5c24071
Rollup merge of #90288 - JakobDegen:import_diagnostics, r=davidtwco
Add hint for people missing `TryFrom`, `TryInto`, `FromIterator` import pre-2021

Adds a hint anytime a `TryFrom`, `TryInto`, `FromIterator` import is suggested noting that these traits are automatically imported in Edition 2021.
2021-10-27 18:25:46 +02:00
Matthias Krüger
17d1742028
Rollup merge of #90267 - EliseZeroTwo:elisezerotwo/fix_invalid_attrs_ice, r=Aaron1011
fix: inner attribute followed by outer attribute causing ICE

Fixes #87936, #88938, and #89971.

This removes the assertion that validates that there are no outer attributes following inner attributes. Where the inner attribute is invalid you get an actual error.
2021-10-27 18:25:44 +02:00
bors
337e1565d3 Auto merge of #90186 - jsha:fix-header-sizes, r=GuillaumeGomez
Fix documentation header sizes

And add a rustdoc-gui test confirming various header sizes.

Split off from #90156. This fixes a regression in #89506 where the heading level of titles within Markdown was too high (h2) for docblocks under structs, unions, and enum impls.

r? `@camelid`

Demo: https://jacob.hoffman-andrews.com/rust/fix-header-sizes/std/string/struct.String.html#impl-Add%3C%26%27_%20str%3E
Stable: https://doc.rust-lang.org/stable/std/string/struct.String.html#impl-Add%3C%26%27_%20str%3E
Beta: https://doc.rust-lang.org/beta/std/string/struct.String.html#impl-Add%3C%26%27_%20str%3E
2021-10-27 12:27:47 +00:00
bors
a8f6e614f8 Auto merge of #89652 - rcvalle:rust-cfi, r=nagisa
Add LLVM CFI support to the Rust compiler

This PR adds LLVM Control Flow Integrity (CFI) support to the Rust compiler. It initially provides forward-edge control flow protection for Rust-compiled code only by aggregating function pointers in groups identified by their number of arguments.

Forward-edge control flow protection for C or C++ and Rust -compiled code "mixed binaries" (i.e., for when C or C++ and Rust -compiled code share the same virtual address space) will be provided in later work as part of this project by defining and using compatible type identifiers (see Type metadata in the design document in the tracking issue #89653).

LLVM CFI can be enabled with -Zsanitizer=cfi and requires LTO (i.e., -Clto).

Thank you, `@eddyb` and `@pcc,` for all the help!
2021-10-27 09:19:42 +00:00
EliseZeroTwo
7f0d43a003
test: add test for inner attribute followed by outer attribute causing ICE 2021-10-27 10:13:25 +02:00
bors
47aeac648e Auto merge of #90337 - matthiaskrgr:rollup-azkr158, r=matthiaskrgr
Rollup of 3 pull requests

Successful merges:

 - #90154 (rustdoc: Remove `GetDefId`)
 - #90232 (rustdoc: Use TTF based font instead of OTF for CJK glyphs to improve readability)
 - #90278 (rustdoc: use better highlighting for *const, *mut, and &mut)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-10-27 06:16:47 +00:00
Bram van den Heuvel
dae7c36b42 Add regression test for #75961 2021-10-27 07:46:42 +02:00
Matthias Krüger
60cad9789c
Rollup merge of #90232 - konan8205:master, r=GuillaumeGomez
rustdoc: Use TTF based font instead of OTF for CJK glyphs to improve readability

Due to Windows' implementation of font rendering, OpenType fonts can be distorted. So the existing font, Noto Sans KR, is not very readable on Windows. This PR improves readability of Korean glyphs on Windows.

## Before
![원1](https://user-images.githubusercontent.com/11029378/138592394-16b15787-532d-4421-a5eb-ed85675290fa.png)

## After
![원2](https://user-images.githubusercontent.com/11029378/138592409-f3a440ee-f0fc-40e4-9561-42c479439c9f.png)

The fonts included in this PR are licensed under the SIL Open Font License and generated with these commands:

```sh
pyftsubset NanumBarunGothic.ttf \
--unicodes=U+AC00-D7AF,U+1100-11FF,U+3130-318F,U+A960-A97F,U+D7B0-D7FF \
--output-file=NanumBarunGothic.ttf.woff --flavor=woff
```
```sh
pyftsubset NanumBarunGothic.ttf \
--unicodes=U+AC00-D7AF,U+1100-11FF,U+3130-318F,U+A960-A97F,U+D7B0-D7FF \
--output-file=NanumBarunGothic.ttf.woff2 --flavor=woff2
```

r? ``@GuillaumeGomez``
2021-10-27 06:11:36 +02:00
bors
a9b2bfb5ed Auto merge of #89937 - JohnTitor:fix-89875, r=Amanieu
Properly check `target_features` not to trigger an assertion

Fixes #89875
I think it should be a condition instead of an assertion to check if it's a register as it's possible that `reg` is a register class.
Also, this isn't related to the issue directly, but `is_target_supported` doesn't check `target_features` attributes. Is there any way to check it on rustc_codegen_llvm?

r? `@Amanieu`
2021-10-27 03:08:47 +00:00
Jakob Degen
cb336f1f67 Reverting switching test to no_std and adjust output after rebase. 2021-10-26 22:30:15 -04:00
Jakob Degen
e41ef36435 Fix line numbers in test 2021-10-26 22:17:01 -04:00
Jakob Degen
6ce3ae4b73 Make ui/suggestions/suggest-tryinto-edition-change.rs no_std to avoid getting inconsistent output between local and CI. 2021-10-26 22:17:01 -04:00
Jakob Degen
958e645946 Adds hint if a trait fails to resolve and a newly added one in Edition 2021 is suggested 2021-10-26 22:17:01 -04:00
Jakob Degen
e91d5ca197 Add test checking that Edition 2021 is suggested for .try_into() and fix other test 2021-10-26 22:17:01 -04:00
Matthias Krüger
fcc9a9a928
Rollup merge of #90305 - vandenheuvel:test_issue_87258, r=Mark-Simulacrum
Add regression test for #87258

Closes #87258.
2021-10-26 19:32:46 +02:00
Matthias Krüger
40d3819a3c
Rollup merge of #90303 - WaffleLapkin:regression_test_90164, r=JohnTitor
Add regression test for issue 90164

Closes #90164 (previously fixed by #90181)
2021-10-26 19:32:45 +02:00
Bram van den Heuvel
f9344296c1 Add regression test for #87258 2021-10-26 16:35:48 +02:00
Maybe Waffle
60ffac07cb Add regression test for issue 90164 2021-10-26 13:23:27 +03:00
bors
c7a30c8b68 Auto merge of #90075 - pierwill:fix-79717, r=petrochenkov
Edit error messages for `rustc_resolve::AmbiguityKind` variants

Edit the language of the ambiguity descriptions for E0659. These strings now appear as notes.

Closes #79717.
2021-10-26 07:57:51 +00:00
Tomasz Miąsko
93f85f5a9d Consider indirect mutation during const qualification dataflow
Previously a local would be qualified if either one of two separate data
flow computations indicated so. First determined if a local could
contain the qualif, but ignored any forms of indirect mutation. Second
determined if a local could be mutably borrowed (and so indirectly
mutated), but which in turn ignored the qualif.

The end result was incorrect because the effect of indirect mutation was
effectivelly ignored in the all but the final stage of computation.

In the new implementation the indirect mutation is directly incorporated
into the qualif data flow. The local variable becomes immediately
qualified once it is mutably borrowed and borrowed place type can
contain the qualif.

In general we will now reject additional programs, program that were
prevously unintentionally accepted.

There are also some cases which are now accepted but were previously
rejected, because previous implementation didn't consider whether
borrowed place could have the qualif under the consideration.
2021-10-26 08:20:01 +02:00
Matthias Krüger
fc8df9b0b8
Rollup merge of #90241 - DrMeepster:thiscall_lint_upgrade, r=petrochenkov
Make thiscall abi on unsupported platforms a hard error

As suggested in https://github.com/rust-lang/rust/issues/42202#issuecomment-950205016, this PR makes use of the `thiscall` abi on unsupported a hard error instead of a lint.
2021-10-26 06:14:07 +02:00
Matthias Krüger
b0df3af5c3
Rollup merge of #90181 - notriddle:notriddle/error-pointer, r=estebank
fix(rustc_typeck): report function argument errors on matching type

Fixes #90101
2021-10-26 06:14:06 +02:00
David Tolnay
c5025f0e4e
Append .0 to unsuffixed float if it would otherwise become int token 2021-10-25 20:30:47 -07:00
Yuki Okushi
bd309e4628
Add a regression test for issue-89875 2021-10-26 11:02:51 +09:00
Shinwoo Park
9e00501c1c rustdoc: use ttf based font for cjk glyphs 2021-10-26 10:58:13 +09:00
pierwill
7de1ff1ba8 Edit error messages for rustc_resolve::AmbiguityKind variants
Emit description of the ambiguity as a note.

Co-authored-by: Noah Lev <camelidcamel@gmail.com>
Co-authored-by: Vadim Petrochenkov <vadim.petrochenkov@gmail.com>
2021-10-25 20:33:07 -05:00
bors
17e13b549f Auto merge of #85830 - bjorn3:separate_provide_extern, r=cjgillot
Avoid a branch on key being local for queries that use the same local and extern providers

Currently based on https://github.com/rust-lang/rust/pull/85810 as it slightly conflicts with it. Only the last two commits are new.
2021-10-26 00:38:58 +00:00
Jacob Hoffman-Andrews
89276ff7ed Fix documentation header sizes
And add a rustdoc-gui test confirming various header sizes.
2021-10-25 16:26:17 -07:00
Ramon de C Valle
5d30e93189 Add LLVM CFI support to the Rust compiler
This commit adds LLVM Control Flow Integrity (CFI) support to the Rust
compiler. It initially provides forward-edge control flow protection for
Rust-compiled code only by aggregating function pointers in groups
identified by their number of arguments.

Forward-edge control flow protection for C or C++ and Rust -compiled
code "mixed binaries" (i.e., for when C or C++ and Rust -compiled code
share the same virtual address space) will be provided in later work as
part of this project by defining and using compatible type identifiers
(see Type metadata in the design document in the tracking issue #89653).

LLVM CFI can be enabled with -Zsanitizer=cfi and requires LTO (i.e.,
-Clto).
2021-10-25 16:23:01 -07:00
DrMeepster
a46daf050b make thiscall on unsupported platforms an error 2021-10-25 14:56:21 -07:00
Matthias Krüger
26e9a719f2
Rollup merge of #90266 - b-naber:uneval_substs, r=lcnr
Prevent duplicate caller bounds candidates by exposing default substs in Unevaluated

Fixes https://github.com/rust-lang/rust/issues/89334

The changes introduced in https://github.com/rust-lang/rust/pull/87280 allowed for "duplicate" caller bounds candidates to be assembled that only differed in their default substs having been "exposed" or not and resulted in an ambiguity error during trait selection. To fix this we expose the defaults substs during the creation of the ParamEnv.

r? `@lcnr`
2021-10-25 22:59:49 +02:00
Michael Howell
8520105464 fix(rustc_typeck): report function argument errors on matching type
Fixes #90101
2021-10-25 12:23:52 -07:00
Guillaume Gomez
6c0dcb41bd
Rollup merge of #90233 - GuillaumeGomez:tooltip-overflow, r=camelid
Tooltip overflow

Fixes #89185.

r? ``@camelid``
2021-10-25 16:34:53 +02:00
Guillaume Gomez
2d85c7eea0
Rollup merge of #90017 - jackh726:issue-tests, r=nikomatsakis
Add a couple tests for normalize under binder issues

Closes #56556
Closes #76956

r? ``@nikomatsakis``
2021-10-25 16:34:52 +02:00
b-naber
0199a81304 add tests 2021-10-25 16:05:03 +02:00
bjorn3
13abc1ae30 Fix test 2021-10-25 15:15:05 +02:00
Guillaume Gomez
345519baa7 Fix scrollbars appearing on information tooltip on mac when they shouldn't 2021-10-25 11:40:13 +02:00
Matthias Krüger
c734a9e076
Rollup merge of #90127 - JohnTitor:fix-90113, r=estebank
Do not mention a reexported item if it's private

Fixes #90113
The _actual_ regression was introduced in #73652, then #88838 made it worse. This fixes the issue by not counting such an import as a candidate.
2021-10-25 07:54:13 +02:00
Matthias Krüger
b25172b504
Rollup merge of #89889 - estebank:unmet-send-bound-on-foreign-future, r=tmandry
Use the "nice E0277 errors"[1] for `!Send` `impl Future` from foreign crate

Partly address #78543 by making the error quieter.

We don't have access to the `typeck` tables from foreign crates, so we
used to completely skip the new code when checking foreign crates. Now,
we carry on and don't provide as nice output (we don't clarify *what* is
making the `Future: !Send`), but at least we no longer emit a sea of
derived obligations in the output.

[1]: https://blog.rust-lang.org/inside-rust/2019/10/11/AsyncAwait-Not-Send-Error-Improvements.html

r? `@tmandry`
2021-10-25 07:54:12 +02:00
bors
41d8c94d45 Auto merge of #89427 - estebank:collect-overlapping-impls, r=jackh726
Point at overlapping impls when type annotations are needed

Address https://github.com/rust-lang/rust/issues/89254.
2021-10-24 22:26:41 +00:00
Esteban Kuber
6dcff4e9f6 Use the "nice E0277 errors"[1] for !Send impl Future from foreign crate
Partly address #78543 by making the error quieter.

We don't have access to the `typeck` tables from foreign crates, so we
used to completely skip the new code when checking foreign crates. Now,
we carry on and don't provide as nice output (we don't clarify *what* is
making the `Future: !Send`), but at least we no longer emit a sea of
derived obligations in the output.

[1]: https://blog.rust-lang.org/inside-rust/2019/10/11/AsyncAwait-Not-Send-Error-Improvements.html
2021-10-24 20:45:33 +00:00
Esteban Kuber
881a50c0b7 Always sort suggestions before emitting them 2021-10-24 20:28:44 +00:00
Esteban Kuber
ef212e7fb3 Point at overlapping impls when type annotations are needed 2021-10-24 18:33:04 +00:00
bors
00d5e42e77 Auto merge of #90235 - matthiaskrgr:rollup-7pqtevk, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #89558 (Add rustc lint, warning when iterating over hashmaps)
 - #90100 (Skip documentation for tier 2 targets on dist-x86_64-apple-darwin)
 - #90155 (Fix alignment of method headings for scannability)
 - #90162 (Mark `{array, slice}::{from_ref, from_mut}` as const fn)
 - #90221 (Fix ICE when forgetting to `Box` a parameter to a `Self::func` call)
 - #90234 (Temporarily turn overflow checks off for rustc-rayon-core)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-10-24 14:12:10 +00:00
Matthias Krüger
d576393e34
Rollup merge of #90221 - JakobDegen:issue-90213, r=cjgillot
Fix ICE when forgetting to `Box` a parameter to a `Self::func` call

Closes #90213 .

Assuming we can get the `DefId` of the receiver causes an ICE if the receiver is `Self`. We can just avoid doing this though.
2021-10-24 15:48:45 +02:00
Matthias Krüger
b837605012
Rollup merge of #90155 - jsha:outdent-methods, r=GuillaumeGomez,camelid
Fix alignment of method headings for scannability

We sometimes use indentation to indicate something is a heading: The section that comes after is indented by 24px relative to the heading. However, the relationship between the "Implementations" section heading, the `impl` headings it contains, and the `pub fn` subheadings within each impl, is awkward. It goes **Implementations**, 15px indent, `impl`, 5px indent, `pub fn`, 4px indent, docblock.

I line up `impl` and `pub fn` with the `Implementations` heading, give `impl` a larger font size to indicate it is higher in the hierarchy, and indent the docblock a full 24px relative to their parent, matching the indents we use elsewhere to distinguish section headings. By letting the `pub fn` stick out to the left of the docblock, I think this makes methods significantly more scannable.

Related to #59829

r? `````@camelid`````

[Old](https://doc.rust-lang.org/nightly/std/string/struct.String.html#implementations):

[![image](https://user-images.githubusercontent.com/220205/138380233-9c63a0f2-0f80-40a3-ab3d-a1ee9fb7c5d8.png)](https://doc.rust-lang.org/nightly/std/string/struct.String.html#implementations)

[New](https://jacob.hoffman-andrews.com/rust/outdent-methods/std/string/struct.String.html#implementations):

[![image](https://user-images.githubusercontent.com/220205/138392479-b45fce3f-bf43-42e0-81ee-c4bb9ac35cda.png)](https://jacob.hoffman-andrews.com/rust/outdent-methods/std/string/struct.String.html#implementations)
2021-10-24 15:48:44 +02:00
Matthias Krüger
87822b27ee
Rollup merge of #89558 - lcnr:query-stable-lint, r=estebank
Add rustc lint, warning when iterating over hashmaps

r? rust-lang/wg-incr-comp
2021-10-24 15:48:42 +02:00
Matthew Jasper
fabede1851 Add more tests for cross-crate hygiene 2021-10-24 12:31:42 +01:00