Commit Graph

187 Commits

Author SHA1 Message Date
Bastian Kauschke
645fedd183 correctly handle const params in type_of 2020-03-22 22:29:54 +01:00
Mazdak Farrokhzad
14f89ded2c {rustc::hir::map -> rustc_hir}::definitions 2020-03-21 22:20:24 +01:00
Mazdak Farrokhzad
0f68ab03c3 separate out an arena for HIR 2020-03-21 22:18:57 +01:00
Eduard-Mihai Burtescu
2b0a21ead1 rustc: use LocalDefId instead of DefIndex in ich. 2020-03-19 11:16:08 +02:00
Eduard-Mihai Burtescu
f3ec069886 rustc: use LocalDefId instead of DefIndex in HirId. 2020-03-19 11:16:08 +02:00
Eduard-Mihai Burtescu
55ed19fe1b rustc: make LocalDefId's index field public like DefId's is. 2020-03-19 11:15:35 +02:00
Mazdak Farrokhzad
292c538265
Rollup merge of #69920 - Centril:hir-cleanup, r=Zoxc
Remove some imports to the rustc crate

- When we have `NestedVisitorMap::None`, we use `type Map = dyn intravisit::Map<'v>;` instead of the actual map. This doesn't actually result in dynamic dispatch (in the future we may want to use an associated type default to simplify the code).

- Use `rustc_session::` imports instead of `rustc::{session, lint}`.

r? @Zoxc
2020-03-18 18:03:44 +01:00
Dylan MacKenzie
cc4a5770fa Add requisite feature gates for const assert 2020-03-17 11:15:40 -07:00
Dylan MacKenzie
7f5a2841ea Rename from_u32_const -> from_u32 2020-03-17 11:15:40 -07:00
Dylan DPC
8872d90572
Rollup merge of #69989 - petrochenkov:nolegacy, r=eddyb,matthewjasper
resolve/hygiene: `macro_rules` are not "legacy"

The "modern" vs "legacy" naming was introduced by jseyfried during initial implementation of macros 2.0.
At this point it's clear that `macro_rules` are not going anywhere and won't be deprecated in the near future.
So this PR changes the naming "legacy" (when it implies "macro_rules") to "macro_rules".
This should also help people reading this code because it's wasn't obvious that "legacy" actually meant "macro_rules" in these contexts.

The most contentious renaming here is probably
```
fn modern -> fn normalize_to_macros_2_0
fn modern_and_legacy -> fn normalize_to_macro_rules
```
Other alternatives that I could think of are `normalize_to_opaque`/`normalize_to_semitransparent`, or `strip_non_opaque`/`strip_transparent`, but they seemed less intuitive.
The documentation to these functions can be found in `symbol.rs`.

r? @matthewjasper
2020-03-16 13:16:44 +01:00
Mazdak Farrokhzad
73a625b5fb remove unnecessary hir::map imports 2020-03-16 02:49:19 +01:00
Mark Mansi
e3c15ae6bc update comment 2020-03-15 19:58:09 -05:00
Mark Mansi
7bd8ce2e50 More Method->Fn renaming 2020-03-15 19:15:55 -05:00
Vadim Petrochenkov
db638bd123 hygiene: modern -> normalize_to_macros_2_0
`modern_and_legacy` -> `normalize_to_macro_rules`
2020-03-16 00:29:42 +03:00
bors
45ebd5808a Auto merge of #68944 - Zoxc:hir-map, r=eddyb
Use queries for the HIR map

r? @eddyb cc @michaelwoerister
2020-03-15 20:40:16 +00:00
Mazdak Farrokhzad
8bca839fdf
Rollup merge of #69988 - petrochenkov:nomacrodef, r=Centril
rustc_metadata: Remove `rmeta::MacroDef`

And other related cleanups.

Follow-up to https://github.com/rust-lang/rust/pull/66364.
r? @Centril
2020-03-15 15:40:08 +01:00
Dylan DPC
f40272ca6f
Rollup merge of #69498 - mark-i-m:describe-it-2, r=matthewjasper
Change "method" to "associated function"

