Document rounding down in std::time::Durations's subsec_millis etc.
Now also the documentations of `subsec_millis`, `subsec_micros`, `as_millis` and `as_micros` make clear that the fractional nanosecond component is rounded down to whole units.
Fixed #52263
[RFC 1513](https://github.com/rust-lang/rfcs/blob/master/text/1513-less-unwinding.md).
* [Add a new crate type, 'cdylib'](https://github.com/rust-lang/rust/pull/33553).
cdylibs are dynamic libraries suitable for loading by non-Rust hosts.
- [RFC 1510](https://github.com/rust-lang/rfcs/blob/master/text/1510-rdylib.md).
+ [RFC 1510](https://github.com/rust-lang/rfcs/blob/master/text/1510-cdylib.md).
Note that Cargo does not yet directly support cdylibs.
Stabilized APIs
[[package]]
name = "clippy"
-version = "0.0.211"
+version = "0.0.212"
dependencies = [
"ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
"backtrace 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
"cargo_metadata 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)",
"clippy-mini-macro-test 0.2.0",
- "clippy_lints 0.0.211",
+ "clippy_lints 0.0.212",
"compiletest_rs 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)",
"derive-new 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
[[package]]
name = "clippy_lints"
-version = "0.0.211"
+version = "0.0.212"
dependencies = [
"cargo_metadata 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)",
"if_chain 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
]
-[[package]]
-name = "enum_primitive"
-version = "0.1.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-dependencies = [
- "num-traits 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)",
-]
-
[[package]]
name = "env_logger"
version = "0.5.10"
[[package]]
name = "languageserver-types"
-version = "0.43.0"
+version = "0.45.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
- "enum_primitive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "num-derive 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "num-traits 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.69 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 1.0.69 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_json 1.0.22 (registry+https://github.com/rust-lang/crates.io-index)",
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
-name = "num-integer"
-version = "0.1.39"
+name = "num-derive"
+version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"num-traits 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
+ "proc-macro2 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
+ "quote 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)",
+ "syn 0.14.4 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
-name = "num-traits"
-version = "0.1.43"
+name = "num-integer"
+version = "0.1.39"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"num-traits 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
dependencies = [
"cargo 0.30.0",
"cargo_metadata 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)",
- "clippy_lints 0.0.211",
+ "clippy_lints 0.0.212",
"env_logger 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)",
"failure 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"itertools 0.7.8 (registry+https://github.com/rust-lang/crates.io-index)",
"json 0.11.13 (registry+https://github.com/rust-lang/crates.io-index)",
"jsonrpc-core 8.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "languageserver-types 0.43.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "languageserver-types 0.45.0 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
"num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"checksum either 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3be565ca5c557d7f59e7cfcf1844f9e3033650c929c6566f511e8005f205c1d0"
"checksum elasticlunr-rs 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4837d77a1e157489a3933b743fd774ae75074e0e390b2b7f071530048a0d87ee"
"checksum ena 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)" = "88dc8393b3c7352f94092497f6b52019643e493b6b890eb417cdb7c46117e621"
-"checksum enum_primitive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "be4551092f4d519593039259a9ed8daedf0da12e5109c5280338073eaeb81180"
"checksum env_logger 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)" = "0e6e40ebb0e66918a37b38c7acab4e10d299e0463fe2af5d29b9cc86710cfd2a"
"checksum environment 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1f4b14e20978669064c33b4c1e0fb4083412e40fe56cbea2eae80fd7591503ee"
"checksum error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ff511d5dc435d703f4971bc399647c9bc38e20cb41452e3b9feb4765419ed3f3"
"checksum json 0.11.13 (registry+https://github.com/rust-lang/crates.io-index)" = "9ad0485404155f45cce53a40d4b2d6ac356418300daed05273d9e26f91c390be"
"checksum jsonrpc-core 8.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ddf83704f4e79979a424d1082dd2c1e52683058056c9280efa19ac5f6bc9033c"
"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d"
-"checksum languageserver-types 0.43.0 (registry+https://github.com/rust-lang/crates.io-index)" = "dedb2c8010c9c7530b205fd16ed24a158c3a46634cb0fc61528b17cbbb55df1a"
+"checksum languageserver-types 0.45.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9d91d91d1c23db74187096d191967cb49f49bb175ad6d855fa9229d16ef2c982"
"checksum lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "76f033c7ad61445c5b347c7382dd1237847eb1bce590fe50365dcb33d546be73"
"checksum lazy_static 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e6412c5e2ad9584b0b8e979393122026cdd6d2a80b933f890dcd694ddbe73739"
"checksum lazycell 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a6f08839bc70ef4a3fe1d566d5350f519c5912ea86be0df1740a7d247c7fc0ef"
"checksum miow 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9224c91f82b3c47cf53dcf78dfaa20d6888fbcc5d272d5f2fcdf8a697f3c987d"
"checksum new_debug_unreachable 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0cdc457076c78ab54d5e0d6fa7c47981757f1e34dc39ff92787f217dede586c4"
"checksum nodrop 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "9a2228dca57108069a5262f2ed8bd2e82496d2e074a06d1ccc7ce1687b6ae0a2"
+"checksum num-derive 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0d2c31b75c36a993d30c7a13d70513cb93f02acafdd5b7ba250f9b0e18615de7"
"checksum num-integer 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)" = "e83d528d2677f0518c570baf2b7abdcf0cd2d248860b68507bdcb3e91d4c0cea"
-"checksum num-traits 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)" = "92e5113e9fd4cc14ded8e499429f396a20f98c772a47cc8622a736e1ec843c31"
"checksum num-traits 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "630de1ef5cc79d0cdd78b7e33b81f083cbfe90de0f4b2b2f07f905867c70e9fe"
"checksum num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c51a3322e4bca9d212ad9a158a02abc6934d005490c054a2778df73a70aa0a30"
"checksum open 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c281318d992e4432cfa799969467003d05921582a7489a8325e37f8a450d5113"
"tools/rls/test_data/workspace_symbol",
]
+# Curiously, LLVM 7.0 will segfault if compiled with opt-level=3
+# See issue https://github.com/rust-lang/rust/issues/52378
+[profile.release]
+opt-level = 2
+[profile.bench]
+opt-level = 2
+
# These options are controlled from our rustc wrapper script, so turn them off
# here and have them controlled elsewhere.
[profile.dev]
rustfmt-nightly = { path = "tools/rustfmt" }
[patch."https://github.com/rust-lang-nursery/rust-clippy"]
-clippy = { path = "tools/clippy" }
clippy_lints = { path = "tools/clippy/clippy_lints" }
let target = self.target;
let compiler = self.compiler;
- if let Some(keep_stage) = builder.config.keep_stage {
- if keep_stage <= compiler.stage {
- println!("Warning: Using a potentially old libstd. This may not behave well.");
- builder.ensure(StdLink {
- compiler: compiler,
- target_compiler: compiler,
- target,
- });
- return;
- }
+ if builder.config.keep_stage.contains(&compiler.stage) {
+ builder.info("Warning: Using a potentially old libstd. This may not behave well.");
+ builder.ensure(StdLink {
+ compiler: compiler,
+ target_compiler: compiler,
+ target,
+ });
+ return;
}
builder.ensure(StartupObjects { compiler, target });
let target = self.target;
let compiler = self.compiler;
- if let Some(keep_stage) = builder.config.keep_stage {
- if keep_stage <= compiler.stage {
- println!("Warning: Using a potentially old libtest. This may not behave well.");
- builder.ensure(TestLink {
- compiler: compiler,
- target_compiler: compiler,
- target,
- });
- return;
- }
- }
-
builder.ensure(Std { compiler, target });
+ if builder.config.keep_stage.contains(&compiler.stage) {
+ builder.info("Warning: Using a potentially old libtest. This may not behave well.");
+ builder.ensure(TestLink {
+ compiler: compiler,
+ target_compiler: compiler,
+ target,
+ });
+ return;
+ }
+
if builder.force_use_stage1(compiler, target) {
builder.ensure(Test {
compiler: builder.compiler(1, builder.config.build),
let compiler = self.compiler;
let target = self.target;
- if let Some(keep_stage) = builder.config.keep_stage {
- if keep_stage <= compiler.stage {
- println!("Warning: Using a potentially old librustc. This may not behave well.");
- builder.ensure(RustcLink {
- compiler: compiler,
- target_compiler: compiler,
- target,
- });
- return;
- }
- }
-
builder.ensure(Test { compiler, target });
+ if builder.config.keep_stage.contains(&compiler.stage) {
+ builder.info("Warning: Using a potentially old librustc. This may not behave well.");
+ builder.ensure(RustcLink {
+ compiler: compiler,
+ target_compiler: compiler,
+ target,
+ });
+ return;
+ }
+
if builder.force_use_stage1(compiler, target) {
builder.ensure(Rustc {
compiler: builder.compiler(1, builder.config.build),
builder.ensure(Rustc { compiler, target });
+ if builder.config.keep_stage.contains(&compiler.stage) {
+ builder.info("Warning: Using a potentially old codegen backend. \
+ This may not behave well.");
+ // Codegen backends are linked separately from this step today, so we don't do
+ // anything here.
+ return;
+ }
+
if builder.force_use_stage1(compiler, target) {
builder.ensure(CodegenBackend {
compiler: builder.compiler(1, builder.config.build),
pub on_fail: Option<String>,
pub stage: Option<u32>,
- pub keep_stage: Option<u32>,
+ pub keep_stage: Vec<u32>,
pub src: PathBuf,
pub jobs: Option<u32>,
pub cmd: Subcommand,
pub verbose: usize, // number of -v args; each extra -v after the first is passed to Cargo
pub on_fail: Option<String>,
pub stage: Option<u32>,
- pub keep_stage: Option<u32>,
+ pub keep_stage: Vec<u32>,
pub host: Vec<Interned<String>>,
pub target: Vec<Interned<String>>,
opts.optopt("", "on-fail", "command to run on failure", "CMD");
opts.optflag("", "dry-run", "dry run; don't build anything");
opts.optopt("", "stage", "stage to build", "N");
- opts.optopt("", "keep-stage", "stage to keep without recompiling", "N");
+ opts.optmulti("", "keep-stage", "stage(s) to keep without recompiling", "N");
opts.optopt("", "src", "path to the root of the rust checkout", "DIR");
opts.optopt("j", "jobs", "number of jobs to run in parallel", "JOBS");
opts.optflag("h", "help", "print this help message");
dry_run: matches.opt_present("dry-run"),
on_fail: matches.opt_str("on-fail"),
rustc_error_format: matches.opt_str("error-format"),
- keep_stage: matches.opt_str("keep-stage").map(|j| j.parse().unwrap()),
+ keep_stage: matches.opt_strs("keep-stage")
+ .into_iter().map(|j| j.parse().unwrap())
+ .collect(),
host: split(matches.opt_strs("host"))
.into_iter()
.map(|x| INTERNER.intern_string(x))
/// Since the DefIndex is mostly treated as an opaque ID, you probably
/// don't have to care about these address spaces.
-#[derive(Clone, Eq, Ord, PartialOrd, PartialEq, Hash, Copy)]
+#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Copy)]
pub struct DefIndex(u32);
/// The crate root is always assigned index 0 by the AST Map code,
impl serialize::UseSpecializedEncodable for DefIndex {}
impl serialize::UseSpecializedDecodable for DefIndex {}
-#[derive(Copy, Clone, Eq, PartialEq, Hash)]
+#[derive(Copy, Clone, Hash)]
pub enum DefIndexAddressSpace {
Low = 0,
High = 1,
/// A DefId identifies a particular *definition*, by combining a crate
/// index and a def index.
-#[derive(Clone, Eq, Ord, PartialOrd, PartialEq, Hash, Copy)]
+#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Copy)]
pub struct DefId {
pub krate: CrateNum,
pub index: DefIndex,
/// few cases where we know that only DefIds from the local crate are expected
/// and a DefId from a different crate would signify a bug somewhere. This
/// is when LocalDefId comes in handy.
-#[derive(Clone, Copy, Eq, PartialEq, Ord, PartialOrd, Hash)]
+#[derive(Clone, Copy, PartialEq, Eq, Hash)]
pub struct LocalDefId(DefIndex);
impl LocalDefId {
use std::cmp;
use std::u32;
-#[derive(Copy, Clone, PartialEq, Eq)]
+#[derive(Copy, Clone)]
pub enum FnKind<'a> {
/// #[xxx] pub async/const/extern "Abi" fn foo()
ItemFn(Name, &'a Generics, FnHeader, &'a Visibility, &'a [Attribute]),
// would be to walk it.
}
-#[derive(Copy, Clone, RustcEncodable, RustcDecodable, Debug, PartialEq, Eq)]
+#[derive(Copy, Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct IdRange {
pub min: NodeId,
pub max: NodeId,
}.lower_crate(krate)
}
-#[derive(Copy, Clone, PartialEq, Eq)]
+#[derive(Copy, Clone, PartialEq)]
enum ParamMode {
/// Any path in a type context.
Explicit,
variadic: decl.variadic,
has_implicit_self: decl.inputs.get(0).map_or(false, |arg| match arg.ty.node {
TyKind::ImplicitSelf => true,
- TyKind::Rptr(_, ref mt) => mt.ty.node == TyKind::ImplicitSelf,
+ TyKind::Rptr(_, ref mt) => mt.ty.node.is_implicit_self(),
_ => false,
}),
})
/// A unique identifier that we can use to lookup a definition
/// precisely. It combines the index of the definition's parent (if
/// any) with a `DisambiguatedDefPathData`.
-#[derive(Clone, Debug, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable)]
+#[derive(Clone, PartialEq, Debug, Hash, RustcEncodable, RustcDecodable)]
pub struct DefKey {
/// Parent path.
pub parent: Option<DefIndex>,
/// between them. This introduces some artificial ordering dependency
/// but means that if you have (e.g.) two impls for the same type in
/// the same module, they do get distinct def-ids.
-#[derive(Clone, Debug, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable)]
+#[derive(Clone, PartialEq, Debug, Hash, RustcEncodable, RustcDecodable)]
pub struct DisambiguatedDefPathData {
pub data: DefPathData,
pub disambiguator: u32
}
-#[derive(Clone, Debug, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable)]
+#[derive(Clone, Debug, Hash, RustcEncodable, RustcDecodable)]
pub struct DefPath {
/// the path leading from the crate root to the item
pub data: Vec<DisambiguatedDefPathData>,
}
}
-#[derive(Clone, Debug, Eq, PartialEq, Hash, RustcEncodable, RustcDecodable)]
+#[derive(Clone, Debug, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable)]
pub enum DefPathData {
// Root: these should only be used for the root nodes, because
// they are treated specially by the `def_path` function.
(pub enum GlobalMetaDataKind {
$($variant:ident),*
}) => (
- #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash,
- RustcEncodable, RustcDecodable)]
+ #[derive(Clone, Copy, Debug, Hash, RustcEncodable, RustcDecodable)]
pub enum GlobalMetaDataKind {
$($variant),*
}
/// the local_id part of the HirId changing, which is a very useful property in
/// incremental compilation where we have to persist things through changes to
/// the code base.
-#[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Debug)]
+#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
pub struct HirId {
pub owner: DefIndex,
pub local_id: ItemLocalId,
/// integers starting at zero, so a mapping that maps all or most nodes within
/// an "item-like" to something else can be implement by a `Vec` instead of a
/// tree or hash map.
-#[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Debug,
+#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug,
RustcEncodable, RustcDecodable)]
pub struct ItemLocalId(pub u32);
pub const DUMMY_ITEM_LOCAL_ID: ItemLocalId = ItemLocalId(!0);
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Copy)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Copy)]
pub struct Label {
pub ident: Ident,
}
}
}
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Copy)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Copy)]
pub struct Lifetime {
pub id: NodeId,
pub span: Span,
/// A "Path" is essentially Rust's notion of a name; for instance:
/// `std::cmp::PartialEq`. It's represented as a sequence of identifiers,
/// along with a bunch of supporting information.
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash)]
+#[derive(Clone, RustcEncodable, RustcDecodable)]
pub struct Path {
pub span: Span,
/// The definition that the path resolved to.
/// A segment of a path: an identifier, an optional lifetime, and a set of
/// types.
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct PathSegment {
/// The identifier portion of this path segment.
pub ident: Ident,
}
}
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub enum GenericArg {
Lifetime(Lifetime),
Type(Ty),
}
}
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct GenericArgs {
/// The generic arguments for this path segment.
pub args: HirVec<GenericArg>,
/// typeck::collect::compute_bounds matches these against
/// the "special" built-in traits (see middle::lang_items) and
/// detects Copy, Send and Sync.
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub enum GenericBound {
Trait(PolyTraitRef, TraitBoundModifier),
Outlives(Lifetime),
pub type GenericBounds = HirVec<GenericBound>;
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub enum GenericParamKind {
/// A lifetime definition, eg `'a: 'b + 'c + 'd`.
Lifetime {
}
}
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct GenericParam {
pub id: NodeId,
pub name: ParamName,
/// Represents lifetimes and type parameters attached to a declaration
/// of a function, enum, trait, etc.
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct Generics {
pub params: HirVec<GenericParam>,
pub where_clause: WhereClause,
}
/// A `where` clause in a definition
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct WhereClause {
pub id: NodeId,
pub predicates: HirVec<WherePredicate>,
}
/// A single predicate in a `where` clause
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub enum WherePredicate {
/// A type binding, eg `for<'c> Foo: Send+Clone+'c`
BoundPredicate(WhereBoundPredicate),
}
/// A type bound, eg `for<'c> Foo: Send+Clone+'c`
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct WhereBoundPredicate {
pub span: Span,
/// Any generics from a `for` binding
}
/// A lifetime predicate, e.g. `'a: 'b+'c`
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct WhereRegionPredicate {
pub span: Span,
pub lifetime: Lifetime,
}
/// An equality predicate (unsupported), e.g. `T=int`
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct WhereEqPredicate {
pub id: NodeId,
pub span: Span,
/// For more details, see the [rustc guide].
///
/// [rustc guide]: https://rust-lang-nursery.github.io/rustc-guide/hir.html
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct Crate {
pub module: Mod,
pub attrs: HirVec<Attribute>,
/// A macro definition, in this crate or imported from another.
///
/// Not parsed directly, but created on macro import or `macro_rules!` expansion.
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct MacroDef {
pub name: Name,
pub vis: Visibility,
pub legacy: bool,
}
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct Block {
/// Statements in a block
pub stmts: HirVec<Stmt>,
pub recovered: bool,
}
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash)]
+#[derive(Clone, RustcEncodable, RustcDecodable)]
pub struct Pat {
pub id: NodeId,
pub hir_id: HirId,
/// Patterns like the fields of Foo `{ x, ref y, ref mut z }`
/// are treated the same as` x: x, y: ref y, z: ref mut z`,
/// except is_shorthand is true
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct FieldPat {
pub id: NodeId,
/// The identifier for the field
/// Explicit binding annotations given in the HIR for a binding. Note
/// that this is not the final binding *mode* that we infer after type
/// inference.
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
+#[derive(Clone, PartialEq, RustcEncodable, RustcDecodable, Debug, Copy)]
pub enum BindingAnnotation {
/// No binding annotation given: this means that the final binding mode
/// will depend on whether we have skipped through a `&` reference
RefMut,
}
-#[derive(Copy, Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, Debug)]
pub enum RangeEnd {
Included,
Excluded,
}
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub enum PatKind {
/// Represents a wildcard pattern (`_`)
Wild,
}
}
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
+#[derive(Clone, PartialEq, RustcEncodable, RustcDecodable, Debug, Copy, Hash)]
pub enum BinOp_ {
/// The `+` operator (addition)
BiAdd,
pub type BinOp = Spanned<BinOp_>;
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
+#[derive(Clone, PartialEq, RustcEncodable, RustcDecodable, Debug, Copy, Hash)]
pub enum UnOp {
/// The `*` operator for dereferencing
UnDeref,
}
}
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash)]
+#[derive(Clone, RustcEncodable, RustcDecodable)]
pub enum Stmt_ {
/// Could be an item or a local (let) binding:
StmtDecl(P<Decl>, NodeId),
}
/// Local represents a `let` statement, e.g., `let <pat>:<ty> = <expr>;`
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct Local {
pub pat: P<Pat>,
pub ty: Option<P<Ty>>,
pub type Decl = Spanned<Decl_>;
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub enum Decl_ {
/// A local (let) binding:
DeclLocal(P<Local>),
}
/// represents one arm of a 'match'
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct Arm {
pub attrs: HirVec<Attribute>,
pub pats: HirVec<P<Pat>>,
pub body: P<Expr>,
}
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct Field {
pub id: NodeId,
pub ident: Ident,
pub is_shorthand: bool,
}
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
+#[derive(Clone, PartialEq, RustcEncodable, RustcDecodable, Debug, Copy)]
pub enum BlockCheckMode {
DefaultBlock,
UnsafeBlock(UnsafeSource),
PopUnsafeBlock(UnsafeSource),
}
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
+#[derive(Clone, PartialEq, RustcEncodable, RustcDecodable, Debug, Copy)]
pub enum UnsafeSource {
CompilerGenerated,
UserProvided,
///
/// All bodies have an **owner**, which can be accessed via the HIR
/// map using `body_owner_def_id()`.
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct Body {
pub arguments: HirVec<Arg>,
pub value: Expr,
/// These are usually found nested inside types (e.g. array lengths)
/// or expressions (e.g. repeat counts), and also used to define
/// explicit discriminant values for enum variants.
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Debug)]
pub struct AnonConst {
pub id: NodeId,
pub hir_id: HirId,
}
/// An expression
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash)]
+#[derive(Clone, RustcEncodable, RustcDecodable)]
pub struct Expr {
pub id: NodeId,
pub span: Span,
}
}
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub enum Expr_ {
/// A `box x` expression.
ExprBox(P<Expr>),
}
/// Optionally `Self`-qualified value/type path or associated extension.
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub enum QPath {
/// Path to a definition, optionally "fully-qualified" with a `Self`
/// type, if the path points to an associated item in a trait.
}
/// Hints at the original code for a let statement
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug, Copy)]
pub enum LocalSource {
/// A `match _ { .. }`
Normal,
}
/// The loop type that yielded an ExprLoop
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
+#[derive(Clone, PartialEq, RustcEncodable, RustcDecodable, Debug, Copy)]
pub enum LoopSource {
/// A `loop { .. }` loop
Loop,
ForLoop,
}
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug, Copy)]
pub enum LoopIdError {
OutsideLoopScope,
UnlabeledCfInWhileCondition,
}
}
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug, Copy)]
pub struct Destination {
// This is `Some(_)` iff there is an explicit user-specified `label
pub label: Option<Label>,
Movable,
}
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug, Copy)]
pub enum CaptureClause {
CaptureByValue,
CaptureByRef,
// NB: If you change this, you'll probably want to change the corresponding
// type structure in middle/ty.rs as well.
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct MutTy {
pub ty: P<Ty>,
pub mutbl: Mutability,
}
/// Represents a method's signature in a trait declaration or implementation.
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct MethodSig {
pub header: FnHeader,
pub decl: P<FnDecl>,
// The bodies for items are stored "out of line", in a separate
// hashmap in the `Crate`. Here we just record the node-id of the item
// so it can fetched later.
-#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, RustcEncodable, RustcDecodable, Debug)]
pub struct TraitItemId {
pub node_id: NodeId,
}
/// possibly including a default implementation. A trait item is
/// either required (meaning it doesn't have an implementation, just a
/// signature) or provided (meaning it has a default implementation).
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct TraitItem {
pub id: NodeId,
pub ident: Ident,
}
/// A trait method's body (or just argument names).
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub enum TraitMethod {
/// No default body in the trait, just a signature.
Required(HirVec<Ident>),
}
/// Represents a trait method or associated constant or type
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub enum TraitItemKind {
/// An associated constant with an optional value (otherwise `impl`s
/// must contain a value)
// The bodies for items are stored "out of line", in a separate
// hashmap in the `Crate`. Here we just record the node-id of the item
// so it can fetched later.
-#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, RustcEncodable, RustcDecodable, Debug)]
pub struct ImplItemId {
pub node_id: NodeId,
}
/// Represents anything within an `impl` block
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct ImplItem {
pub id: NodeId,
pub ident: Ident,
}
/// Represents different contents within `impl`s
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub enum ImplItemKind {
/// An associated constant of the given type, set to the constant result
/// of the expression
}
// Bind a type to an associated type: `A=Foo`.
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct TypeBinding {
pub id: NodeId,
pub ident: Ident,
}
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash)]
+#[derive(Clone, RustcEncodable, RustcDecodable)]
pub struct Ty {
pub id: NodeId,
pub node: Ty_,
TyChar,
}
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct BareFnTy {
pub unsafety: Unsafety,
pub abi: Abi,
pub arg_names: HirVec<Ident>,
}
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct ExistTy {
pub generics: Generics,
pub bounds: GenericBounds,
pub impl_trait_fn: Option<DefId>,
}
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
/// The different kinds of types recognized by the compiler
pub enum Ty_ {
/// A variable length slice (`[T]`)
TyErr,
}
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct InlineAsmOutput {
pub constraint: Symbol,
pub is_rw: bool,
pub is_indirect: bool,
}
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct InlineAsm {
pub asm: Symbol,
pub asm_str_style: StrStyle,
}
/// represents an argument in a function header
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct Arg {
pub pat: P<Pat>,
pub id: NodeId,
}
/// Represents the header (not the body) of a function declaration
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct FnDecl {
pub inputs: HirVec<Ty>,
pub output: FunctionRetTy,
}
/// Is the trait definition an auto trait?
-#[derive(Copy, Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, Debug)]
pub enum IsAuto {
Yes,
No
}
-#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, RustcEncodable, RustcDecodable, Debug)]
pub enum IsAsync {
Async,
NotAsync,
Normal,
}
-#[derive(Copy, Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, Debug)]
pub enum Constness {
Const,
NotConst,
}
-#[derive(Copy, Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, Debug)]
pub enum Defaultness {
Default { has_value: bool },
Final,
}
}
-#[derive(Copy, Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash)]
+#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable)]
pub enum ImplPolarity {
/// `impl Trait for Type`
Positive,
}
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub enum FunctionRetTy {
/// Return type is not specified.
///
}
}
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct Mod {
/// A span from the first token past `{` to the last token until `}`.
/// For `mod foo;`, the inner span ranges from the first token
pub item_ids: HirVec<ItemId>,
}
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct ForeignMod {
pub abi: Abi,
pub items: HirVec<ForeignItem>,
}
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct GlobalAsm {
pub asm: Symbol,
pub ctxt: SyntaxContext,
}
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct EnumDef {
pub variants: HirVec<Variant>,
}
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct Variant_ {
pub name: Name,
pub attrs: HirVec<Attribute>,
pub type Variant = Spanned<Variant_>;
-#[derive(Copy, Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, Debug)]
pub enum UseKind {
/// One import, e.g. `use foo::bar` or `use foo::bar as baz`.
/// Also produced for each element of a list `use`, e.g.
/// that the ref_id is for. Note that ref_id's value is not the NodeId of the
/// trait being referred to but just a unique NodeId that serves as a key
/// within the DefMap.
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct TraitRef {
pub path: Path,
pub ref_id: NodeId,
}
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct PolyTraitRef {
/// The `'a` in `<'a> Foo<&'a T>`
pub bound_generic_params: HirVec<GenericParam>,
pub type Visibility = Spanned<VisibilityKind>;
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub enum VisibilityKind {
Public,
Crate(CrateSugar),
}
}
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct StructField {
pub span: Span,
pub ident: Ident,
/// used for `Struct`-structs (but still presents). Structures don't have an analogue of "Id of
/// the variant itself" from enum variants.
/// Id of the whole struct lives in `Item`.
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub enum VariantData {
Struct(HirVec<StructField>, NodeId),
Tuple(HirVec<StructField>, NodeId),
// The bodies for items are stored "out of line", in a separate
// hashmap in the `Crate`. Here we just record the node-id of the item
// so it can fetched later.
-#[derive(Copy, Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Copy, Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct ItemId {
pub id: NodeId,
}
/// An item
///
/// The name might be a dummy name in case of anonymous items
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct Item {
pub name: Name,
pub id: NodeId,
pub span: Span,
}
-#[derive(Clone, Copy, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, Copy, RustcEncodable, RustcDecodable, Debug)]
pub struct FnHeader {
pub unsafety: Unsafety,
pub constness: Constness,
pub abi: Abi,
}
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub enum Item_ {
/// An `extern crate` item, with optional *original* crate name if the crate was renamed.
///
/// type or method, and whether it is public). This allows other
/// passes to find the impl they want without loading the id (which
/// means fewer edges in the incremental compilation graph).
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct TraitItemRef {
pub id: TraitItemId,
pub ident: Ident,
/// type or method, and whether it is public). This allows other
/// passes to find the impl they want without loading the id (which
/// means fewer edges in the incremental compilation graph).
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct ImplItemRef {
pub id: ImplItemId,
pub ident: Ident,
pub defaultness: Defaultness,
}
-#[derive(Copy, Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, Debug)]
pub enum AssociatedItemKind {
Const,
Method { has_self: bool },
Type,
}
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct ForeignItem {
pub name: Name,
pub attrs: HirVec<Attribute>,
}
/// An item within an `extern` block
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub enum ForeignItem_ {
/// A foreign function
ForeignItemFn(P<FnDecl>, HirVec<Ident>, Generics),
providers.describe_def = map::describe_def;
}
-#[derive(Clone, RustcEncodable, RustcDecodable, Hash)]
+#[derive(Clone, RustcEncodable, RustcDecodable)]
pub struct CodegenFnAttrs {
pub flags: CodegenFnAttrFlags,
pub inline: InlineAttr,
if !before.is_empty() {
self.word_space(",")?;
}
- if p.node != PatKind::Wild {
+ if let PatKind::Wild = p.node {
+ // Print nothing
+ } else {
self.print_pat(&p)?;
}
self.s.word("..")?;
s.ann.nested(s, Nested::BodyArgPat(body_id, i))?;
i += 1;
- if ty.node != hir::TyInfer {
+ if let hir::TyInfer = ty.node {
+ // Print nothing
+ } else {
s.s.word(":")?;
s.s.space()?;
s.print_type(ty)?;
let (span_1, span_2, main_label, span_label) = match (sup_is_ret_type, sub_is_ret_type) {
(None, None) => {
- let (main_label_1, span_label_1) = if ty_sup == ty_sub {
+ let (main_label_1, span_label_1) = if ty_sup.id == ty_sub.id {
(
format!("this type is declared with multiple lifetimes..."),
format!(
NativeUnknown,
}
-#[derive(Clone, Hash, RustcEncodable, RustcDecodable)]
+#[derive(Clone, RustcEncodable, RustcDecodable)]
pub struct NativeLibrary {
pub kind: NativeLibraryKind,
pub name: Symbol,
fn should_warn_about_field(&mut self, field: &hir::StructField) -> bool {
let field_type = self.tcx.type_of(self.tcx.hir.local_def_id(field.id));
- let is_marker_field = match field_type.ty_to_def_id() {
- Some(def_id) => self.tcx.lang_items().items().iter().any(|item| *item == Some(def_id)),
- _ => false
- };
!field.is_positional()
&& !self.symbol_is_live(field.id, None)
- && !is_marker_field
+ && !field_type.is_phantom_data()
&& !has_allow_dead_code_or_lang_attr(self.tcx, field.id, &field.attrs)
}
flags.push((name, Some(value)));
}
- if let Some(true) = self_ty.ty_to_def_id().map(|def_id| def_id.is_local()) {
+ if let Some(true) = self_ty.ty_adt_def().map(|def| def.did.is_local()) {
flags.push(("crate_local".to_string(), None));
}
}
let found_trait_ty = found_trait_ref.self_ty();
- let found_did = found_trait_ty.ty_to_def_id();
+ let found_did = match found_trait_ty.sty {
+ ty::TyClosure(did, _) |
+ ty::TyForeign(did) |
+ ty::TyFnDef(did, _) => Some(did),
+ ty::TyAdt(def, _) => Some(def.did),
+ _ => None,
+ };
let found_span = found_did.and_then(|did| {
self.tcx.hir.span_if_local(did)
}).map(|sp| self.tcx.sess.codemap().def_span(sp)); // the sp could be an fn def
pub predicates: Vec<Predicate<'tcx>>,
}
-#[derive(Copy, Clone, Debug, PartialEq, Eq)]
+#[derive(Copy, Clone, Debug, PartialEq)]
pub struct AssociatedItem {
pub def_id: DefId,
pub ident: Ident,
}
}
- pub fn ty_to_def_id(&self) -> Option<DefId> {
- match self.sty {
- TyDynamic(ref tt, ..) => tt.principal().map(|p| p.def_id()),
- TyAdt(def, _) => Some(def.did),
- TyForeign(did) => Some(did),
- TyClosure(id, _) => Some(id),
- TyFnDef(id, _) => Some(id),
- _ => None,
- }
- }
-
pub fn ty_adt_def(&self) -> Option<&'tcx AdtDef> {
match self.sty {
TyAdt(adt, _) => Some(adt),
}
struct DiagnosticHandlers<'a> {
- inner: Box<(&'a CodegenContext, &'a Handler)>,
+ data: *mut (&'a CodegenContext, &'a Handler),
llcx: ContextRef,
}
fn new(cgcx: &'a CodegenContext,
handler: &'a Handler,
llcx: ContextRef) -> DiagnosticHandlers<'a> {
- let data = Box::new((cgcx, handler));
+ let data = Box::into_raw(Box::new((cgcx, handler)));
unsafe {
- let arg = &*data as &(_, _) as *const _ as *mut _;
- llvm::LLVMRustSetInlineAsmDiagnosticHandler(llcx, inline_asm_handler, arg);
- llvm::LLVMContextSetDiagnosticHandler(llcx, diagnostic_handler, arg);
- }
- DiagnosticHandlers {
- inner: data,
- llcx: llcx,
+ llvm::LLVMRustSetInlineAsmDiagnosticHandler(llcx, inline_asm_handler, data as *mut _);
+ llvm::LLVMContextSetDiagnosticHandler(llcx, diagnostic_handler, data as *mut _);
}
+ DiagnosticHandlers { data, llcx }
}
}
impl<'a> Drop for DiagnosticHandlers<'a> {
fn drop(&mut self) {
+ use std::ptr::null_mut;
unsafe {
- llvm::LLVMRustSetInlineAsmDiagnosticHandler(self.llcx, inline_asm_handler, 0 as *mut _);
- llvm::LLVMContextSetDiagnosticHandler(self.llcx, diagnostic_handler, 0 as *mut _);
+ llvm::LLVMRustSetInlineAsmDiagnosticHandler(self.llcx, inline_asm_handler, null_mut());
+ llvm::LLVMContextSetDiagnosticHandler(self.llcx, diagnostic_handler, null_mut());
+ drop(Box::from_raw(self.data));
}
}
}
hir::ItemUnion(..) => "a union",
hir::ItemTrait(.., ref trait_item_refs) => {
// Issue #11592, traits are always considered exported, even when private.
- if it.vis.node == hir::VisibilityKind::Inherited {
+ if let hir::VisibilityKind::Inherited = it.vis.node {
self.private_traits.insert(it.id);
for trait_item_ref in trait_item_refs {
self.private_traits.insert(trait_item_ref.id.node_id);
if let Some(node_id) = cx.tcx.hir.as_local_node_id(real_trait) {
match cx.tcx.hir.find(node_id) {
Some(hir_map::NodeItem(item)) => {
- if item.vis.node == hir::VisibilityKind::Inherited {
+ if let hir::VisibilityKind::Inherited = item.vis.node {
for impl_item_ref in impl_item_refs {
self.private_traits.insert(impl_item_ref.id.node_id);
}
if self.impling_types.is_none() {
let mut impls = NodeSet();
cx.tcx.for_each_impl(debug, |d| {
- if let Some(ty_def) = cx.tcx.type_of(d).ty_to_def_id() {
- if let Some(node_id) = cx.tcx.hir.as_local_node_id(ty_def) {
+ if let Some(ty_def) = cx.tcx.type_of(d).ty_adt_def() {
+ if let Some(node_id) = cx.tcx.hir.as_local_node_id(ty_def.did) {
impls.insert(node_id);
}
}
}
fn invalid_visibility(&self, vis: &Visibility, note: Option<&str>) {
- if vis.node != VisibilityKind::Inherited {
- let mut err = struct_span_err!(self.session,
- vis.span,
- E0449,
- "unnecessary visibility qualifier");
- if vis.node == VisibilityKind::Public {
- err.span_label(vis.span, "`pub` not permitted here because it's implied");
- }
- if let Some(note) = note {
- err.note(note);
- }
- err.emit();
+ if let VisibilityKind::Inherited = vis.node {
+ return
+ }
+
+ let mut err = struct_span_err!(self.session,
+ vis.span,
+ E0449,
+ "unnecessary visibility qualifier");
+ if vis.node.is_pub() {
+ err.span_label(vis.span, "`pub` not permitted here because it's implied");
+ }
+ if let Some(note) = note {
+ err.note(note);
}
+ err.emit();
}
fn check_decl_no_pat<ReportFn: Fn(Span, bool)>(&self, decl: &FnDecl, report_err: ReportFn) {
match item.node {
ItemKind::Impl(unsafety, polarity, _, _, Some(..), ref ty, ref impl_items) => {
self.invalid_visibility(&item.vis, None);
- if ty.node == TyKind::Err {
+ if let TyKind::Err = ty.node {
self.err_handler()
.struct_span_err(item.span, "`impl Trait for .. {}` is an obsolete syntax")
.help("use `auto trait Trait {}` instead").emit();
use syntax::ast;
use syntax::attr;
use syntax_pos::{Span, DUMMY_SP};
+use self::Promotability::*;
+use std::ops::{BitAnd, BitOr};
+
pub fn provide(providers: &mut Providers) {
*providers = Providers {
tables: &ty::TypeckTables::empty(None),
in_fn: false,
in_static: false,
- promotable: false,
mut_rvalue_borrows: NodeSet(),
param_env: ty::ParamEnv::empty(),
identity_substs: Substs::empty(),
let node_id = tcx.hir.as_local_node_id(def_id)
.expect("rvalue_promotable_map invoked with non-local def-id");
let body_id = tcx.hir.body_owned_by(node_id);
- visitor.visit_nested_body(body_id);
+ let _ = visitor.check_nested_body(body_id);
Lrc::new(visitor.result)
}
tcx: TyCtxt<'a, 'tcx, 'tcx>,
in_fn: bool,
in_static: bool,
- promotable: bool,
mut_rvalue_borrows: NodeSet,
param_env: ty::ParamEnv<'tcx>,
identity_substs: &'tcx Substs<'tcx>,
result: ItemLocalSet,
}
+#[must_use]
+#[derive(Debug, PartialEq)]
+enum Promotability {
+ Promotable,
+ NotPromotable
+}
+
+impl BitAnd for Promotability {
+ type Output = Self;
+
+ fn bitand(self, rhs: Self) -> Self {
+ match (self, rhs) {
+ (Promotable, NotPromotable) => NotPromotable,
+ (NotPromotable, Promotable) => NotPromotable,
+ (NotPromotable, NotPromotable) => NotPromotable,
+ (Promotable, Promotable) => Promotable,
+ }
+ }
+}
+
+impl BitOr for Promotability {
+ type Output = Self;
+
+ fn bitor(self, rhs: Self) -> Self {
+ match (self, rhs) {
+ (Promotable, NotPromotable) => Promotable,
+ (NotPromotable, Promotable) => Promotable,
+ (NotPromotable, NotPromotable) => NotPromotable,
+ (Promotable, Promotable) => Promotable,
+ }
+ }
+}
+
impl<'a, 'gcx> CheckCrateVisitor<'a, 'gcx> {
// Returns true iff all the values of the type are promotable.
- fn type_has_only_promotable_values(&mut self, ty: Ty<'gcx>) -> bool {
- ty.is_freeze(self.tcx, self.param_env, DUMMY_SP) &&
- !ty.needs_drop(self.tcx, self.param_env)
+ fn type_promotability(&mut self, ty: Ty<'gcx>) -> Promotability {
+ debug!("type_promotability({})", ty);
+
+ if ty.is_freeze(self.tcx, self.param_env, DUMMY_SP) &&
+ !ty.needs_drop(self.tcx, self.param_env) {
+ Promotable
+ } else {
+ NotPromotable
+ }
}
- fn handle_const_fn_call(&mut self, def_id: DefId, ret_ty: Ty<'gcx>, span: Span) {
- self.promotable &= self.type_has_only_promotable_values(ret_ty);
+ fn handle_const_fn_call(&mut self, def_id: DefId,
+ ret_ty: Ty<'gcx>, span: Span) -> Promotability {
+ if let NotPromotable = self.type_promotability(ret_ty) {
+ return NotPromotable;
+ }
- self.promotable &= if let Some(fn_id) = self.tcx.hir.as_local_node_id(def_id) {
+ let node_check = if let Some(fn_id) = self.tcx.hir.as_local_node_id(def_id) {
FnLikeNode::from_node(self.tcx.hir.get(fn_id)).map_or(false, |fn_like| {
fn_like.constness() == hir::Constness::Const
})
self.tcx.is_const_fn(def_id)
};
+ if !node_check {
+ return NotPromotable
+ }
+
if let Some(&attr::Stability {
rustc_const_unstable: Some(attr::RustcConstUnstable {
feature: ref feature_name
}),
.. }) = self.tcx.lookup_stability(def_id) {
- self.promotable &=
+ let stable_check =
// feature-gate is enabled,
self.tcx.features()
.declared_lib_features
// this comes from a macro that has #[allow_internal_unstable]
span.allows_unstable();
- }
+ if !stable_check {
+ return NotPromotable
+ }
+ };
+ Promotable
}
/// While the `ExprUseVisitor` walks, we will identify which
}
impl<'a, 'tcx> CheckCrateVisitor<'a, 'tcx> {
- fn visit_nested_body(&mut self, body_id: hir::BodyId) {
+ fn check_nested_body(&mut self, body_id: hir::BodyId) -> Promotability {
let item_id = self.tcx.hir.body_owner(body_id);
let item_def_id = self.tcx.hir.local_def_id(item_id);
euv::ExprUseVisitor::new(self, tcx, param_env, ®ion_scope_tree, self.tables, None)
.consume_body(body);
- self.visit_expr(&body.value);
+ let body_promotable = self.check_expr(&body.value);
self.in_fn = outer_in_fn;
self.tables = outer_tables;
self.param_env = outer_param_env;
self.identity_substs = outer_identity_substs;
+ body_promotable
}
- fn visit_stmt(&mut self, stmt: &'tcx hir::Stmt) {
+ fn check_stmt(&mut self, stmt: &'tcx hir::Stmt) -> Promotability {
match stmt.node {
hir::StmtDecl(ref decl, _node_id) => {
match &decl.node {
hir::DeclLocal(local) => {
- self.promotable = false;
if self.remove_mut_rvalue_borrow(&local.pat) {
if let Some(init) = &local.init {
self.mut_rvalue_borrows.insert(init.id);
}
match local.init {
- Some(ref expr) => self.visit_expr(&expr),
+ Some(ref expr) => { let _ = self.check_expr(&expr); },
None => {},
}
+ NotPromotable
}
// Item statements are allowed
- hir::DeclItem(_) => {}
+ hir::DeclItem(_) => Promotable
}
}
hir::StmtExpr(ref box_expr, _node_id) |
hir::StmtSemi(ref box_expr, _node_id) => {
- self.visit_expr(box_expr);
- self.promotable = false;
+ let _ = self.check_expr(box_expr);
+ NotPromotable
}
}
}
- fn visit_expr(&mut self, ex: &'tcx hir::Expr) {
- let outer = self.promotable;
- self.promotable = true;
-
+ fn check_expr(&mut self, ex: &'tcx hir::Expr) -> Promotability {
let node_ty = self.tables.node_id_to_type(ex.hir_id);
- check_expr(self, ex, node_ty);
- check_adjustments(self, ex);
+ let mut outer = check_expr_kind(self, ex, node_ty);
+ outer = outer & check_adjustments(self, ex);
// Handle borrows on (or inside the autorefs of) this expression.
if self.mut_rvalue_borrows.remove(&ex.id) {
- self.promotable = false;
+ outer = NotPromotable
}
- if self.promotable {
+ if outer == Promotable {
self.result.insert(ex.hir_id.local_id);
}
- self.promotable &= outer;
+ outer
}
- fn visit_block(&mut self, block: &'tcx hir::Block) {
+ fn check_block(&mut self, block: &'tcx hir::Block) -> Promotability {
+ let mut iter_result = Promotable;
for index in block.stmts.iter() {
- self.visit_stmt(index)
+ iter_result = iter_result & self.check_stmt(index);
}
match block.expr {
- Some(ref box_expr) => { self.visit_expr(&*box_expr) },
- None => {},
+ Some(ref box_expr) => iter_result & self.check_expr(&*box_expr),
+ None => iter_result,
}
}
}
/// every nested expression. If the expression is not part
/// of a const/static item, it is qualified for promotion
/// instead of producing errors.
-fn check_expr<'a, 'tcx>(
+fn check_expr_kind<'a, 'tcx>(
v: &mut CheckCrateVisitor<'a, 'tcx>,
- e: &'tcx hir::Expr, node_ty: Ty<'tcx>) {
- match node_ty.sty {
+ e: &'tcx hir::Expr, node_ty: Ty<'tcx>) -> Promotability {
+
+ let ty_result = match node_ty.sty {
ty::TyAdt(def, _) if def.has_dtor(v.tcx) => {
- v.promotable = false;
+ NotPromotable
}
- _ => {}
- }
+ _ => Promotable
+ };
- match e.node {
+ let node_result = match e.node {
hir::ExprBox(ref expr) => {
- v.visit_expr(&expr);
- v.promotable = false;
+ let _ = v.check_expr(&expr);
+ NotPromotable
}
hir::ExprUnary(op, ref expr) => {
+ let expr_promotability = v.check_expr(expr);
if v.tables.is_method_call(e) {
- v.promotable = false;
+ return NotPromotable;
}
if op == hir::UnDeref {
- v.promotable = false;
+ return NotPromotable;
}
- v.visit_expr(expr);
+ expr_promotability
}
hir::ExprBinary(op, ref lhs, ref rhs) => {
+ let lefty = v.check_expr(lhs);
+ let righty = v.check_expr(rhs);
if v.tables.is_method_call(e) {
- v.promotable = false;
+ return NotPromotable;
}
- v.visit_expr(lhs);
- v.visit_expr(rhs);
match v.tables.node_id_to_type(lhs.hir_id).sty {
ty::TyRawPtr(_) => {
assert!(op.node == hir::BiEq || op.node == hir::BiNe ||
op.node == hir::BiLe || op.node == hir::BiLt ||
op.node == hir::BiGe || op.node == hir::BiGt);
- v.promotable = false;
+ NotPromotable
}
- _ => {}
+ _ => lefty & righty
}
}
hir::ExprCast(ref from, _) => {
- v.visit_expr(from);
+ let expr_promotability = v.check_expr(from);
debug!("Checking const cast(id={})", from.id);
match v.tables.cast_kinds().get(from.hir_id) {
- None => v.tcx.sess.delay_span_bug(e.span, "no kind for cast"),
+ None => {
+ v.tcx.sess.delay_span_bug(e.span, "no kind for cast");
+ NotPromotable
+ },
Some(&CastKind::PtrAddrCast) | Some(&CastKind::FnPtrAddrCast) => {
- v.promotable = false;
+ NotPromotable
}
- _ => {}
+ _ => expr_promotability
}
}
hir::ExprPath(ref qpath) => {
let def = v.tables.qpath_def(qpath, e.hir_id);
match def {
Def::VariantCtor(..) | Def::StructCtor(..) |
- Def::Fn(..) | Def::Method(..) => {}
+ Def::Fn(..) | Def::Method(..) => Promotable,
// References to a static that are themselves within a static
// are inherently promotable with the exception
Def::Static(did, _) => {
if v.in_static {
- let mut thread_local = false;
-
for attr in &v.tcx.get_attrs(did)[..] {
if attr.check_name("thread_local") {
debug!("Reference to Static(id={:?}) is unpromotable \
due to a #[thread_local] attribute", did);
- v.promotable = false;
- thread_local = true;
- break;
+ return NotPromotable;
}
}
-
- if !thread_local {
- debug!("Allowing promotion of reference to Static(id={:?})", did);
- }
+ Promotable
} else {
debug!("Reference to Static(id={:?}) is unpromotable as it is not \
referenced from a static", did);
- v.promotable = false;
+ NotPromotable
}
}
Def::AssociatedConst(did) => {
let promotable = if v.tcx.trait_of_item(did).is_some() {
// Don't peek inside trait associated constants.
- false
+ NotPromotable
+ } else if v.tcx.at(e.span).const_is_rvalue_promotable_to_static(did) {
+ Promotable
} else {
- v.tcx.at(e.span).const_is_rvalue_promotable_to_static(did)
+ NotPromotable
};
-
// Just in case the type is more specific than the definition,
// e.g. impl associated const with type parameters, check it.
// Also, trait associated consts are relaxed by this.
- v.promotable &= promotable || v.type_has_only_promotable_values(node_ty);
- }
-
- _ => {
- v.promotable = false;
+ promotable | v.type_promotability(node_ty)
}
+ _ => NotPromotable
}
}
hir::ExprCall(ref callee, ref hirvec) => {
- v.visit_expr(callee);
+ let mut call_result = v.check_expr(callee);
for index in hirvec.iter() {
- v.visit_expr(index)
+ call_result = call_result & v.check_expr(index);
}
let mut callee = &**callee;
loop {
} else {
Def::Err
};
- match def {
+ let def_result = match def {
Def::StructCtor(_, CtorKind::Fn) |
- Def::VariantCtor(_, CtorKind::Fn) => {}
+ Def::VariantCtor(_, CtorKind::Fn) => Promotable,
Def::Fn(did) => {
v.handle_const_fn_call(did, node_ty, e.span)
}
ty::ImplContainer(_) => {
v.handle_const_fn_call(did, node_ty, e.span)
}
- ty::TraitContainer(_) => v.promotable = false
+ ty::TraitContainer(_) => NotPromotable,
}
}
- _ => v.promotable = false
- }
+ _ => NotPromotable,
+ };
+ def_result & call_result
}
hir::ExprMethodCall(ref _pathsegment, ref _span, ref hirvec) => {
+ let mut method_call_result = Promotable;
for index in hirvec.iter() {
- v.visit_expr(index)
+ method_call_result = method_call_result & v.check_expr(index);
}
if let Some(def) = v.tables.type_dependent_defs().get(e.hir_id) {
let def_id = def.def_id();
match v.tcx.associated_item(def_id).container {
- ty::ImplContainer(_) => v.handle_const_fn_call(def_id, node_ty, e.span),
- ty::TraitContainer(_) => v.promotable = false
- }
+ ty::ImplContainer(_) => {
+ method_call_result = method_call_result
+ & v.handle_const_fn_call(def_id, node_ty, e.span);
+ }
+ ty::TraitContainer(_) => return NotPromotable,
+ };
} else {
v.tcx.sess.delay_span_bug(e.span, "no type-dependent def for method call");
}
+ method_call_result
}
hir::ExprStruct(ref _qpath, ref hirvec, ref option_expr) => {
+ let mut struct_result = Promotable;
for index in hirvec.iter() {
- v.visit_expr(&index.expr);
+ struct_result = struct_result & v.check_expr(&index.expr);
}
match *option_expr {
- Some(ref expr) => { v.visit_expr(&expr) },
+ Some(ref expr) => { struct_result = struct_result & v.check_expr(&expr); },
None => {},
}
if let ty::TyAdt(adt, ..) = v.tables.expr_ty(e).sty {
// unsafe_cell_type doesn't necessarily exist with no_core
if Some(adt.did) == v.tcx.lang_items().unsafe_cell_type() {
- v.promotable = false;
+ return NotPromotable;
}
}
+ struct_result
}
- hir::ExprLit(_) => {}
+ hir::ExprLit(_) => Promotable,
hir::ExprAddrOf(_, ref expr) |
hir::ExprRepeat(ref expr, _) => {
- v.visit_expr(expr);
+ v.check_expr(&expr)
}
hir::ExprClosure(_capture_clause, ref _box_fn_decl,
body_id, _span, _option_generator_movability) => {
- v.visit_nested_body(body_id);
+ let nested_body_promotable = v.check_nested_body(body_id);
// Paths in constant contexts cannot refer to local variables,
// as there are none, and thus closures can't have upvars there.
if v.tcx.with_freevars(e.id, |fv| !fv.is_empty()) {
- v.promotable = false;
+ NotPromotable
+ } else {
+ nested_body_promotable
}
}
hir::ExprField(ref expr, _ident) => {
- v.visit_expr(expr);
+ let expr_promotability = v.check_expr(&expr);
if let Some(def) = v.tables.expr_ty(expr).ty_adt_def() {
if def.is_union() {
- v.promotable = false
+ return NotPromotable;
}
}
+ expr_promotability
}
hir::ExprBlock(ref box_block, ref _option_label) => {
- v.visit_block(box_block);
+ v.check_block(box_block)
}
hir::ExprIndex(ref lhs, ref rhs) => {
+ let lefty = v.check_expr(lhs);
+ let righty = v.check_expr(rhs);
if v.tables.is_method_call(e) {
- v.promotable = false;
+ return NotPromotable;
}
- v.visit_expr(lhs);
- v.visit_expr(rhs);
+ lefty & righty
}
hir::ExprArray(ref hirvec) => {
+ let mut array_result = Promotable;
for index in hirvec.iter() {
- v.visit_expr(index)
+ array_result = array_result & v.check_expr(index);
}
+ array_result
}
hir::ExprType(ref expr, ref _ty) => {
- v.visit_expr(expr);
+ v.check_expr(&expr)
}
hir::ExprTup(ref hirvec) => {
+ let mut tup_result = Promotable;
for index in hirvec.iter() {
- v.visit_expr(index)
+ tup_result = tup_result & v.check_expr(index);
}
+ tup_result
}
v.mut_rvalue_borrows.insert(expr.id);
}
- v.visit_expr(expr);
+ let _ = v.check_expr(expr);
for index in hirvec_arm.iter() {
- v.visit_expr(&*index.body);
+ let _ = v.check_expr(&*index.body);
match index.guard {
- Some(ref expr) => v.visit_expr(&expr),
+ Some(ref expr) => {
+ let _ = v.check_expr(&expr);
+ },
None => {},
- }
+ };
}
- v.promotable = false;
+ NotPromotable
}
hir::ExprIf(ref lhs, ref rhs, ref option_expr) => {
- v.visit_expr(lhs);
- v.visit_expr(rhs);
+ let _ = v.check_expr(lhs);
+ let _ = v.check_expr(rhs);
match option_expr {
- Some(ref expr) => v.visit_expr(&expr),
+ Some(ref expr) => { let _ = v.check_expr(&expr); },
None => {},
- }
- v.promotable = false;
+ };
+ NotPromotable
}
// Loops (not very meaningful in constants).
hir::ExprWhile(ref expr, ref box_block, ref _option_label) => {
- v.visit_expr(expr);
- v.visit_block(box_block);
- v.promotable = false;
+ let _ = v.check_expr(expr);
+ let _ = v.check_block(box_block);
+ NotPromotable
}
hir::ExprLoop(ref box_block, ref _option_label, ref _loop_source) => {
- v.visit_block(box_block);
- v.promotable = false;
+ let _ = v.check_block(box_block);
+ NotPromotable
}
// More control flow (also not very meaningful).
hir::ExprBreak(_, ref option_expr) | hir::ExprRet(ref option_expr) => {
match *option_expr {
- Some(ref expr) => { v.visit_expr(&expr) },
+ Some(ref expr) => { let _ = v.check_expr(&expr); },
None => {},
}
- v.promotable = false;
+ NotPromotable
}
hir::ExprContinue(_) => {
- v.promotable = false;
+ NotPromotable
}
// Generator expressions
hir::ExprYield(ref expr) => {
- v.visit_expr(&expr);
- v.promotable = false;
+ let _ = v.check_expr(&expr);
+ NotPromotable
}
// Expressions with side-effects.
hir::ExprAssignOp(_, ref lhs, ref rhs) | hir::ExprAssign(ref lhs, ref rhs) => {
- v.visit_expr(lhs);
- v.visit_expr(rhs);
- v.promotable = false;
+ let _ = v.check_expr(lhs);
+ let _ = v.check_expr(rhs);
+ NotPromotable
}
hir::ExprInlineAsm(ref _inline_asm, ref hirvec_lhs, ref hirvec_rhs) => {
for index in hirvec_lhs.iter() {
- v.visit_expr(index)
+ let _ = v.check_expr(index);
}
for index in hirvec_rhs.iter() {
- v.visit_expr(index)
+ let _ = v.check_expr(index);
}
- v.promotable = false;
+ NotPromotable
}
- }
+ };
+ ty_result & node_result
}
/// Check the adjustments of an expression
-fn check_adjustments<'a, 'tcx>(v: &mut CheckCrateVisitor<'a, 'tcx>, e: &hir::Expr) {
+fn check_adjustments<'a, 'tcx>(
+ v: &mut CheckCrateVisitor<'a, 'tcx>,
+ e: &hir::Expr) -> Promotability {
use rustc::ty::adjustment::*;
let mut adjustments = v.tables.expr_adjustments(e).iter().peekable();
continue;
}
}
- v.promotable = false;
- break;
+ return NotPromotable;
}
}
}
+ Promotable
}
impl<'a, 'gcx, 'tcx> euv::Delegate<'tcx> for CheckCrateVisitor<'a, 'gcx> {
fn ty(&mut self) -> &mut Self {
let ty = self.ev.tcx.type_of(self.item_def_id);
- self.walk_ty(ty)
- }
-
- fn walk_ty(&mut self, ty: Ty<'tcx>) -> &mut Self {
ty.visit_with(self);
if let ty::TyFnDef(def_id, _) = ty.sty {
if def_id == self.item_def_id {
// where `X` is the `impl Iterator<Item=T>` itself,
// stored in `predicates_of`, not in the `Ty` itself.
- self.check(item.id, self.inner_visibility).predicates();
+ self.check(item.id, item_visibility).predicates();
}
// Subitems of these items have inherited publicity
hir::ItemConst(..) | hir::ItemStatic(..) | hir::ItemFn(..) |
// because this means that they were generated in some fashion by the
// compiler and we don't need to consider them.
if let ast::ItemKind::Use(..) = item.node {
- if item.vis.node == ast::VisibilityKind::Public || item.span.is_dummy() {
+ if item.vis.node.is_pub() || item.span.is_dummy() {
return;
}
}
Maybe,
}
-#[derive(Copy, Clone, PartialEq, Eq, Debug)]
+#[derive(Copy, Clone, Debug)]
enum PathSource<'a> {
// Type paths `Path`.
Type,
macro_rules! access_from {
($save_ctxt:expr, $vis:expr, $id:expr) => {
Access {
- public: $vis.node == ast::VisibilityKind::Public,
+ public: $vis.node.is_pub(),
reachable: $save_ctxt.analysis.access_levels.is_reachable($id),
}
};
($save_ctxt:expr, $item:expr) => {
Access {
- public: $item.vis.node == ast::VisibilityKind::Public,
+ public: $item.vis.node.is_pub(),
reachable: $save_ctxt.analysis.access_levels.is_reachable($item.id),
}
};
.iter()
.enumerate()
.filter_map(|(i, f)| {
- if include_priv_fields || f.vis.node == ast::VisibilityKind::Public {
+ if include_priv_fields || f.vis.node.is_pub() {
f.ident
.map(|i| i.to_string())
.or_else(|| Some(i.to_string()))
Match,
}
-#[derive(Debug, PartialEq, Eq, Clone)]
+#[derive(Debug, PartialEq, Clone)]
pub struct Pick<'tcx> {
pub item: ty::AssociatedItem,
pub kind: PickKind<'tcx>,
// separately
Def::Macro(did, MacroKind::Bang) => {
record_extern_fqn(cx, did, clean::TypeKind::Macro);
- clean::MacroItem(build_macro(cx, did, name))
+ if let Some(mac) = build_macro(cx, did, name) {
+ clean::MacroItem(mac)
+ } else {
+ return None;
+ }
}
_ => return None,
};
}
}
-fn build_macro(cx: &DocContext, did: DefId, name: ast::Name) -> clean::Macro {
+fn build_macro(cx: &DocContext, did: DefId, name: ast::Name) -> Option<clean::Macro> {
let imported_from = cx.tcx.original_crate_name(did.krate);
let def = match cx.cstore.load_macro_untracked(did, cx.sess()) {
LoadedMacro::MacroDef(macro_def) => macro_def,
// FIXME(jseyfried): document proc macro re-exports
- LoadedMacro::ProcMacro(..) => panic!("attempting to document proc-macro re-export"),
+ LoadedMacro::ProcMacro(..) => return None,
};
let matchers: hir::HirVec<Span> = if let ast::ItemKind::MacroDef(ref def) = def.node {
format!(" {} => {{ ... }};\n", span.to_src(cx))
}).collect::<String>());
- clean::Macro {
+ Some(clean::Macro {
source,
imported_from: Some(imported_from).clean(cx),
- }
+ })
}
/// A trait's generics clause actually contains all of the predicates for all of
use std::collections::hash_map::Entry;
use std::fmt;
+use std::hash::{Hash, Hasher};
use std::default::Default;
use std::{mem, slice, vec};
use std::iter::{FromIterator, once};
}
}
-#[derive(Clone, RustcEncodable, RustcDecodable, PartialEq, Eq, Debug, Default, Hash)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug, Default)]
pub struct Attributes {
pub doc_strings: Vec<DocFragment>,
pub other_attrs: Vec<ast::Attribute>,
}
}
+impl PartialEq for Attributes {
+ fn eq(&self, rhs: &Self) -> bool {
+ self.doc_strings == rhs.doc_strings &&
+ self.cfg == rhs.cfg &&
+ self.span == rhs.span &&
+ self.links == rhs.links &&
+ self.other_attrs.iter().map(|attr| attr.id).eq(rhs.other_attrs.iter().map(|attr| attr.id))
+ }
+}
+
+impl Eq for Attributes {}
+
+impl Hash for Attributes {
+ fn hash<H: Hasher>(&self, hasher: &mut H) {
+ self.doc_strings.hash(hasher);
+ self.cfg.hash(hasher);
+ self.span.hash(hasher);
+ self.links.hash(hasher);
+ for attr in &self.other_attrs {
+ attr.id.hash(hasher);
+ }
+ }
+}
+
impl AttributesExt for Attributes {
fn lists<'a>(&'a self, name: &'a str) -> ListAttributesIter<'a> {
self.other_attrs.lists(name)
impl<
K: Encodable + PartialEq + Ord,
- V: Encodable + PartialEq
+ V: Encodable
> Encodable for BTreeMap<K, V> {
fn encode<S: Encoder>(&self, e: &mut S) -> Result<(), S::Error> {
e.emit_map(self.len(), |e| {
impl<
K: Decodable + PartialEq + Ord,
- V: Decodable + PartialEq
+ V: Decodable
> Decodable for BTreeMap<K, V> {
fn decode<D: Decoder>(d: &mut D) -> Result<BTreeMap<K, V>, D::Error> {
d.read_map(|d, len| {
pub use rustc_target::abi::FloatTy;
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Copy)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Copy)]
pub struct Label {
pub ident: Ident,
}
}
}
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Copy)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Copy)]
pub struct Lifetime {
pub id: NodeId,
pub ident: Ident,
/// along with a bunch of supporting information.
///
/// E.g. `std::cmp::PartialEq`
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash)]
+#[derive(Clone, RustcEncodable, RustcDecodable)]
pub struct Path {
pub span: Span,
/// The segments in the path: the things separated by `::`.
/// A segment of a path: an identifier, an optional lifetime, and a set of types.
///
/// E.g. `std`, `String` or `Box<T>`
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct PathSegment {
/// The identifier portion of this path segment.
pub ident: Ident,
/// Arguments of a path segment.
///
/// E.g. `<A, B>` as in `Foo<A, B>` or `(A, B)` as in `Foo(A, B)`
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub enum GenericArgs {
/// The `<'a, A,B,C>` in `foo::bar::baz::<'a, A,B,C>`
AngleBracketed(AngleBracketedArgs),
}
}
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub enum GenericArg {
Lifetime(Lifetime),
Type(P<Ty>),
}
/// A path like `Foo<'a, T>`
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Default)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug, Default)]
pub struct AngleBracketedArgs {
/// Overall span
pub span: Span,
}
/// A path like `Foo(A,B) -> C`
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct ParenthesisedArgs {
/// Overall span
pub span: Span,
pub output: Option<P<Ty>>,
}
-#[derive(Clone, Copy, PartialEq, PartialOrd, Eq, Ord, Hash, Debug)]
+#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
pub struct NodeId(u32);
impl NodeId {
/// A modifier on a bound, currently this is only used for `?Sized`, where the
/// modifier is `Maybe`. Negative bounds should also be handled here.
-#[derive(Copy, Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Copy, Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Debug)]
pub enum TraitBoundModifier {
None,
Maybe,
/// typeck::collect::compute_bounds matches these against
/// the "special" built-in traits (see middle::lang_items) and
/// detects Copy, Send and Sync.
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub enum GenericBound {
Trait(PolyTraitRef, TraitBoundModifier),
Outlives(Lifetime)
pub type GenericBounds = Vec<GenericBound>;
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub enum GenericParamKind {
/// A lifetime definition, e.g. `'a: 'b+'c+'d`.
Lifetime,
}
}
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct GenericParam {
pub id: NodeId,
pub ident: Ident,
/// Represents lifetime, type and const parameters attached to a declaration of
/// a function, enum, trait, etc.
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct Generics {
pub params: Vec<GenericParam>,
pub where_clause: WhereClause,
}
/// A `where` clause in a definition
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct WhereClause {
pub id: NodeId,
pub predicates: Vec<WherePredicate>,
}
/// A single predicate in a `where` clause
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub enum WherePredicate {
/// A type binding, e.g. `for<'c> Foo: Send+Clone+'c`
BoundPredicate(WhereBoundPredicate),
/// A type bound.
///
/// E.g. `for<'c> Foo: Send+Clone+'c`
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct WhereBoundPredicate {
pub span: Span,
/// Any generics from a `for` binding
/// A lifetime predicate.
///
/// E.g. `'a: 'b+'c`
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct WhereRegionPredicate {
pub span: Span,
pub lifetime: Lifetime,
/// An equality predicate (unsupported).
///
/// E.g. `T=int`
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct WhereEqPredicate {
pub id: NodeId,
pub span: Span,
/// used to drive conditional compilation
pub type CrateConfig = HashSet<(Name, Option<Symbol>)>;
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct Crate {
pub module: Mod,
pub attrs: Vec<Attribute>,
/// Possible values inside of compile-time attribute lists.
///
/// E.g. the '..' in `#[name(..)]`.
-#[derive(Clone, Eq, RustcEncodable, RustcDecodable, Hash, Debug, PartialEq)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub enum NestedMetaItemKind {
/// A full MetaItem, for recursive meta items.
MetaItem(MetaItem),
/// A spanned compile-time attribute item.
///
/// E.g. `#[test]`, `#[derive(..)]`, `#[rustfmt::skip]` or `#[feature = "foo"]`
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct MetaItem {
pub ident: Path,
pub node: MetaItemKind,
/// A compile-time attribute item.
///
/// E.g. `#[test]`, `#[derive(..)]` or `#[feature = "foo"]`
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub enum MetaItemKind {
/// Word meta item.
///
/// A Block (`{ .. }`).
///
/// E.g. `{ .. }` as in `fn foo() { .. }`
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct Block {
/// Statements in a block
pub stmts: Vec<Stmt>,
pub recovered: bool,
}
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash)]
+#[derive(Clone, RustcEncodable, RustcDecodable)]
pub struct Pat {
pub id: NodeId,
pub node: PatKind,
/// Patterns like the fields of Foo `{ x, ref y, ref mut z }`
/// are treated the same as` x: x, y: ref y, z: ref mut z`,
/// except is_shorthand is true
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct FieldPat {
/// The identifier for the field
pub ident: Ident,
pub attrs: ThinVec<Attribute>,
}
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
+#[derive(Clone, PartialEq, RustcEncodable, RustcDecodable, Debug, Copy)]
pub enum BindingMode {
ByRef(Mutability),
ByValue(Mutability),
}
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub enum RangeEnd {
Included(RangeSyntax),
Excluded,
}
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub enum RangeSyntax {
DotDotDot,
DotDotEq,
}
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub enum PatKind {
/// Represents a wildcard pattern (`_`)
Wild,
Mac(Mac),
}
-#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
+#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable, Debug, Copy)]
pub enum Mutability {
Mutable,
Immutable,
}
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
+#[derive(Clone, PartialEq, RustcEncodable, RustcDecodable, Debug, Copy)]
pub enum BinOpKind {
/// The `+` operator (addition)
Add,
pub type BinOp = Spanned<BinOpKind>;
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug, Copy)]
pub enum UnOp {
/// The `*` operator for dereferencing
Deref,
}
/// A statement
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash)]
+#[derive(Clone, RustcEncodable, RustcDecodable)]
pub struct Stmt {
pub id: NodeId,
pub node: StmtKind,
}
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash)]
+#[derive(Clone, RustcEncodable, RustcDecodable)]
pub enum StmtKind {
/// A local (let) binding.
Local(P<Local>),
Mac(P<(Mac, MacStmtStyle, ThinVec<Attribute>)>),
}
-#[derive(Clone, Copy, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, Copy, PartialEq, RustcEncodable, RustcDecodable, Debug)]
pub enum MacStmtStyle {
/// The macro statement had a trailing semicolon, e.g. `foo! { ... };`
/// `foo!(...);`, `foo![...];`
}
/// Local represents a `let` statement, e.g., `let <pat>:<ty> = <expr>;`
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct Local {
pub pat: P<Pat>,
pub ty: Option<P<Ty>>,
/// _ => { println!("no match!") },
/// }
/// ```
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct Arm {
pub attrs: Vec<Attribute>,
pub pats: Vec<P<Pat>>,
pub body: P<Expr>,
}
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct Field {
pub ident: Ident,
pub expr: P<Expr>,
pub attrs: ThinVec<Attribute>,
}
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
+pub type SpannedIdent = Spanned<Ident>;
+
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug, Copy)]
pub enum BlockCheckMode {
Default,
Unsafe(UnsafeSource),
}
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug, Copy)]
pub enum UnsafeSource {
CompilerGenerated,
UserProvided,
/// These are usually found nested inside types (e.g. array lengths)
/// or expressions (e.g. repeat counts), and also used to define
/// explicit discriminant values for enum variants.
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct AnonConst {
pub id: NodeId,
pub value: P<Expr>,
/// An expression
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash,)]
+#[derive(Clone, RustcEncodable, RustcDecodable)]
pub struct Expr {
pub id: NodeId,
pub node: ExprKind,
}
/// Limit types of a range (inclusive or exclusive)
-#[derive(Copy, Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, Debug)]
pub enum RangeLimits {
/// Inclusive at the beginning, exclusive at the end
HalfOpen,
Closed,
}
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub enum ExprKind {
/// A `box x` expression.
Box(P<Expr>),
/// ^~~~~ ^
/// ty position = 0
/// ```
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct QSelf {
pub ty: P<Ty>,
}
/// A capture clause
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
+#[derive(Clone, Copy, PartialEq, RustcEncodable, RustcDecodable, Debug)]
pub enum CaptureBy {
Value,
Ref,
}
/// The movability of a generator / closure literal
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
+#[derive(Clone, PartialEq, RustcEncodable, RustcDecodable, Debug, Copy)]
pub enum Movability {
Static,
Movable,
///
/// NB: the additional ident for a macro_rules-style macro is actually
/// stored in the enclosing item. Oog.
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct Mac_ {
pub path: Path,
pub delim: MacDelimiter,
pub tts: ThinTokenStream,
}
-#[derive(Copy, Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Copy, Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Debug)]
pub enum MacDelimiter {
Parenthesis,
Bracket,
}
}
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct MacroDef {
pub tokens: ThinTokenStream,
pub legacy: bool,
}
}
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug, Copy, Hash, PartialEq)]
pub enum StrStyle {
/// A regular string, like `"foo"`
Cooked,
/// A literal
pub type Lit = Spanned<LitKind>;
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug, Copy, Hash, PartialEq)]
pub enum LitIntType {
Signed(IntTy),
Unsigned(UintTy),
/// Literal kind.
///
/// E.g. `"foo"`, `42`, `12.34` or `bool`
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug, Hash, PartialEq)]
pub enum LitKind {
/// A string literal (`"foo"`)
Str(Symbol, StrStyle),
// NB: If you change this, you'll probably want to change the corresponding
// type structure in middle/ty.rs as well.
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct MutTy {
pub ty: P<Ty>,
pub mutbl: Mutability,
/// Represents a method's signature in a trait declaration,
/// or in an implementation.
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct MethodSig {
pub header: FnHeader,
pub decl: P<FnDecl>,
/// possibly including a default implementation. A trait item is
/// either required (meaning it doesn't have an implementation, just a
/// signature) or provided (meaning it has a default implementation).
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct TraitItem {
pub id: NodeId,
pub ident: Ident,
pub tokens: Option<TokenStream>,
}
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub enum TraitItemKind {
Const(P<Ty>, Option<P<Expr>>),
Method(MethodSig, Option<P<Block>>),
Macro(Mac),
}
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct ImplItem {
pub id: NodeId,
pub ident: Ident,
pub tokens: Option<TokenStream>,
}
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub enum ImplItemKind {
Const(P<Ty>, P<Expr>),
Method(MethodSig, P<Block>),
Macro(Mac),
}
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Copy,
- PartialOrd, Ord)]
+#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable, Copy)]
pub enum IntTy {
Isize,
I8,
}
}
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Copy,
- PartialOrd, Ord)]
+#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable, Copy)]
pub enum UintTy {
Usize,
U8,
}
// Bind a type to an associated type: `A=Foo`.
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct TypeBinding {
pub id: NodeId,
pub ident: Ident,
pub span: Span,
}
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash)]
+#[derive(Clone, RustcEncodable, RustcDecodable)]
pub struct Ty {
pub id: NodeId,
pub node: TyKind,
}
}
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct BareFnTy {
pub unsafety: Unsafety,
pub abi: Abi,
}
/// The different kinds of types recognized by the compiler
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub enum TyKind {
/// A variable-length slice (`[T]`)
Slice(P<Ty>),
Err,
}
+impl TyKind {
+ pub fn is_implicit_self(&self) -> bool {
+ if let TyKind::ImplicitSelf = *self { true } else { false }
+ }
+
+ crate fn is_unit(&self) -> bool {
+ if let TyKind::Tup(ref tys) = *self { tys.is_empty() } else { false }
+ }
+}
+
/// Syntax used to declare a trait object.
-#[derive(Clone, Copy, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, Copy, PartialEq, RustcEncodable, RustcDecodable, Debug)]
pub enum TraitObjectSyntax {
Dyn,
None,
/// Inline assembly dialect.
///
/// E.g. `"intel"` as in `asm!("mov eax, 2" : "={eax}"(result) : : : "intel")`
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
+#[derive(Clone, PartialEq, RustcEncodable, RustcDecodable, Debug, Copy)]
pub enum AsmDialect {
Att,
Intel,
/// Inline assembly.
///
/// E.g. `"={eax}"(result)` as in `asm!("mov eax, 2" : "={eax}"(result) : : : "intel")`
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct InlineAsmOutput {
pub constraint: Symbol,
pub expr: P<Expr>,
/// Inline assembly.
///
/// E.g. `asm!("NOP");`
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct InlineAsm {
pub asm: Symbol,
pub asm_str_style: StrStyle,
/// An argument in a function header.
///
/// E.g. `bar: usize` as in `fn foo(bar: usize)`
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct Arg {
pub ty: P<Ty>,
pub pat: P<Pat>,
/// Alternative representation for `Arg`s describing `self` parameter of methods.
///
/// E.g. `&mut self` as in `fn foo(&mut self)`
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub enum SelfKind {
/// `self`, `mut self`
Value(Mutability),
if ident.name == keywords::SelfValue.name() {
return match self.ty.node {
TyKind::ImplicitSelf => Some(respan(self.pat.span, SelfKind::Value(mutbl))),
- TyKind::Rptr(lt, MutTy{ref ty, mutbl}) if ty.node == TyKind::ImplicitSelf => {
+ TyKind::Rptr(lt, MutTy{ref ty, mutbl}) if ty.node.is_implicit_self() => {
Some(respan(self.pat.span, SelfKind::Region(lt, mutbl)))
}
_ => Some(respan(self.pat.span.to(self.ty.span),
/// Header (not the body) of a function declaration.
///
/// E.g. `fn foo(bar: baz)`
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct FnDecl {
pub inputs: Vec<Arg>,
pub output: FunctionRetTy,
}
/// Is the trait definition an auto trait?
-#[derive(Copy, Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, Debug)]
pub enum IsAuto {
Yes,
No
}
-#[derive(Copy, Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, Debug)]
pub enum Unsafety {
Unsafe,
Normal,
}
-#[derive(Copy, Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Copy, Clone, RustcEncodable, RustcDecodable, Debug)]
pub enum IsAsync {
Async {
closure_id: NodeId,
}
}
-#[derive(Copy, Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, Debug)]
pub enum Constness {
Const,
NotConst,
}
-#[derive(Copy, Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, Debug)]
pub enum Defaultness {
Default,
Final,
}
}
-#[derive(Copy, Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash)]
+#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable)]
pub enum ImplPolarity {
/// `impl Trait for Type`
Positive,
}
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub enum FunctionRetTy {
/// Return type is not specified.
///
/// Module declaration.
///
/// E.g. `mod foo;` or `mod foo { .. }`
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct Mod {
/// A span from the first token past `{` to the last token until `}`.
/// For `mod foo;`, the inner span ranges from the first token
/// Foreign module declaration.
///
/// E.g. `extern { .. }` or `extern C { .. }`
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct ForeignMod {
pub abi: Abi,
pub items: Vec<ForeignItem>,
/// Global inline assembly
///
/// aka module-level assembly or file-scoped assembly
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug, Copy)]
pub struct GlobalAsm {
pub asm: Symbol,
pub ctxt: SyntaxContext,
}
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct EnumDef {
pub variants: Vec<Variant>,
}
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct Variant_ {
pub ident: Ident,
pub attrs: Vec<Attribute>,
pub type Variant = Spanned<Variant_>;
/// Part of `use` item to the right of its prefix.
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub enum UseTreeKind {
/// `use prefix` or `use prefix as rename`
///
/// A tree of paths sharing common prefixes.
/// Used in `use` items both at top-level and inside of braces in import groups.
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct UseTree {
pub prefix: Path,
pub kind: UseTreeKind,
/// Distinguishes between Attributes that decorate items and Attributes that
/// are contained as statements within items. These two cases need to be
/// distinguished for pretty-printing.
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
+#[derive(Clone, PartialEq, RustcEncodable, RustcDecodable, Debug, Copy)]
pub enum AttrStyle {
Outer,
Inner,
/// Meta-data associated with an item
/// Doc-comments are promoted to attributes that have is_sugared_doc = true
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct Attribute {
pub id: AttrId,
pub style: AttrStyle,
/// that the ref_id is for. The impl_id maps to the "self type" of this impl.
/// If this impl is an ItemKind::Impl, the impl_id is redundant (it could be the
/// same as the impl's node id).
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct TraitRef {
pub path: Path,
pub ref_id: NodeId,
}
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct PolyTraitRef {
/// The `'a` in `<'a> Foo<&'a T>`
pub bound_generic_params: Vec<GenericParam>,
}
}
-#[derive(Copy, Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Copy, Clone, RustcEncodable, RustcDecodable, Debug)]
pub enum CrateSugar {
/// Source is `pub(crate)`
PubCrate,
pub type Visibility = Spanned<VisibilityKind>;
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub enum VisibilityKind {
Public,
Crate(CrateSugar),
Inherited,
}
+impl VisibilityKind {
+ pub fn is_pub(&self) -> bool {
+ if let VisibilityKind::Public = *self { true } else { false }
+ }
+}
+
/// Field of a struct.
///
/// E.g. `bar: usize` as in `struct Foo { bar: usize }`
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct StructField {
pub span: Span,
pub ident: Option<Ident>,
/// used for `Struct`-structs (but still presents). Structures don't have an analogue of "Id of
/// the variant itself" from enum variants.
/// Id of the whole struct lives in `Item`.
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub enum VariantData {
/// Struct variant.
///
/// An item
///
/// The name might be a dummy name in case of anonymous items
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct Item {
pub ident: Ident,
pub attrs: Vec<Attribute>,
///
/// All the information between the visibility & the name of the function is
/// included in this struct (e.g. `async unsafe fn` or `const extern "C" fn`)
-#[derive(Clone, Copy, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, Copy, RustcEncodable, RustcDecodable, Debug)]
pub struct FnHeader {
pub unsafety: Unsafety,
pub asyncness: IsAsync,
}
}
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub enum ItemKind {
/// An `extern crate` item, with optional *original* crate name if the crate was renamed.
///
}
}
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct ForeignItem {
pub ident: Ident,
pub attrs: Vec<Attribute>,
}
/// An item within an `extern` block
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub enum ForeignItemKind {
/// A foreign function
Fn(P<FnDecl>, Generics),
fn check_unused_macros(&self);
}
-#[derive(Copy, Clone, Debug, PartialEq)]
+#[derive(Copy, Clone, PartialEq, Debug)]
pub enum Determinacy {
Determined,
Undetermined,
/// Contains the sub-token-trees of a "delimited" token tree, such as the contents of `(`. Note
/// that the delimiter itself might be `NoDelim`.
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, PartialEq, RustcEncodable, RustcDecodable, Debug)]
pub struct Delimited {
pub delim: token::DelimToken,
pub tts: Vec<TokenTree>,
}
}
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, PartialEq, RustcEncodable, RustcDecodable, Debug)]
pub struct SequenceRepetition {
/// The sequence of token trees
pub tts: Vec<TokenTree>,
/// A Kleene-style [repetition operator](http://en.wikipedia.org/wiki/Kleene_star)
/// for token sequences.
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
+#[derive(Clone, PartialEq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
pub enum KleeneOp {
/// Kleene star (`*`) for zero or more repetitions
ZeroOrMore,
/// Similar to `tokenstream::TokenTree`, except that `$i`, `$i:ident`, and `$(...)`
/// are "first-class" token trees. Useful for parsing macros.
-#[derive(Debug, Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash)]
+#[derive(Debug, Clone, PartialEq, RustcEncodable, RustcDecodable)]
pub enum TokenTree {
Token(Span, token::Token),
Delimited(Span, Lrc<Delimited>),
// move that documentation into the relevant place in the other docs, and
// remove the chapter on the flag.
-#[derive(PartialEq, Copy, Clone, Debug)]
+#[derive(Copy, Clone, PartialEq, Debug)]
pub enum AttributeType {
/// Normal, builtin attribute that is consumed
/// by the compiler before the unused_attribute check
}
}
-#[derive(Copy, Clone, PartialEq, Eq, Debug)]
+#[derive(Copy, Clone, Debug)]
pub enum Stability {
Unstable,
// Argument is tracking issue link.
("target_has_atomic", "cfg_target_has_atomic", cfg_fn!(cfg_target_has_atomic)),
];
-#[derive(Debug, Eq, PartialEq)]
+#[derive(Debug)]
pub struct GatedCfg {
span: Span,
index: usize,
Library(Option<u32>)
}
-#[derive(Debug, Copy, Clone, PartialEq, Eq)]
+#[derive(Debug, Copy, Clone, PartialEq)]
pub enum GateStrength {
/// A hard error. (Most feature gates should use this.)
Hard,
fn visit_fn_ret_ty(&mut self, ret_ty: &'a ast::FunctionRetTy) {
if let ast::FunctionRetTy::Ty(ref output_ty) = *ret_ty {
- if output_ty.node != ast::TyKind::Never {
+ if let ast::TyKind::Never = output_ty.node {
+ // Do nothing
+ } else {
self.visit_ty(output_ty)
}
}
visit::walk_crate(visitor, krate);
}
-#[derive(Clone, Copy, PartialEq, Eq, Hash)]
+#[derive(Clone, Copy, Hash)]
pub enum UnstableFeatures {
/// Hard errors for unstable features are active, as on
/// beta/stable channels.
use parse::parser::{Parser, TokenType, PathStyle};
use tokenstream::TokenStream;
-#[derive(PartialEq, Eq, Debug)]
+#[derive(Debug)]
enum InnerAttributeParsePolicy<'a> {
Permitted,
NotPermitted { reason: &'a str },
let lo = self.span;
self.bump();
- if inner_parse_policy == InnerAttributeParsePolicy::Permitted {
+ if let InnerAttributeParsePolicy::Permitted = inner_parse_policy {
self.expected_tokens.push(TokenType::Token(token::Not));
}
let style = if self.token == token::Not {
mod tokentrees;
mod unicode_chars;
-#[derive(Clone, PartialEq, Eq, Debug)]
+#[derive(Clone, Debug)]
pub struct TokenAndSpan {
pub tok: token::Token,
pub sp: Span,
tok: token::Ident(id, false),
sp: Span::new(BytePos(21), BytePos(23), NO_EXPANSION),
};
- assert_eq!(tok1, tok2);
+ assert_eq!(tok1.tok, tok2.tok);
+ assert_eq!(tok1.sp, tok2.sp);
assert_eq!(string_reader.next_token().tok, token::Whitespace);
// the 'main' id is already read:
assert_eq!(string_reader.pos.clone(), BytePos(28));
tok: mk_ident("main"),
sp: Span::new(BytePos(24), BytePos(28), NO_EXPANSION),
};
- assert_eq!(tok3, tok4);
+ assert_eq!(tok3.tok, tok4.tok);
+ assert_eq!(tok3.sp, tok4.sp);
// the lparen is already read:
assert_eq!(string_reader.pos.clone(), BytePos(29))
})
})
}
+/// `SeqSep` : a sequence separator (token)
+/// and whether a trailing separator is allowed.
+pub struct SeqSep {
+ pub sep: Option<token::Token>,
+ pub trailing_sep_allowed: bool,
+}
+
+impl SeqSep {
+ pub fn trailing_allowed(t: token::Token) -> SeqSep {
+ SeqSep {
+ sep: Some(t),
+ trailing_sep_allowed: true,
+ }
+ }
+
+ pub fn none() -> SeqSep {
+ SeqSep {
+ sep: None,
+ trailing_sep_allowed: false,
+ }
+ }
+}
+
#[cfg(test)]
mod tests {
use super::*;
- use syntax_pos::{self, Span, BytePos, Pos, NO_EXPANSION};
- use codemap::{respan, Spanned};
+ use syntax_pos::{Span, BytePos, Pos, NO_EXPANSION};
use ast::{self, Ident, PatKind};
- use rustc_target::spec::abi::Abi;
use attr::first_attr_value_str_by_name;
use parse;
- use parse::parser::Parser;
use print::pprust::item_to_string;
- use ptr::P;
use tokenstream::{self, TokenTree};
- use util::parser_testing::{string_to_stream, string_to_parser};
- use util::parser_testing::{string_to_expr, string_to_item, string_to_stmt};
- use util::ThinVec;
+ use util::parser_testing::string_to_stream;
+ use util::parser_testing::{string_to_expr, string_to_item};
use with_globals;
// produce a syntax_pos::span
Span::new(BytePos(a), BytePos(b), NO_EXPANSION)
}
- fn str2seg(s: &str, lo: u32, hi: u32) -> ast::PathSegment {
- ast::PathSegment::from_ident(Ident::new(Symbol::intern(s), sp(lo, hi)))
- }
-
- #[test] fn path_exprs_1() {
- with_globals(|| {
- assert!(string_to_expr("a".to_string()) ==
- P(ast::Expr{
- id: ast::DUMMY_NODE_ID,
- node: ast::ExprKind::Path(None, ast::Path {
- span: sp(0, 1),
- segments: vec![str2seg("a", 0, 1)],
- }),
- span: sp(0, 1),
- attrs: ThinVec::new(),
- }))
- })
- }
-
- #[test] fn path_exprs_2 () {
- with_globals(|| {
- assert!(string_to_expr("::a::b".to_string()) ==
- P(ast::Expr {
- id: ast::DUMMY_NODE_ID,
- node: ast::ExprKind::Path(None, ast::Path {
- span: sp(0, 6),
- segments: vec![ast::PathSegment::crate_root(sp(0, 0)),
- str2seg("a", 2, 3),
- str2seg("b", 5, 6)]
- }),
- span: sp(0, 6),
- attrs: ThinVec::new(),
- }))
- })
- }
-
#[should_panic]
#[test] fn bad_path_expr_1() {
with_globals(|| {
})
}
- #[test] fn ret_expr() {
- with_globals(|| {
- assert!(string_to_expr("return d".to_string()) ==
- P(ast::Expr{
- id: ast::DUMMY_NODE_ID,
- node:ast::ExprKind::Ret(Some(P(ast::Expr{
- id: ast::DUMMY_NODE_ID,
- node:ast::ExprKind::Path(None, ast::Path{
- span: sp(7, 8),
- segments: vec![str2seg("d", 7, 8)],
- }),
- span:sp(7,8),
- attrs: ThinVec::new(),
- }))),
- span:sp(0,8),
- attrs: ThinVec::new(),
- }))
- })
- }
-
- #[test] fn parse_stmt_1 () {
- with_globals(|| {
- assert!(string_to_stmt("b;".to_string()) ==
- Some(ast::Stmt {
- node: ast::StmtKind::Expr(P(ast::Expr {
- id: ast::DUMMY_NODE_ID,
- node: ast::ExprKind::Path(None, ast::Path {
- span:sp(0,1),
- segments: vec![str2seg("b", 0, 1)],
- }),
- span: sp(0,1),
- attrs: ThinVec::new()})),
- id: ast::DUMMY_NODE_ID,
- span: sp(0,1)}))
- })
- }
-
- fn parser_done(p: Parser){
- assert_eq!(p.token.clone(), token::Eof);
- }
-
- #[test] fn parse_ident_pat () {
- with_globals(|| {
- let sess = ParseSess::new(FilePathMapping::empty());
- let mut parser = string_to_parser(&sess, "b".to_string());
- assert!(panictry!(parser.parse_pat())
- == P(ast::Pat{
- id: ast::DUMMY_NODE_ID,
- node: PatKind::Ident(ast::BindingMode::ByValue(ast::Mutability::Immutable),
- Ident::new(Symbol::intern("b"), sp(0, 1)),
- None),
- span: sp(0,1)}));
- parser_done(parser);
- })
- }
-
- // check the contents of the tt manually:
- #[test] fn parse_fundecl () {
- with_globals(|| {
- // this test depends on the intern order of "fn" and "i32"
- let item = string_to_item("fn a (b : i32) { b; }".to_string()).map(|m| {
- m.map(|mut m| {
- m.tokens = None;
- m
- })
- });
- assert_eq!(item,
- Some(
- P(ast::Item{ident:Ident::from_str("a"),
- attrs:Vec::new(),
- id: ast::DUMMY_NODE_ID,
- tokens: None,
- node: ast::ItemKind::Fn(P(ast::FnDecl {
- inputs: vec![ast::Arg{
- ty: P(ast::Ty{id: ast::DUMMY_NODE_ID,
- node: ast::TyKind::Path(None, ast::Path{
- span:sp(10,13),
- segments: vec![str2seg("i32", 10, 13)],
- }),
- span:sp(10,13)
- }),
- pat: P(ast::Pat {
- id: ast::DUMMY_NODE_ID,
- node: PatKind::Ident(
- ast::BindingMode::ByValue(
- ast::Mutability::Immutable),
- Ident::new(Symbol::intern("b"), sp(6, 7)),
- None
- ),
- span: sp(6,7)
- }),
- id: ast::DUMMY_NODE_ID
- }],
- output: ast::FunctionRetTy::Default(sp(15, 15)),
- variadic: false
- }),
- ast::FnHeader {
- unsafety: ast::Unsafety::Normal,
- asyncness: ast::IsAsync::NotAsync,
- constness: Spanned {
- span: sp(0,2),
- node: ast::Constness::NotConst,
- },
- abi: Abi::Rust,
- },
- ast::Generics{
- params: Vec::new(),
- where_clause: ast::WhereClause {
- id: ast::DUMMY_NODE_ID,
- predicates: Vec::new(),
- span: syntax_pos::DUMMY_SP,
- },
- span: syntax_pos::DUMMY_SP,
- },
- P(ast::Block {
- stmts: vec![ast::Stmt {
- node: ast::StmtKind::Semi(P(ast::Expr{
- id: ast::DUMMY_NODE_ID,
- node: ast::ExprKind::Path(None,
- ast::Path{
- span:sp(17,18),
- segments: vec![str2seg("b", 17, 18)],
- }),
- span: sp(17,18),
- attrs: ThinVec::new()})),
- id: ast::DUMMY_NODE_ID,
- span: sp(17,19)}],
- id: ast::DUMMY_NODE_ID,
- rules: ast::BlockCheckMode::Default, // no idea
- span: sp(15,21),
- recovered: false,
- })),
- vis: respan(sp(0, 0), ast::VisibilityKind::Inherited),
- span: sp(0,21)})));
- })
- }
-
#[test] fn parse_use() {
with_globals(|| {
let use_s = "use foo::bar::baz;";
});
}
}
-
-/// `SeqSep` : a sequence separator (token)
-/// and whether a trailing separator is allowed.
-pub struct SeqSep {
- pub sep: Option<token::Token>,
- pub trailing_sep_allowed: bool,
-}
-
-impl SeqSep {
- pub fn trailing_allowed(t: token::Token) -> SeqSep {
- SeqSep {
- sep: Some(t),
- trailing_sep_allowed: true,
- }
- }
-
- pub fn none() -> SeqSep {
- SeqSep {
- sep: None,
- trailing_sep_allowed: false,
- }
- }
-}
Mod,
}
-#[derive(Clone, Copy, Debug, PartialEq)]
+#[derive(Clone, Copy, PartialEq, Debug)]
enum SemiColonMode {
Break,
Ignore,
}
-#[derive(Clone, Copy, Debug, PartialEq)]
+#[derive(Clone, Copy, PartialEq, Debug)]
enum BlockMode {
Break,
Ignore,
}
}
-#[derive(PartialEq, Eq, Clone)]
+#[derive(Clone, PartialEq)]
crate enum TokenType {
Token(token::Token),
Keyword(keywords::Keyword),
Arg { ty: P(ty), pat: pat, id: ast::DUMMY_NODE_ID }
}
-#[derive(Copy, Clone, Debug, PartialEq, Eq)]
+#[derive(Copy, Clone, Debug)]
enum TokenExpectType {
Expect,
NoExpect,
// Verify whether we have encountered a struct or method definition where the user forgot to
// add the `struct` or `fn` keyword after writing `pub`: `pub S {}`
- if visibility.node == VisibilityKind::Public &&
+ if visibility.node.is_pub() &&
self.check_ident() &&
self.look_ahead(1, |t| *t != token::Not)
{
use std::mem;
use rustc_data_structures::sync::{Lrc, Lock};
-#[derive(Clone, RustcEncodable, RustcDecodable, PartialEq, Eq, Hash, Debug, Copy)]
+#[derive(Clone, PartialEq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
pub enum BinOpToken {
Plus,
Minus,
}
/// A delimiter token
-#[derive(Clone, RustcEncodable, RustcDecodable, PartialEq, Eq, Hash, Debug, Copy)]
+#[derive(Clone, PartialEq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
pub enum DelimToken {
/// A round parenthesis: `(` or `)`
Paren,
}
}
-#[derive(Clone, RustcEncodable, RustcDecodable, PartialEq, Eq, Hash, Debug, Copy)]
+#[derive(Clone, PartialEq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
pub enum Lit {
Byte(ast::Name),
Char(ast::Name),
].contains(&ident.name)
}
-#[derive(Clone, RustcEncodable, RustcDecodable, PartialEq, Eq, Hash, Debug)]
+#[derive(Clone, RustcEncodable, RustcDecodable, PartialEq, Debug)]
pub enum Token {
/* Expression-operator symbols. */
Eq,
}
}
-#[derive(Clone, RustcEncodable, RustcDecodable, Eq, Hash)]
+#[derive(Clone, RustcEncodable, RustcDecodable)]
/// For interpolation during macro expansion.
pub enum Nonterminal {
NtItem(P<ast::Item>),
|s, p| s.print_pat(p))?;
if let Some(ref p) = *slice {
if !before.is_empty() { self.word_space(",")?; }
- if p.node != PatKind::Wild {
+ if let PatKind::Wild = p.node {
+ // Print nothing
+ } else {
self.print_pat(p)?;
}
self.s.word("..")?;
use rustc_data_structures::stable_hasher::{StableHasher, StableHasherResult,
HashStable};
/// An owned smart pointer.
-#[derive(Hash, PartialEq, Eq, PartialOrd, Ord)]
+#[derive(Hash, PartialEq, Eq)]
pub struct P<T: ?Sized> {
ptr: Box<T>
}
sp.with_ctxt(cx.ctxt)
}
-#[derive(PartialEq)]
enum HasTestSignature {
Yes,
No(BadTestSignature),
// type implements the `Termination` trait as `libtest` enforces that.
let has_output = match decl.output {
ast::FunctionRetTy::Default(..) => false,
- ast::FunctionRetTy::Ty(ref t) if t.node == ast::TyKind::Tup(vec![]) => false,
+ ast::FunctionRetTy::Ty(ref t) if t.node.is_unit() => false,
_ => true
};
use std::borrow::Cow;
use std::{fmt, iter, mem};
-use std::hash::{self, Hash};
/// A delimited sequence of token trees
-#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
+#[derive(Clone, PartialEq, RustcEncodable, RustcDecodable, Debug)]
pub struct Delimited {
/// The type of delimiter
pub delim: token::DelimToken,
///
/// The RHS of an MBE macro is the only place `SubstNt`s are substituted.
/// Nothing special happens to misnamed or misplaced `SubstNt`s.
-#[derive(Debug, Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash)]
+#[derive(Debug, Clone, PartialEq, RustcEncodable, RustcDecodable)]
pub enum TokenTree {
/// A single token
Token(Span, token::Token),
}
}
-impl Hash for TokenStream {
- fn hash<H: hash::Hasher>(&self, state: &mut H) {
- for tree in self.trees() {
- tree.hash(state);
- }
- }
-}
-
impl Encodable for ThinTokenStream {
fn encode<E: Encoder>(&self, encoder: &mut E) -> Result<(), E::Error> {
TokenStream::from(self.clone()).encode(encoder)
}
}
-impl Hash for ThinTokenStream {
- fn hash<H: hash::Hasher>(&self, state: &mut H) {
- TokenStream::from(self.clone()).hash(state);
- }
-}
-
-
#[cfg(test)]
mod tests {
use super::*;
use symbol::keywords;
use ast::{self, BinOpKind};
-use std::cmp::Ordering;
-
/// Associative operator with precedence.
///
/// This is the enum which specifies operator precedence and fixity to the parser.
-#[derive(Debug, PartialEq, Eq)]
+#[derive(PartialEq, Debug)]
pub enum AssocOp {
/// `+`
Add,
Colon,
}
-#[derive(Debug, PartialEq, Eq)]
+#[derive(PartialEq, Debug)]
pub enum Fixity {
/// The operator is left-associative
Left,
pub const PREC_PAREN: i8 = 99;
pub const PREC_FORCE_PAREN: i8 = 100;
-#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+#[derive(Debug, Clone, Copy)]
pub enum ExprPrecedence {
Closure,
Break,
Async,
}
-impl PartialOrd for ExprPrecedence {
- fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
- Some(self.order().cmp(&other.order()))
- }
-}
-
-impl Ord for ExprPrecedence {
- fn cmp(&self, other: &Self) -> Ordering {
- self.order().cmp(&other.order())
- }
-}
-
impl ExprPrecedence {
pub fn order(self) -> i8 {
match self {
})
}
-/// Parse a string, return a stmt
-pub fn string_to_stmt(source_str : String) -> Option<ast::Stmt> {
- let ps = ParseSess::new(FilePathMapping::empty());
- with_error_checking_parse(source_str, &ps, |p| {
- p.parse_stmt()
- })
-}
-
/// Parse a string, return a pat. Uses "irrefutable"... which doesn't
/// (currently) affect parsing.
pub fn string_to_pat(source_str: String) -> P<ast::Pat> {
use parse::token::Token;
use tokenstream::{TokenTree, TokenStream};
-#[derive(Copy, Clone, PartialEq, Eq)]
+#[derive(Copy, Clone)]
pub enum FnKind<'a> {
/// fn foo() or extern "Abi" fn foo()
ItemFn(Ident, FnHeader, &'a Visibility, &'a Block),
pub use self::SubstructureFields::*;
use std::cell::RefCell;
-use std::collections::HashSet;
use std::vec;
use rustc_target::spec::abi::Abi;
.map(|ty_param| ty_param.ident.name)
.collect();
- let mut processed_field_types = HashSet::new();
for field_ty in field_tys {
let tys = find_type_parameters(&field_ty, &ty_param_names, self.span, cx);
// if we have already handled this type, skip it
if let ast::TyKind::Path(_, ref p) = ty.node {
if p.segments.len() == 1 &&
- ty_param_names.contains(&p.segments[0].ident.name) ||
- processed_field_types.contains(&p.segments) {
+ ty_param_names.contains(&p.segments[0].ident.name) {
continue;
};
- processed_field_types.insert(p.segments.clone());
}
let mut bounds: Vec<_> = self.additional_bounds
.iter()
Self_ if nonstatic => {
self_args.push(arg_expr);
}
- Ptr(ref ty, _) if **ty == Self_ && nonstatic => {
+ Ptr(ref ty, _) if (if let Self_ = **ty { true } else { false }) && nonstatic => {
self_args.push(cx.expr_deref(trait_.span, arg_expr))
}
_ => {
use syntax_pos::symbol::keywords;
/// The types of pointers
-#[derive(Clone, Eq, PartialEq)]
-#[allow(dead_code)]
+#[derive(Clone)]
pub enum PtrTy<'a> {
/// &'lifetime mut
Borrowed(Option<&'a str>, ast::Mutability),
/// A path, e.g. `::std::option::Option::<i32>` (global). Has support
/// for type parameters and a lifetime.
-#[derive(Clone, Eq, PartialEq)]
+#[derive(Clone)]
pub struct Path<'a> {
path: Vec<&'a str>,
lifetime: Option<&'a str>,
kind: PathKind,
}
-#[derive(Clone, Eq, PartialEq)]
+#[derive(Clone)]
pub enum PathKind {
Local,
Global,
}
/// A type. Supports pointers, Self, and literals
-#[derive(Clone, Eq, PartialEq)]
+#[derive(Clone)]
pub enum Ty<'a> {
Self_,
/// &/Box/ Ty
use super::strcursor::StrCursor as Cur;
/// Represents a single `printf`-style substitution.
- #[derive(Clone, Eq, PartialEq, Debug)]
+ #[derive(Clone, PartialEq, Debug)]
pub enum Substitution<'a> {
/// A formatted output substitution.
Format(Format<'a>),
}
}
- #[derive(Clone, Eq, PartialEq, Debug)]
+ #[derive(Clone, PartialEq, Debug)]
/// A single `printf`-style formatting directive.
pub struct Format<'a> {
/// The entire original formatting directive.
}
/// A general number used in a `printf` formatting directive.
- #[derive(Copy, Clone, Eq, PartialEq, Debug)]
+ #[derive(Copy, Clone, PartialEq, Debug)]
pub enum Num {
// The range of these values is technically bounded by `NL_ARGMAX`... but, at least for GNU
// libc, it apparently has no real fixed limit. A `u16` is used here on the basis that it
pub mod shell {
use super::strcursor::StrCursor as Cur;
- #[derive(Clone, Eq, PartialEq, Debug)]
+ #[derive(Clone, PartialEq, Debug)]
pub enum Substitution<'a> {
Ordinal(u8),
Name(&'a str),
use syntax::parse::ParseSess;
use syntax::ptr::P;
use syntax::symbol::Symbol;
+use syntax::symbol::keywords;
use syntax::visit::{self, Visitor};
use syntax_pos::{Span, DUMMY_SP};
impl<'a> CollectProcMacros<'a> {
fn check_not_pub_in_root(&self, vis: &ast::Visibility, sp: Span) {
- if self.is_proc_macro_crate &&
- self.in_root &&
- vis.node == ast::VisibilityKind::Public {
+ if self.is_proc_macro_crate && self.in_root && vis.node.is_pub() {
self.handler.span_err(sp,
"`proc-macro` crate types cannot \
export any items other than functions \
Vec::new()
};
- if self.in_root && item.vis.node == ast::VisibilityKind::Public {
+ if self.in_root && item.vis.node.is_pub() {
self.derives.push(ProcMacroDerive {
span: item.span,
trait_name,
return;
}
- if self.in_root && item.vis.node == ast::VisibilityKind::Public {
+ if self.in_root && item.vis.node.is_pub() {
self.attr_macros.push(ProcMacroDef {
span: item.span,
function_name: item.ident,
return;
}
- if self.in_root && item.vis.node == ast::VisibilityKind::Public {
+ if self.in_root && item.vis.node.is_pub() {
self.bang_macros.push(ProcMacroDef {
span: item.span,
function_name: item.ident,
for attr in &item.attrs {
if is_proc_macro_attr(&attr) {
if let Some(prev_attr) = found_attr {
- let msg = if attr.path == prev_attr.path {
+ let msg = if attr.path.segments[0].ident.name ==
+ prev_attr.path.segments[0].ident.name {
format!("Only one `#[{}]` attribute is allowed on any given function",
attr.path)
} else {
let register_custom_derive = Ident::from_str("register_custom_derive");
let register_attr_proc_macro = Ident::from_str("register_attr_proc_macro");
let register_bang_proc_macro = Ident::from_str("register_bang_proc_macro");
+ let crate_kw = Ident::with_empty_ctxt(keywords::Crate.name());
+ let local_path = |cx: &mut ExtCtxt, sp: Span, name: Ident| {
+ cx.path(sp.with_ctxt(span.ctxt()), vec![crate_kw, name])
+ };
let mut stmts = custom_derives.iter().map(|cd| {
- let path = cx.path_global(cd.span, vec![cd.function_name]);
+ let path = local_path(cx, cd.span, cd.function_name);
let trait_name = cx.expr_str(cd.span, cd.trait_name);
let attrs = cx.expr_vec_slice(
span,
stmts.extend(custom_attrs.iter().map(|ca| {
let name = cx.expr_str(ca.span, ca.function_name.name);
- let path = cx.path_global(ca.span, vec![ca.function_name]);
+ let path = local_path(cx, ca.span, ca.function_name);
let registrar = cx.expr_ident(ca.span, registrar);
let ufcs_path = cx.path(span,
stmts.extend(custom_macros.iter().map(|cm| {
let name = cx.expr_str(cm.span, cm.function_name.name);
- let path = cx.path_global(cm.span, vec![cm.function_name]);
+ let path = local_path(cx, cm.span, cm.function_name);
let registrar = cx.expr_ident(cm.span, registrar);
let ufcs_path = cx.path(span,
use std::str::FromStr;
/// The edition of the compiler (RFC 2052)
-#[derive(Clone, Copy, Hash, PartialOrd, Ord, Eq, PartialEq, Debug, RustcEncodable, RustcDecodable)]
+#[derive(Clone, Copy, Hash, PartialEq, PartialOrd, Debug, RustcEncodable, RustcDecodable)]
#[non_exhaustive]
pub enum Edition {
// editions must be kept in order, oldest to newest
--- /dev/null
+// Copyright 2018 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.
+
+#![allow(const_err)]
+
+// nll successfully compiles this. It is a bug.
+// See https://github.com/rust-lang/rust/issues/52384
+fn main() {
+ let x: &'static _ = &|| { let z = 3; z }; //~ ERROR does not live long enough
+}
+++ /dev/null
-// Copyright 2017 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.
-
-// ignore-stage1
-// ignore-cross-compile
-#![feature(quote, rustc_private)]
-
-extern crate syntax;
-extern crate rustc_data_structures;
-
-use syntax::ext::base::{ExtCtxt, DummyResolver};
-use syntax::ext::expand::ExpansionConfig;
-use syntax::parse::ParseSess;
-use syntax::codemap::{FilePathMapping, dummy_spanned};
-use syntax::print::pprust::expr_to_string;
-use syntax::ast::{ExprKind, LitKind, RangeLimits};
-use syntax::ptr::P;
-
-use rustc_data_structures::sync::Lrc;
-
-fn main() {
- syntax::with_globals(|| run());
-}
-
-fn run() {
- let parse_sess = ParseSess::new(FilePathMapping::empty());
- let exp_cfg = ExpansionConfig::default("issue_35829".to_owned());
- let mut resolver = DummyResolver;
- let cx = ExtCtxt::new(&parse_sess, exp_cfg, &mut resolver);
-
- // check byte string
- let byte_string = quote_expr!(&cx, b"one");
- let byte_string_lit_kind = LitKind::ByteStr(Lrc::new(b"one".to_vec()));
- assert_eq!(byte_string.node, ExprKind::Lit(P(dummy_spanned(byte_string_lit_kind))));
-
- // check raw byte string
- let raw_byte_string = quote_expr!(&cx, br###"#"two"#"###);
- let raw_byte_string_lit_kind = LitKind::ByteStr(Lrc::new(b"#\"two\"#".to_vec()));
- assert_eq!(raw_byte_string.node, ExprKind::Lit(P(dummy_spanned(raw_byte_string_lit_kind))));
-
- // check dotdoteq
- let closed_range = quote_expr!(&cx, 0 ..= 1);
- assert_eq!(closed_range.node, ExprKind::Range(
- Some(quote_expr!(&cx, 0)),
- Some(quote_expr!(&cx, 1)),
- RangeLimits::Closed
- ));
-
- // test case from 35829
- let expr_35829 = quote_expr!(&cx, std::io::stdout().write(b"one"));
- assert_eq!(expr_to_string(&expr_35829), r#"std::io::stdout().write(b"one")"#);
-}
1
}
+fn other_internal_fn() -> u32 {
+ 1
+}
+
// See #40839
pub fn return_closure_accessing_internal_fn() -> impl Fn() -> u32 {
|| {
}
pub fn return_internal_fn() -> impl Fn() -> u32 {
- some_internal_fn
+ other_internal_fn
}
--- /dev/null
+// Copyright 2012-2013 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.
+
+// Issue #52129: ICE when trying to document the `quote` proc-macro from proc_macro
+
+// As of this writing, we don't currently attempt to document proc-macros. However, we shouldn't
+// crash when we try.
+
+extern crate proc_macro;
+
+pub use proc_macro::*;
--- /dev/null
+// Copyright 2018 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.
+
+// compile-pass
+
+#![crate_type = "proc-macro"]
+#![deny(rust_2018_compatibility)]
+#![feature(rust_2018_preview)]
+
+extern crate proc_macro;
+
+use proc_macro::TokenStream;
+
+#[proc_macro_derive(Template, attributes(template))]
+pub fn derive_template(input: TokenStream) -> TokenStream {
+ input
+}
--- /dev/null
+// Copyright 2018 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.
+
+// compile-pass
+
+#![deny(warnings)]
+
+use std::collections::BTreeMap;
+
+pub struct RangeMap {
+ map: BTreeMap<Range, u8>,
+}
+
+#[derive(Eq, PartialEq, Ord, PartialOrd)]
+struct Range;
+
+impl RangeMap {
+ fn iter_with_range<'a>(&'a self) -> impl Iterator<Item = (&'a Range, &'a u8)> + 'a {
+ self.map.range(Range..Range)
+ }
+
+ pub fn iter<'a>(&'a self) -> impl Iterator<Item = &'a u8> + 'a {
+ self.iter_with_range().map(|(_, data)| data)
+ }
+
+}
+
+fn main() {}
-Subproject commit aad450ef923091ba4699891df0fe518f0d3686f6
+Subproject commit 5e085e43104f6748a9717bb78de8b634712638b4
-Subproject commit 6b4238b46595de1660a95887b287ddabe62726ea
+Subproject commit 2b57851099ffbdaecb26cdecd47fa3477e3b75a6