Commit graph

7059 commits

Author SHA1 Message Date
bors
2939249f29 Auto merge of #87725 - JohnTitor:rollup-2ywcpuk, r=JohnTitor
Rollup of 8 pull requests

Successful merges:

 - #87645 (Properly find owner of closure in THIR unsafeck)
 - #87646 (Fix a parser ICE on invalid `fn` body)
 - #87652 (Validate that naked functions are never inlined)
 - #87685 (Write docs for SyncOnceCell From and Default impl)
 - #87693 (Add `aarch64-apple-ios-sim` as a possible target to the manifest)
 - #87708 (Add convenience method for handling ipv4-mapped addresses by canonicalizing them)
 - #87711 (Correct typo)
 - #87716 (Allow generic SIMD array element type)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-08-03 10:42:30 +00:00
Yuki Okushi
331e78d804
Rollup merge of #87716 - calebzulawski:master, r=workingjubilee
Allow generic SIMD array element type

Fixes the following:
```rust
#[repr(simd)]
struct V<T>([T; 4]);
```

cc ``@workingjubilee``
2021-08-03 19:07:50 +09:00
Yuki Okushi
a14b283022
Rollup merge of #87652 - npmccallum:naked_inline, r=Amanieu
Validate that naked functions are never inlined

Reject all uses of the inline attribute on naked functions.

https://github.com/rust-lang/rfcs/pull/2774
https://github.com/rust-lang/rfcs/pull/2972

cc `@joshtriplett` `@tmiasko` `@Amanieu`
2021-08-03 19:07:44 +09:00
Yuki Okushi
f69daa2617
Rollup merge of #87646 - JohnTitor:fix-parser-ice, r=oli-obk
Fix a parser ICE on invalid `fn` body

Fixes #87635
A better fix would add a check for `fn` body on `expected_one_of_not_found` but I haven't come up with a graceful way. Any idea?
r? ```@oli-obk``` ```@estebank```
2021-08-03 19:07:44 +09:00
Yuki Okushi
345862d224
Rollup merge of #87645 - LeSeulArtichaut:issue-87414, r=oli-obk
Properly find owner of closure in THIR unsafeck

Previously, when encountering a closure in a constant, the THIR unsafeck gets invoked on the owner of the constant instead of the constant itself, producing cycles.
Supersedes #87492. ```@FabianWolff``` thanks for your work on that PR, I copied your test file and added you as a co-author.

Fixes #87414.
r? ```@oli-obk```
2021-08-03 19:07:43 +09:00
bors
3354a44d2f Auto merge of #87033 - FabianWolff:issue-87017, r=estebank
Provide a suggestion when trying to destructure a `Vec` as a slice

Fixes #87017.

r? `@estebank`
2021-08-03 08:00:30 +00:00
bors
e91405b9d5 Auto merge of #87262 - dtolnay:negative, r=Aaron1011
Support negative numbers in Literal::from_str

proc_macro::Literal has allowed negative numbers in a single literal token ever since Rust 1.29, using https://doc.rust-lang.org/stable/proc_macro/struct.Literal.html#method.isize_unsuffixed and similar constructors.

```rust
let lit = proc_macro::Literal::isize_unsuffixed(-10);
```

However, the suite of constructors on Literal is not sufficient for all use cases, for example arbitrary precision floats, or custom suffixes in FFI macros.

```rust
let lit = proc_macro::Literal::f64_unsuffixed(0.101001000100001000001000000100000001); // :(
let lit = proc_macro::Literal::i???_suffixed(10ulong); // :(
```

For those, macros construct the literal using from_str instead, which preserves arbitrary precision, custom suffixes, base, and digit grouping.

```rust
let lit = "0.101001000100001000001000000100000001".parse::<Literal>().unwrap();
let lit = "10ulong".parse::<Literal>().unwrap();
let lit = "0b1000_0100_0010_0001".parse::<Literal>().unwrap();
```

However, until this PR it was not possible to construct a literal token that is **both** negative **and** preserving of arbitrary precision etc.

This PR fixes `Literal::from_str` to recognize negative integer and float literals.
2021-08-03 04:50:28 +00:00
Caleb Zulawski
b23de51dcb Allow generic SIMD array element type 2021-08-03 03:33:09 +00:00
Nathaniel McCallum
157e0a0e8f Validate that naked functions are never inlined
Reject all uses of the inline attribute on naked functions.

