Auto merge of #46556 - michaelwoerister:enable-query-caching, r=nmatsakis

incr.comp.: Enable query result caching for many more queries

Newly cached queries are:
* const_is_rvalue_promotable_to_static
* trans_fulfill_obligation
* optimized_mir
* unsafety_check_result
* borrowck
* mir_borrowck
* mir_const_qualif
* contains_extern_indicator
* def_symbol_name
* symbol_name

This also includes the stricter `Span` hashing first mentioned in #46490, which will lead to more false positives in release builds but overall is more correct -- and necessary for caching MIR. Hopefully we will soon be able to reduce the rate of false positives again by factoring `Span` out of MIR.

r? @nikomatsakis
This commit is contained in:
bors 2017-12-08 11:34:23 +00:00
commit 88fc3bc271
55 changed files with 260 additions and 995 deletions

View File

@ -14,7 +14,6 @@ use hir::map::DefPathHash;
use hir::map::definitions::Definitions;
use ich::{self, CachingCodemapView};
use middle::cstore::CrateStore;
use session::config::DebugInfoLevel::NoDebugInfo;
use ty::{TyCtxt, fast_reject};
use session::Session;
@ -24,7 +23,7 @@ use std::cell::RefCell;
use std::collections::HashMap;
use syntax::ast;
use syntax::attr;
use syntax::codemap::CodeMap;
use syntax::ext::hygiene::SyntaxContext;
use syntax::symbol::Symbol;
@ -51,7 +50,6 @@ pub struct StableHashingContext<'gcx> {
body_resolver: BodyResolver<'gcx>,
hash_spans: bool,
hash_bodies: bool,
overflow_checks_enabled: bool,
node_id_hashing_mode: NodeIdHashingMode,
// Very often, we are hashing something that does not need the
@ -89,8 +87,7 @@ impl<'gcx> StableHashingContext<'gcx> {
definitions: &'gcx Definitions,
cstore: &'gcx CrateStore)
-> Self {
let hash_spans_initial = sess.opts.debuginfo != NoDebugInfo;
let check_overflow_initial = sess.overflow_checks();
let hash_spans_initial = !sess.opts.debugging_opts.incremental_ignore_spans;
debug_assert!(ich::IGNORED_ATTRIBUTES.len() > 0);
IGNORED_ATTR_NAMES.with(|names| {
@ -110,7 +107,6 @@ impl<'gcx> StableHashingContext<'gcx> {
raw_codemap: sess.codemap(),
hash_spans: hash_spans_initial,
hash_bodies: true,
overflow_checks_enabled: check_overflow_initial,
node_id_hashing_mode: NodeIdHashingMode::HashDefPath,
}
}
@ -120,11 +116,6 @@ impl<'gcx> StableHashingContext<'gcx> {
self.sess
}
pub fn force_span_hashing(mut self) -> Self {
self.hash_spans = true;
self
}
#[inline]
pub fn while_hashing_hir_bodies<F: FnOnce(&mut Self)>(&mut self,
hash_bodies: bool,
@ -174,11 +165,6 @@ impl<'gcx> StableHashingContext<'gcx> {
self.definitions.node_to_hir_id(node_id)
}
#[inline]
pub fn hash_spans(&self) -> bool {
self.hash_spans
}
#[inline]
pub fn hash_bodies(&self) -> bool {
self.hash_bodies
@ -204,58 +190,13 @@ impl<'gcx> StableHashingContext<'gcx> {
})
}
pub fn hash_hir_item_like<F: FnOnce(&mut Self)>(&mut self,
item_attrs: &[ast::Attribute],
is_const: bool,
f: F) {
let prev_overflow_checks = self.overflow_checks_enabled;
if is_const || attr::contains_name(item_attrs, "rustc_inherit_overflow_checks") {
self.overflow_checks_enabled = true;
}
pub fn hash_hir_item_like<F: FnOnce(&mut Self)>(&mut self, f: F) {
let prev_hash_node_ids = self.node_id_hashing_mode;
self.node_id_hashing_mode = NodeIdHashingMode::Ignore;
f(self);
self.node_id_hashing_mode = prev_hash_node_ids;
self.overflow_checks_enabled = prev_overflow_checks;
}
#[inline]
pub fn binop_can_panic_at_runtime(&self, binop: hir::BinOp_) -> bool
{
match binop {
hir::BiAdd |
hir::BiSub |
hir::BiShl |
hir::BiShr |
hir::BiMul => self.overflow_checks_enabled,
hir::BiDiv |
hir::BiRem => true,
hir::BiAnd |
hir::BiOr |
hir::BiBitXor |
hir::BiBitAnd |
hir::BiBitOr |
hir::BiEq |
hir::BiLt |
hir::BiLe |
hir::BiNe |
hir::BiGe |
hir::BiGt => false
}
}
#[inline]
pub fn unop_can_panic_at_runtime(&self, unop: hir::UnOp) -> bool
{
match unop {
hir::UnDeref |
hir::UnNot => false,
hir::UnNeg => self.overflow_checks_enabled,
}
}
}

View File

@ -529,63 +529,9 @@ impl<'gcx> HashStable<StableHashingContext<'gcx>> for hir::Expr {
ref attrs
} = *self;
let spans_always_on = match *node {
hir::ExprBox(..) |
hir::ExprArray(..) |
hir::ExprCall(..) |
hir::ExprLit(..) |
hir::ExprCast(..) |
hir::ExprType(..) |
hir::ExprIf(..) |
hir::ExprWhile(..) |
hir::ExprLoop(..) |
hir::ExprMatch(..) |
hir::ExprClosure(..) |
hir::ExprBlock(..) |
hir::ExprAssign(..) |
hir::ExprTupField(..) |
hir::ExprAddrOf(..) |
hir::ExprBreak(..) |
hir::ExprAgain(..) |
hir::ExprRet(..) |
hir::ExprYield(..) |
hir::ExprInlineAsm(..) |
hir::ExprRepeat(..) |
hir::ExprTup(..) |
hir::ExprMethodCall(..) |
hir::ExprPath(..) |
hir::ExprStruct(..) |
hir::ExprField(..) => {
// For these we only hash the span when debuginfo is on.
false
}
// For the following, spans might be significant because of
// panic messages indicating the source location.
hir::ExprBinary(op, ..) => {
hcx.binop_can_panic_at_runtime(op.node)
}
hir::ExprUnary(op, _) => {
hcx.unop_can_panic_at_runtime(op)
}
hir::ExprAssignOp(op, ..) => {
hcx.binop_can_panic_at_runtime(op.node)
}
hir::ExprIndex(..) => {
true
}
};
if spans_always_on {
hcx.while_hashing_spans(true, |hcx| {
span.hash_stable(hcx, hasher);
node.hash_stable(hcx, hasher);
attrs.hash_stable(hcx, hasher);
});
} else {
span.hash_stable(hcx, hasher);
node.hash_stable(hcx, hasher);
attrs.hash_stable(hcx, hasher);
}
span.hash_stable(hcx, hasher);
node.hash_stable(hcx, hasher);
attrs.hash_stable(hcx, hasher);
})
}
}
@ -712,15 +658,7 @@ impl<'gcx> HashStable<StableHashingContext<'gcx>> for hir::TraitItem {
span
} = *self;
let is_const = match *node {
hir::TraitItemKind::Const(..) |
hir::TraitItemKind::Type(..) => true,
hir::TraitItemKind::Method(hir::MethodSig { constness, .. }, _) => {
constness == hir::Constness::Const
}
};
hcx.hash_hir_item_like(attrs, is_const, |hcx| {
hcx.hash_hir_item_like(|hcx| {
name.hash_stable(hcx, hasher);
attrs.hash_stable(hcx, hasher);
generics.hash_stable(hcx, hasher);
@ -757,15 +695,7 @@ impl<'gcx> HashStable<StableHashingContext<'gcx>> for hir::ImplItem {
span
} = *self;
let is_const = match *node {
hir::ImplItemKind::Const(..) |
hir::ImplItemKind::Type(..) => true,
hir::ImplItemKind::Method(hir::MethodSig { constness, .. }, _) => {
constness == hir::Constness::Const
}
};
hcx.hash_hir_item_like(attrs, is_const, |hcx| {
hcx.hash_hir_item_like(|hcx| {
name.hash_stable(hcx, hasher);
vis.hash_stable(hcx, hasher);
defaultness.hash_stable(hcx, hasher);
@ -884,30 +814,6 @@ impl<'gcx> HashStable<StableHashingContext<'gcx>> for hir::Item {
fn hash_stable<W: StableHasherResult>(&self,
hcx: &mut StableHashingContext<'gcx>,
hasher: &mut StableHasher<W>) {
let is_const = match self.node {
hir::ItemStatic(..) |
hir::ItemConst(..) => {
true
}
hir::ItemFn(_, _, constness, ..) => {
constness == hir::Constness::Const
}
hir::ItemUse(..) |
hir::ItemExternCrate(..) |
hir::ItemForeignMod(..) |
hir::ItemGlobalAsm(..) |
hir::ItemMod(..) |
hir::ItemAutoImpl(..) |
hir::ItemTrait(..) |
hir::ItemImpl(..) |
hir::ItemTy(..) |
hir::ItemEnum(..) |
hir::ItemStruct(..) |
hir::ItemUnion(..) => {
false
}
};
let hir::Item {
name,
ref attrs,
@ -918,7 +824,7 @@ impl<'gcx> HashStable<StableHashingContext<'gcx>> for hir::Item {
span
} = *self;
hcx.hash_hir_item_like(attrs, is_const, |hcx| {
hcx.hash_hir_item_like(|hcx| {
name.hash_stable(hcx, hasher);
attrs.hash_stable(hcx, hasher);
node.hash_stable(hcx, hasher);

View File

@ -55,48 +55,11 @@ for mir::UnsafetyViolationKind {
}
}
}
impl<'gcx> HashStable<StableHashingContext<'gcx>>
for mir::Terminator<'gcx> {
#[inline]
fn hash_stable<W: StableHasherResult>(&self,
hcx: &mut StableHashingContext<'gcx>,
hasher: &mut StableHasher<W>) {
let mir::Terminator {
ref kind,
ref source_info,
} = *self;
let hash_spans_unconditionally = match *kind {
mir::TerminatorKind::Assert { .. } => {
// Assert terminators generate a panic message that contains the
// source location, so we always have to feed its span into the
// ICH.
true
}
mir::TerminatorKind::Goto { .. } |
mir::TerminatorKind::SwitchInt { .. } |
mir::TerminatorKind::Resume |
mir::TerminatorKind::Return |
mir::TerminatorKind::GeneratorDrop |
mir::TerminatorKind::Unreachable |
mir::TerminatorKind::Drop { .. } |
mir::TerminatorKind::DropAndReplace { .. } |
mir::TerminatorKind::Yield { .. } |
mir::TerminatorKind::Call { .. } |
mir::TerminatorKind::FalseEdges { .. } => false,
};
if hash_spans_unconditionally {
hcx.while_hashing_spans(true, |hcx| {
source_info.hash_stable(hcx, hasher);
})
} else {
source_info.hash_stable(hcx, hasher);
}
kind.hash_stable(hcx, hasher);
}
}
impl_stable_hash_for!(struct mir::Terminator<'tcx> {
kind,
source_info
});
impl<'gcx, T> HashStable<StableHashingContext<'gcx>> for mir::ClearCrossCrate<T>
where T: HashStable<StableHashingContext<'gcx>>

View File

@ -1830,7 +1830,7 @@ pub struct GeneratorLayout<'tcx> {
/// instance of the closure is created, the corresponding free regions
/// can be extracted from its type and constrained to have the given
/// outlives relationship.
#[derive(Clone, Debug)]
#[derive(Clone, Debug, RustcEncodable, RustcDecodable)]
pub struct ClosureRegionRequirements {
/// The number of external regions defined on the closure. In our
/// example above, it would be 3 -- one for `'static`, then `'1`
@ -1846,7 +1846,7 @@ pub struct ClosureRegionRequirements {
/// Indicates an outlives constraint between two free-regions declared
/// on the closure.
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable)]
pub struct ClosureOutlivesRequirement {
// This region ...
pub free_region: ty::RegionVid,

View File

@ -1084,6 +1084,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
"dump hash information in textual format to stdout"),
incremental_verify_ich: bool = (false, parse_bool, [UNTRACKED],
"verify incr. comp. hashes of green query instances"),
incremental_ignore_spans: bool = (false, parse_bool, [UNTRACKED],
"ignore spans during ICH computation -- used for testing"),
dump_dep_graph: bool = (false, parse_bool, [UNTRACKED],
"dump the dependency graph to $RUST_DEP_GRAPH (default: /tmp/dep_graph.gv)"),
query_dep_graph: bool = (false, parse_bool, [UNTRACKED],

View File

@ -27,6 +27,7 @@ pub trait QueryConfig {
pub(super) trait QueryDescription<'tcx>: QueryConfig {
fn describe(tcx: TyCtxt, key: Self::Key) -> String;
#[inline]
fn cache_on_disk(_: Self::Key) -> bool {
false
}
@ -34,7 +35,7 @@ pub(super) trait QueryDescription<'tcx>: QueryConfig {
fn try_load_from_disk(_: TyCtxt<'_, 'tcx, 'tcx>,
_: SerializedDepNodeIndex)
-> Option<Self::Value> {
bug!("QueryDescription::load_from_disk() called for unsupport query.")
bug!("QueryDescription::load_from_disk() called for an unsupported query.")
}
}
@ -166,6 +167,18 @@ impl<'tcx> QueryDescription<'tcx> for queries::symbol_name<'tcx> {
fn describe(_tcx: TyCtxt, instance: ty::Instance<'tcx>) -> String {
format!("computing the symbol for `{}`", instance)
}
#[inline]
fn cache_on_disk(_: Self::Key) -> bool {
true
}
#[inline]
fn try_load_from_disk<'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
id: SerializedDepNodeIndex)
-> Option<Self::Value> {
tcx.on_disk_query_result_cache.try_load_query_result(tcx, id)
}
}
impl<'tcx> QueryDescription<'tcx> for queries::describe_def<'tcx> {
@ -234,6 +247,18 @@ impl<'tcx> QueryDescription<'tcx> for queries::const_is_rvalue_promotable_to_sta
format!("const checking if rvalue is promotable to static `{}`",
tcx.item_path_str(def_id))
}
#[inline]
fn cache_on_disk(_: Self::Key) -> bool {
true
}
#[inline]
fn try_load_from_disk<'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
id: SerializedDepNodeIndex)
-> Option<Self::Value> {
tcx.on_disk_query_result_cache.try_load_query_result(tcx, id)
}
}
impl<'tcx> QueryDescription<'tcx> for queries::rvalue_promotable_map<'tcx> {
@ -254,6 +279,18 @@ impl<'tcx> QueryDescription<'tcx> for queries::trans_fulfill_obligation<'tcx> {
fn describe(tcx: TyCtxt, key: (ty::ParamEnv<'tcx>, ty::PolyTraitRef<'tcx>)) -> String {
format!("checking if `{}` fulfills its obligations", tcx.item_path_str(key.1.def_id()))
}
#[inline]
fn cache_on_disk(_: Self::Key) -> bool {
true
}
#[inline]
fn try_load_from_disk<'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
id: SerializedDepNodeIndex)
-> Option<Self::Value> {
tcx.on_disk_query_result_cache.try_load_query_result(tcx, id)
}
}
impl<'tcx> QueryDescription<'tcx> for queries::trait_impls_of<'tcx> {
@ -567,3 +604,42 @@ impl<'tcx> QueryDescription<'tcx> for queries::typeck_tables_of<'tcx> {
}
}
impl<'tcx> QueryDescription<'tcx> for queries::optimized_mir<'tcx> {
#[inline]
fn cache_on_disk(def_id: Self::Key) -> bool {
def_id.is_local()
}
fn try_load_from_disk<'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
id: SerializedDepNodeIndex)
-> Option<Self::Value> {
let mir: Option<::mir::Mir<'tcx>> = tcx.on_disk_query_result_cache
.try_load_query_result(tcx, id);
mir.map(|x| tcx.alloc_mir(x))
}
}
macro_rules! impl_disk_cacheable_query(
($query_name:ident, |$key:tt| $cond:expr) => {
impl<'tcx> QueryDescription<'tcx> for queries::$query_name<'tcx> {
#[inline]
fn cache_on_disk($key: Self::Key) -> bool {
$cond
}
#[inline]
fn try_load_from_disk<'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
id: SerializedDepNodeIndex)
-> Option<Self::Value> {
tcx.on_disk_query_result_cache.try_load_query_result(tcx, id)
}
}
}
);
impl_disk_cacheable_query!(unsafety_check_result, |def_id| def_id.is_local());
impl_disk_cacheable_query!(borrowck, |def_id| def_id.is_local());
impl_disk_cacheable_query!(mir_borrowck, |def_id| def_id.is_local());
impl_disk_cacheable_query!(mir_const_qualif, |def_id| def_id.is_local());
impl_disk_cacheable_query!(contains_extern_indicator, |_| true);
impl_disk_cacheable_query!(def_symbol_name, |_| true);

