Dylan DPC [Sun, 29 Nov 2020 02:14:07 +0000 (03:14 +0100)]
Rollup merge of #79327 - TimDiekmann:static-alloc-pin-in-box, r=Mark-Simulacrum
Require allocator to be static for boxed `Pin`-API
Allocators has to retain their validity until the instance and all of its clones are dropped. When pinning a value, it must live forever, thus, the allocator requires a `'static` lifetime for pinning a value. [Example from reddit](https://www.reddit.com/r/rust/comments/jymzdw/the_story_continues_vec_now_supports_custom/gd7qak2?utm_source=share&utm_medium=web2x&context=3):
```rust
let alloc = MyAlloc(/* ... */);
let pinned = Box::pin_in(42, alloc);
mem::forget(pinned); // Now `value` must live forever
// Otherwise `Pin`'s invariants are violated, storage invalidated
// before Drop was called.
// borrow of `memory` can end here, there is no value keeping it.
drop(alloc); // Oh, value doesn't live forever.
```
Jonas Schievink [Sat, 28 Nov 2020 14:58:26 +0000 (15:58 +0100)]
Rollup merge of #79476 - bjorn3:sync_cg_clif-2020-11-27, r=bjorn3
Sync rustc_codegen_cranelift
This implements a few extra simd intrinsics, fixes yet another 128bit bug and updates a few dependencies. It also fixes an cg_clif subtree update that did compile, but that caused a panic when compiling libcore. Other than that this is mostly cleanups.
Jonas Schievink [Sat, 28 Nov 2020 14:58:19 +0000 (15:58 +0100)]
Rollup merge of #79344 - JRF63:fix_install_script_win, r=Mark-Simulacrum
Convert UNC path to local path to satisfy install script on Windows
`mkdir` with the `-p` flag attempts to create `//?` if passed a UNC path. This fails on both MSYS2 and Git Bash.
The UNC paths come from [canonicalizing](https://github.com/rust-lang/rust/blob/32da90b431919eedb3e281a91caea063ba4edb77/src/bootstrap/install.rs#L79) the install prefix path. `mkdir -p` gets invoked on the [install script](https://github.com/rust-lang/rust-installer/blob/d66f476b4d5e7fdf1ec215c9ac16c923dc292324/install-template.sh#L149).
Jonas Schievink [Sat, 28 Nov 2020 14:58:17 +0000 (15:58 +0100)]
Rollup merge of #79234 - ortem:fix-hashmap-pretty-printers, r=Mark-Simulacrum
Resolve typedefs in HashMap gdb/lldb pretty-printers
`GetTypedefedType` (LLDB) and `strip_typedefs` (GDB) calls are needed to resolve key and value types completely.
Without these calls, debugger doesn't show the actual type.
Jonas Schievink [Sat, 28 Nov 2020 14:58:15 +0000 (15:58 +0100)]
Rollup merge of #78853 - calebcartwright:fix-const-block-expr-span, r=spastorino
rustc_parse: fix ConstBlock expr span
The span for a ConstBlock expression should presumably run through the end of the block it contains and not stop at the keyword, just like is done with similar block-containing expression kinds, such as a TryBlock
bors [Sat, 28 Nov 2020 07:48:56 +0000 (07:48 +0000)]
Auto merge of #78296 - Aaron1011:fix/stmt-tokens, r=petrochenkov
Properly handle attributes on statements
We now collect tokens for the underlying node wrapped by `StmtKind`
nstead of storing tokens directly in `Stmt`.
`LazyTokenStream` now supports capturing a trailing semicolon after it
is initially constructed. This allows us to avoid refactoring statement
parsing to wrap the parsing of the semicolon in `parse_tokens`.
Attributes on item statements
(e.g. `fn foo() { #[bar] struct MyStruct; }`) are now treated as
item attributes, not statement attributes, which is consistent with how
we handle attributes on other kinds of statements. The feature-gating
code is adjusted so that proc-macro attributes are still allowed on item
statements on stable.
Two built-in macros (`#[global_allocator]` and `#[test]`) needed to be
adjusted to support being passed `Annotatable::Stmt`.
bors [Sat, 28 Nov 2020 00:53:02 +0000 (00:53 +0000)]
Auto merge of #79469 - rust-lang:revert-77467-query-docs, r=jyn514
Revert "Normalize `<X as Y>::T` for rustdoc"
Reverts rust-lang/rust#77467 by disabling normalization. See https://github.com/rust-lang/rust/issues/79459; I intend to reland normalization once that's fixed.
bors [Fri, 27 Nov 2020 22:34:59 +0000 (22:34 +0000)]
Auto merge of #79284 - Nadrieril:constructor-module, r=varkor
Split match exhaustiveness into two files
I feel the constructor-related things in the `_match` module make enough sense on their own so I split them off. It makes `_match` feel less like a complicated mess. I'm not aware of PRs in progress against this module apart from my own so hopefully I'm not annoying too many people.
I have a lot of questions about the conventions in naming and modules around the compiler. Like, why is the module named `_match`? Could I rename it to `usefulness` maybe? Should `deconstruct_pat` be a submodule of `_match` since only `_match` uses it? Is it ok to move big piles of code around even if it makes git blame more difficult?
bors [Fri, 27 Nov 2020 19:30:58 +0000 (19:30 +0000)]
Auto merge of #79372 - jyn514:more-cleanup, r=GuillaumeGomez
Cleanup more of rustdoc
- Use `Item::from_def_id` for StructField
- Use `from_def_id_and_parts` for primitives and keywords
- Take `String` instead of `Symbol` in `from_def_id` - this avoids having to intern then immediately stringify the existing string.
- Remove unused `get_stability` and `get_deprecation`
- Remove unused `attrs` field from `primitives`
- Remove unused `attrs` field from `keywords`
This will probably conflict with https://github.com/rust-lang/rust/pull/79335 and I would prefer for that PR to land first - I'm anxious for https://github.com/rust-lang/rust/pull/77467 to land :)
Makes https://github.com/rust-lang/rust/issues/76998 easier to add.
bors [Fri, 27 Nov 2020 15:58:26 +0000 (15:58 +0000)]
Auto merge of #77484 - terhechte:support-ios-catalyst-macabi-arm64-target-triple, r=nikomatsakis
Add support for Arm64 Catalyst on ARM Macs
This is an iteration on https://github.com/rust-lang/rust/pull/63467 which was merged a while ago. In the aforementioned PR, I added support for the `X86_64-apple-ios-macabi` target triple, which is Catalyst, iOS apps running on macOS.
Very soon, Apple will launch ARM64 based Macs which will introduce `aarch64_apple_darwin.rs`, macOS apps using the Darwin ABI running on ARM. This PR adds support for Catalyst apps on ARM Macs: iOS apps compiled for the darwin ABI.
I don't have access to a Apple Developer Transition Kit (DTK), so I can't really test if the generated binaries work correctly. I'm vaguely hopeful that somebody with access to a DTK could give this a spin.
Aaron Hill [Fri, 27 Nov 2020 14:36:59 +0000 (09:36 -0500)]
Don't lint on redundant semicolons after item statements
This preserves the current lint behavior for now.
Linting after item statements currently prevents the compiler from bootstrapping.
Fixing this is blocked on fixing this upstream in Cargo, and bumping the Cargo
submodule.
Aaron Hill [Fri, 27 Nov 2020 02:44:09 +0000 (21:44 -0500)]
Use custom macro instead of println
Loading a macro from libstd causes us to load serialized
`SyntaxContext`s in a platform-dependent way, causing the printed spans
to differ between platforms.
Aaron Hill [Wed, 25 Nov 2020 21:52:24 +0000 (16:52 -0500)]
Only eat semicolons for statements that need them
When parsing a statement (e.g. inside a function body),
we now consider `struct Foo {};` and `$stmt;` to each consist
of two statements: `struct Foo {}` and `;`, and `$stmt` and `;`.
As a result, an attribute macro invoke as
`fn foo() { #[attr] struct Bar{}; }` will see `struct Bar{}` as its
input. Additionally, the 'unused semicolon' lint now fires in more
places.
Aaron Hill [Tue, 17 Nov 2020 19:27:44 +0000 (14:27 -0500)]
Properly handle attributes on statements
We now collect tokens for the underlying node wrapped by `StmtKind`
instead of storing tokens directly in `Stmt`.
`LazyTokenStream` now supports capturing a trailing semicolon after it
is initially constructed. This allows us to avoid refactoring statement
parsing to wrap the parsing of the semicolon in `parse_tokens`.
Attributes on item statements
(e.g. `fn foo() { #[bar] struct MyStruct; }`) are now treated as
item attributes, not statement attributes, which is consistent with how
we handle attributes on other kinds of statements. The feature-gating
code is adjusted so that proc-macro attributes are still allowed on item
statements on stable.
Two built-in macros (`#[global_allocator]` and `#[test]`) needed to be
adjusted to support being passed `Annotatable::Stmt`.
bors [Thu, 26 Nov 2020 22:02:45 +0000 (22:02 +0000)]
Auto merge of #79338 - Aaron1011:fix/token-reparse-cache, r=petrochenkov
Cache pretty-print/retokenize result to avoid compile time blowup
Fixes #79242
If a `macro_rules!` recursively builds up a nested nonterminal
(passing it to a proc-macro at each step), we will end up repeatedly
pretty-printing/retokenizing the same nonterminals. Unfortunately, the
'probable equality' check we do has a non-trivial cost, which leads to a
blowup in compilation time.
As a workaround, we cache the result of the 'probable equality' check,
which eliminates the compilation time blowup for the linked issue. This
commit only touches a single file (other than adding tests), so it
should be easy to backport.
The proper solution is to remove the pretty-print/retokenize hack
entirely. However, this will almost certainly break a large number of
crates that were relying on hygiene bugs created by using the reparsed
`TokenStream`. As a result, we will definitely not want to backport
such a change.
Joshua Nelson [Tue, 24 Nov 2020 03:33:10 +0000 (22:33 -0500)]
Use `from_def_id_and_parts` for primitives and keywords
- Take `String` instead of `Symbol` - this avoids having to intern then
immediately stringify the existing string.
- Remove unused `get_stability` and `get_deprecation`
- Remove unused `attrs` field from `primitives`
bors [Thu, 26 Nov 2020 18:51:45 +0000 (18:51 +0000)]
Auto merge of #77671 - flip1995:lint_list_always_plugins, r=oli-obk,Manishearth
Always print lints from plugins, if they're available
Currently you can get a list of lints and lint groups by running `rustc
-Whelp`. This prints an additional line at the end:
```
Compiler plugins can provide additional lints and lint groups. To see a listing of these, re-run `rustc -W help` with a crate filename.
```
Clippy is such a "compiler plugin", that provides additional lints.
Running `clippy-driver -Whelp` (`rustc` wrapper) still only prints the
rustc lints with the above message at the end. But when running
`clippy-driver -Whelp main.rs`, where `main.rs` is any rust file, it
also prints Clippy lints. I don't think this is a good approach from a
UX perspective: Why is a random file necessary to print a help message?
This PR changes this behavior: Whenever a compiler callback
registers lints, it is assumed that these lints come from a plugin and
are printed without having to specify a Rust source file.
Fixes rust-lang/rust-clippy#6122
cc `@Manishearth` `@ebroto` for the Clippy changes.
bors [Thu, 26 Nov 2020 14:14:57 +0000 (14:14 +0000)]
Auto merge of #79441 - jonas-schievink:rollup-l9v00bl, r=jonas-schievink
Rollup of 10 pull requests
Successful merges:
- #77758 (suggest turbofish syntax for uninferred const arguments)
- #79000 (Move lev_distance to rustc_ast, make non-generic)
- #79362 (Lower patterns before using the bound variable)
- #79365 (Upgrades the coverage map to Version 4)
- #79402 (Fix typos)
- #79412 (Clean up rustdoc tests by removing unnecessary features)
- #79413 (Fix persisted doctests on Windows / when using workspaces)
- #79420 (Fixes a word typo in librustdoc)
- #79421 (Fix docs formatting for `thir::pattern::_match`)
- #79428 (Fixup compiler docs)
Jonas Schievink [Thu, 26 Nov 2020 12:39:15 +0000 (13:39 +0100)]
Rollup merge of #79413 - Swatinem:rustdoc-persist-crate, r=GuillaumeGomez
Fix persisted doctests on Windows / when using workspaces
When using the unstable `--persist-doctests` option,
Windows path separators were not escaped properly. Also when running
the command in a workspace, crate files can overwrite each other.
Jonas Schievink [Thu, 26 Nov 2020 12:39:09 +0000 (13:39 +0100)]
Rollup merge of #79365 - richkadel:llvm-cov-map-version-4, r=wesleywiser
Upgrades the coverage map to Version 4
Changes the coverage map injected into binaries compiled with
`-Zinstrument-coverage` to LLVM Coverage Mapping Format, Version 4 (from
Version 3). Note, binaries compiled with this version will require LLVM
tools from at least LLVM Version 11.
Jonas Schievink [Thu, 26 Nov 2020 12:39:05 +0000 (13:39 +0100)]
Rollup merge of #79000 - sivadeilra:user/ardavis/lev_distance, r=wesleywiser
Move lev_distance to rustc_ast, make non-generic
rustc_ast currently has a few dependencies on rustc_lexer. Ideally, an AST
would not have any dependency its lexer, for minimizing
design-time dependencies. Breaking this dependency would also have practical
benefits, since modifying rustc_lexer would not trigger a rebuild of rustc_ast.
This commit does not remove the rustc_ast --> rustc_lexer dependency,
but it does remove one of the sources of this dependency, which is the
code that handles fuzzy matching between symbol names for making suggestions
in diagnostics. Since that code depends only on Symbol, it is easy to move
it to rustc_span. It might even be best to move it to a separate crate,
since other tools such as Cargo use the same algorithm, and have simply
contain a duplicate of the code.
This changes the signature of find_best_match_for_name so that it is no
longer generic over its input. I checked the optimized binaries, and this
function was duplicated for nearly every call site, because most call sites
used short-lived iterator chains, generic over Map and such. But there's
no good reason for a function like this to be generic, since all it does
is immediately convert the generic input (the Iterator impl) to a concrete
Vec<Symbol>. This has all of the costs of generics (duplicated method bodies)
with no benefit.
Changing find_best_match_for_name to be non-generic removed about 10KB of
code from the optimized binary. I know it's a drop in the bucket, but we have
to start reducing binary size, and beginning to tame over-use of generics
is part of that.
Jonas Schievink [Thu, 26 Nov 2020 12:39:00 +0000 (13:39 +0100)]
Rollup merge of #77758 - Stupremee:turbofish-help-for-const, r=varkor
suggest turbofish syntax for uninferred const arguments
When not providing a const generic value, and it can not be inferred, the following suggestion is suggested:
![image](https://user-images.githubusercontent.com/39732259/95616180-af127b80-0a69-11eb-8877-551c815f9627.png)
bors [Thu, 26 Nov 2020 11:59:17 +0000 (11:59 +0000)]
Auto merge of #79427 - Aaron1011:fix/const-array-index, r=oli-obk
Resolve inference variables before trying to remove overloaded indexing
Fixes #79152
This code was already set up to handle indexing an array. However, it
appears that we never end up with an inference variable for the slice
case, so the missing call to `resolve_vars_if_possible` had no effect
until now.
Aaron Hill [Wed, 25 Nov 2020 21:03:10 +0000 (16:03 -0500)]
Resolve inference variables before trying to remove overloaded indexing
Fixes #79152
This code was already set up to handle indexing an array. However, it
appears that we never end up with an inference variable for the slice
case, so the missing call to `resolve_vars_if_possible` had no effect
until now.
bors [Wed, 25 Nov 2020 21:22:46 +0000 (21:22 +0000)]
Auto merge of #79411 - tmiasko:naked-params, r=Amanieu
Validate use of parameters in naked functions
* Reject use of parameters inside naked function body.
* Reject use of patterns inside function parameters, to emphasize role
of parameters a signature declaration (mirroring existing behaviour
for function declarations) and avoid generating code introducing
specified bindings.
Closes issues below by considering input to be ill-formed.