Commit Graph

2502 Commits

Author SHA1 Message Date
Yuki Okushi
e453a0cc49
Rollup merge of #69637 - matthiaskrgr:if_let_some_result, r=ecstatic-morse
Don't convert Results to Options just for matching.
2020-03-03 17:50:17 +09:00
Yuki Okushi
f19684c7cf
Rollup merge of #69619 - matthiaskrgr:misc, r=eddyb
more cleanups

* use starts_with() instead of chars().next() == Some(x)
* use subsec_micros() instead of subsec_nanos() / 1000
* use for (idx, item) in iter.enumerate() instead of manually counting loop iterations with variables
* use values() or keys() respectively when iterating only over keys or values of maps.
2020-03-03 17:50:08 +09:00
Matthias Krüger
0ec14089a9 Don't convert Results to Options just for matching. 2020-03-02 15:31:14 +01: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
bors
9dc8dad14f Auto merge of #69432 - petrochenkov:alldeps, r=eddyb
rustc_metadata: Load metadata for indirect macro-only dependencies

Imagine this dependency chain between crates
```
Executable crate -> Library crate -> Macro crate
```
where "Library crate" uses the macros from "Macro crate" for some code generation, but doesn't reexport them any further.

Currently, when compiling "Executable crate" we don't even load metadata for it, because why would we want to load any metadata from "Macro crate" if it already did all its code generation job when compiling "Library crate".
Right?

