Commit graph

6275 commits

Author SHA1 Message Date
Ralf Jung
719dafc48b double-check mutability inside Allocation 2021-06-28 09:19:36 +02:00
bors
345530412f Auto merge of #85909 - cjgillot:alloc-kind-query, r=Aaron1011
Make allocator_kind a query.

Part of #85153

r? `@Aaron1011`
2021-06-28 01:20:01 +00:00
bors
e8cb1a4a56 Auto merge of #85359 - lrh2000:reserved-prefixes, r=nikomatsakis
Reserve prefixed identifiers and literals (RFC 3101)

This PR denies any identifiers immediately followed by one of three tokens `"`, `'` or `#`, which is stricter than the requirements of RFC 3101 but may be necessary according to the discussion at [Zulip].

[Zulip]: https://rust-lang.zulipchat.com/#narrow/stream/268952-edition-2021/topic/reserved.20prefixes/near/238470099

The tracking issue #84599 says we'll add a feature gate named `reserved_prefixes`, but I don't think I can do this because it is impossible for the lexer to know whether a feature is enabled or not. I guess determining the behavior by the edition information should be enough.

Fixes #84599
2021-06-27 20:33:25 +00:00
bors
a4f832b275 Auto merge of #86445 - sexxi-goose:box_fix, r=nikomatsakis
2229: Capture box completely in move closures

Even if the content from box is used in a sharef-ref context,
we capture the box entirerly.

This is motivated by:
1) We only capture data that is on the stack.
2) Capturing data from within the box might end up moving more data than
the user anticipated.

Closes https://github.com/rust-lang/project-rfc-2229/issues/50

r? `@nikomatsakis`
2021-06-27 18:10:35 +00:00
bors
a5b7511a6c Auto merge of #86645 - FabianWolff:issue-82328, r=LeSeulArtichaut
Fix ICE with `-Zunpretty=hir,typed`

This PR fixes #82328. The `-Zunpretty=hir,typed` pretty-printer maintains an `Option` with type-checking results and sets the `Option` to `Some` when entering a body. However, this leads to an ICE if an expression occurs in a function signature (i.e. outside of a body), such as `128` in
```rust
fn foo(-128..=127: i8) {}
```
This PR fixes the ICE by checking (if necessary) whether the expression's owner has a body, and retrieving type-checking results for that on the fly.
2021-06-27 00:15:49 +00:00
Fabian Wolff
a8b57723d4 Use Option::map() instead of if let 2021-06-26 22:26:26 +02:00
bors
a1411de9de Auto merge of #86267 - ZuseZ4:master, r=nagisa
Allow loading of llvm plugins on nightly

Based on a discussion in  #82734 / with `@wsmoses.`
Mainly moves [this](0149bc4e7e) behind a -Z flag, so it can only be used on nightly,
as requested by `@nagisa` in https://github.com/rust-lang/rust/issues/82734#issuecomment-835863940

This change allows loading of llvm plugins like Enzyme.
Right now it also requires a shared library LLVM build of rustc for symbol resolution.

```rust
// test.rs
extern { fn __enzyme_autodiff(_: usize, ...) -> f64; }

fn square(x : f64) -> f64 {
   return x * x;
}

fn main() {
   unsafe {
      println!("Hello, world {} {}!", square(3.0), __enzyme_autodiff(square as usize, 3.0));
   }
}
```
```
./rustc test.rs -Z llvm-plugins="./LLVMEnzyme-12.so" -C passes="enzyme"
./test
Hello, world 9 6!
```

I will try to figure out how to simplify the usage and get this into stable in a later iteration,
but having this on nightly will already help testing further steps.
2021-06-26 19:20:41 +00:00
Manuel Drehwald
abdd24a040 Remove dropping of loaded plugins and better debug info 2021-06-26 19:30:09 +02:00
lrh2000
e9fc942b4d Use FutureIncompatibilityReason to denote edition 2021-06-26 23:40:07 +08:00
Mara Bos
7490305e13 No reserved_prefix suggestion in proc macro call_site. 2021-06-26 23:11:14 +08:00
Mara Bos
0eeeebc990 Rename 'bad prefix' to 'unknown prefix'. 2021-06-26 23:11:14 +08:00
Mara Bos
d40be0fc64 Check the span's edition for the reserved prefixes. 2021-06-26 23:11:13 +08:00
Mara Bos
6adce70a58 Improve comments for reserved prefixes.
Co-authored-by: Niko Matsakis <niko@alum.mit.edu>
2021-06-26 23:11:13 +08:00
Mara Bos
d837c00d10 Add migration lint for reserved prefixes. 2021-06-26 23:11:04 +08:00
Mara Bos
ce43fc9404 Fix note in reserved prefix error. 2021-06-26 23:09:43 +08:00
Mara Bos
c856e6fa53 Add machine applicable suggestion to unknown prefix error. 2021-06-26 23:09:43 +08:00
lrh2000
8dee9bc8fc Reserve prefixed identifiers and string literals (RFC 3101)
This commit denies any identifiers immediately followed by
one of three tokens `"`, `'` or `#`, which is stricter than
the requirements of RFC 3101 but may be necessary according
to the discussion at [Zulip].

