Commit Graph

110 Commits

Author SHA1 Message Date
Mazdak Farrokhzad
a73ed5aad9
Rollup merge of #69981 - oli-obk:const_blocks, r=eddyb
Evaluate repeat expression lengths as late as possible

Fixes #68567

r? @varkor
2020-03-24 00:49:39 +01:00
Oliver Scherer
9bcd9fe674 Address review comments 2020-03-23 19:19:07 +01:00
Oliver Scherer
770be24ccd Use DefIds to identify anon consts when converting from HIR to ty::Const 2020-03-23 13:15:02 +01:00
Oliver Scherer
799b15ed96 Evaluate repeat expression lengths as late as possible 2020-03-23 13:14:36 +01:00
Mazdak Farrokhzad
bee074f032
Rollup merge of #69968 - eddyb:tupled-closure-captures, r=nikomatsakis
rustc: keep upvars tupled in {Closure,Generator}Substs.

Previously, each closure/generator capture's (aka "upvar") type was tracked as one "synthetic" type parameter in the closure/generator substs, and figuring out where the parent `fn`'s generics end and the synthetics start involved slicing at `tcx.generics_of(def_id).parent_count`.

Needing to query `generics_of` limited @davidtwco (who wants to compute some `TypeFlags` differently for parent generics vs upvars, and `TyCtxt` is not available there), which is how I got started on this, but it's also possible that the `generics_of` queries are slowing down `{Closure,Generator}Substs` methods.

To give an example, for a `foo::<T, U>::{closure#0}` with captures `x: X` and `y: Y`, substs are:
* before this PR: `[T, U, /*kind*/, /*signature*/, X, Y]`
* after this PR: `[T, U, /*kind*/, /*signature*/, (X, Y)]`

You can see that, with this PR, no matter how many captures, the last 3 entries in the substs (or 5 for a generator) are always the "synthetic" ones, with the last one being the tuple of capture types.

r? @nikomatsakis cc @Zoxc
2020-03-23 10:29:11 +01:00
Mazdak Farrokhzad
c984a96189
Rollup merge of #70269 - matthiaskrgr:clippy_closures, r=Dylan-DPC
remove redundant closures (clippy::redundant_closure)
2020-03-23 04:26:15 +01:00
Matthias Krüger
263cbd1bbe remove redundant closures (clippy::redundant_closure) 2020-03-22 12:43:19 +01:00
Matthias Krüger
e45fdcfa9a remove unused unit values (clippy::unused_unit) 2020-03-21 20:45:19 +01:00
Matthias Krüger
47e9775a9a make some let-if-bindings more idiomatic (clippy::useless_let_if_seq) 2020-03-21 20:45:18 +01:00
Eduard-Mihai Burtescu
10f08abd2e rustc: keep upvars tupled in {Closure,Generator}Substs. 2020-03-21 14:23:50 +02:00
Mazdak Farrokhzad
3e6b1ac964
Rollup merge of #70187 - matthiaskrgr:cl2ppy, r=Mark-Simulacrum
more clippy fixes

    * remove redundant returns (clippy::needless_return)
    * remove redundant import (clippy::single_component_path_imports)
    * remove redundant format!() call (clippy::useless_format)
    * don't use ok() before calling expect() (clippy::ok_expect)
2020-03-21 05:33:31 +01:00
Mazdak Farrokhzad
b24d168e10
Rollup merge of #70165 - matthewjasper:erase-more, r=nikomatsakis
Remove the erase regions MIR transform

We now ensure that MIR never contains unerased regions in the first place.
2020-03-21 05:33:24 +01:00
Matthias Krüger
ad00e91887 remove redundant returns (clippy::needless_return) 2020-03-20 20:23:03 +01:00
Matthew Jasper
0f0f254a9c Use erased regions in MIR 2020-03-19 19:59:13 +00:00
Eduard-Mihai Burtescu
f3ec069886 rustc: use LocalDefId instead of DefIndex in HirId. 2020-03-19 11:16:08 +02:00
Eduard-Mihai Burtescu
0c692797d7 rustc: rename DefId::to_local to expect_local and use it instead of LocalDefId::from_def_id. 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
Mazdak Farrokhzad
252184969b
Rollup merge of #69899 - ecstatic-morse:const-idx-methods, r=oli-obk
Make methods declared by `newtype_index` macro `const`

