Commit Graph

72 Commits

Author SHA1 Message Date
Tobias Bucher
0872cc37bc Remove incorrect comment about PartialEq implementation 2016-03-31 21:19:17 +02:00
Jorge Aparicio
0f02309e4b try! -> ?
Automated conversion using the untry tool [1] and the following command:

```
$ find -name '*.rs' -type f | xargs untry
```

at the root of the Rust repo.

[1]: https://github.com/japaric/untry
2016-03-22 22:01:37 -05:00
Eduard Burtescu
cfd768e2e6 hir_map: Provide expression and statement attributes. 2016-03-17 22:48:07 +02:00
Eduard Burtescu
856185dbb2 hir, mir: Separate HIR expressions / MIR operands from InlineAsm. 2016-03-17 21:51:55 +02:00
Aaron Turon
940adda2ae Move specialization graph walks to iterators; make associated type
projection sensitive to "mode" (most importantly, trans vs middle).

This commit introduces several pieces of iteration infrastructure in the
specialization graph data structure, as well as various helpers for
finding the definition of a given item, given its kind and name.

In addition, associated type projection is now *mode-sensitive*, with
three possible modes:

- **Topmost**. This means that projection is only possible if there is a
    non-`default` definition of the associated type directly on the
    selected impl. This mode is a bit of a hack: it's used during early
    coherence checking before we have built the specialization
    graph (and therefore before we can walk up the specialization
    parents to find other definitions). Eventually, this should be
    replaced with a less "staged" construction of the specialization
    graph.

- **AnyFinal**. Projection succeeds for any non-`default` associated
    type definition, even if it is defined by a parent impl. Used
    throughout typechecking.

- **Any**. Projection always succeeds. Used by trans.

The lasting distinction here is between `AnyFinal` and `Any` -- we wish
to treat `default` associated types opaquely for typechecking purposes.

In addition to the above, the commit includes a few other minor review fixes.
2016-03-14 15:04:40 -07:00
Aaron Turon
8fe63e2342 Add default as contextual keyword, and parse it for impl items. 2016-03-14 15:04:33 -07:00
srinivasreddy
fe541b168e removed suffixes for librustc_front 2016-03-11 01:32:03 +05:30
Jorge Aparicio
210dd611aa implement the ? operator
The `?` postfix operator is sugar equivalent to the try! macro, but is more amenable to chaining:
`File::open("foo")?.metadata()?.is_dir()`.

`?` is accepted on any *expression* that can return a `Result`, e.g. `x()?`, `y!()?`, `{z}?`,
`(w)?`, etc. And binds more tightly than unary operators, e.g. `!x?` is parsed as `!(x?)`.

