rust/src/libsyntax
Alex Crichton e6166b7498 rollup merge of #23712: nikomatsakis/reflect-trait
This PR introduces a `Reflect` marker trait which is a supertrait of `Any`. The idea is that `Reflect` is defined for all concrete types, but is not defined for type parameters unless there is a `T:Reflect` bound. This is intended to preserve the parametricity property. This allows the `Any` interface to be stabilized without committing us to unbounded reflection that is not easily detectable by the caller.

The implementation of `Reflect` relies on an experimental variant of OIBIT. This variant behaves differently for objects, since it requires that all types exposed as part of the object's *interface* are `Reflect`, but isn't concerned about other types that may be closed over. In other words, you don't have to write `Foo+Reflect` in order for `Foo: Reflect` to hold (where `Foo` is a trait).

Given that `Any` is slated to stabilization and hence that we are committed to some form of reflection, the goal of this PR is to leave our options open with respect to parametricity. I see the options for full stabilization as follows (I think an RFC would be an appropriate way to confirm whichever of these three routes we take):

1. We make `Reflect` a lang-item.
2. We stabilize some version of the OIBIT variation I implemented as a general mechanism that may be appropriate for other use cases.
3. We give up on preserving parametricity here and just have `impl<T> Reflect for T` instead. In that case, `Reflect` is a harmless but not especially useful trait going forward.

cc @aturon
cc @alexcrichton
cc @glaebhoerl (this is more-or-less your proposal, as I understood it)
cc @reem (this is more-or-less what we discussed on IRC at some point)
cc @FlaPer87 (vaguely pertains to OIBIT)
2015-03-27 10:07:43 -07:00
..
ast_map syntax: move MethMac to MacImplItem and combine {Provided,Required}Method into MethodTraitItem. 2015-03-11 23:39:16 +02:00
diagnostics Change span_help calls to fileline_help where appropriate 2015-03-03 15:18:33 +02:00
ext Auto merge of #22930 - Gankro:entry_3, r=aturon 2015-03-27 12:55:23 +00:00
parse Prevent ICEs when parsing invalid escapes, closes #23620 2015-03-27 17:47:16 +01:00
print Auto merge of #23359 - erickt:quote, r=pnkfelix 2015-03-26 18:43:56 +00:00
util syntax: use lookahead to distinguish inner and outer attributes, instead of passing the latter around. 2015-03-13 11:36:30 +02:00
abi.rs Use consts instead of statics where appropriate 2015-03-02 17:11:51 +01:00
ast.rs rustc: Add support for extern crate foo as bar 2015-03-24 14:55:15 -07:00
ast_util.rs syntax: move MethMac to MacImplItem and combine {Provided,Required}Method into MethodTraitItem. 2015-03-11 23:39:16 +02:00
attr.rs Remove the re-exports for InlineAttr variants. 2015-02-28 13:56:32 +01:00
codemap.rs Add trivial cast lints. 2015-03-25 10:03:57 +13:00
config.rs syntax: gather common fields of impl & trait items into their respective types. 2015-03-11 23:39:16 +02:00
diagnostic.rs Fallout of std::old_io deprecation 2015-03-13 10:00:28 -07:00
feature_gate.rs Implement Reflect trait with a variant on the standard OIBIT 2015-03-26 17:52:38 -04:00
fold.rs Switch drop-flag to u8 to allow special tags to instrument state. 2015-03-26 14:08:54 +01:00
lib.rs default => or_insert per RFC 2015-03-27 07:42:03 -04:00
owned_slice.rs Switched to Box::new in many places. 2015-03-03 21:05:55 +01:00
ptr.rs Switch drop-flag to u8 to allow special tags to instrument state. 2015-03-26 14:08:54 +01:00
show_span.rs std: Stabilize FromStr and parse 2015-01-30 08:52:44 -08:00
std_inject.rs rustc: Add support for extern crate foo as bar 2015-03-24 14:55:15 -07:00
test.rs Reviewer changes 2015-03-16 17:01:12 +13:00
visit.rs syntax: move MethMac to MacImplItem and combine {Provided,Required}Method into MethodTraitItem. 2015-03-11 23:39:16 +02:00