Crates that use the macro to define an `Idx` type need to enable `#![feature(const_if_match, const_panic)]`.
2020-03-18 18:03:42 +01:00
Dylan MacKenzie
cc4a5770fa Add requisite feature gates for const assert 2020-03-17 11:15:40 -07:00
Oliver Scherer
7894509b00 Fiddle ParamEnv through to a place that used to use ParamEnv::empty in a buggy manner 2020-03-16 18:51:55 +01:00
Mazdak Farrokhzad
4392a8b73c use direct imports for rustc::{lint, session}. 2020-03-16 02:52:06 +01:00
Mazdak Farrokhzad
73a625b5fb remove unnecessary hir::map imports 2020-03-16 02:49:19 +01:00
Mark Mansi
7bd8ce2e50 More Method->Fn renaming 2020-03-15 19:15:55 -05: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
Vadim Petrochenkov
78f01eca3f resolve: Prevent fresh bindings from shadowing ambiguity items
Correctly treat const generic parameters in fresh binding disambiguation
2020-03-15 12:35:48 +03:00
John Kåre Alsaker
8b16b023b1 Index HIR after creating TyCtxt 2020-03-14 22:52:30 +01:00
Camille GILLOT
1fcdc52f70 Make downstream crates compile. 2020-03-14 14:17:43 +01:00
Camille GILLOT
c1e3d556bf Move rustc_infer::traits to new crate rustc_trait_selection. 2020-03-14 14:15:50 +01:00
Mazdak Farrokhzad
9bc7386970
Rollup merge of #69674 - mark-i-m:assoc-fn, r=matthewjasper
Rename DefKind::Method and TraitItemKind::Method

r? @eddyb, @Centril, or @matthewjasper

cc #69498 #60163
2020-03-12 16:32:13 +01:00
Mazdak Farrokhzad
4d16c217b8 Matrix::push: recursively expand or-patterns 2020-03-10 17:46:19 +01:00
Mazdak Farrokhzad
10f999b72d
Rollup merge of #69773 - matthiaskrgr:typos, r=petrochenkov
fix various typos
2020-03-07 17:27:32 +01:00
Mazdak Farrokhzad
709325af67
Rollup merge of #69782 - matthiaskrgr:redundant_field_name_rep, r=cramertj
Don't redundantly repeat field names (clippy::redundant_field_names)
2020-03-07 08:15:33 +01:00
Mazdak Farrokhzad
5d1433b1f4
Rollup merge of #69656 - matthiaskrgr:iter_nth_zero, r=oli-obk
Use .next() instead of .nth(0) on iterators.
2020-03-07 08:15:24 +01:00
Matthias Krüger
83980aca20 Don't redundantly repeat field names (clippy::redundant_field_names) 2020-03-06 19:42:18 +01:00
Matthias Krüger
136ad015b6 fix various typos 2020-03-06 15:19:31 +01:00
Matthias Krüger
3fc5c118dd Use righthand '&' instead of lefthand "ref". (clippy::toplevel_ref_arg) 2020-03-05 16:39:12 +01:00
bors
4d71c164a8 Auto merge of #69550 - RalfJung:scalar, r=oli-obk
interpret engine: Scalar cleanup

* Remove `to_ptr`
* Make `to_bits` private

r? @oli-obk
2020-03-04 04:10:58 +00: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
d3e5177f81 Use .next() instead of .nth(0) on iterators. 2020-03-03 03:15:03 +01:00
bors
360e42de82 Auto merge of #69380 - Zoxc:parent-module, r=michaelwoerister
Use a query to get parent modules

Split out from https://github.com/rust-lang/rust/pull/69015 / https://github.com/rust-lang/rust/pull/68944.

r? @michaelwoerister
2020-03-01 14:21:03 +00:00
Yuki Okushi
680a0e1dd5
Rollup merge of #69580 - matthiaskrgr:map_clone, r=Centril
use .copied() instead of .map(|x| *x) on iterators
2020-03-01 19:28:12 +09: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
Matthias Krüger
c9a02c2e42 use .copied() instead of .map(|x| *x) on iterators 2020-02-29 15:23:13 +01:00
John Kåre Alsaker
542d813475 Add a parent_module_from_def_id query 2020-02-29 05:59:38 +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
Ralf Jung
1fec68277a remove check_raw after reducing it to one use only 2020-02-28 09:34:35 +01:00
Matthias Krüger
7be94a8a95 don't use .into() to convert types into identical types.
example:
    let s: String = format!("hello").into();
2020-02-27 23:32:46 +01:00
Matthias Krüger
d4a005bd03 librustc{, codegen_ssa,infer,mir_build}: don't clone types that are copy 2020-02-24 14:56:29 +01:00