2016-09-16 17:25:54 +03:00
|
|
|
// Copyright 2012-2016 The Rust Project Developers. See the COPYRIGHT
|
|
|
|
// file at the top-level directory of this distribution and at
|
|
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
|
|
|
use astencode;
|
|
|
|
use index;
|
|
|
|
|
|
|
|
use rustc::hir;
|
2016-09-15 00:51:46 +03:00
|
|
|
use rustc::hir::def::{self, CtorKind};
|
2016-09-16 17:25:54 +03:00
|
|
|
use rustc::hir::def_id::{DefIndex, DefId};
|
2017-02-05 07:01:48 +02:00
|
|
|
use rustc::middle::const_val::ConstVal;
|
rustc: Implement #[link(cfg(..))] and crt-static
This commit is an implementation of [RFC 1721] which adds a new target feature
to the compiler, `crt-static`, which can be used to select how the C runtime for
a target is linked. Most targets dynamically linke the C runtime by default with
the notable exception of some of the musl targets.
[RFC 1721]: https://github.com/rust-lang/rfcs/blob/master/text/1721-crt-static.md
This commit first adds the new target-feature, `crt-static`. If enabled, then
the `cfg(target_feature = "crt-static")` will be available. Targets like musl
will have this enabled by default. This feature can be controlled through the
standard target-feature interface, `-C target-feature=+crt-static` or
`-C target-feature=-crt-static`.
Next this adds an gated and unstable `#[link(cfg(..))]` feature to enable the
`crt-static` semantics we want with libc. The exact behavior of this attribute
is a little squishy, but it's intended to be a forever-unstable
implementation detail of the liblibc crate.
Specifically the `#[link(cfg(..))]` annotation means that the `#[link]`
directive is only active in a compilation unit if that `cfg` value is satisfied.
For example when compiling an rlib, these directives are just encoded and
ignored for dylibs, and all staticlibs are continued to be put into the rlib as
usual. When placing that rlib into a staticlib, executable, or dylib, however,
the `cfg` is evaluated *as if it were defined in the final artifact* and the
library is decided to be linked or not.
Essentially, what'll happen is:
* On MSVC with `-C target-feature=-crt-static`, the `msvcrt.lib` library will be
linked to.
* On MSVC with `-C target-feature=+crt-static`, the `libcmt.lib` library will be
linked to.
* On musl with `-C target-feature=-crt-static`, the object files in liblibc.rlib
are removed and `-lc` is passed instead.
* On musl with `-C target-feature=+crt-static`, the object files in liblibc.rlib
are used and `-lc` is not passed.
This commit does **not** include an update to the liblibc module to implement
these changes. I plan to do that just after the 1.14.0 beta release is cut to
ensure we get ample time to test this feature.
cc #37406
2016-10-31 16:40:13 -07:00
|
|
|
use rustc::middle::cstore::{DepKind, LinkagePreference, NativeLibrary};
|
2016-09-16 17:25:54 +03:00
|
|
|
use rustc::middle::lang_items;
|
|
|
|
use rustc::mir;
|
2017-02-06 15:26:32 -05:00
|
|
|
use rustc::ty::{self, Ty, ReprOptions};
|
2016-09-27 21:26:08 -05:00
|
|
|
use rustc_back::PanicStrategy;
|
2016-09-16 17:25:54 +03:00
|
|
|
|
|
|
|
use rustc_serialize as serialize;
|
|
|
|
use syntax::{ast, attr};
|
2016-11-16 10:52:37 +00:00
|
|
|
use syntax::symbol::Symbol;
|
2016-09-16 17:25:54 +03:00
|
|
|
use syntax_pos::{self, Span};
|
|
|
|
|
|
|
|
use std::marker::PhantomData;
|
|
|
|
|
2016-09-30 16:24:50 -06:00
|
|
|
pub fn rustc_version() -> String {
|
2016-10-22 18:44:32 +05:30
|
|
|
format!("rustc {}",
|
|
|
|
option_env!("CFG_VERSION").unwrap_or("unknown version"))
|
2016-09-30 16:24:50 -06:00
|
|
|
}
|
2016-09-18 14:05:49 +03:00
|
|
|
|
2016-09-16 17:25:54 +03:00
|
|
|
/// Metadata encoding version.
|
|
|
|
/// NB: increment this if you change the format of metadata such that
|
2016-11-22 14:51:55 +02:00
|
|
|
/// the rustc version can't be found to compare with `rustc_version()`.
|
|
|
|
pub const METADATA_VERSION: u8 = 4;
|
2016-09-16 17:25:54 +03:00
|
|
|
|
|
|
|
/// Metadata header which includes `METADATA_VERSION`.
|
|
|
|
/// To get older versions of rustc to ignore this metadata,
|
|
|
|
/// there are 4 zero bytes at the start, which are treated
|
|
|
|
/// as a length of 0 by old compilers.
|
|
|
|
///
|
2016-11-22 14:51:55 +02:00
|
|
|
/// This header is followed by the position of the `CrateRoot`,
|
|
|
|
/// which is encoded as a 32-bit big-endian unsigned integer,
|
|
|
|
/// and further followed by the rustc version string.
|
2016-10-22 18:44:32 +05:30
|
|
|
pub const METADATA_HEADER: &'static [u8; 12] =
|
|
|
|
&[0, 0, 0, 0, b'r', b'u', b's', b't', 0, 0, 0, METADATA_VERSION];
|
2016-09-16 17:25:54 +03:00
|
|
|
|
|
|
|
/// The shorthand encoding uses an enum's variant index `usize`
|
|
|
|
/// and is offset by this value so it never matches a real variant.
|
|
|
|
/// This offset is also chosen so that the first byte is never < 0x80.
|
|
|
|
pub const SHORTHAND_OFFSET: usize = 0x80;
|
|
|
|
|
|
|
|
/// A value of type T referred to by its absolute position
|
|
|
|
/// in the metadata, and which can be decoded lazily.
|
2016-09-17 10:33:47 +03:00
|
|
|
///
|
|
|
|
/// Metadata is effective a tree, encoded in post-order,
|
|
|
|
/// and with the root's position written next to the header.
|
|
|
|
/// That means every single `Lazy` points to some previous
|
|
|
|
/// location in the metadata and is part of a larger node.
|
|
|
|
///
|
|
|
|
/// The first `Lazy` in a node is encoded as the backwards
|
|
|
|
/// distance from the position where the containing node
|
|
|
|
/// starts and where the `Lazy` points to, while the rest
|
|
|
|
/// use the forward distance from the previous `Lazy`.
|
|
|
|
/// Distances start at 1, as 0-byte nodes are invalid.
|
|
|
|
/// Also invalid are nodes being referred in a different
|
|
|
|
/// order than they were encoded in.
|
2016-09-16 17:25:54 +03:00
|
|
|
#[must_use]
|
|
|
|
pub struct Lazy<T> {
|
|
|
|
pub position: usize,
|
2016-10-22 18:44:32 +05:30
|
|
|
_marker: PhantomData<T>,
|
2016-09-16 17:25:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
impl<T> Lazy<T> {
|
|
|
|
pub fn with_position(position: usize) -> Lazy<T> {
|
|
|
|
Lazy {
|
|
|
|
position: position,
|
2016-10-22 18:44:32 +05:30
|
|
|
_marker: PhantomData,
|
2016-09-16 17:25:54 +03:00
|
|
|
}
|
|
|
|
}
|
2016-09-17 10:33:47 +03:00
|
|
|
|
|
|
|
/// Returns the minimum encoded size of a value of type `T`.
|
|
|
|
// FIXME(eddyb) Give better estimates for certain types.
|
|
|
|
pub fn min_size() -> usize {
|
|
|
|
1
|
|
|
|
}
|
2016-09-16 17:25:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
impl<T> Copy for Lazy<T> {}
|
|
|
|
impl<T> Clone for Lazy<T> {
|
2016-10-22 18:44:32 +05:30
|
|
|
fn clone(&self) -> Self {
|
|
|
|
*self
|
|
|
|
}
|
2016-09-16 17:25:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
impl<T> serialize::UseSpecializedEncodable for Lazy<T> {}
|
|
|
|
impl<T> serialize::UseSpecializedDecodable for Lazy<T> {}
|
|
|
|
|
|
|
|
/// A sequence of type T referred to by its absolute position
|
|
|
|
/// in the metadata and length, and which can be decoded lazily.
|
2016-09-17 10:33:47 +03:00
|
|
|
/// The sequence is a single node for the purposes of `Lazy`.
|
2016-09-16 17:25:54 +03:00
|
|
|
///
|
|
|
|
/// Unlike `Lazy<Vec<T>>`, the length is encoded next to the
|
|
|
|
/// position, not at the position, which means that the length
|
|
|
|
/// doesn't need to be known before encoding all the elements.
|
2016-09-17 10:33:47 +03:00
|
|
|
///
|
|
|
|
/// If the length is 0, no position is encoded, but otherwise,
|
|
|
|
/// the encoding is that of `Lazy`, with the distinction that
|
|
|
|
/// the minimal distance the length of the sequence, i.e.
|
|
|
|
/// it's assumed there's no 0-byte element in the sequence.
|
2016-09-16 17:25:54 +03:00
|
|
|
#[must_use]
|
|
|
|
pub struct LazySeq<T> {
|
|
|
|
pub len: usize,
|
|
|
|
pub position: usize,
|
2016-10-22 18:44:32 +05:30
|
|
|
_marker: PhantomData<T>,
|
2016-09-16 17:25:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
impl<T> LazySeq<T> {
|
|
|
|
pub fn empty() -> LazySeq<T> {
|
|
|
|
LazySeq::with_position_and_length(0, 0)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn with_position_and_length(position: usize, len: usize) -> LazySeq<T> {
|
|
|
|
LazySeq {
|
|
|
|
len: len,
|
|
|
|
position: position,
|
2016-10-22 18:44:32 +05:30
|
|
|
_marker: PhantomData,
|
2016-09-16 17:25:54 +03:00
|
|
|
}
|
|
|
|
}
|
2016-09-17 10:33:47 +03:00
|
|
|
|
|
|
|
/// Returns the minimum encoded size of `length` values of type `T`.
|
|
|
|
pub fn min_size(length: usize) -> usize {
|
|
|
|
length
|
|
|
|
}
|
2016-09-16 17:25:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
impl<T> Copy for LazySeq<T> {}
|
|
|
|
impl<T> Clone for LazySeq<T> {
|
2016-10-22 18:44:32 +05:30
|
|
|
fn clone(&self) -> Self {
|
|
|
|
*self
|
|
|
|
}
|
2016-09-16 17:25:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
impl<T> serialize::UseSpecializedEncodable for LazySeq<T> {}
|
|
|
|
impl<T> serialize::UseSpecializedDecodable for LazySeq<T> {}
|
|
|
|
|
2016-09-17 10:33:47 +03:00
|
|
|
/// Encoding / decoding state for `Lazy` and `LazySeq`.
|
|
|
|
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
|
|
|
|
pub enum LazyState {
|
|
|
|
/// Outside of a metadata node.
|
|
|
|
NoNode,
|
|
|
|
|
|
|
|
/// Inside a metadata node, and before any `Lazy` or `LazySeq`.
|
|
|
|
/// The position is that of the node itself.
|
|
|
|
NodeStart(usize),
|
|
|
|
|
|
|
|
/// Inside a metadata node, with a previous `Lazy` or `LazySeq`.
|
|
|
|
/// The position is a conservative estimate of where that
|
|
|
|
/// previous `Lazy` / `LazySeq` would end (see their comments).
|
2016-10-22 18:44:32 +05:30
|
|
|
Previous(usize),
|
2016-09-17 10:33:47 +03:00
|
|
|
}
|
|
|
|
|
2016-09-16 17:25:54 +03:00
|
|
|
#[derive(RustcEncodable, RustcDecodable)]
|
|
|
|
pub struct CrateRoot {
|
2016-11-16 10:52:37 +00:00
|
|
|
pub name: Symbol,
|
2016-09-16 17:25:54 +03:00
|
|
|
pub triple: String,
|
|
|
|
pub hash: hir::svh::Svh,
|
2016-11-16 10:52:37 +00:00
|
|
|
pub disambiguator: Symbol,
|
2016-09-16 17:25:54 +03:00
|
|
|
pub panic_strategy: PanicStrategy,
|
|
|
|
pub plugin_registrar_fn: Option<DefIndex>,
|
|
|
|
pub macro_derive_registrar: Option<DefIndex>,
|
|
|
|
|
|
|
|
pub crate_deps: LazySeq<CrateDep>,
|
|
|
|
pub dylib_dependency_formats: LazySeq<Option<LinkagePreference>>,
|
|
|
|
pub lang_items: LazySeq<(DefIndex, usize)>,
|
|
|
|
pub lang_items_missing: LazySeq<lang_items::LangItem>,
|
rustc: Implement #[link(cfg(..))] and crt-static
This commit is an implementation of [RFC 1721] which adds a new target feature
to the compiler, `crt-static`, which can be used to select how the C runtime for
a target is linked. Most targets dynamically linke the C runtime by default with
the notable exception of some of the musl targets.
[RFC 1721]: https://github.com/rust-lang/rfcs/blob/master/text/1721-crt-static.md
This commit first adds the new target-feature, `crt-static`. If enabled, then
the `cfg(target_feature = "crt-static")` will be available. Targets like musl
will have this enabled by default. This feature can be controlled through the
standard target-feature interface, `-C target-feature=+crt-static` or
`-C target-feature=-crt-static`.
Next this adds an gated and unstable `#[link(cfg(..))]` feature to enable the
`crt-static` semantics we want with libc. The exact behavior of this attribute
is a little squishy, but it's intended to be a forever-unstable
implementation detail of the liblibc crate.
Specifically the `#[link(cfg(..))]` annotation means that the `#[link]`
directive is only active in a compilation unit if that `cfg` value is satisfied.
For example when compiling an rlib, these directives are just encoded and
ignored for dylibs, and all staticlibs are continued to be put into the rlib as
usual. When placing that rlib into a staticlib, executable, or dylib, however,
the `cfg` is evaluated *as if it were defined in the final artifact* and the
library is decided to be linked or not.
Essentially, what'll happen is:
* On MSVC with `-C target-feature=-crt-static`, the `msvcrt.lib` library will be
linked to.
* On MSVC with `-C target-feature=+crt-static`, the `libcmt.lib` library will be
linked to.
* On musl with `-C target-feature=-crt-static`, the object files in liblibc.rlib
are removed and `-lc` is passed instead.
* On musl with `-C target-feature=+crt-static`, the object files in liblibc.rlib
are used and `-lc` is not passed.
This commit does **not** include an update to the liblibc module to implement
these changes. I plan to do that just after the 1.14.0 beta release is cut to
ensure we get ample time to test this feature.
cc #37406
2016-10-31 16:40:13 -07:00
|
|
|
pub native_libraries: LazySeq<NativeLibrary>,
|
2016-09-17 10:33:47 +03:00
|
|
|
pub codemap: LazySeq<syntax_pos::FileMap>,
|
2016-12-16 12:51:36 -05:00
|
|
|
pub def_path_table: Lazy<hir::map::definitions::DefPathTable>,
|
2016-09-16 17:25:54 +03:00
|
|
|
pub impls: LazySeq<TraitImpls>,
|
2016-11-28 18:05:53 -05:00
|
|
|
pub exported_symbols: LazySeq<DefIndex>,
|
2016-09-17 10:33:47 +03:00
|
|
|
pub index: LazySeq<index::Index>,
|
2016-09-16 17:25:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(RustcEncodable, RustcDecodable)]
|
|
|
|
pub struct CrateDep {
|
|
|
|
pub name: ast::Name,
|
|
|
|
pub hash: hir::svh::Svh,
|
2016-10-27 09:18:45 +00:00
|
|
|
pub kind: DepKind,
|
2016-09-16 17:25:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(RustcEncodable, RustcDecodable)]
|
|
|
|
pub struct TraitImpls {
|
|
|
|
pub trait_id: (u32, DefIndex),
|
2016-10-22 18:44:32 +05:30
|
|
|
pub impls: LazySeq<DefIndex>,
|
2016-09-16 17:25:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(RustcEncodable, RustcDecodable)]
|
|
|
|
pub struct Entry<'tcx> {
|
|
|
|
pub kind: EntryKind<'tcx>,
|
2016-12-20 08:32:15 +00:00
|
|
|
pub visibility: Lazy<ty::Visibility>,
|
2016-11-24 01:39:13 +02:00
|
|
|
pub span: Lazy<Span>,
|
2016-09-16 17:25:54 +03:00
|
|
|
pub attributes: LazySeq<ast::Attribute>,
|
|
|
|
pub children: LazySeq<DefIndex>,
|
|
|
|
pub stability: Option<Lazy<attr::Stability>>,
|
|
|
|
pub deprecation: Option<Lazy<attr::Deprecation>>,
|
|
|
|
|
|
|
|
pub ty: Option<Lazy<Ty<'tcx>>>,
|
|
|
|
pub inherent_impls: LazySeq<DefIndex>,
|
|
|
|
pub variances: LazySeq<ty::Variance>,
|
2017-01-25 22:01:11 +02:00
|
|
|
pub generics: Option<Lazy<ty::Generics>>,
|
2016-09-16 17:25:54 +03:00
|
|
|
pub predicates: Option<Lazy<ty::GenericPredicates<'tcx>>>,
|
|
|
|
|
|
|
|
pub ast: Option<Lazy<astencode::Ast<'tcx>>>,
|
2016-09-19 23:50:00 +03:00
|
|
|
pub mir: Option<Lazy<mir::Mir<'tcx>>>,
|
2016-09-16 17:25:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Copy, Clone, RustcEncodable, RustcDecodable)]
|
|
|
|
pub enum EntryKind<'tcx> {
|
2017-02-20 03:55:28 +02:00
|
|
|
Const(u8),
|
2016-09-16 17:25:54 +03:00
|
|
|
ImmStatic,
|
|
|
|
MutStatic,
|
|
|
|
ForeignImmStatic,
|
|
|
|
ForeignMutStatic,
|
|
|
|
ForeignMod,
|
|
|
|
Type,
|
2017-02-05 07:01:48 +02:00
|
|
|
Enum(ReprOptions),
|
2016-09-16 17:25:54 +03:00
|
|
|
Field,
|
2017-02-15 15:00:20 +02:00
|
|
|
Variant(Lazy<VariantData<'tcx>>),
|
|
|
|
Struct(Lazy<VariantData<'tcx>>, ReprOptions),
|
|
|
|
Union(Lazy<VariantData<'tcx>>, ReprOptions),
|
2016-09-16 17:25:54 +03:00
|
|
|
Fn(Lazy<FnData>),
|
|
|
|
ForeignFn(Lazy<FnData>),
|
|
|
|
Mod(Lazy<ModData>),
|
2016-10-28 06:52:45 +00:00
|
|
|
MacroDef(Lazy<MacroDef>),
|
2016-09-16 17:25:54 +03:00
|
|
|
Closure(Lazy<ClosureData<'tcx>>),
|
|
|
|
Trait(Lazy<TraitData<'tcx>>),
|
|
|
|
Impl(Lazy<ImplData<'tcx>>),
|
|
|
|
DefaultImpl(Lazy<ImplData<'tcx>>),
|
2016-11-10 02:06:34 +02:00
|
|
|
Method(Lazy<MethodData>),
|
2016-09-16 17:25:54 +03:00
|
|
|
AssociatedType(AssociatedContainer),
|
2017-02-20 03:55:28 +02:00
|
|
|
AssociatedConst(AssociatedContainer, u8),
|
2016-09-16 17:25:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(RustcEncodable, RustcDecodable)]
|
|
|
|
pub struct ModData {
|
2016-10-22 18:44:32 +05:30
|
|
|
pub reexports: LazySeq<def::Export>,
|
2016-09-16 17:25:54 +03:00
|
|
|
}
|
|
|
|
|
2016-11-24 01:39:13 +02:00
|
|
|
#[derive(RustcEncodable, RustcDecodable)]
|
|
|
|
pub struct MacroDef {
|
|
|
|
pub body: String,
|
|
|
|
}
|
|
|
|
|
2016-09-16 17:25:54 +03:00
|
|
|
#[derive(RustcEncodable, RustcDecodable)]
|
|
|
|
pub struct FnData {
|
|
|
|
pub constness: hir::Constness,
|
2016-10-22 18:44:32 +05:30
|
|
|
pub arg_names: LazySeq<ast::Name>,
|
2016-09-16 17:25:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(RustcEncodable, RustcDecodable)]
|
2017-02-15 15:00:20 +02:00
|
|
|
pub struct VariantData<'tcx> {
|
2016-09-15 00:51:46 +03:00
|
|
|
pub ctor_kind: CtorKind,
|
2017-02-05 07:01:48 +02:00
|
|
|
pub discr: ty::VariantDiscr,
|
2017-02-15 15:00:20 +02:00
|
|
|
pub evaluated_discr: Option<ConstVal<'tcx>>,
|
2016-09-16 17:25:54 +03:00
|
|
|
|
|
|
|
/// If this is a struct's only variant, this
|
|
|
|
/// is the index of the "struct ctor" item.
|
2016-10-22 18:44:32 +05:30
|
|
|
pub struct_ctor: Option<DefIndex>,
|
2016-09-16 17:25:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(RustcEncodable, RustcDecodable)]
|
|
|
|
pub struct TraitData<'tcx> {
|
|
|
|
pub unsafety: hir::Unsafety,
|
|
|
|
pub paren_sugar: bool,
|
|
|
|
pub has_default_impl: bool,
|
2016-10-22 18:44:32 +05:30
|
|
|
pub super_predicates: Lazy<ty::GenericPredicates<'tcx>>,
|
2016-09-16 17:25:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(RustcEncodable, RustcDecodable)]
|
|
|
|
pub struct ImplData<'tcx> {
|
|
|
|
pub polarity: hir::ImplPolarity,
|
|
|
|
pub parent_impl: Option<DefId>,
|
|
|
|
pub coerce_unsized_kind: Option<ty::adjustment::CustomCoerceUnsized>,
|
2016-10-22 18:44:32 +05:30
|
|
|
pub trait_ref: Option<Lazy<ty::TraitRef<'tcx>>>,
|
2016-09-16 17:25:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Describes whether the container of an associated item
|
|
|
|
/// is a trait or an impl and whether, in a trait, it has
|
|
|
|
/// a default, or an in impl, whether it's marked "default".
|
|
|
|
#[derive(Copy, Clone, RustcEncodable, RustcDecodable)]
|
|
|
|
pub enum AssociatedContainer {
|
|
|
|
TraitRequired,
|
|
|
|
TraitWithDefault,
|
|
|
|
ImplDefault,
|
2016-10-22 18:44:32 +05:30
|
|
|
ImplFinal,
|
2016-09-16 17:25:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
impl AssociatedContainer {
|
2016-11-10 02:06:34 +02:00
|
|
|
pub fn with_def_id(&self, def_id: DefId) -> ty::AssociatedItemContainer {
|
2016-09-16 17:25:54 +03:00
|
|
|
match *self {
|
|
|
|
AssociatedContainer::TraitRequired |
|
2016-10-22 18:44:32 +05:30
|
|
|
AssociatedContainer::TraitWithDefault => ty::TraitContainer(def_id),
|
2016-09-16 17:25:54 +03:00
|
|
|
|
|
|
|
AssociatedContainer::ImplDefault |
|
2016-10-22 18:44:32 +05:30
|
|
|
AssociatedContainer::ImplFinal => ty::ImplContainer(def_id),
|
2016-09-16 17:25:54 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn defaultness(&self) -> hir::Defaultness {
|
|
|
|
match *self {
|
2016-11-14 11:00:02 -05:00
|
|
|
AssociatedContainer::TraitRequired => hir::Defaultness::Default {
|
|
|
|
has_value: false,
|
|
|
|
},
|
|
|
|
|
2016-09-16 17:25:54 +03:00
|
|
|
AssociatedContainer::TraitWithDefault |
|
2016-11-14 11:00:02 -05:00
|
|
|
AssociatedContainer::ImplDefault => hir::Defaultness::Default {
|
|
|
|
has_value: true,
|
|
|
|
},
|
2016-09-16 17:25:54 +03:00
|
|
|
|
2016-10-22 18:44:32 +05:30
|
|
|
AssociatedContainer::ImplFinal => hir::Defaultness::Final,
|
2016-09-16 17:25:54 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(RustcEncodable, RustcDecodable)]
|
2016-11-10 02:06:34 +02:00
|
|
|
pub struct MethodData {
|
2016-09-16 17:25:54 +03:00
|
|
|
pub fn_data: FnData,
|
|
|
|
pub container: AssociatedContainer,
|
2016-11-10 02:06:34 +02:00
|
|
|
pub has_self: bool,
|
2016-09-16 17:25:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(RustcEncodable, RustcDecodable)]
|
|
|
|
pub struct ClosureData<'tcx> {
|
|
|
|
pub kind: ty::ClosureKind,
|
2017-02-13 10:51:06 +02:00
|
|
|
pub ty: Lazy<ty::PolyFnSig<'tcx>>,
|
2016-09-16 17:25:54 +03:00
|
|
|
}
|