[Zulip]: https://rust-lang.zulipchat.com/#narrow/stream/268952-edition-2021/topic/reserved.20prefixes/near/238470099
2021-06-26 23:09:43 +08:00
Fabian Wolff
7682e87c6d Fix ICE with -Zunpretty=hir,typed when an expression occurs in a function signature 2021-06-26 16:05:53 +02:00
Mara Bos
ef152d9b9f Better suggestion for array_into_iter in for loop. 2021-06-26 12:14:22 +00:00
Mara Bos
5cfe2a5fc6 Add new suggestion to array_into_iter lint. 2021-06-26 12:03:33 +00:00
Mara Bos
37e17803b5 Change wording on array_into_iter lint for 1.53 and edition changes. 2021-06-26 12:03:33 +00:00
bors
481971978f Auto merge of #86586 - Smittyvb:https-everywhere, r=petrochenkov
Use HTTPS links where possible

While looking at #86583, I wondered how many other (insecure) HTTP links were in `rustc`. This changes most other `http` links to `https`. While most of the links are in comments or documentation, there are a few other HTTP links that are used by CI that are changed to HTTPS.

Notes:
- I didn't change any to or in licences
- Some links don't support HTTPS :(
- Some `http` links were dead, in those cases I upgraded them to their new places (all of which used HTTPS)
2021-06-26 08:24:31 +00:00
bors
6830052c7b Auto merge of #86637 - ehuss:spellings, r=dtolnay
Fix a few misspellings.
2021-06-26 05:09:27 +00:00
bors
bca6d9baa9 Auto merge of #86622 - FabianWolff:issue-83475, r=jonas-schievink
Check that `#[cmse_nonsecure_entry]` is applied to a function definition

This PR fixes #83475. The compiler currently neglects to check whether `#[cmse_nonsecure_entry]` is applied to a function (and not, say, a struct) definition, leading to an ICE later on when the type checker attempts to retrieve the function signature. I have fixed this problem by adding an appropriate check to the `check_attr` pass, so that an error is reported instead of an ICE.
2021-06-26 02:28:45 +00:00
bors
e6b4c252ea Auto merge of #86599 - Amanieu:asm_raw, r=nagisa
Add a "raw" option for asm! which ignores format string specifiers

This is useful when including raw assembly snippets using `include_str!`.
2021-06-25 20:44:28 +00:00
Eric Huss
6235e6f93f Fix a few misspellings. 2021-06-25 13:18:56 -07:00
bors
0d7f236b8a Auto merge of #86627 - JohnTitor:rollup-ey29pc1, r=JohnTitor
Rollup of 5 pull requests

Successful merges:

 - #86330 (Change how edition based future compatibility warnings are handled)
 - #86513 (Rustdoc: Do not list impl when trait has doc(hidden))
 - #86592 (Use `#[non_exhaustive]` where appropriate)
 - #86608 (chore(rustdoc): remove unused members of RenderType)
 - #86624 (Update compiler-builtins)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-06-25 18:16:37 +00:00
Fabian Wolff
499afcdfcf Check that #[cmse_nonsecure_entry] is applied to a function definition 2021-06-25 17:49:41 +02:00
Yuki Okushi
9e4649995f
Rollup merge of #86592 - jhpratt:non_exhaustive, r=JohnTitor
Use `#[non_exhaustive]` where appropriate

Due to the std/alloc split, it is not possible to make `alloc::collections::TryReserveError::AllocError` non-exhaustive without having an unstable, doc-hidden method to construct (which negates the benefits from `#[non_exhaustive]`).

`@rustbot` label +C-cleanup +T-libs +S-waiting-on-review
2021-06-26 00:42:12 +09:00
bors
f726dbe934 Auto merge of #85603 - ogoffart:fix-uninhabited-enum-branching-pass, r=wesleywiser
Fix uninhabited enum branching pass

when the discriminant is taken with some projection.
2021-06-25 15:35:47 +00:00
Ryan Levick
15eae851de Fix new lints 2021-06-25 14:51:56 +02:00
Ryan Levick
5ef071ee42 Add back missing doc 2021-06-25 14:51:56 +02:00
Ryan Levick
7b3940f44b Address PR feedback 2021-06-25 14:51:56 +02:00
Ryan Levick
23176f60e7 Change how edition based future compatibility warnings are handled 2021-06-25 14:51:56 +02:00
bors
117799b73c Auto merge of #86505 - JohnTitor:fix-86483, r=jackh726
Do not panic in `return_type_impl_trait`

Fixes #86483
2021-06-25 09:28:17 +00:00
bors
50a9081216 Auto merge of #85640 - bjorn3:custom_ice_hook, r=jackh726
Allow changing the bug report url for the ice hook

