Commit Graph

54 Commits

Author SHA1 Message Date
Seiichi Uchida 42410a96c4 Use delay_span_bug() over debug!() 2018-01-13 00:54:56 +09:00
Seiichi Uchida 142134d54f Ignore CTFE errors while lowering patterns
Closes #43105.
2018-01-12 20:50:03 +09:00
Eduard-Mihai Burtescu 9deea47c96 rustc_mir: always downcast enums, even if univariant. 2017-11-18 20:52:38 +02:00
Tobias Schottdorf de55b4f077 implement pattern-binding-modes RFC
See the [RFC] and [tracking issue].

[tracking issue]: https://github.com/rust-lang/rust/issues/42640
[RFC]: https://github.com/rust-lang/rfcs/blob/491e0af/text/2005-match-ergonomics.md
2017-10-06 16:30:23 -04:00
Michael Woerister b9816c5fab incr.comp.: Already hash HIR bodies during metadata export so they don't have to be hashed in downstream crates. 2017-09-18 11:26:11 +02:00
Eduard-Mihai Burtescu 74349fa288 rustc: evaluate fixed-length array length expressions lazily. 2017-09-11 08:41:16 +03:00
Eduard-Mihai Burtescu 8a9b78f5cc rustc: use ty::Const for the length of TyArray. 2017-09-11 08:41:15 +03:00
Eduard-Mihai Burtescu 3ce31eb990 rustc: replace usize with u64 and ConstUsize. 2017-09-11 08:41:15 +03:00
Eduard-Mihai Burtescu 932289c12d rustc: introduce ty::Const { ConstVal, Ty }. 2017-09-11 08:41:15 +03:00
Eduard-Mihai Burtescu 50076b00c2 rustc: intern ConstVal's in TyCtxt. 2017-09-11 08:41:03 +03:00
Eduard-Mihai Burtescu da0a47a081 Use NodeId/HirId instead of DefId for local variables. 2017-09-08 22:00:59 +03:00
Alex Crichton 0182c8bbda rustc: Rename item_body query to extern_const_body
Should hopefully more accurately reflect what's happening! This commit also
removes the cache in the cstore implementation as it's already cached through
the query infrastructure.
2017-09-05 07:37:58 -07:00
Alex Crichton 84ae4b75be rustc: Migrate CrateStore::item_body to a query
This commit migrates the `item_body` method on `CrateStore` to a query instead
to enable better tracking of dependencies and whatnot.
2017-09-05 07:37:58 -07:00
Zack M. Davis 1b6c9605e4 use field init shorthand EVERYWHERE
Like #43008 (f668999), but _much more aggressive_.
2017-08-15 15:29:17 -07:00
Michael Woerister 1f54df1101 Encapsulate sub-table access in TypeckTables and validate keys on each access. 2017-08-11 12:17:07 +02:00
Michael Woerister e777189b4a Use ItemLocalId as key for TypeckTables::pat_binding_modes. 2017-08-11 12:11:38 +02:00
Michael Woerister 7f2423eede Use ItemLocalId as key for node_types, node_substs, and adjustments in TypeckTables. 2017-08-11 12:11:38 +02:00
Michael Woerister 783ccc443b Make TypeckTables::type_dependent_defs use ItemLocalId instead of NodeId. 2017-08-11 12:11:38 +02:00
Tobias Schottdorf 851c77088d default binding modes: add pat_binding_modes
This PR kicks off the implementation of the [default binding modes RFC][1] by
introducing the `pat_binding_modes` typeck table mentioned in the [mentoring
instructions][2].

`pat_binding_modes` is populated in `librustc_typeck/check/_match.rs` and
used wherever the HIR would be scraped prior to this PR. Unfortunately, one
blemish, namely a two callers to `contains_explicit_ref_binding`, remains.
This will likely have to be removed when the second part of [1], the
`pat_adjustments` table, is tackled. Appropriate comments have been added.

See #42640.

[1]: https://github.com/rust-lang/rfcs/pull/2005
[2]: https://github.com/rust-lang/rust/issues/42640#issuecomment-313535089
2017-07-30 10:19:53 -04:00
Eduard-Mihai Burtescu 60cf5428b3 rustc_const_eval: keep track of the appropriate ParamEnv. 2017-07-27 20:59:40 +03:00
Eduard-Mihai Burtescu 4c900c5248 rustc_const_eval: always require correct Substs. 2017-07-27 12:22:26 +03:00
Eduard-Mihai Burtescu 33ecf72e8e rustc: move the PolyFnSig out of TyFnDef. 2017-06-27 16:39:52 +03:00
bors 4ed2edaafe Auto merge of #42281 - eddyb:well-adjusted, r=nikomatsakis
Decompose Adjustment into smaller steps and remove the method map.

The method map held method callee information for:
* actual method calls (`x.f(...)`)
* overloaded unary, binary, indexing and call operators
* *every overloaded deref adjustment* (many can exist for each expression)

That last one was a historical ~~accident~~ hack, and part of the motivation for this PR, along with:
* a desire to compose adjustments more freely
* containing the autoderef logic better to avoid mutation within an inference snapshot
* not creating `TyFnDef` types which are incompatible with the original one
  * i.e. we used to take a`TyFnDef`'s `for<'a> &'a T -> &'a U` signature and instantiate `'a` using a region inference variable, *then* package the resulting `&'b T -> &'b U` signature in another `TyFnDef`, while keeping *the same* `DefId` and `Substs`