Wrong!
Hygiene data and spans (https://github.com/rust-lang/rust/issues/68686, https://github.com/rust-lang/rust/pull/68941) from "Macro crate" still may need to be decoded from "Executable crate".
So we'll have to load them properly.

Questions:
- How this will affect compile times for larger crate trees in practice? How to measure it?
Hygiene/span encoding/decoding will necessarily slow down compilation because right now we just don't do some work that we should do, but this introduces a whole new way to slow down things. E.g. loading metadata for `syn` (and its dependencies) when compiling your executable if one of its library dependencies uses it.
- We are currently detecting whether a crate reexports macros from "Macro crate" or not, could we similarly detect whether a crate "reexports spans" and keep it unloaded if it doesn't?
Or at least "reexports important spans" affecting hygiene, we can probably lose spans that only affect diagnostics.
2020-03-02 00:07:06 +00:00
Dylan DPC
87284d7e79
Rollup merge of #69569 - matthiaskrgr:nonminimal_bool, r=mark-Simulacrum
simplify boolean expressions
2020-03-01 17:23:30 +01:00
bors
2917d99302 Auto merge of #69592 - petrochenkov:nosyntax, r=Centril
Rename `libsyntax` to `librustc_ast`

This was the last rustc crate that wasn't following the `rustc_*` naming convention.

Follow-up to https://github.com/rust-lang/rust/pull/67763.
2020-03-01 01:36:58 +00:00
Vadim Petrochenkov
e08c279eac Rename syntax to rustc_ast in source code 2020-02-29 21:59:09 +03:00
Dylan DPC
7d43997053
Rollup merge of #69572 - matthiaskrgr:try_err_and_iter_on_ref, r=Centril
use .iter() instead of .into_iter() on references
2020-02-29 18:54:01 +01:00
Vadim Petrochenkov
6054a30370 Make it build again 2020-02-29 20:47:10 +03:00
Matthias Krüger
56a3da3bd0 simplify boolean expressions 2020-02-29 11:36:18 +01:00
Matthias Krüger
de7c40c168 use .iter() instead of .into_iter() on references. 2020-02-29 03:14:01 +01:00
Dylan DPC
bbfec7ca41
Rollup merge of #69567 - matthiaskrgr:useless_fmt, r=nagisa
use .to_string() instead of format!() macro to create strings

handles what is left after https://github.com/rust-lang/rust/pull/69541
2020-02-29 02:16:24 +01:00
Dylan DPC
c8db7dcc1c
Rollup merge of #69551 - matthiaskrgr:len_zero, r=Mark-Simulacrum
use is_empty() instead of len() == x  to determine if structs are empty.
2020-02-29 02:16:21 +01:00
Matthias Krüger
85e59b7664 use .to_string() instead of format!() macro to create strings 2020-02-29 01:32:42 +01:00
Mazdak Farrokhzad
13e4c6c51f
Rollup merge of #69547 - matthiaskrgr:more_misc, r=Mark-Simulacrum
remove redundant clones, references to operands, explicit boolean comparisons and filter(x).next() calls.
2020-02-28 17:17:38 +01:00
Mazdak Farrokhzad
61b091b440
Rollup merge of #69541 - dotdash:format, r=Mark-Simulacrum
Remove unneeded calls to format!()
2020-02-28 17:17:36 +01:00
Mazdak Farrokhzad
b95945c8d6
Rollup merge of #69539 - Centril:fix-69401, r=petrochenkov
late resolve, visit_fn: bail early if there's no body.

Fixes https://github.com/rust-lang/rust/issues/69401 which was injected by b2c6eeb713 in https://github.com/rust-lang/rust/pull/68788.

r? @petrochenkov
2020-02-28 17:17:34 +01:00
Matthias Krüger
9523c89f18 use is_empty() instead of len() == x to determine if structs are empty. 2020-02-28 15:16:27 +01:00
Matthias Krüger
ff9341a9e3 remove redundant clones, references to operands, explicit boolean comparisons and filter(x).next() calls. 2020-02-28 13:45:30 +01:00
Mazdak Farrokhzad
85b585daaf late resolve, visit_fn: bail early if there's no body. 2020-02-28 07:58:37 +01:00
Björn Steinbrink
c1de0b1b70 Remove unneeded calls to format!() 2020-02-27 15:25:19 +01:00
Matthias Krüger
7c84ba1124 use char instead of &str for single char patterns 2020-02-27 14:57:22 +01:00
Yuki Okushi
0d66c7c34c
Rollup merge of #69439 - petrochenkov:latelife, r=matthewjasper
resolve: `lifetimes.rs` -> `late/lifetimes.rs`

Lifetime resolution should ideally be merged into the late resolution pass, at least for named lifetimes.
Let's move it closer to it for a start.
2020-02-27 14:38:03 +09:00
Vadim Petrochenkov
f7d55be7e5 resolve: lifetimes.rs -> late/lifetime.rs 2020-02-24 21:46:21 +03:00
Matthias Krüger
addd7426be don't explicitly compare against true or false 2020-02-24 16:52:40 +01:00
Vadim Petrochenkov
487c378fc6 rustc_metadata: Load metadata for indirect macro-only dependencies 2020-02-24 18:03:00 +03:00
Mazdak Farrokhzad
62930d3151 parse/ast: move Defaultness into variants. 2020-02-24 00:59:38 +01:00
Dylan DPC
bdd275de2a
Rollup merge of #69375 - Menschenkindlein:master, r=Dylan-DPC
Rename CodeMap to SourceMap follow up

See https://github.com/rust-lang/rust/issues/51574
2020-02-23 09:57:44 +01:00
Maxim Zholobak
20c9a40fec Rename CodeMap to SourceMap follow up 2020-02-22 16:17:31 +02:00
Mazdak Farrokhzad
9f3dfd29a2 parse: allow type Foo: Ord syntactically. 2020-02-22 00:19:27 +01:00
Mazdak Farrokhzad
b864d23f34
Rollup merge of #69194 - Centril:assoc-extern-fuse, r=petrochenkov
parse: fuse associated and extern items up to defaultness

Language changes:

- The grammar of extern `type` aliases is unified with associated ones, and becomes:
  ```rust
  TypeItem = "type" ident generics {":" bounds}? where_clause {"=" type}? ";" ;
  ```

  Semantic restrictions (`ast_validation`) are added to forbid any parameters in `generics`, any bounds in `bounds`, and any predicates in `where_clause`, as well as the presence of a type expression (`= u8`).

  (Work still remains to fuse this with free `type` aliases, but this can be done later.)

- The grammar of constants and static items (free, associated, and extern) now permits the absence of an expression, and becomes:

  ```rust
  GlobalItem = {"const" {ident | "_"} | "static" "mut"? ident} {"=" expr}? ";" ;
  ```

  - A semantic restriction is added to enforce the presence of the expression (the body).
  - A semantic restriction is added to reject `const _` in associated contexts.

Together, these changes allow us to fuse the grammar of associated items and extern items up to `default`ness which is the main goal of the PR.

-----------------------

We are now very close to fully fusing the entirely of item parsing and their ASTs. To progress further, we must make a decision: should we parse e.g. `default use foo::bar;` and whatnot? Accepting that is likely easiest from a parsing perspective, as it does not require using look-ahead, but it is perhaps not too onerous to only accept it for `fn`s (and all their various qualifiers), `const`s, `static`s, and `type`s.

r? @petrochenkov
2020-02-18 22:16:26 +01:00
Yuki Okushi
eb12ed889d Rename FunctionRetTy to FnRetTy 2020-02-17 11:24:29 +09:00
Camille GILLOT
f07e889145 Make librustc_infer compile. 2020-02-16 11:49:29 +01:00
Mazdak Farrokhzad
35884fe168 parse extern consts 2020-02-15 20:57:12 +01:00
Mazdak Farrokhzad
f8d2264463 parse associated statics. 2020-02-15 20:57:12 +01:00
Mazdak Farrokhzad
f3e9763543 ast: make = <expr>; optional in free statics/consts. 2020-02-15 20:57:12 +01:00
Mazdak Farrokhzad
95dc9b9a73 ast: normalize ForeignItemKind::Ty & AssocItemKind::TyAlias. 2020-02-15 18:00:01 +01:00
Mazdak Farrokhzad
2fd15442f2 ast: move Generics into AssocItemKinds 2020-02-15 18:00:01 +01:00
Dylan DPC
b5ee867b50
Rollup merge of #69108 - cjgillot:trait_candidate, r=Zoxc
Use HirId in TraitCandidate.

I had to duplicate the `TraitMap` type to hold `NodeId`s until AST->HIR lowering is done.

r? @Zoxc
2020-02-13 21:28:06 +01:00
Dylan DPC
998daf36b9
Rollup merge of #68938 - Areredify:gat_lifetime_shadowing, r=estebank
fix lifetime shadowing check in GATs

closes #67512
2020-02-13 21:28:00 +01: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
c30f068dc8 IsAsync -> enum Async { Yes { span: Span, .. }, No }
use new span for better diagnostics.
2020-02-13 10:39:24 +01:00
bors
3f32e3001e Auto merge of #69062 - Dylan-DPC:rollup-7wpjpqu, r=Dylan-DPC
Rollup of 8 pull requests

Successful merges:

 - #66498 (Remove unused feature gates)
 - #68816 (Tweak borrow error on `FnMut` when `Fn` is expected)
 - #68824 (Enable Control Flow Guard in rustbuild)
 - #69022 (traits: preallocate 2 Vecs of known initial size)
 - #69031 (Use `dyn Trait` more in tests)
 - #69044 (Don't run coherence twice for future-compat lints)
 - #69047 (Don't rustfmt check the vendor directory.)
 - #69055 (Clean up E0307 explanation)

Failed merges:

r? @ghost
2020-02-11 17:45:49 +00:00
Dylan DPC
ec0cfd1d01
Rollup merge of #66498 - bjorn3:less_feature_flags, r=Dylan-DPC
Remove unused feature gates

I think many of the remaining unstable things can be easily be replaced with stable things. I have kept the `#![feature(nll)]` even though it is only necessary in `libstd`, to make regressions of it harder.
2020-02-11 16:36:54 +01:00
jumbatm
d246385122 Run RustFmt 2020-02-11 19:49:01 +10:00
jumbatm
7c58ffe874 Invert control in struct_lint_level.
Caller now passes in a `decorate` function, which is only run if the
lint is allowed.
2020-02-11 19:47:40 +10:00
Mikhail Babenko
953f6ecb6a fix lifetime shadowing check in GATs 2020-02-08 01:12:41 +03:00
Dylan DPC
90f6267dea
Rollup merge of #68889 - Zoxc:hir-krate, r=eddyb
Move the `hir().krate()` method to a query and remove the `Krate` dep node

r? @eddyb cc @michaelwoerister
2020-02-07 17:00:19 +01:00