cc https://github.com/bjorn3/rustc_codegen_cranelift/issues/1174
2021-06-25 04:06:32 +00:00
Aman Arora
d37a07ffbe fixup! 2229: Capture box completely in move closures
fixup! 2229: Capture box completely in move closures
2021-06-24 21:45:29 -04:00
bors
079aa837d2 Auto merge of #86574 - m-ou-se:or-pattern-lint-fix, r=petrochenkov
Don't lint :pat when re-parsing a macro from another crate.

`compile_macro` is used both when compiling the original definition in the crate that defines it, and to compile the macro when loading it when compiling a crate that uses it. We should only emit lints in the first case.

This adds a `is_definition: bool` to pass this information in, so we don't warn about things that only concern the definition site.

Fixes #86567
2021-06-25 01:23:16 +00:00
Aman Arora
de2052af9c 2229: Capture box completely in move closures
Even if the content from box is used in a sharef-ref context,
we capture the box entirerly.

This is motivated by:
1) We only capture data that is on the stack.
2) Capturing data from within the box might end up moving more data than
the user anticipated.
2021-06-24 19:39:51 -04:00
Amanieu d'Antras
d0443bb7c2 Add a "raw" option for asm! which ignores format string specifiers 2021-06-24 23:42:15 +01:00
Mara Bos
06db210459 Don't lint :pat when re-parsing a macro from another crate. 2021-06-24 22:04:55 +00:00
bors
d95745e5fa Auto merge of #85427 - ehuss:fix-use-placement, r=jackh726
Fix use placement for suggestions near main.

This fixes an edge case for the suggestion to add a `use`. When running with `--test`, the `main` function will be annotated with an `#[allow(dead_code)]` attribute. The `UsePlacementFinder` would end up using the dummy span of that synthetic attribute. If there are top-level inner attributes, this would place the `use` in the wrong position. The solution here is to ignore attributes with dummy spans.

In the process of working on this, I discovered that the `use_suggestion_placement` test was broken. `UsePlacementFinder` is unaware of active attributes. Attributes like `#[derive]` don't exist in the AST since they are removed. Fixing that is difficult, since the AST does not retain enough information. I considered trying to place the `use` towards the top of the module after any `extern crate` items, but I couldn't find a way to get a span for the start of a module block (the `mod` span starts at the `mod` keyword, and it seems tricky to find the spot just after the opening bracket and past inner attributes). For now, I just put some comments about the issue. This appears to have been a known issue in #44215 where the test for it was introduced, and the fix seemed to be deferred to later.
2021-06-24 14:56:28 +00:00
Jacob Pratt
3f14f4b3ce
Use #[non_exhaustive] where appropriate
Due to the std/alloc split, it is not possible to make
`alloc::collections::TryReserveError::AllocError` non-exhaustive without
having an unstable, doc-hidden method to construct (which negates the
benefits from `#[non_exhaustive]`.
2021-06-24 04:16:11 -04:00
bors
456a03227e Auto merge of #86279 - JohnTitor:transparent-zero-size-fields, r=nikomatsakis
Permit zero non-zero-field on transparent types

Fixes #77841

This makes the transparent fields meet the below:
> * A `repr(transparent)` type `T` must meet the following rules:
>   * It may have any number of 1-ZST fields
>   * In addition, it may have at most one other field of type U

r? `@nikomatsakis`
2021-06-24 07:29:59 +00:00
Yuki Okushi
9323a2824b
Prefer "allow list" structure to check a type 2021-06-24 15:02:50 +09:00
Yuki Okushi
462c74007e
Rename function name in comments 2021-06-24 14:21:50 +09:00
Yuki Okushi
a141d29612
Do not panic in return_type_impl_trait 2021-06-24 14:06:28 +09:00
Yuki Okushi
64c9712cf3
Rollup merge of #86566 - fee1-dead:mir-pretty-print, r=oli-obk
Use `use_verbose` for `mir::Constant`

Fixes #79799.
2021-06-24 13:47:39 +09:00
Yuki Okushi
3998c03a65
Rollup merge of #86536 - sexxi-goose:edition, r=nikomatsakis
Edition 2021 enables disjoint capture

First part for https://github.com/rust-lang/project-rfc-2229/issues/43
2021-06-24 13:47:36 +09:00
Yuki Okushi
6b618c82ba
Rollup merge of #86533 - inquisitivecrystal:lower-case-error-explain, r=petrochenkov
Support lowercase error codes in `--explain`

This enables `rustc --explain` to accept a lowercase error code. Thus, for instance, `rustc --explain e0573` would be valid after this change, where before a user would have needed to do `rustc --explain E0573`. Although the upper case form of an error code is canonical, the user may prefer the easier-to-type lowercase form, and there's nothing to be gained by forcing them to type the upper case version.

Resolves #86518.
2021-06-24 13:47:35 +09:00