Commit Graph

2490 Commits

Author SHA1 Message Date
Esteban Küber
70dbf5526d Use spans for input borrowed types unrelated to return type 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
Mazdak Farrokhzad
b2c6eeb713 parser: merge fn grammars wrt. bodies & headers
also refactor `FnKind` and `visit_assoc_item` visitors
2020-02-05 01:27:09 +01:00
bors
126ad2b813 Auto merge of #68708 - Mark-Simulacrum:stage0-step, r=pietroalbini
Step stage0 to bootstrap from 1.42

This also includes a commit which fixes the rustfmt downloading logic to redownload when the rustfmt channel changes, and bumps rustfmt to a more recent version.
2020-02-04 14:16:18 +00:00
Yuki Okushi
87bb0c4389
Rollup merge of #68740 - JohnTitor:do-not-sugg-underscore, r=Centril
Do not suggest things named underscore

Fixes #68719

r? @estebank
2020-02-02 08:30:21 +09:00
Yuki Okushi
726568bd1b Do not suggest things named underscore 2020-02-02 04:55:37 +09: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
93a8283614 Move builtin attribute logic to new rustc_attr crate.
For now, this is all the crate contains, but more
attribute logic & types will be moved there over time.
2020-02-01 18:54:56 +01:00
Mark Rousskov
31dcdc9e13 Drop cfg(bootstrap) code 2020-01-31 12:31:09 -05:00
Nicholas Nethercote
0d69fe8308 Use P for NtTraitItem, NtImplItem, and NtForeignItem.
This commit reduces the size of `Nonterminal` from a whopping 240 bytes
to 72 bytes (on x86-64), which gets it below the `memcpy` threshold.

It also removes some impedance mismatches with `Annotatable`, which
already uses `P` for these variants.
2020-01-30 11:18:56 +11:00
Esteban Küber
697fdc568e Suggest defining type parameter when appropriate
```
error[E0412]: cannot find type `T` in this scope
 --> file.rs:3:12
  |
3 | impl Trait<T> for Struct {}
  |     -      ^ not found in this scope
  |     |
  |     help: you might be missing a type parameter: `<T>`
```

Fix #64298.
2020-01-26 10:57:18 -08:00
bors
ce361fb24f Auto merge of #68267 - estebank:lt-sugg, r=petrochenkov
Tweak lifetime definition errors

Taking inspiration from the narrative in @fasterthanlime's https://fasterthanli.me/blog/2019/declarative-memory-management/, add suggestions to some lifetime definition errors.
2020-01-21 06:28:33 +00:00
Esteban Küber
03d7fed165 review comments 2020-01-19 17:59:01 -08:00
Esteban Küber
0a6b5538ad Deal with stabilization of feature(slice_patterns) 2020-01-19 17:31:34 -08:00
Esteban Küber
12ff4d0bd6 review comments: use closures 2020-01-19 17:31:34 -08:00
Esteban Küber
2102723887 review comments 2020-01-19 17:31:34 -08:00
Esteban Küber
78d3ea5484 When encountering an expected named lifetime and none are present, suggest adding one 2020-01-19 17:31:33 -08:00
Esteban Küber
6ba08755df When encountering an undefined named lifetime, point to where it can be
This doesn't mention that using an existing lifetime is possible, but
that would hopefully be clear as always being an option. The intention
of this is to teach newcomers what the lifetime syntax is.
2020-01-19 17:31:33 -08:00
Mazdak Farrokhzad
de6046fa0f remove rustc_error_codes deps except in rustc_driver 2020-01-18 21:53:53 +01:00
Dylan MacKenzie
4743995ed3 Use named fields for hir::ItemKind::Impl 2020-01-17 16:14:29 -08:00
Dylan MacKenzie
d461e6d6cb Use named fields for ast::ItemKind::Impl 2020-01-17 15:59:07 -08:00
Vadim Petrochenkov
c84efe9b6c resolve: Say "import" when reporting private imports 2020-01-16 21:59:11 +03:00
Vadim Petrochenkov
28c3f6eb40 resolve: Point at the private item definitions in privacy errors 2020-01-16 21:59:11 +03:00
Vadim Petrochenkov
0f70daa9b0 resolve: Move privacy error reporting into a separate method
Give named fields to `struct PrivacyError`
Move `fn report_ambiguity_error` to `diagnostics.rs`
2020-01-16 21:59:11 +03:00
Dylan DPC
1389caf860
Rollup merge of #68096 - varkor:diagnostic-cleanup, r=Centril
Clean up some diagnostics by making them more consistent

In general:

- Diagnostic should start with a lowercase letter.
- Diagnostics should not end with a full stop.
- Ellipses contain three dots.
- Backticks should encode Rust code.

I also reworded a couple of messages to make them read more clearly.