View File

@ -207,6 +207,16 @@ impl<'sess> OnDiskCache<'sess> {
// Encode TypeckTables
encode_query_results::<typeck_tables_of, _>(tcx, enc, qri)?;
encode_query_results::<optimized_mir, _>(tcx, enc, qri)?;
encode_query_results::<unsafety_check_result, _>(tcx, enc, qri)?;
encode_query_results::<borrowck, _>(tcx, enc, qri)?;
encode_query_results::<mir_borrowck, _>(tcx, enc, qri)?;
encode_query_results::<mir_const_qualif, _>(tcx, enc, qri)?;
encode_query_results::<def_symbol_name, _>(tcx, enc, qri)?;
encode_query_results::<const_is_rvalue_promotable_to_static, _>(tcx, enc, qri)?;
encode_query_results::<contains_extern_indicator, _>(tcx, enc, qri)?;
encode_query_results::<symbol_name, _>(tcx, enc, qri)?;
encode_query_results::<trans_fulfill_obligation, _>(tcx, enc, qri)?;
}
// Encode diagnostics

View File

@ -974,4 +974,7 @@ impl_load_from_cache!(
BorrowCheck => borrowck,
MirBorrowCheck => mir_borrowck,
MirConstQualif => mir_const_qualif,
SymbolName => def_symbol_name,
ConstIsRvaluePromotableToStatic => const_is_rvalue_promotable_to_static,
ContainsExternIndicator => contains_extern_indicator,
);