rust-lang/rfcs#2774
rust-lang/rfcs#2972
2021-08-02 21:49:51 -04:00
bors
f63ab6cfa2 Auto merge of #87628 - estebank:unmet-explicit-lifetime-bound, r=oli-obk
Point at unmet explicit lifetime obligation bound

r? `@oli-obk`

Split off of #85799.
2021-08-02 23:16:40 +00:00
bors
6be8a06bcf Auto merge of #87698 - camsteffen:rollup-yvjfc26, r=camsteffen
Rollup of 6 pull requests

Successful merges:

 - #86176 (Implement a `explicit_generic_args_with_impl_trait` feature gate)
 - #87654 (Add documentation for the order of Option and Result)
 - #87659 (Fix invalid suggestions for non-ASCII characters in byte constants)
 - #87673 (Tweak opaque type mismatch error)
 - #87687 (Inline some macros)
 - #87690 (Add missing "allocated object" doc link to `<*mut T>::add`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-08-02 15:54:11 +00:00
Cameron Steffen
87a99c5949
Rollup merge of #87687 - camsteffen:inline-macros, r=oli-obk
Inline some macros

I factored out some macros that are not really necessary.
2021-08-02 09:36:54 -05:00
Cameron Steffen
1b48f4d1ea
Rollup merge of #87673 - estebank:opaque-ty-mismatch, r=davidtwco
Tweak opaque type mismatch error
2021-08-02 09:36:52 -05:00
Cameron Steffen
4380056397
Rollup merge of #87659 - FabianWolff:issue-87397, r=davidtwco
Fix invalid suggestions for non-ASCII characters in byte constants

Fixes #87397.
2021-08-02 09:36:51 -05:00
Cameron Steffen
14f3418f79
Rollup merge of #86176 - nbdd0121:explicit-generic-args, r=jackh726
Implement a `explicit_generic_args_with_impl_trait` feature gate

Implements #83701

When this gate is enabled, explicit generic arguments can be specified even if `impl Trait` is used in argument position. Generic arguments can only be specified for explicit generic parameters but not for the synthetic type parameters from  `impl Trait`

So code like this will be accepted:
```rust
#![feature(explicit_generic_args_with_impl_trait)]

fn foo<T: ?Sized>(_f: impl AsRef<T>) {}
fn main() {
    foo::<str>("".to_string());
}
```
2021-08-02 09:36:49 -05:00
bors
3227e35765 Auto merge of #87248 - RalfJung:ctfe-partial-overwrite, r=oli-obk
CTFE: throw unsupported error when partially overwriting a pointer

Currently, during CTFE, when a write to memory would overwrite parts of a pointer, we make the remaining parts of that pointer "uninitialized". This is probably not what users expect, so if this ever happens they will be quite confused about why some of the data just vanishes for seemingly no good reason.
So I propose we change this to abort CTFE when that happens, to at last avoid silently doing the wrong thing.
Cc https://github.com/rust-lang/rust/issues/87184

Our CTFE test suite still seems to pass. However, we should probably crater this, and I want to do some tests with Miri as well.
2021-08-02 13:31:02 +00:00
bors
b53a93db2d Auto merge of #87535 - lf-:authors, r=Mark-Simulacrum
rfc3052 followup: Remove authors field from Cargo manifests

Since RFC 3052 soft deprecated the authors field, hiding it from
crates.io, docs.rs, and making Cargo not add it by default, and it is
not generally up to date/useful information for contributors, we may as well
remove it from crates in this repo.
2021-08-02 05:49:17 +00:00
Gary Guo
9b90e7e980 Implement a explicit_generic_args_with_impl_trait feature gate
When this gate is enabled, explicit generic arguments can be specified even
if `impl Trait` is used in argument position. Generic arguments can only be
specified for explicit generic parameters but not for the synthetic type
parameters from  `impl Trait`
2021-08-02 04:17:01 +01:00
Yuki Okushi
5cf6566df4
Rollup merge of #87608 - Aaron1011:remove-system-library, r=Mark-Simulacrum
Remove unused field `Session.system_library_path`
2021-08-02 11:03:27 +09:00
Cameron Steffen
02cd72e34b Inline make_if macro 2021-08-01 17:46:28 -05:00
Cameron Steffen
8746b79a38 Inline create_maybe_get_coercion_reason macro 2021-08-01 17:46:23 -05:00
bors
2827db2b13 Auto merge of #87622 - pietroalbini:bump-bootstrap, r=Mark-Simulacrum
Bump bootstrap compiler to 1.55