It might be sensible to create a style guide for diagnostics, so these informal conventions are written down somewhere, after which we could audit the existing diagnostics.

r? @Centril
2020-01-16 11:58:02 +05:30
Matthias Krüger
312c3a067a remove redundant clones, found by clippy 2020-01-15 15:00:25 +01:00
varkor
3de9b8a3b7 Fix formatting ellipses at the end of some diagnostics 2020-01-12 15:37:50 +00:00
varkor
e84248921b Add backticks in appropriate places 2020-01-12 15:37:50 +00:00
varkor
8461fa5119 Diagnostics should not end with a full stop 2020-01-12 15:37:50 +00:00
bors
543b7d97d0 Auto merge of #65912 - estebank:variants-orig, r=petrochenkov
Point at the span for the definition of crate foreign ADTs

Follow up to #65421. Partially addresses #65386. Blocked on #53081.
2020-01-11 06:15:59 +00:00
Mazdak Farrokhzad
b4809d0818 appease rustfmt 2020-01-11 03:30:20 +01:00
Mazdak Farrokhzad
7dbccf5b55 buffered lint infra -> rustc_session 2020-01-11 03:21:34 +01:00
Mazdak Farrokhzad
1af8c10bd4 simplify feature_err imports 2020-01-11 03:19:50 +01:00
Esteban Küber
6d97718886 ./x.py fmt 2020-01-10 11:40:29 -08:00
Esteban Küber
8eb7ac561e Use def_span to minimize definition span to first line when possible 2020-01-10 11:40:29 -08:00
Esteban Küber
39c96a0f53 Point at the span for the definition of crate foreign ADTs 2020-01-10 11:40:29 -08:00
Mazdak Farrokhzad
8bd3d240e3 nix syntax::errors & prefer rustc_errors over errors 2020-01-10 07:41:30 +01:00
Mazdak Farrokhzad
5dafa6a464 add CStore::item_generics_num_lifetimes 2020-01-09 09:26:55 +01:00
Mazdak Farrokhzad
b743af6a24 rename a method in Resolver trait 2020-01-09 08:57:25 +01:00
Mazdak Farrokhzad
7472f9ef13 lowering: remove dep on CrateStore 2020-01-09 08:57:24 +01:00
Mazdak Farrokhzad
0997388b87 normalize rustc::hir::intravisit imports 2020-01-08 22:09:42 +01:00
Mazdak Farrokhzad
8351667091 intravisit: abstract over HIR Map 2020-01-08 22:01:07 +01:00
Mazdak Farrokhzad
2c3e5d3de0 - remove syntax::{span_warn!, span_err!, span_fatal!. struct_err!}
- remove syntax::{help!, span_help!, span_note!}
- remove unused syntax::{struct_span_fatal, struct_span_err_or_warn!, span_err_or_warn!}
- lintify check_for_bindings_named_same_as_variants + conflicting_repr_hints
- inline syntax::{struct_span_warn!, diagnostic_used!}
- stringify_error_code! -> error_code! & use it more.
- find_plugin_registrar: de-fatalize an error
- de-fatalize metadata errors
- move type_error_struct! to rustc_typeck
- struct_span_err! -> rustc_errors
2020-01-08 04:25:33 +01:00
Mazdak Farrokhzad
ebfd8673a7 Remove rustc_hir reexports in rustc::hir. 2020-01-05 12:49:22 +01:00
Mazdak Farrokhzad
62ac10ffde simplify reexports in rustc::hir 2020-01-05 12:47:11 +01:00
bors
7494250106 Auto merge of #67803 - Centril:librustc_hir, r=Zoxc
Extract `rustc_hir` out of `rustc`

The new crate contains:
```rust
pub mod def;
pub mod def_id;
mod hir;
pub mod hir_id;
pub mod itemlikevisit;
pub mod pat_util;
pub mod print;
mod stable_hash_impls;

pub use hir::*;
pub use hir_id::*;
pub use stable_hash_impls::HashStableContext;
```

Remains to be done in follow-up PRs:

- Move `rustc::hir::map` into `rustc_hir_map` -- this has to be a separate crate due to the `dep_graph` (blocked on https://github.com/rust-lang/rust/pull/67761).

- Move references to `rustc::hir` to `rustc_hir` where possible.

cc https://github.com/rust-lang/rust/issues/65031

r? @Zoxc
2020-01-04 21:50:12 +00:00
Dylan DPC
5dabc3b339
Rollup merge of #67775 - mental32:master, r=Dylan-DPC
Make "use $crate" a hard error

Closes #37390
2020-01-04 23:52:50 +05:30
Mazdak Farrokhzad
1f7b4e9a59 extract Export, ExportMap from hir::def 2020-01-04 19:03:27 +01:00
Mazdak Farrokhzad
2f64ab6633 {HirId,ItemLocal}{Map,Set} -> rustc::hir & nix rustc::nodemap 2020-01-04 19:01:42 +01:00
Mazdak Farrokhzad
ca297f8cf4 DefId{Map,Set} -> rustc::hir::def_id 2020-01-04 19:01:42 +01:00
Mazdak Farrokhzad
5ccc1e45bd move Node{Map,Set} -> rustc_session::node_id 2020-01-04 18:59:28 +01:00
Mazdak Farrokhzad
7901c7f707 canonicalize FxHash{Map,Set} imports 2020-01-04 18:57:22 +01:00
Mazdak Farrokhzad
814e3af8bd
Rollup merge of #67786 - Centril:canon-span, r=petrochenkov
Nix reexports from `rustc_span` in `syntax`

Remove reexports `syntax::{source_map, symbol, edition}` and use `rustc_span` paths directly.

r? @petrochenkov
2020-01-04 02:19:49 +01:00
Mazdak Farrokhzad
a436293994
Rollup merge of #66913 - VirrageS:help-self, r=varkor,Centril
Suggest calling method when first argument is `self`

Closes: #66782

I've explored different approaches for this MR but I think the most straightforward is the best one.

I've tried to find out if the methods for given type exist (to maybe have a better suggestion), but we don't collect them anywhere and collecting them is quite problematic. Moreover, collecting all the methods would require rewriting big part of the code and also could potentially include performance degradation, which I don't think is necessary for this simple case.
2020-01-04 02:19:44 +01:00
Mazdak Farrokhzad
b1aad76586 Normalize syntax::edition imports. 2020-01-02 19:31:38 +01:00
Mazdak Farrokhzad
4ff12ce4c1 Normalize syntax::symbol imports. 2020-01-02 13:57:04 +01:00
Mazdak Farrokhzad
75e4783f63 Normalize syntax::source_map imports. 2020-01-02 13:57:04 +01:00
mental
72ee3622d7 Forgot an .emit() 2020-01-01 14:44:19 +02:00
mental
37f4535d49 Make use $crate a hard error 2020-01-01 14:33:53 +02:00
Vadim Petrochenkov
70f1d57048 Rename syntax_pos to rustc_span in source code 2020-01-01 09:15:18 +03:00
bors
119307a83e Auto merge of #67764 - Centril:rollup-ycbq3os, r=Centril
Rollup of 6 pull requests

Successful merges:

 - #67574 (Extract `rustc_ast_lowering` crate from `rustc`)
 - #67685 (Constify Result)
 - #67702 (Add symbol normalization for proc_macro_server.)
 - #67730 (Cleanup pattern type checking, fix diagnostics bugs (+ improvements))
 - #67744 (parser: reduce diversity in error handling mechanisms)
 - #67748 (Use function attribute "frame-pointer" instead of "no-frame-pointer-elim")

Failed merges:

r? @ghost
2019-12-31 19:41:36 +00:00
Mazdak Farrokhzad
52179c56be librustc_ast_lowering: fix misc fallout. 2019-12-31 17:56:25 +01:00
Mazdak Farrokhzad
7b6ef2b369 librustc_ast_lowering: cargo changes. 2019-12-31 17:33:10 +01:00
Camille GILLOT
7e4345ca79 Simplify ResolveLiftimes creation. 2019-12-31 10:21:33 +01:00
Camille GILLOT
31f85d3fe2 Review comments. 2019-12-31 10:21:33 +01:00
Camille GILLOT
1b92e7e446 Inert doc comments. 2019-12-31 10:21:32 +01:00
Camille GILLOT
28eefb3797 Move resolve_lifetimes query in librustc_resolve. 2019-12-31 10:21:32 +01:00
Camille GILLOT
2675765a1e Move resolve_lifetime.rs to librustc_resolve. 2019-12-31 10:21:32 +01:00
Vadim Petrochenkov
7608f21b27 Rename rustc_resolve/resolve_imports.rs -> rustc_resolve/imports.rs 2019-12-30 19:18:18 +03:00
Vadim Petrochenkov
a2823e3af6 Rename libsyntax_ext and libsyntax_expand in code 2019-12-30 19:18:17 +03:00
Vadim Petrochenkov
b9a9c5b4fd Make things build again 2019-12-30 19:18:16 +03:00
Vadim Petrochenkov
a0d8b794d6 resolve: Minor cleanup of duplicate macro reexports 2019-12-28 17:37:22 +03:00
Mark Rousskov
6891388e66 x.py fmt after previous deignore 2019-12-24 17:38:22 -05:00
Janusz Marcinkiewicz
7b91ef8837 Simplify match expr 2019-12-23 15:55:35 +01:00
Janusz Marcinkiewicz
2168c0b979 Extract checking for self arg to separate method 2019-12-23 12:06:17 +01:00
Janusz Marcinkiewicz
7353afdfd9 Extend suggestion span to whole method call 2019-12-23 11:57:09 +01:00
Janusz Marcinkiewicz
091853946b Add arguments to suggestion method call 2019-12-23 11:57:09 +01:00
Janusz Marcinkiewicz
8e5b2c80d3 Add more detailed suggestion 2019-12-23 11:57:09 +01:00
Janusz Marcinkiewicz
8d189ed2f1 Suggest calling method when first argument is self 2019-12-23 11:57:08 +01:00
Mark Rousskov
a06baa56b9 Format the world 2019-12-22 17:42:47 -05:00
Mazdak Farrokhzad
b50c3b7ddf
Rollup merge of #67160 - matthewjasper:gat-generics, r=nikomatsakis
Make GATs less ICE-prone.

After this PR simple lifetime-generic associated types can now be used in a compiling program. There are two big limitations:

* #30472 has not been addressed in any way (see src/test/ui/generic-associated-types/iterable.rs)
* Using type- and const-generic associated types errors because bound types and constants aren't handled by trait solving.
    * The errors are technically non-fatal, but they happen in a [part of the compiler](4abb0ad273/src/librustc_typeck/lib.rs (L298)) that fairly aggressively stops compiling on errors.

closes #47206
closes #49362
closes #62521
closes #63300
closes #64755
closes #67089
2019-12-21 19:07:31 +01:00
Mazdak Farrokhzad
a7aec3f207 1. ast::Mutability::{Mutable -> Mut, Immutable -> Not}.
2. mir::Mutability -> ast::Mutability.
2019-12-20 22:22:44 +01:00
Matthew Jasper
c5028f686d Resolve names in the generics of impl associated types 2019-12-20 20:14:11 +00:00
Mazdak Farrokhzad
054458b48d make visitor uses more robust 2019-12-12 18:05:05 +01:00
Mazdak Farrokhzad
e52f902a8a AssocImplKind::{Method -> Fn}. 2019-12-12 18:05:05 +01:00
Mazdak Farrokhzad
abf2e7aa95 Remove ast::{Impl,Trait}{Item,ItemKind}. 2019-12-12 18:05:05 +01:00
Mazdak Farrokhzad
b499a88dfc Unify assoc item visitors more. 2019-12-12 18:01:33 +01:00
Mazdak Farrokhzad
0d8a9d74e3 Unify associated item visitor. 2019-12-12 18:00:00 +01:00
Mazdak Farrokhzad
39073767a4 Unify {Trait,Impl}ItemKind::TyAlias structures. 2019-12-12 17:54:48 +01:00
Mazdak Farrokhzad
c02fd31302 TraitItemKind::Type -> TraitItemKind::TyAlias. 2019-12-12 17:54:48 +01:00
Mazdak Farrokhzad
f6403c6c76 Use Option in ImplItemKind::Method. 2019-12-12 17:54:48 +01:00
Vadim Petrochenkov
914c9aa78d resolve: Always resolve visibilities on impl items 2019-12-11 22:10:09 +03:00
Mazdak Farrokhzad
4c3e95e84b
Rollup merge of #67074 - ehuss:extern-options, r=petrochenkov
Add options to --extern flag.

This changes the `--extern` flag so that it can take a series of options that changes its behavior. The general syntax is `[opts ':'] name ['=' path]` where `opts` is a comma separated list of options. Two options are supported, `priv` which replaces `--extern-private` and `noprelude` which avoids adding the crate to the extern prelude.

```text
--extern priv:mylib=/path/to/libmylib.rlib
--extern noprelude:alloc=/path/to/liballoc.rlib
```

`noprelude` is to be used by Cargo's build-std feature in order to use `--extern` to reference standard library crates.

This also includes a second commit which adds the `aux-crate` directive to compiletest. I can split this off into a separate PR if desired, but it helps with defining these kinds of tests. It is based on #54020, and can be used in the future to replace and simplify some of the Makefile tests.
2019-12-11 10:10:44 +01:00
Vadim Petrochenkov
5f6267c8b3 resolve: Make visibility resolution more speculative
To avoid potential duplicate diagnostics and separate the error reporting logic
2019-12-09 22:41:47 +03:00
Vadim Petrochenkov
e2c962d3d0 resolve: Cleanup some field processing code 2019-12-09 22:33:28 +03:00
Vadim Petrochenkov
9e6725dcfe resolve: Resolve visibilities on fields with non-builtin attributes 2019-12-09 22:33:23 +03:00
Eric Huss
590dd7dfef Add options to --extern flag. 2019-12-09 08:08:13 -08:00
varkor
9f1269f23c Rename to then_some and then 2019-12-06 12:24:54 +00:00
varkor
e3a8ea4e18 Use to_option in various places 2019-12-06 12:23:23 +00:00