cc #31436
2016-03-07 14:39:39 -05:00
bors
8484831d29 Auto merge of #30884 - durka:inclusive-ranges, r=aturon
This PR implements [RFC 1192](https://github.com/rust-lang/rfcs/blob/master/text/1192-inclusive-ranges.md), which is triple-dot syntax for inclusive range expressions. The new stuff is behind two feature gates (one for the syntax and one for the std::ops types). This replaces the deprecated functionality in std::iter. Along the way I simplified the desugaring for all ranges.

This is my first contribution to rust which changes more than one character outside of a test or comment, so please review carefully! Some of the individual commit messages have more of my notes. Also thanks for putting up with my dumb questions in #rust-internals.

- For implementing `std::ops::RangeInclusive`, I took @Stebalien's suggestion from https://github.com/rust-lang/rfcs/pull/1192#issuecomment-137864421. It seemed to me to make the implementation easier and increase type safety. If that stands, the RFC should be amended to avoid confusion.
- I also kind of like @glaebhoerl's [idea](https://github.com/rust-lang/rfcs/pull/1254#issuecomment-147815299), which is unified inclusive/exclusive range syntax something like `x>..=y`. We can experiment with this while everything is behind a feature gate.
- There are a couple of FIXMEs left (see the last commit). I didn't know what to do about `RangeArgument` and I haven't added `Index` impls yet. Those should be discussed/finished before merging.

cc @Gankro since you [complained](https://www.reddit.com/r/rust/comments/3xkfro/what_happened_to_inclusive_ranges/cy5j0yq)
cc #27777 #30877 rust-lang/rust#1192 rust-lang/rfcs#1254
relevant to #28237 (tracking issue)
2016-03-06 07:16:41 +00:00
Vadim Petrochenkov
9047b201bf Move span into StructField
+ some cleanup in rustdoc
2016-03-02 10:32:04 +03:00
Vadim Petrochenkov
8b026a6e48 Use numeric field Names ("0", "1" etc) for positional fields 2016-03-02 10:31:19 +03:00
Vadim Petrochenkov
8b60b948d9 Get rid of hir::StructFieldKind 2016-03-02 10:31:19 +03:00
Alex Burka
a331278451 HIR: add inclusive ranges, desugar all ranges (remove ExprRange) 2016-02-27 02:01:41 -05:00
Vadim Petrochenkov
06755d90ce Split PatKind::Enum into PatKind::TupleStruct and PatKind::Path 2016-02-16 00:40:38 +03:00
Vadim Petrochenkov
9b40e1e5b3 Rename hir::Pat_ and its variants 2016-02-14 15:25:12 +03:00
bors
3d150397a2 Auto merge of #30470 - petrochenkov:owned5, r=nrc
cc https://github.com/rust-lang/rust/pull/30095

r? @nrc
2015-12-20 22:50:34 +00:00
bors
440ef8b154 Auto merge of #30184 - petrochenkov:ascr, r=nikomatsakis
This PR is a rebase of the original PR by @eddyb https://github.com/rust-lang/rust/pull/21836 with some unrebasable parts manually reapplied, feature gate added + type equality restriction added as described below.

This implementation is partial because the type equality restriction is applied to all type ascription expressions and not only those in lvalue contexts. Thus, all difficulties with detection of these contexts and translation of coercions having effect in runtime are avoided.
So, you can't write things with coercions like `let slice = &[1, 2, 3]: &[u8];`. It obviously makes type ascription less useful than it should be, but it's still much more useful than not having type ascription at all.
In particular, things like `let v = something.iter().collect(): Vec<_>;` and `let u = t.into(): U;` work as expected and I'm pretty happy with these improvements alone.

Part of https://github.com/rust-lang/rust/issues/23416
2015-12-19 02:45:15 +00:00
Vadim Petrochenkov
e3da2a9003 Improve OwnedSlice and use it in HIR 2015-12-19 04:20:11 +03:00
Vadim Petrochenkov
6c87b19158 Abstract away differences between Vec and ptr::P in HIR 2015-12-18 00:52:56 +03:00
Vadim Petrochenkov
0d298f9904 Deprecate name OwnedSlice and don't use it 2015-12-18 00:52:56 +03:00
Vadim Petrochenkov
e0ceef5a9e Add ExprType to HIR and make everything compile
+ Apply parser changes manually
+ Add feature gate
2015-12-16 17:13:16 +03:00
bors
50a02b43ba Auto merge of #29735 - Amanieu:asm_indirect_constraint, r=pnkfelix
This PR reverts #29543 and instead implements proper support for "=*m" and "+*m" indirect output operands. This provides a framework on top of which support for plain memory operands ("m", "=m" and "+m") can be implemented.

This also fixes the liveness analysis pass not handling read/write operands correctly.
2015-12-14 13:48:41 +00:00
bors
462ec05764 Auto merge of #30145 - petrochenkov:hyg, r=nrc
Instead of `ast::Ident`, bindings, paths and labels in HIR now keep a new structure called `hir::Ident` containing mtwt-renamed `name` and the original not-renamed `unhygienic_name`. `name` is supposed to be used by default, `unhygienic_name` is rarely used.

This is not ideal, but better than the status quo for two reasons:
- MTWT tables can be cleared immediately after lowering to HIR
- This is less bug-prone, because it is impossible now to forget applying `mtwt::resolve` to a name. It is still possible to use `name` instead of `unhygienic_name` by mistake, but `unhygienic_name`s are used only in few very special circumstances, so it shouldn't be a problem.

Besides name resolution `unhygienic_name` is used in some lints and debuginfo. `unhygienic_name` can be very well approximated by "reverse renaming" `token::intern(name.as_str())` or even plain string `name.as_str()`, except that it would break gensyms like `iter` in desugared `for` loops. This approximation is likely good enough for lints and debuginfo, but not for name resolution, unfortunately (see https://github.com/rust-lang/rust/issues/27639), so `unhygienic_name` has to be kept.

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

r? @nrc
2015-12-09 00:41:26 +00:00
Vadim Petrochenkov
c1d3164700 Add comments for Ident::from_name and identifiers in path segments 2015-12-07 20:19:36 +03:00
Vadim Petrochenkov
ca88e9c536 Remove some unnecessary indirection from HIR structures 2015-12-07 17:17:41 +03:00
Amanieu d'Antras
65707dfc00 Use a struct instead of a tuple for inline asm output operands 2015-12-05 10:11:20 +00:00
Amanieu d'Antras
9d7b113b44 Add proper support for indirect output constraints in inline asm 2015-12-05 08:18:30 +00:00
Vadim Petrochenkov
eb789de803 Do MTWT resolution during lowering to HIR 2015-12-05 00:40:21 +03:00
Marvin Löbel
f0beba0217 Moved and refactored ThinAttributes 2015-11-26 21:46:12 +01:00
Marvin Löbel
2a8f358de7 Add syntax support for attributes on expressions and all syntax
nodes in statement position.

Extended #[cfg] folder to allow removal of statements, and
of expressions in optional positions like expression lists and trailing
block expressions.

Extended lint checker to recognize lint levels on expressions and
locals.
2015-11-26 21:46:12 +01:00
Niko Matsakis
e303c250f1 Change to a BTreeMap rather than sorting the keys of a FnvHashMap. 2015-11-18 19:23:29 -05:00
Niko Matsakis
767ee79c4c Refactor the HIR so that items are stored in a map in the Crate,
rather being stored inline. Refactor (and rename) the visitor so that
(by default) it only visits the interior content of an item not nested
items.

This is a [breaking-change] for anyone who uses the HIR visitor. Besides
changing `visit::` to `intravisit::`, you need to refactor your visitor
in one of two ways, depending on what it requires:

1. If you just want to visit all items (most common), you should call
   `krate.visit_all_items(&mut visitor)`.

2. If you need to visit nested items in the middle of the parent items,
   you should override `visit_nested_item` with something like:
   `self.visit_item(self.tcx.map.expect_item(item.id))`, presuming you
   have access to a tcx (or at least a HIR map).
2015-11-18 19:22:18 -05:00
bors
b31cc644d1 Auto merge of #29766 - oli-obk:impl_item, r=nikomatsakis
[breaking change]

I'm not sure if those renames are ok. [TokenType::Tt* to TokenType::*](https://github.com/rust-lang/rust/pull/29582) was obvious, but for all those Item-enums it's less obvious to me what the right way forward is due to the underscore.
2015-11-17 18:24:19 +00:00
Vadim Petrochenkov
4a850159cd Remove TyParen from HIR 2015-11-16 22:49:47 +03:00
Oliver Schneider
e36872da5b ImplItem_ -> ImplItemKind rename 2015-11-16 10:35:30 +01:00
Oliver Schneider
eaaa60dbea rename ImplItem_::*ImplItem to ImplItem_::*
[breaking change]
2015-11-16 10:34:45 +01:00
Jose Narvaez
cbd2ef8185 Rustfmting librustc_front (again). 2015-11-09 21:55:51 +00:00
bors
e2bb53ca52 Auto merge of #29291 - petrochenkov:privacy, r=alexcrichton
The public set is expanded with trait items, impls and their items, foreign items, exported macros, variant fields, i.e. all the missing parts. Now it's a subset of the exported set.
This is needed for https://github.com/rust-lang/rust/pull/29083 because stability annotation pass uses the public set and all things listed above need to be annotated.
Rustdoc can now be migrated to the public set as well, I guess.

Exported set is now slightly more correct with regard to exported items in blocks - 1) blocks in foreign items are considered and 2) publicity is not inherited from the block's parent - if a function is public it doesn't mean structures defined in its body are public.

r? @alexcrichton or maybe someone else
2015-11-02 23:38:49 +00:00
bors
6307719a12 Auto merge of #29501 - Manishearth:pat-docs, r=alexcrichton
None
2015-11-01 21:42:18 +00:00
Manish Goregaokar
8bb72cfe00 Add code formatting on PatVec docs 2015-11-01 16:37:12 +05:30
Manish Goregaokar
7e9d73cf2d Fix PatEnum docs 2015-11-01 16:32:51 +05:30
Vadim Petrochenkov
3468b8d42c Remove PatWildMulti 2015-10-31 03:44:43 +03:00
Vadim Petrochenkov
e8ddbba2ed syntax/rustc_front: Simplify VariantData::fields
And use VariantData instead of P<VariantData> in Item_ and Variant_
2015-10-25 18:33:51 +03:00
Vadim Petrochenkov
599df16551 rustc_privacy: Expand public node set, build exported node set more correctly 2015-10-25 04:42:31 +03:00
Vadim Petrochenkov
607b8c3892 Comment on the purpose(s) of NodeId in VariantData 2015-10-13 16:18:33 +03:00
Vadim Petrochenkov
46750d0409 Merge VariantData and VariantData_ 2015-10-13 15:19:27 +03:00
Vadim Petrochenkov
40aa09e4c9 Merge struct fields and struct kind 2015-10-13 15:19:25 +03:00
Vadim Petrochenkov
30af54dede Dict -> Struct, StructDef -> VariantData, def -> data 2015-10-13 15:19:24 +03:00
Vadim Petrochenkov
beda1f88a7 Provide span for visit_struct_def + remove some dead code 2015-10-13 15:19:19 +03:00
Vadim Petrochenkov
877c35e8a2 Remove now redundant NodeId from Variant 2015-10-13 15:19:18 +03:00