Changing the cfgs for stdarch is missing, but my understanding is that we don't need to do it as part of this PR?

r? `@Mark-Simulacrum`
2021-08-01 19:04:37 +00:00
Pietro Albini
24f9de5a44 bump bootstrap compiler to 1.55 2021-08-01 11:19:24 -04:00
bors
2e9c8705e9 Auto merge of #87664 - devnexen:netbsd_sanitizers_support, r=nagisa
netbsd x86_64 arch enable supported sanitizers.
2021-08-01 14:16:37 +00:00
bors
8d57c0ab2b Auto merge of #87546 - rusticstuff:issue87450-take-two, r=davidtwco
Bail on any found recursion when expanding opaque types

Fixes #87450. More of a bandaid because it does not fix the exponential complexity of the type folding used for opaque type expansion.
2021-08-01 11:56:02 +00:00
bors
aadd6189ad Auto merge of #87449 - matthiaskrgr:clippyy_v2, r=nagisa
more clippy::complexity fixes

(also a couple of clippy::perf fixes)
2021-08-01 09:15:15 +00:00
bors
4e282795d7 Auto merge of #87662 - FabianWolff:rb-string, r=estebank
Suggest `br` if the unknown string prefix `rb` is found

Currently, for the following code:
```rust
fn main() {
    rb"abc";
}
```
we issue the following suggestion:
```
help: consider inserting whitespace here
  |
2 |     rb "abc";
  |       --
```
With my changes (only in edition 2021, where unknown prefixes became an error), I get:
```
help: use `br` for a raw byte string
  |
2 |     br"abc";
  |     ^^
```
2021-07-31 20:20:18 +00:00
Fabian Wolff
c29aadd9cf Provide a suggestion when trying to destructure a Vec as a slice 2021-07-31 21:47:36 +02:00
Esteban Küber
052084af13 Tweak opaque type mismatch error 2021-07-31 12:20:00 -07:00
Esteban Küber
e5d42af6ba Point at unmet explicit lifetime obligation bound 2021-07-31 07:56:01 -07:00
David Carlier
4258e937f6 netbsd x86_64 arch enable supported sanitizers. 2021-07-31 15:26:55 +01:00
bors
337181e07d Auto merge of #87607 - JohnTitor:help-to-unused-must-use-op, r=estebank
Add a hint that the expressions produce a value

Fixes #85913
The second commit is semi-_unrelated_ but it allows us to run the related tests just on `src/test/ui/lint`.
2021-07-31 13:47:25 +00:00
Fabian Wolff
f2c9654dcd Suggest br if the unknown string prefix rb is found 2021-07-31 15:37:36 +02:00
Fabian Wolff
c1abb6f4d6 Fix invalid suggestions for non-ASCII characters in byte constants 2021-07-31 15:21:11 +02:00
Ralf Jung
b7b5091378 typo
Co-authored-by: Oli Scherer <github35764891676564198441@oli-obk.de>
2021-07-31 11:30:35 +02:00
Ralf Jung
14de6ec8d8 CTFE: throw unsupported error when partially overwriting a pointer 2021-07-31 11:30:33 +02:00
bors
7069a8c2b7 Auto merge of #86264 - crlf0710:trait_upcasting_part1, r=nikomatsakis
Trait upcasting coercion (part1)

This revives the first part of earlier PR #60900 .

It's not very clear to me which parts of that pr was design decisions, so i decide to cut it into pieces and land them incrementally. This allows more eyes on the details.

This is the first part, it adds feature gates, adds feature gates tests, and implemented the unsize conversion part.
(I hope i have dealt with the `ExistentialTraitRef` values correctly...)

The next part will be implementing the pointer casting.
2021-07-31 07:46:14 +00:00
bors
199d1aebe4 Auto merge of #86754 - estebank:use-multispans-more, r=varkor
Use `multipart_suggestions` more