* to fix #3548 by explicitly writing autorefs for the RHS of comparison operators

Individual commits tell their own story, of "atomic" changes avoiding breaking semantics.

Future work based on this PR could include:
* removing the signature from `TyFnDef`, now that it's always "canonical"
  * some questions of variance remain, as subtyping *still* treats the signature differently
* moving part of the typeck logic for methods, autoderef and coercion into `rustc::traits`
* allowing LUB coercions (joining multiple expressions) to "stack up" many adjustments
* transitive coercions (e.g. reify or unsize after multiple steps of autoderef)

r? @nikomatsakis
2017-06-01 11:34:13 +00:00
Eduard-Mihai Burtescu 9eae6ba7fa rustc: remove unnecessary ItemSubsts wrapper. 2017-06-01 08:59:47 +03:00
Vadim Petrochenkov caecb76f08 Turn sufficiently old compatibility lints into hard errors 2017-05-30 22:00:30 +03:00
Niko Matsakis c7dc39dbf0 intern CodeExtents
Make a `CodeExtent<'tcx>` be something allocated in an arena
instead of an index into the `RegionMaps`.
2017-04-30 17:02:59 -04:00
Eduard-Mihai Burtescu 612bb1f54e rustc: rename some of the queries to match tcx methods. 2017-04-24 15:20:52 +03:00
Eduard-Mihai Burtescu 8054377f8f rustc_const_eval: support all unit enum variants. 2017-04-23 11:11:57 +03:00
Eduard-Mihai Burtescu e22873d912 rustc: make the const-eval cache polymorphic. 2017-04-23 11:11:54 +03:00
Eduard-Mihai Burtescu 8854164d0c rustc_const_eval: move ConstEvalErr to the rustc crate. 2017-04-16 01:31:06 +03:00
Esteban Küber ad06fc718b Fix ICE: don't use struct_variant on enums
Fix #40221 and add unittest.
2017-03-06 00:13:14 -03:00
Eduard-Mihai Burtescu e7a48821c0 rustc_const_eval: always demand typeck_tables for evaluating constants. 2017-02-25 18:35:26 +02:00
Andrew Cann 2cc84df44c Add warning for () to ! switch 2017-02-03 18:48:15 +08:00
Vadim Petrochenkov ffba0cea62 Merge ty::TyBox into ty::TyAdt 2017-01-30 23:14:15 +03:00
Eduard-Mihai Burtescu 45c8c5678a rustc: rename TyCtxt's map field to hir. 2017-01-26 13:41:28 +02:00
Niko Matsakis 282f7a3c44 rename Tables to TypeckTables 2017-01-25 16:24:00 -05:00
Oliver Schneider c951341a78 add exclusive range patterns under a feature gate 2017-01-19 10:13:32 +01:00
Eduard-Mihai Burtescu cde0a7e7e0 rustc: store ty::Tables separately for each body (except closures'). 2017-01-06 22:23:29 +02:00
Eduard-Mihai Burtescu 85a4a192c7 rustc: keep track of tables everywhere as if they were per-body. 2017-01-06 22:23:29 +02:00
Andrew Cann 70b7bd94cc Fix build after rebase 2017-01-04 11:07:32 +08:00
Andrew Cann d2827aa9bc Fix build after rebase 2017-01-03 15:48:29 +08:00
Andrew Cann 9c5e86d0cd More pattern matching for empty types changes
Fix is_uninhabited for enum types. It used to assume that an enums variant's
fields were all private.

Fix MIR generation for irrefutable Variant pattern matches. This allows code
like this to work:

    let x: Result<32, !> = Ok(123);
    let Ok(y) = x;

Carry type information on dummy wildcard patterns. Sometimes we need to expand
these patterns into their constructors and we don't want to be expanding a
TyError into a Constructor::Single.
2017-01-03 15:33:31 +08:00
Eduard-Mihai Burtescu c6e130e89b rustc_const_eval: convert constants to Pattern instead of hir::Pat. 2017-01-01 22:17:18 +02:00
Eduard-Mihai Burtescu c001b0940c rustc_const_eval: build Pattern instead of hir::Pat for pretty-printing. 2017-01-01 20:57:21 +02:00
Eduard-Mihai Burtescu 07ff914be1 rustc: simplify AdtDef by removing the field types and ty::ivar. 2016-11-29 21:24:26 +02:00
Eduard-Mihai Burtescu 962633cdbb rustc: embed path resolutions into the HIR instead of keeping DefMap. 2016-11-28 04:18:10 +02:00
Anthony Ramine 84239dfc4a Work around a borrow surviving too long (fixes #37686) 2016-11-10 14:43:46 +01:00
Eduard Burtescu 6a8d131e5d rustc: make all read access to tcx.tables go through a method. 2016-11-02 03:50:32 +02:00
Eduard Burtescu 36340ba994 rustc: move mir::repr::* to mir. 2016-10-28 10:37:24 +03:00
Vadim Petrochenkov 8a38928b44 Address comments + Fix rebase 2016-10-27 22:20:25 +03:00