View File

@ -47,9 +47,7 @@ impl<'a, 'b, 'tcx> IsolatedEncoder<'a, 'b, 'tcx> {
let mut hasher = StableHasher::new();
hcx.while_hashing_hir_bodies(true, |hcx| {
hcx.while_hashing_spans(false, |hcx| {
body.hash_stable(hcx, &mut hasher);
});
body.hash_stable(hcx, &mut hasher);
});
hasher.finish()

View File

@ -273,25 +273,23 @@ impl<'a, 'tcx> SpecializedDecoder<Span> for DecodeContext<'a, 'tcx> {
let lo = BytePos::decode(self)?;
let hi = BytePos::decode(self)?;
if lo == BytePos(0) && hi == BytePos(0) {
// Don't try to rebase DUMMY_SP. Otherwise it will look like a valid
// Span again.
return Ok(DUMMY_SP)
}
if hi < lo {
// Consistently map invalid spans to DUMMY_SP.
return Ok(DUMMY_SP)
}
let sess = if let Some(sess) = self.sess {
sess
} else {
bug!("Cannot decode Span without Session.")
};
let (lo, hi) = if lo > hi {
// Currently macro expansion sometimes produces invalid Span values
// where lo > hi. In order not to crash the compiler when trying to
// translate these values, let's transform them into something we
// can handle (and which will produce useful debug locations at
// least some of the time).
// This workaround is only necessary as long as macro expansion is
// not fixed. FIXME(#23480)
(lo, lo)
} else {
(lo, hi)
};
let imported_filemaps = self.cdata().imported_filemaps(&sess.codemap());
let filemap = {
// Optimize for the case that most spans within a translated item
@ -321,6 +319,16 @@ impl<'a, 'tcx> SpecializedDecoder<Span> for DecodeContext<'a, 'tcx> {
}
};
// Make sure our binary search above is correct.
debug_assert!(lo >= filemap.original_start_pos &&
lo <= filemap.original_end_pos);
if hi < filemap.original_start_pos || hi > filemap.original_end_pos {
// `hi` points to a different FileMap than `lo` which is invalid.
// Again, map invalid Spans to DUMMY_SP.
return Ok(DUMMY_SP)
}
let lo = (lo + filemap.translated_filemap.start_pos) - filemap.original_start_pos;
let hi = (hi + filemap.translated_filemap.start_pos) - filemap.original_start_pos;

View File

@ -18,7 +18,7 @@
// must-compile-successfully
// revisions: cfail1 cfail2 cfail3
// compile-flags: -Z query-dep-graph
// compile-flags: -Z query-dep-graph -Zincremental-ignore-spans
#![allow(warnings)]

View File

@ -18,7 +18,7 @@
// must-compile-successfully
// revisions: cfail1 cfail2 cfail3
// compile-flags: -Z query-dep-graph
// compile-flags: -Z query-dep-graph -Zincremental-ignore-spans
#![allow(warnings)]
#![feature(rustc_attrs)]

View File

@ -18,7 +18,7 @@
// must-compile-successfully
// revisions: cfail1 cfail2 cfail3
// compile-flags: -Z query-dep-graph
// compile-flags: -Z query-dep-graph -Zincremental-ignore-spans
#![allow(warnings)]
#![feature(rustc_attrs)]

View File

@ -18,7 +18,7 @@
// must-compile-successfully
// revisions: cfail1 cfail2 cfail3
// compile-flags: -Z query-dep-graph
// compile-flags: -Z query-dep-graph -Zincremental-ignore-spans
#![allow(warnings)]
#![feature(rustc_attrs)]

View File

@ -23,7 +23,7 @@
// must-compile-successfully
// revisions: cfail1 cfail2 cfail3
// compile-flags: -Z query-dep-graph
// compile-flags: -Z query-dep-graph -Zincremental-ignore-spans
#![allow(warnings)]
#![feature(rustc_attrs)]

View File

@ -10,7 +10,7 @@
// must-compile-successfully
// revisions: cfail1 cfail2 cfail3
// compile-flags: -Z query-dep-graph
// compile-flags: -Z query-dep-graph -Zincremental-ignore-spans
#![allow(warnings)]
#![feature(rustc_attrs)]

View File

@ -18,7 +18,7 @@
// must-compile-successfully
// revisions: cfail1 cfail2 cfail3
// compile-flags: -Z query-dep-graph
// compile-flags: -Z query-dep-graph -Zincremental-ignore-spans
#![allow(warnings)]
#![feature(rustc_attrs)]

View File

@ -18,7 +18,7 @@
// must-compile-successfully
// revisions: cfail1 cfail2 cfail3
// compile-flags: -Z query-dep-graph
// compile-flags: -Z query-dep-graph -Zincremental-ignore-spans
#![allow(warnings)]
#![feature(rustc_attrs)]

View File

@ -18,7 +18,7 @@
// must-compile-successfully
// revisions: cfail1 cfail2 cfail3
// compile-flags: -Z query-dep-graph
// compile-flags: -Z query-dep-graph -Zincremental-ignore-spans
#![allow(warnings)]

View File

@ -18,7 +18,7 @@
// must-compile-successfully
// revisions: cfail1 cfail2 cfail3
// compile-flags: -Z query-dep-graph
// compile-flags: -Z query-dep-graph -Zincremental-ignore-spans
#![allow(warnings)]

View File

@ -18,7 +18,7 @@
// must-compile-successfully
// revisions: cfail1 cfail2 cfail3
// compile-flags: -Z query-dep-graph
// compile-flags: -Z query-dep-graph -Zincremental-ignore-spans
#![allow(warnings)]
#![feature(rustc_attrs)]

View File

@ -18,7 +18,7 @@
// must-compile-successfully
// revisions: cfail1 cfail2 cfail3
// compile-flags: -Z query-dep-graph
// compile-flags: -Z query-dep-graph -Zincremental-ignore-spans
#![allow(warnings)]

View File

@ -18,7 +18,7 @@
// must-compile-successfully
// revisions: cfail1 cfail2 cfail3
// compile-flags: -Z query-dep-graph
// compile-flags: -Z query-dep-graph -Zincremental-ignore-spans
#![allow(warnings)]
#![feature(rustc_attrs)]

View File

@ -18,7 +18,7 @@
// must-compile-successfully
// revisions: cfail1 cfail2 cfail3
// compile-flags: -Z query-dep-graph
// compile-flags: -Z query-dep-graph -Zincremental-ignore-spans
#![allow(warnings)]

View File

@ -18,7 +18,7 @@
// must-compile-successfully
// revisions: cfail1 cfail2 cfail3
// compile-flags: -Z query-dep-graph
// compile-flags: -Z query-dep-graph -Zincremental-ignore-spans
#![allow(warnings)]
#![feature(rustc_attrs)]

View File

@ -18,7 +18,7 @@
// must-compile-successfully
// revisions: cfail1 cfail2 cfail3
// compile-flags: -Z query-dep-graph
// compile-flags: -Z query-dep-graph -Zincremental-ignore-spans
#![allow(warnings)]

View File

@ -28,155 +28,134 @@
// Indexing expression ---------------------------------------------------------
#[cfg(cfail1)]
pub fn indexing(slice: &[u8]) -> u8 {
slice[100]
}
#[cfg(not(cfail1))]
#[rustc_clean(cfg="cfail2", except="HirBody,MirValidated,MirOptimized")]
#[rustc_clean(cfg="cfail3")]
pub fn indexing(slice: &[u8]) -> u8 {
slice[100]
#[cfg(cfail1)]
{
slice[100]
}
#[cfg(not(cfail1))]
{
slice[100]
}
}
// Arithmetic overflow plus ----------------------------------------------------
#[cfg(cfail1)]
pub fn arithmetic_overflow_plus(val: i32) -> i32 {
val + 1
}
#[cfg(not(cfail1))]
#[rustc_clean(cfg="cfail2", except="HirBody,MirValidated,MirOptimized")]
#[rustc_clean(cfg="cfail3")]
pub fn arithmetic_overflow_plus(val: i32) -> i32 {
val + 1
#[cfg(cfail1)]
{
val + 1
}
#[cfg(not(cfail1))]
{
val + 1
}
}
// Arithmetic overflow minus ----------------------------------------------------
#[cfg(cfail1)]
pub fn arithmetic_overflow_minus(val: i32) -> i32 {
val - 1
}
#[cfg(not(cfail1))]
#[rustc_clean(cfg="cfail2", except="HirBody,MirValidated,MirOptimized")]
#[rustc_clean(cfg="cfail3")]
pub fn arithmetic_overflow_minus(val: i32) -> i32 {
val - 1
#[cfg(cfail1)]
{
val - 1
}
#[cfg(not(cfail1))]
{
val - 1
}
}
// Arithmetic overflow mult ----------------------------------------------------
#[cfg(cfail1)]
pub fn arithmetic_overflow_mult(val: i32) -> i32 {
val * 2
}
#[cfg(not(cfail1))]
#[rustc_clean(cfg="cfail2", except="HirBody,MirValidated,MirOptimized")]
#[rustc_clean(cfg="cfail3")]
pub fn arithmetic_overflow_mult(val: i32) -> i32 {
val * 2
#[cfg(cfail1)]
{
val * 2
}
#[cfg(not(cfail1))]
{
val * 2
}
}
// Arithmetic overflow negation ------------------------------------------------
#[cfg(cfail1)]
pub fn arithmetic_overflow_negation(val: i32) -> i32 {
-val
}
#[cfg(not(cfail1))]
#[rustc_clean(cfg="cfail2", except="HirBody,MirValidated,MirOptimized")]
#[rustc_clean(cfg="cfail3")]
pub fn arithmetic_overflow_negation(val: i32) -> i32 {
-val
#[cfg(cfail1)]
{
-val
}
#[cfg(not(cfail1))]
{
-val
}
}
// Division by zero ------------------------------------------------------------
#[cfg(cfail1)]
pub fn division_by_zero(val: i32) -> i32 {
2 / val
}
#[cfg(not(cfail1))]
#[rustc_clean(cfg="cfail2", except="HirBody,MirValidated,MirOptimized")]
#[rustc_clean(cfg="cfail3")]
pub fn division_by_zero(val: i32) -> i32 {
2 / val
#[cfg(cfail1)]
{
2 / val
}
#[cfg(not(cfail1))]
{
2 / val
}
}
// Division by zero ------------------------------------------------------------
#[cfg(cfail1)]
pub fn mod_by_zero(val: i32) -> i32 {
2 % val
}
#[cfg(not(cfail1))]
#[rustc_clean(cfg="cfail2", except="HirBody,MirValidated,MirOptimized")]
#[rustc_clean(cfg="cfail3")]
pub fn mod_by_zero(val: i32) -> i32 {
2 % val
#[cfg(cfail1)]
{
2 % val
}
#[cfg(not(cfail1))]
{
2 % val
}
}
// shift left ------------------------------------------------------------------
#[cfg(cfail1)]
pub fn shift_left(val: i32, shift: usize) -> i32 {
val << shift
}
#[cfg(not(cfail1))]
#[rustc_clean(cfg="cfail2", except="HirBody,MirValidated,MirOptimized")]
#[rustc_clean(cfg="cfail3")]
pub fn shift_left(val: i32, shift: usize) -> i32 {
val << shift
#[cfg(cfail1)]
{
val << shift
}
#[cfg(not(cfail1))]
{
val << shift
}
}
// shift right ------------------------------------------------------------------
#[cfg(cfail1)]
pub fn shift_right(val: i32, shift: usize) -> i32 {
val >> shift
}
#[cfg(not(cfail1))]
#[rustc_clean(cfg="cfail2", except="HirBody,MirValidated,MirOptimized")]
#[rustc_clean(cfg="cfail3")]
pub fn shift_right(val: i32, shift: usize) -> i32 {
val >> shift
}
// THE FOLLOWING ITEMS SHOULD NOT BE INFLUENCED BY THEIR SOURCE LOCATION
// bitwise ---------------------------------------------------------------------
#[cfg(cfail1)]
pub fn bitwise(val: i32) -> i32 {
!val & 0x101010101 | 0x45689 ^ 0x2372382
}
#[cfg(not(cfail1))]
#[rustc_clean(cfg="cfail2")]
#[rustc_clean(cfg="cfail3")]
pub fn bitwise(val: i32) -> i32 {
!val & 0x101010101 | 0x45689 ^ 0x2372382
}
// logical ---------------------------------------------------------------------
#[cfg(cfail1)]
pub fn logical(val1: bool, val2: bool, val3: bool) -> bool {
val1 && val2 || val3
}
#[cfg(not(cfail1))]
#[rustc_clean(cfg="cfail2")]
#[rustc_clean(cfg="cfail3")]
pub fn logical(val1: bool, val2: bool, val3: bool) -> bool {
val1 && val2 || val3
#[cfg(cfail1)]
{
val >> shift
}
#[cfg(not(cfail1))]
{
val >> shift
}
}

View File

@ -1,225 +0,0 @@
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// This test case tests the incremental compilation hash (ICH) implementation
// for exprs that can panic at runtime (e.g. because of bounds checking). For
// these expressions an error message containing their source location is
// generated, so their hash must always depend on their location in the source
// code, not just when debuginfo is enabled.
// As opposed to the panic_exprs.rs test case, this test case checks that things
// behave as expected when overflow checks are off:
//
// - Addition, subtraction, and multiplication do not change the ICH, unless
// the function containing them is marked with rustc_inherit_overflow_checks.
// - Division by zero and bounds checks always influence the ICH
// The general pattern followed here is: Change one thing between rev1 and rev2
// and make sure that the hash has changed, then change nothing between rev2 and
// rev3 and make sure that the hash has not changed.
// must-compile-successfully
// revisions: cfail1 cfail2 cfail3
// compile-flags: -Z query-dep-graph -Z force-overflow-checks=off
#![allow(warnings)]
#![feature(rustc_attrs)]
#![crate_type="rlib"]
// Indexing expression ---------------------------------------------------------
#[cfg(cfail1)]
pub fn indexing(slice: &[u8]) -> u8 {
slice[100]
}
#[cfg(not(cfail1))]
#[rustc_clean(cfg="cfail2", except="HirBody,MirValidated,MirOptimized")]
#[rustc_clean(cfg="cfail3")]
pub fn indexing(slice: &[u8]) -> u8 {
slice[100]
}
// Arithmetic overflow plus ----------------------------------------------------
#[cfg(cfail1)]
#[rustc_inherit_overflow_checks]
pub fn arithmetic_overflow_plus_inherit(val: i32) -> i32 {
val + 1
}
#[cfg(not(cfail1))]
#[rustc_clean(cfg="cfail2", except="HirBody,MirValidated,MirOptimized")]
#[rustc_clean(cfg="cfail3")]
#[rustc_inherit_overflow_checks]
pub fn arithmetic_overflow_plus_inherit(val: i32) -> i32 {
val + 1
}
// Arithmetic overflow minus ----------------------------------------------------
#[cfg(cfail1)]
#[rustc_inherit_overflow_checks]
pub fn arithmetic_overflow_minus_inherit(val: i32) -> i32 {
val - 1
}
#[cfg(not(cfail1))]
#[rustc_clean(cfg="cfail2", except="HirBody,MirValidated,MirOptimized")]
#[rustc_clean(cfg="cfail3")]
#[rustc_inherit_overflow_checks]
pub fn arithmetic_overflow_minus_inherit(val: i32) -> i32 {
val - 1
}
// Arithmetic overflow mult ----------------------------------------------------
#[cfg(cfail1)]
#[rustc_inherit_overflow_checks]
pub fn arithmetic_overflow_mult_inherit(val: i32) -> i32 {
val * 2
}
#[cfg(not(cfail1))]
#[rustc_clean(cfg="cfail2", except="HirBody,MirValidated,MirOptimized")]
#[rustc_clean(cfg="cfail3")]
#[rustc_inherit_overflow_checks]
pub fn arithmetic_overflow_mult_inherit(val: i32) -> i32 {
val * 2
}
// Arithmetic overflow negation ------------------------------------------------
#[cfg(cfail1)]
#[rustc_inherit_overflow_checks]
pub fn arithmetic_overflow_negation_inherit(val: i32) -> i32 {
-val
}
#[cfg(not(cfail1))]
#[rustc_clean(cfg="cfail2", except="HirBody,MirValidated,MirOptimized")]
#[rustc_clean(cfg="cfail3")]
#[rustc_inherit_overflow_checks]
pub fn arithmetic_overflow_negation_inherit(val: i32) -> i32 {
-val
}
// Division by zero ------------------------------------------------------------
#[cfg(cfail1)]
pub fn division_by_zero(val: i32) -> i32 {
2 / val
}
#[cfg(not(cfail1))]
#[rustc_clean(cfg="cfail2", except="HirBody,MirValidated,MirOptimized")]
#[rustc_clean(cfg="cfail3")]
pub fn division_by_zero(val: i32) -> i32 {
2 / val
}
// Division by zero ------------------------------------------------------------
#[cfg(cfail1)]
pub fn mod_by_zero(val: i32) -> i32 {
2 % val
}
#[cfg(not(cfail1))]
#[rustc_clean(cfg="cfail2", except="HirBody,MirValidated,MirOptimized")]
#[rustc_clean(cfg="cfail3")]
pub fn mod_by_zero(val: i32) -> i32 {
2 % val
}
// THE FOLLOWING ITEMS SHOULD NOT BE INFLUENCED BY THEIR SOURCE LOCATION
// bitwise ---------------------------------------------------------------------
#[cfg(cfail1)]
pub fn bitwise(val: i32) -> i32 {
!val & 0x101010101 | 0x45689 ^ 0x2372382 << 1 >> 1
}
#[cfg(not(cfail1))]
#[rustc_clean(cfg="cfail2")]
#[rustc_clean(cfg="cfail3")]
pub fn bitwise(val: i32) -> i32 {
!val & 0x101010101 | 0x45689 ^ 0x2372382 << 1 >> 1
}
// logical ---------------------------------------------------------------------
#[cfg(cfail1)]
pub fn logical(val1: bool, val2: bool, val3: bool) -> bool {
val1 && val2 || val3
}
#[cfg(not(cfail1))]
#[rustc_clean(cfg="cfail2")]
#[rustc_clean(cfg="cfail3")]
pub fn logical(val1: bool, val2: bool, val3: bool) -> bool {
val1 && val2 || val3
}
// Arithmetic overflow plus ----------------------------------------------------
#[cfg(cfail1)]
pub fn arithmetic_overflow_plus(val: i32) -> i32 {
val + 1
}
#[cfg(not(cfail1))]
#[rustc_clean(cfg="cfail2")]
#[rustc_clean(cfg="cfail3")]
pub fn arithmetic_overflow_plus(val: i32) -> i32 {
val + 1
}
// Arithmetic overflow minus ----------------------------------------------------
#[cfg(cfail1)]
pub fn arithmetic_overflow_minus(val: i32) -> i32 {
val - 1
}
#[cfg(not(cfail1))]
#[rustc_clean(cfg="cfail2")]
#[rustc_clean(cfg="cfail3")]
pub fn arithmetic_overflow_minus(val: i32) -> i32 {
val - 1
}
// Arithmetic overflow mult ----------------------------------------------------
#[cfg(cfail1)]
pub fn arithmetic_overflow_mult(val: i32) -> i32 {
val * 2
}
#[cfg(not(cfail1))]
#[rustc_clean(cfg="cfail2")]
#[rustc_clean(cfg="cfail3")]
pub fn arithmetic_overflow_mult(val: i32) -> i32 {
val * 2
}
// Arithmetic overflow negation ------------------------------------------------
#[cfg(cfail1)]
pub fn arithmetic_overflow_negation(val: i32) -> i32 {
-val
}
#[cfg(not(cfail1))]
#[rustc_clean(cfg="cfail2")]
#[rustc_clean(cfg="cfail3")]
pub fn arithmetic_overflow_negation(val: i32) -> i32 {
-val
}

View File

@ -18,7 +18,7 @@
// must-compile-successfully
// revisions: cfail1 cfail2 cfail3
// compile-flags: -Z query-dep-graph
// compile-flags: -Z query-dep-graph -Zincremental-ignore-spans
#![allow(warnings)]
#![feature(rustc_attrs)]

View File

@ -18,7 +18,7 @@
// must-compile-successfully
// revisions: cfail1 cfail2 cfail3
// compile-flags: -Z query-dep-graph
// compile-flags: -Z query-dep-graph -Zincremental-ignore-spans
#![allow(warnings)]
#![feature(rustc_attrs)]

View File

@ -23,7 +23,7 @@
// must-compile-successfully
// revisions: cfail1 cfail2 cfail3
// compile-flags: -Z query-dep-graph
// compile-flags: -Z query-dep-graph -Zincremental-ignore-spans
#![allow(warnings)]

View File

@ -23,7 +23,7 @@
// must-compile-successfully
// revisions: cfail1 cfail2 cfail3
// compile-flags: -Z query-dep-graph
// compile-flags: -Z query-dep-graph -Zincremental-ignore-spans
#![allow(warnings)]
#![feature(rustc_attrs)]

View File

@ -18,7 +18,7 @@
// must-compile-successfully
// revisions: cfail1 cfail2 cfail3
// compile-flags: -Z query-dep-graph
// compile-flags: -Z query-dep-graph -Zincremental-ignore-spans
#![allow(warnings)]

View File

@ -23,7 +23,7 @@
// must-compile-successfully
// revisions: cfail1 cfail2 cfail3
// compile-flags: -Z query-dep-graph
// compile-flags: -Z query-dep-graph -Zincremental-ignore-spans
#![allow(warnings)]
#![feature(rustc_attrs)]

View File

@ -18,7 +18,7 @@
// must-compile-successfully
// revisions: cfail1 cfail2 cfail3
// compile-flags: -Z query-dep-graph -Z force-overflow-checks=off
// compile-flags: -Z query-dep-graph -Zincremental-ignore-spans
#![allow(warnings)]
#![feature(rustc_attrs)]

View File

@ -18,7 +18,7 @@
// must-compile-successfully
// revisions: cfail1 cfail2 cfail3
// compile-flags: -Z query-dep-graph
// compile-flags: -Z query-dep-graph -Zincremental-ignore-spans
#![allow(warnings)]
#![feature(rustc_attrs)]

View File

@ -18,7 +18,7 @@
// must-compile-successfully
// revisions: cfail1 cfail2 cfail3
// compile-flags: -Z query-dep-graph
// compile-flags: -Z query-dep-graph -Zincremental-ignore-spans
#![allow(warnings)]
#![feature(rustc_attrs)]

View File

@ -30,21 +30,10 @@ trait Trait2 {
impl Trait2 for () { }
#[cfg(rpass1)]
mod mod3 {
#[cfg(rpass1)]
use Trait1;
fn bar() {
().method();
}
fn baz() {
22; // no method call, traits in scope don't matter
}
}
#[cfg(rpass2)]
mod mod3 {
#[cfg(rpass2)]
use Trait2;
#[rustc_clean(label="Hir", cfg="rpass2")]

View File

@ -17,23 +17,18 @@
#![crate_type = "rlib"]
#![feature(rustc_attrs)]
#[cfg(cfail1)]
pub fn foo() {
pub fn bar() { }
pub fn baz() { }
}
#[cfg(cfail2)]
#[rustc_clean(label="Hir", cfg="cfail2")]
#[rustc_dirty(label="HirBody", cfg="cfail2")]
pub fn foo() {
#[rustc_clean(label="Hir", cfg="cfail2")]
#[rustc_clean(label="HirBody", cfg="cfail2")]
#[cfg(cfail1)]
pub fn baz() { } // order is different...
#[rustc_clean(label="Hir", cfg="cfail2")]
#[rustc_clean(label="HirBody", cfg="cfail2")]
pub fn bar() { } // but that doesn't matter.
#[cfg(cfail2)]
pub fn baz() { } // order is different...
pub fn bap() { } // neither does adding a new item
}

View File

@ -25,49 +25,29 @@ mod mod2 {
pub struct Foo(pub i64);
}
#[cfg(rpass1)]
mod mod3 {
#[cfg(rpass1)]
use mod1::Foo;
use test;
// In rpass2 we move the use declaration.
#[cfg(rpass2)]
use mod1::Foo;
fn in_expr() {
Foo(0);
}
fn in_type() {
test::<Foo>();
}
}
#[cfg(rpass2)]
mod mod3 {
use mod1::Foo; // <-- Nothing changed, but reordered!
use test;
// In rpass3 we let the declaration point to something else.
#[cfg(rpass3)]
use mod2::Foo;
#[rustc_clean(label="Hir", cfg="rpass2")]
#[rustc_clean(label="HirBody", cfg="rpass2")]
fn in_expr() {
Foo(0);
}
#[rustc_clean(label="Hir", cfg="rpass2")]
#[rustc_clean(label="HirBody", cfg="rpass2")]
fn in_type() {
test::<Foo>();
}
}
#[cfg(rpass3)]
mod mod3 {
use test;
use mod2::Foo; // <-- This changed!
#[rustc_clean(label="Hir", cfg="rpass3")]
#[rustc_dirty(label="HirBody", cfg="rpass3")]
fn in_expr() {
Foo(0);
}
#[rustc_clean(label="Hir", cfg="rpass2")]
#[rustc_clean(label="HirBody", cfg="rpass2")]
#[rustc_clean(label="Hir", cfg="rpass3")]
#[rustc_dirty(label="HirBody", cfg="rpass3")]
fn in_type() {

View File

@ -35,28 +35,30 @@ fn file_same() {
let _ = file!();
}
#[cfg(rpass1)]
fn line_different() {
let _ = line!();
}
#[cfg(rpass2)]
#[rustc_clean(label="Hir", cfg="rpass2")]
#[rustc_dirty(label="HirBody", cfg="rpass2")]
fn line_different() {
let _ = line!();
#[cfg(rpass1)]
{
let _ = line!();
}
#[cfg(rpass2)]
{
let _ = line!();
}
}
#[cfg(rpass1)]
fn col_different() {
let _ = column!();
}
#[cfg(rpass2)]
#[rustc_clean(label="Hir", cfg="rpass2")]
#[rustc_dirty(label="HirBody", cfg="rpass2")]
fn col_different() {
let _ = column!();
#[cfg(rpass1)]
{
let _ = column!();
}
#[cfg(rpass2)]
{
let _ = column!();
}
}
fn main() {

View File

@ -1,26 +0,0 @@
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// This test makes sure that just changing a definition's location in the
// source file does *not* change its incr. comp. hash, if debuginfo is disabled.
// revisions:rpass1 rpass2
// compile-flags: -Z query-dep-graph
#![feature(rustc_attrs)]
#[cfg(rpass1)]
pub fn main() {}
#[cfg(rpass2)]
#[rustc_clean(label="Hir", cfg="rpass2")]
#[rustc_clean(label="HirBody", cfg="rpass2")]
pub fn main() {}

View File

@ -23,8 +23,7 @@ pub fn main() {
}
#[cfg(rpass2)]
#[rustc_clean(label="Hir", cfg="rpass2")]
#[rustc_dirty(label="HirBody", cfg="rpass2")]
#[rustc_dirty(label="MirOptimized", cfg="rpass2")]
pub fn main() {
let _ = 0u8 + 1;
}

View File

@ -1,36 +0,0 @@
// Copyright 2014 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.
//! The `svh-a-*.rs` files are all deviations from the base file
//! svh-a-base.rs with some difference (usually in `fn foo`) that
//! should not affect the strict version hash (SVH) computation
//! (#14132).
#![crate_name = "a"]
macro_rules! three {
() => { 3 }
}
pub trait U {}
pub trait V {}
impl U for () {}
impl V for () {}
static A_CONSTANT : isize = 2;
pub fn foo<T:U>(_: isize) -> isize {
// a comment does not affect the svh
3
}
pub fn an_unused_name() -> isize {
4
}

View File

@ -1,38 +0,0 @@
// Copyright 2014 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.
//! The `svh-a-*.rs` files are all deviations from the base file
//! svh-a-base.rs with some difference (usually in `fn foo`) that
//! should not affect the strict version hash (SVH) computation
//! (#14132).
#![crate_name = "a"]
macro_rules! three {
() => { 3 }
}
pub trait U {}
pub trait V {}
impl U for () {}
impl V for () {}
static A_CONSTANT : isize = 2;
// Adding some documentation does not affect the svh.
/// foo always returns three.
pub fn foo<T:U>(_: isize) -> isize {
3
}
pub fn an_unused_name() -> isize {
4
}

View File

@ -1,37 +0,0 @@
// Copyright 2014 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.
//! The `svh-a-*.rs` files are all deviations from the base file
//! svh-a-base.rs with some difference (usually in `fn foo`) that
//! should not affect the strict version hash (SVH) computation
//! (#14132).
#![crate_name = "a"]
macro_rules! three {
() => { 3 }
}
pub trait U {}
pub trait V {}
impl U for () {}
impl V for () {}
static A_CONSTANT : isize = 2;
pub fn foo<T:U>(_: isize) -> isize {
// a macro invocation in a function body does not affect the svh,
// as long as it yields the same code.
three!()
}
pub fn an_unused_name() -> isize {
4
}

View File

@ -1,35 +0,0 @@
// Copyright 2014 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.
//! The `svh-a-*.rs` files are all deviations from the base file
//! svh-a-base.rs with some difference (usually in `fn foo`) that
//! should not affect the strict version hash (SVH) computation
//! (#14132).
#![crate_name = "a"]
macro_rules! three {
() => { 3 }
}
pub trait U {}
pub trait V {}
impl U for () {}
impl V for () {}
static A_CONSTANT : isize = 2;
pub fn foo<T:U>(_: isize) -> isize {
3
}
pub fn an_unused_name() -> isize {
4
}

View File

@ -1,37 +0,0 @@
// Copyright 2014 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.
//! The `svh-a-*.rs` files are all deviations from the base file
//! svh-a-base.rs with some difference (usually in `fn foo`) that
//! should not affect the strict version hash (SVH) computation
//! (#14132).
#![crate_name = "a"]
macro_rules! three {
() => { 3 }
}
pub trait U {}
pub trait V {}
impl U for () {}
impl V for () {}
static A_CONSTANT : isize = 2;
// cfg attribute does not affect the svh, as long as it yields the same code.
#[cfg(not(an_unused_name))]
pub fn foo<T:U>(_: isize) -> isize {
3
}
pub fn an_unused_name() -> isize {
4
}

View File

@ -1,37 +0,0 @@
// Copyright 2014 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.
//! The `svh-a-*.rs` files are all deviations from the base file
//! svh-a-base.rs with some difference (usually in `fn foo`) that
//! should not affect the strict version hash (SVH) computation
//! (#14132).
#![crate_name = "a"]
macro_rules! three {
() => { 3 }
}
pub trait U {}
pub trait V {}
impl U for () {}
impl V for () {}
static A_CONSTANT : isize = 2;
pub fn foo<T:U>(_: isize) -> isize {
3
}
pub fn an_unused_name() -> isize {
4
}

View File

@ -1,23 +0,0 @@
// Copyright 2014 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.
// note that these aux-build directives must be in this order
// aux-build:svh-a-base.rs
// aux-build:svh-b.rs
// aux-build:svh-a-comment.rs
// pretty-expanded FIXME #23616
extern crate a;
extern crate b;
fn main() {
b::foo()
}

View File

@ -1,23 +0,0 @@
// Copyright 2014 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.
// note that these aux-build directives must be in this order
// aux-build:svh-a-base.rs
// aux-build:svh-b.rs
// aux-build:svh-a-doc.rs
// pretty-expanded FIXME #23616
extern crate a;
extern crate b;
fn main() {
b::foo()
}

View File

@ -1,23 +0,0 @@
// Copyright 2014 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.
// note that these aux-build directives must be in this order
// aux-build:svh-a-base.rs
// aux-build:svh-b.rs
// aux-build:svh-a-macro.rs
// pretty-expanded FIXME #23616
extern crate a;
extern crate b;
fn main() {
b::foo()
}

View File

@ -11,7 +11,7 @@
// note that these aux-build directives must be in this order
// aux-build:svh-a-base.rs
// aux-build:svh-b.rs
// aux-build:svh-a-no-change.rs
// aux-build:svh-a-base.rs
// pretty-expanded FIXME #23616

View File

@ -1,23 +0,0 @@
// Copyright 2014 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.
// note that these aux-build directives must be in this order
// aux-build:svh-a-base.rs
// aux-build:svh-b.rs
// aux-build:svh-a-redundant-cfg.rs
// pretty-expanded FIXME #23616
extern crate a;
extern crate b;
fn main() {
b::foo()
}

View File

@ -1,23 +0,0 @@
// Copyright 2014 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.
// note that these aux-build directives must be in this order
// aux-build:svh-a-base.rs
// aux-build:svh-b.rs
// aux-build:svh-a-whitespace.rs
// pretty-expanded FIXME #23616
extern crate a;
extern crate b;
fn main() {
b::foo()
}