Built on top of #86532
2021-07-30 23:18:12 +00:00
Yuki Okushi
924eddf30d
Apply review suggestion 2021-07-31 06:21:52 +09:00
Yuki Okushi
eaff0fc25b
Add a hint that the expressions produce a value 2021-07-31 06:12:42 +09:00
Yuki Okushi
d2d851949b
Fix a parser ICE on invalid fn body 2021-07-31 06:09:54 +09:00
bors
1f0a591b3a Auto merge of #87640 - JohnTitor:rollup-yq24nq5, r=JohnTitor
Rollup of 9 pull requests

Successful merges:

 - #86072 (Cross compiling rustc_llvm on Darwin requires zlib.)
 - #87385 (Make `SEMICOLON_IN_EXPRESSIONS_FROM_MACROS` warn by default)
 - #87547 (Add missing examples for NonNull)
 - #87557 (Fix issue with autofix for ambiguous associated function from Rust 2021 prelude when struct is generic)
 - #87559 (Tweak borrowing suggestion in `for` loop)
 - #87596 (Add warning when whitespace is not skipped after an escaped newline)
 - #87606 (Add some TAIT-related regression tests)
 - #87609 (Add docs about performance and `Iterator::map` to `[T; N]::map`)
 - #87616 (Fix missing word in rustdoc book)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-07-30 19:45:55 +00:00
Yuki Okushi
aa9e6aa8ad
Rollup merge of #87596 - jesyspa:issue-87318-hidden-whitespace, r=estebank
Add warning when whitespace is not skipped after an escaped newline

Fixes issue #87318, also simplifies issue #87319.

* Add support to the lexer to emit warnings as well as errors.
* Emit a warning when a string literal contains an escaped newline, but when (some of) the whitespace on the next line is not skipped due to it being non-ASCII.
2021-07-31 04:09:31 +09:00
Yuki Okushi
5e2655d27f
Rollup merge of #87559 - estebank:consider-borrowing, r=oli-obk
Tweak borrowing suggestion in `for` loop
2021-07-31 04:09:30 +09:00
Yuki Okushi
fb27c4cc70
Rollup merge of #87557 - rylev:fix-invalid-prelude-collision-error, r=nikomatsakis
Fix issue with autofix for ambiguous associated function from Rust 2021 prelude when struct is generic

Fixes #86940

The test cases and associated issue should make it clear what specifically this is meant to fix. The fix is slightly hacky in that we check against the literal source code of the call site for the presence of `<` in order to determine if the user has included the generics for the struct (meaning we don't need to include them for them).

r? ``@nikomatsakis``
2021-07-31 04:09:29 +09:00
Yuki Okushi
f6bc738433
Rollup merge of #87385 - Aaron1011:final-enable-semi, r=petrochenkov
Make `SEMICOLON_IN_EXPRESSIONS_FROM_MACROS` warn by default

This PR makes the `SEMICOLON_IN_EXPRESSIONS_FROM_MACROS` lint warn by default.

To avoid showing a large number of un-actionable warnings to users, we only enable the lint for macros defined in the same crate. This ensures that users will be able to fix the warning by simply removing a semicolon.

In the future, I'd like to enable this lint unconditionally, and eventually make it into a hard error in a future edition. This PR is a step towards that goal.
2021-07-31 04:09:20 +09:00
Yuki Okushi
9391d55204
Rollup merge of #86072 - MarcusCalhoun-Lopez:llvm_cross, r=nagisa
Cross compiling rustc_llvm on Darwin requires zlib.
2021-07-31 04:09:19 +09:00
bors
ef9549b6c0 Auto merge of #87421 - estebank:perf-run, r=oli-obk
Do not discard `?Sized` type params and suggest their removal
2021-07-30 17:18:50 +00:00
LeSeulArtichaut
12804230a2 Properly find owner of closure in THIR unsafeck
Co-authored-by: FabianWolff <fabian.wolff@alumni.ethz.ch>
2021-07-30 19:05:34 +02:00
Charles Lew
fb4e0a0972 Implement trait upcasting coercion type-checking. 2021-07-31 00:51:39 +08:00