Commit Graph

2231 Commits

Author SHA1 Message Date
Nadrieril
bdd2bdb53b Don't store ty and span in IntRange
We prefer to grab `ty` and `span` from `pcx`. This makes it consistent
with other constructors.
2020-11-28 22:07:15 +00:00
Nadrieril
d8983655c1 Correctly detect usize/isize range overlaps 2020-11-28 21:23:38 +00:00
bors
4ae328bef4 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`.
2020-11-28 07:48:56 +00:00
bors
f8e5209a21 Auto merge of #79353 - cjgillot:procmacro, r=petrochenkov
Setup proc-macro metadata at encoding instead of decoding

This should improve the common non-proc-macro case for metadata decoding.
2020-11-28 03:20:09 +00:00
bors
fd6b5376b7 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?

r? `@varkor`
`@rustbot` modify labels: +A-exhaustiveness-checking
2020-11-27 22:34:59 +00:00
Aaron Hill
92bfa05b07
Bump recursion_limit in rustc_ast_passes
When cfg(parallel_compiler) is enabled, we end up trying to prove
Send/Sync bounds for some deeply nested types (at least when rustdoc is
run).
2020-11-27 15:47:58 -05:00
Camille GILLOT
9dd32e177e Encode proc_macro directly.
Encode proc_macro name directly.

Do not store None values.
2020-11-27 20:39:49 +01:00
Nadrieril
941c6ac1a2 Rename _match to usefulness 2020-11-27 18:43:28 +00:00
Nadrieril
2de0475826 Rename pat_constructor to Constructor::from_pat 2020-11-27 18:22:19 +00:00
Nadrieril
ba3c419a43 Move the definitions of the two Ctxts to the top 2020-11-27 18:22:19 +00:00
Nadrieril
2184a1444c Extract everything related to pattern deconstruction to a new module 2020-11-27 18:22:17 +00:00
Nadrieril
3715f1ed00 No need to expose Matrix internals 2020-11-27 18:20:30 +00:00
Nadrieril
d447bdff9b Disentangle Fields and PatStack 2020-11-27 18:20:30 +00:00
Nadrieril
b59792128c Move Constructor::apply to Fields 2020-11-27 18:20:30 +00:00
bors
774bce7f5e 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.
2020-11-27 15:58:26 +00:00
Aaron Hill
772292fa51
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.
2020-11-27 09:37:49 -05:00
bors
c922857066 Auto merge of #79318 - cjgillot:fitem, r=lcnr
Store HIR ForeignItem in a side table

In a similar fashion to Item, ImplItem and TraitItem.
2020-11-27 13:45:22 +00:00
bors
361543d776 Auto merge of #79433 - calebcartwright:parse-attr-vis, r=petrochenkov
rustc_parse: restore public visibility on parse_attribute

Make `parse_attribute` public as rustfmt is a downstream consumer. Refs https://github.com/rust-lang/rust/pull/78782#discussion_r530658904

r? `@petrochenkov`
2020-11-27 11:23:11 +00:00
bors
72d2a7cd35 Auto merge of #78194 - bugadani:generic, r=varkor
Skip most of `create_substs_for_ast_path` if type is not generic
2020-11-27 06:53:47 +00:00
bors
cfed9184f4 Auto merge of #79266 - b-naber:gat_trait_path_parser, r=petrochenkov
Generic Associated Types in Trait Paths - Ast part

The Ast part of https://github.com/rust-lang/rust/pull/78978

r? `@petrochenkov`
2020-11-27 00:18:24 +00:00
Camille GILLOT
d6b22fa534 Rebase fallout. 2020-11-26 23:56:15 +01:00
Dániel Buga
aebea52263 Skip most of create_substs_for_ast_path if type is not generic
Co-authored-by: varkor <github@varkor.com>
2020-11-26 23:14:38 +01:00
Aaron Hill
6f91c32da6
Fix new 'unnecessary trailing semicolon' warnings 2020-11-26 17:08:36 -05:00
Aaron Hill
758834d3e2
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.
2020-11-26 17:08:35 -05:00
Aaron Hill
de88bf148b
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`.
2020-11-26 17:08:35 -05:00
bors
cb56a4420c 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.
2020-11-26 22:02:45 +00:00
Camille GILLOT
12a3024c57 Use visitor for its very purpose. 2020-11-26 21:32:29 +01:00
Camille GILLOT
60c3bbd844 Formatting. 2020-11-26 21:32:29 +01:00
Camille GILLOT
032f68d625 Remove ForeignMod struct. 2020-11-26 21:32:27 +01:00
Camille GILLOT
419a9186a4 Store ForeignItem in a side table. 2020-11-26 21:29:27 +01:00
Caleb Cartwright
5930a8ab12 rustc_parse: restore pub vis on parse_attribute 2020-11-26 12:54:09 -06:00
bors
72da5a9d85 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.
2020-11-26 18:51:45 +00:00
bors
0beba93337 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)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2020-11-26 14:14:57 +00:00
Jonas Schievink
89ab56344d
Rollup merge of #79428 - camelid:fixup-compiler-docs, r=davidtwco
Fixup compiler docs

The sublist was being rendered as a code block because it was indented 4
spaces.
2020-11-26 13:39:20 +01:00
Jonas Schievink
815d96111d
Rollup merge of #79421 - camelid:_match-docs-fmt, r=petrochenkov
Fix docs formatting for `thir::pattern::_match`

They were being rendered all on one line.
2020-11-26 13:39:18 +01:00
Jonas Schievink
005a3e5986
Rollup merge of #79402 - bugadani:typos, r=matthewjasper
Fix typos
2020-11-26 13:39:11 +01:00
Jonas Schievink
0ae653a531
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.

r? ``@wesleywiser``
2020-11-26 13:39:09 +01:00
Jonas Schievink
85c11de2f2
Rollup merge of #79362 - cjgillot:relou, r=oli-obk
Lower patterns before using the bound variable

So as to avoid having to lower patterns twice.
2020-11-26 13:39:07 +01:00
Jonas Schievink
6fcd589025
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.
2020-11-26 13:39:05 +01:00
Jonas Schievink
9b2117d1f6
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)

Resolves #76737

r? ``@varkor``
2020-11-26 13:39:00 +01:00
bors
aefcf1f342 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.
2020-11-26 11:59:17 +00:00
Benedikt Terhechte
96779647c4 Add support for Arm64 Catalyst on ARM Macs 2020-11-26 11:31:59 +01:00
Aaron Hill
0b64110b10
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.
2020-11-25 18:41:10 -05:00
Rich Kadel
fdbc121620
fix URLs in doc comment
The angle brackets were confusing my IDE and I thought they were unnecessary. I was wrong.
2020-11-25 13:30:33 -08:00
Camelid
c5c70d4017 Fix docs formatting for thir::pattern::_match
A list was being rendered all on one line and there were other
formatting issues as well.
2020-11-25 13:23:06 -08:00
bors
b48cafd9eb 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.

Closes #75922.
Closes #77848.
Closes #79350.
2020-11-25 21:22:46 +00:00
Camelid
46a750e35b Fixup compiler docs
The sublist was being rendered as a code block because it was indented 4
spaces.
2020-11-25 13:15:48 -08:00
Rich Kadel
d334f589c4
Update compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs 2020-11-25 11:41:23 -08:00
Rich Kadel
b1df6c0e63
replace assert with condition and fatal error 2020-11-25 11:38:09 -08:00
Dániel Buga
29e8e72675 Fix typos 2020-11-25 20:18:36 +01:00