r? @matthewjasper

cc @Centril @eddyb #67742

I'm opening this mostly as a test to see what the diagnostic changes would be. It seems that this makes them somewhat more verbose, and I'm not sure it's worth it...

The relevant changes are the last two commits (it is rebased on top of #67742)
2020-03-15 02:44:17 +01:00
John Kåre Alsaker
8b16b023b1 Index HIR after creating TyCtxt 2020-03-14 22:52:30 +01:00
John Kåre Alsaker
b40e6baec7 Update visit_item_likes_in_module 2020-03-14 22:52:29 +01:00
John Kåre Alsaker
38e613c4eb Update krate_attrs and get_module 2020-03-14 22:52:29 +01:00
John Kåre Alsaker
cfa1d4e383 Add HIR queries 2020-03-14 22:52:28 +01:00
bors
be055d96c4 Auto merge of #67502 - Mark-Simulacrum:opt-catch, r=Mark-Simulacrum
Optimize catch_unwind to match C++ try/catch

This refactors the implementation of catching unwinds to allow LLVM to inline the "try" closure directly into the happy path, avoiding indirection. This means that the catch_unwind implementation is (after this PR) zero-cost unless a panic is thrown.

https://rust.godbolt.org/z/cZcUSB is an example of the current codegen in a simple case. Notably, the codegen is *exactly the same* if `-Cpanic=abort` is passed, which is clearly not great.

This PR, on the other hand, generates the following assembly:

```asm
# -Cpanic=unwind:
	push   rbx
	mov    ebx,0x2a
	call   QWORD PTR [rip+0x1c53c]        # <happy>
	mov    eax,ebx
	pop    rbx
	ret
	mov    rdi,rax
	call   QWORD PTR [rip+0x1c537]        # cleanup function call
	call   QWORD PTR [rip+0x1c539]        # <unfortunate>
	mov    ebx,0xd
	mov    eax,ebx
	pop    rbx
	ret

# -Cpanic=abort:
	push   rax
	call   QWORD PTR [rip+0x20a1]        # <happy>
	mov    eax,0x2a
	pop    rcx
	ret
```

Fixes #64224, and resolves #64222.
2020-03-13 22:43:06 +00:00
Vadim Petrochenkov
01a0c6d441 rustc_metadata: Remove rmeta::MacroDef
Use `ast::MacroDef` instead.

Also remove `Session::imported_macro_spans`, external macros have spans now.
2020-03-14 00:27:13 +03:00
Yuki Okushi
c13548dccd
Rollup merge of #69809 - matthiaskrgr:lifetimes, r=eddyb
remove lifetimes that can be elided (clippy::needless_lifetimes)
2020-03-14 04:03:26 +09:00
Mark Mansi
c8b527ed99 change method -> associated function 2020-03-12 15:46:45 -05:00
Matthias Krüger
7b1b08cfee remove lifetimes that can be elided (clippy::needless_lifetimes) 2020-03-12 20:03:09 +01:00
Mazdak Farrokhzad
39c6405097
Rollup merge of #69747 - spastorino:rename-rustc-guide, r=pietroalbini
Rename rustc guide

This is in preparation for https://github.com/rust-lang/rustc-guide/issues/470
Needs to be merged after we actually rename the guide.

Have used this to rename:

`git grep -l 'rustc_guide' | xargs sed -i 's/rustc_guide/rustc_dev_guide/g'`
`git grep -l 'rustc-guide' | xargs sed -i 's/rustc-guide/rustc-dev-guide/g'`
`git grep -l 'rustc guide' | xargs sed -i 's/rustc guide/rustc dev guide/g'`
2020-03-12 16:32:19 +01:00
Mazdak Farrokhzad
4f7fc5ad67
Rollup merge of #69722 - estebank:negative-impl-span-ast, r=Centril
Tweak output for invalid negative impl AST errors

Use more accurate spans for negative `impl` errors.

r? @Centril
2020-03-12 16:32:17 +01:00
Santiago Pastorino
b3b32b74bc
rust-lang.github.io/rustc-dev-guide -> rustc-dev-guide.rust-lang.org 2020-03-10 17:08:18 -03:00
Santiago Pastorino
9d4fdba8be
Rename rustc guide to rustc dev guide 2020-03-10 17:08:16 -03:00
Santiago Pastorino
0037f4e37c
Rename rustc-guide to rustc-dev-guide 2020-03-10 17:08:10 -03:00
Amanieu d'Antras
f4f91f0b2f Remove eh_unwind_resume lang item 2020-03-05 17:36:50 +00:00
Esteban Küber
91525fd078 Tweak output for invalid negative impl AST errors 2020-03-04 16:15:23 -08:00
Mark Mansi
3aeb9f0faf rename TraitItemKind::Method -> Fn 2020-03-03 12:49:58 -06:00
Mark Mansi
98c7ed67fb DefKind::Method -> DefKind::AssocFn 2020-03-03 12:29:07 -06:00
Matthias Krüger
21affdd00d use values() or keys() respectively when iterating only over keys or values of maps. 2020-03-02 13:01:05 +01:00
Vadim Petrochenkov
e08c279eac Rename syntax to rustc_ast in source code 2020-02-29 21:59:09 +03:00
Vadim Petrochenkov
6054a30370 Make it build again 2020-02-29 20:47:10 +03:00
Mazdak Farrokhzad
07d9ed2c09
Rollup merge of #69481 - matthiaskrgr:single_char, r=ecstatic-morse
use char instead of &str for single char patterns
2020-02-28 17:17:30 +01:00
bors
6d69caba11 Auto merge of #68434 - varkor:astconv-mismatch-error, r=nikomatsakis
Move generic arg/param validation to `create_substs_for_generic_args` to resolve various const generics issues

This changes some diagnostics, but I think they're around as helpful as the previous ones, and occur infrequently regardless.

Fixes https://github.com/rust-lang/rust/issues/68257.
Fixes https://github.com/rust-lang/rust/issues/68398.

r? @eddyb
2020-02-27 18:38:19 +00:00
Matthias Krüger
7c84ba1124 use char instead of &str for single char patterns 2020-02-27 14:57:22 +01:00
Dylan DPC
41bf200073
Rollup merge of #69387 - petrochenkov:idprint, r=Mark-Simulacrum
Deduplicate identifier printing a bit

https://github.com/rust-lang/rust/pull/67010 introduced a couple more subtly different ways to print an identifier.
This PR attempts to restore the order.

The most basic identifier printing interface is `Formatter`-based now, so `String`s are not allocated unless required.

r? @Mark-Simulacrum
2020-02-26 02:07:11 +01:00
Mazdak Farrokhzad
b01c1e2092 parser: tweak item kind wording 2020-02-24 00:59:38 +01:00
Vadim Petrochenkov
e355a33077 Deduplicate identifier printing a bit 2020-02-23 17:35:48 +03:00
Maxim Zholobak
20c9a40fec Rename CodeMap to SourceMap follow up 2020-02-22 16:17:31 +02:00
varkor
c9b7b1f73b Refactor create_substs_for_generic_args a little 2020-02-22 00:28:48 +00:00
Dylan MacKenzie
3bb7da2e4f Replace rustc_typeck::Namespace with rustc_hir::def::Namespace 2020-02-19 10:51:40 -08:00
Yuki Okushi
eb12ed889d Rename FunctionRetTy to FnRetTy 2020-02-17 11:24:29 +09:00
Aaron Hill
51a16e574a
Record proc macro harness order for use during metadata deserialization
Fixes #68690

When we generate the proc macro harness, we now explicitly recorder the
order in which we generate entries. We then use this ordering data to
deserialize the correct proc-macro-data from the crate metadata.
2020-02-15 15:48:36 -05:00
Matthew Jasper
60970be1fd Distinguish RPIT from other impl trait 2020-02-14 20:12:46 +00:00
Camille GILLOT
2a899e2a2f Make TraitCandidate generic. 2020-02-13 16:47:51 +01:00
Camille GILLOT
4706c38e17 Use HirId in TraitCandidate. 2020-02-13 16:39:09 +01:00
Mazdak Farrokhzad
05e5530577 parser: address review comments 2020-02-13 10:39:24 +01:00
Mazdak Farrokhzad
e839b2ec84 Constness -> enum Const { Yes(Span), No }
Same idea for `Unsafety` & use new span for better diagnostics.
2020-02-13 10:39:23 +01:00
Camille GILLOT
fc73e196d9 Review comments. 2020-02-11 23:21:21 +01:00
Camille GILLOT
d3b2385d40 Move it all into rustc_hir. 2020-02-11 23:14:07 +01:00
bors
840bdc349d Auto merge of #67665 - Patryk27:master, r=zackmdavis
Improve reporting errors and suggestions for trait bounds

Fix #66802

- When printing errors for unsized function parameter, properly point at the parameter instead of function's body.
- Improve `consider further restricting this bound` (and related) messages by separating human-oriented hints from the machine-oriented ones.
2020-02-09 22:13:05 +00:00
Jonas Schievink
da005822ce
Rollup merge of #68913 - Areredify:gat_pretty, r=cramertj
Pretty-print generic params and where clauses on associated types

closes #67509
2020-02-09 18:23:34 +01:00
Patryk Wychowaniec
a8d34c1062
Improve reporting errors and suggestions for trait bounds 2020-02-09 10:33:47 +01:00
Aaron Hill
619051e4f0
Move librustc_hir/def_id.rs to librustc_span/def_id.rs
For noww, librustc_hir re-exports the `def_id` module from
librustc_span, so the rest of rustc can continue to reference
rustc_hir::def_id
2020-02-08 16:48:01 -05:00
Mikhail Babenko
bf82582d6f add hir printing 2020-02-07 18:27:12 +03:00
bors
333c32a5a4 Auto merge of #68583 - estebank:hrlt, r=oli-obk
Account for HR lifetimes when suggesting introduction of named lifetime

```
error[E0106]: missing lifetime specifier
 --> src/test/ui/suggestions/fn-missing-lifetime-in-item.rs:2:32
  |
2 | struct S2<F: Fn(&i32, &i32) -> &i32>(F);
  |                 ----  ----     ^ expected named lifetime parameter
  |
  = help: this function's return type contains a borrowed value, but the signature does not say whether it is borrowed from argument 1 or argument 2
  = note: for more information on higher-ranked polymorphism, visit https://doc.rust-lang.org/nomicon/hrtb.html
help: consider making the bound lifetime-generic with a new `'a` lifetime
  |
2 | struct S2<F: for<'a> Fn(&'a i32, &'a i32) -> &'a i32>(F);
  |              ^^^^^^^    ^^^^^^^  ^^^^^^^     ^^^
help: consider introducing a named lifetime parameter
  |
2 | struct S2<'a, F: Fn(&'a i32, &'a i32) -> &'a i32>(F);=
  |           ^^^       ^^^^^^^  ^^^^^^^     ^^^
```

Follow up to #68267. Addresses the diagnostics part of #49287.
2020-02-06 05:19:52 +00:00
Esteban Küber
2100b31535 review comments 2020-02-05 10:32:01 -08:00
Esteban Küber
183dfac1f3 Account for HKTB when suggesting introduction of named lifetime 2020-02-05 10:32:01 -08:00
ljedrz
e8b72f44b0 move item reference comment 2020-02-05 11:29:07 +01:00
ljedrz
28b0ed020a merge item id stable hashing functions 2020-02-05 11:11:34 +01:00
Esteban Küber
a52ec87a17 Use more appropriate spans on object unsafe traits and provide structured suggestions when possible 2020-02-02 11:53:10 -08:00
Mazdak Farrokhzad
e233331a51 syntax::print -> new crate rustc_ast_pretty 2020-02-01 18:59:49 +01:00
Mazdak Farrokhzad
097d5e1c5e 1. move node_id to syntax
2. invert rustc_session & syntax deps
3. drop rustc_session dep in rustc_hir
2020-02-01 18:58:08 +01:00
Mazdak Farrokhzad
64d0143c2c pretty: remove ParseSess dependency 2020-02-01 18:54:55 +01:00
Victor Ding
6a6ebb4403 Add -Z no-link flag
Adds a compiler option to allow rustc compile a crate without linking.
With this flag, rustc serializes codegen_results into a .rlink file.
2020-01-23 11:00:36 +11:00
Dylan MacKenzie
eb60346cc9 Add MaybeConst variant to {ast,hir}::TraitBoundModifier 2020-01-20 00:00:08 -08:00
Dylan MacKenzie
a790f9bb2d Add constness field to hir::ItemKind::Impl 2020-01-19 23:41:44 -08:00
Dylan MacKenzie
4743995ed3 Use named fields for hir::ItemKind::Impl 2020-01-17 16:14:29 -08:00
Esteban Küber
00e2626895 Account for object safety when suggesting Box<dyn Trait> 2020-01-16 09:49:14 -08:00
Mazdak Farrokhzad
50d76d6471
Rollup merge of #68114 - ecstatic-morse:fix-feature-gating, r=Centril
Don't require `allow_internal_unstable` unless `staged_api` is enabled.

#63770 changed `qualify_min_const_fn` to require `allow_internal_unstable` for *all* crates that used an unstable feature, regardless of whether `staged_api` was enabled or the `fn` that used that feature was stably const. In practice, this meant that every crate in the ecosystem that wanted to use nightly features added `#![feature(const_fn)]`, which skips `qualify_min_const_fn` entirely.

After this PR, crates that do not have `#![feature(staged_api)]` will only need to enable the feature they are interested in. For example, `#![feature(const_if_match)]` will be enough to enable `if` and `match` in constants. Crates with `staged_api` (e.g., `libstd`) require `#[allow_internal_unstable]` to be added to a function if it uses nightly features unless that function is also marked `#[rustc_const_unstable]`. This prevents proliferation of `#[allow_internal_unstable]` into functions that are not callable in a `const` context on stable.

r? @oli-obk (author of #63770)
cc @Centril
2020-01-11 12:36:14 +01:00
Dylan MacKenzie
09b5c854de Remove unnecessary const_fn feature gates
This flag opts out of the min-const-fn checks entirely, which is usually
not what we want. The few cases where the flag is still necessary have
been annotated.
2020-01-10 18:51:12 -08:00
Mazdak Farrokhzad
d5598aa7a0 Introduce #![feature(half_open_range_patterns)].
This feature adds `X..`, `..X`, and `..=X` patterns.
2020-01-10 07:29:04 +01:00
Mazdak Farrokhzad
2db97ede27 refactor 'Output = $ty' & reduce rustc dep 2020-01-09 08:57:24 +01:00
Mazdak Farrokhzad
922f8b70f2 intravisit: use walk_list! more 2020-01-08 22:01:07 +01:00
Mazdak Farrokhzad
37d76dc2f7 {rustc::hir -> rustc_hir}::intravisit 2020-01-08 22:01:07 +01:00
Matthew Jasper
9462c8babb Improve hygiene of newtype_index
Also add unit tests
2020-01-06 20:43:10 +00:00
Mazdak Farrokhzad
cdf32e1a0f pacify the parallel compiler 2020-01-04 19:03:27 +01:00
Mazdak Farrokhzad
937c76bfb2 cleanup librustc_hir/Cargo.toml 2020-01-04 19:03:27 +01:00
Mazdak Farrokhzad
ef08662613 hir::{hir,def,itemlikevisit,pat_util,print} -> rustc_hir
Also fix fallout wrt. HashStable.
2020-01-04 19:03:27 +01:00
Mazdak Farrokhzad
72241ad348 move HirId to librustc_hir::hir_id 2020-01-04 19:01:42 +01:00
Mazdak Farrokhzad
7a14073875 move def_id to new rustc_hir crate 2020-01-04 19:01:42 +01:00