Skip to content

Commit a4670b9

Browse files
committed
---
yaml --- r: 276467 b: refs/heads/master c: fef8276 h: refs/heads/master i: 276465: 59fa81c 276463: 299b252
1 parent 975508d commit a4670b9

File tree

25 files changed

+549
-663
lines changed

25 files changed

+549
-663
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 04308ceefaaa208e636f594c7895b95950b9e44e
2+
refs/heads/master: fef827672ddb0df866c77239f3fc034ed98de556
33
refs/heads/snap-stage3: 235d77457d80b549dad3ac36d94f235208a1eafb
44
refs/heads/try: 49312a405e14a449b98fe0056b12a40ac128be4a
55
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105

trunk/src/librustc_borrowck/borrowck/mod.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -970,11 +970,13 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
970970
if let Categorization::Local(local_id) = err.cmt.cat {
971971
let span = self.tcx.map.span(local_id);
972972
if let Ok(snippet) = self.tcx.sess.codemap().span_to_snippet(span) {
973-
db.span_suggestion(
974-
span,
975-
&format!("to make the {} mutable, use `mut` as shown:",
976-
self.cmt_to_string(&err.cmt)),
977-
format!("mut {}", snippet));
973+
if snippet != "self" {
974+
db.span_suggestion(
975+
span,
976+
&format!("to make the {} mutable, use `mut` as shown:",
977+
self.cmt_to_string(&err.cmt)),
978+
format!("mut {}", snippet));
979+
}
978980
}
979981
}
980982
}

trunk/src/librustc_resolve/lib.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ use rustc::util::nodemap::{NodeMap, NodeSet, FnvHashMap, FnvHashSet};
5757
use syntax::ext::mtwt;
5858
use syntax::ast::{self, FloatTy};
5959
use syntax::ast::{CRATE_NODE_ID, Name, NodeId, CrateNum, IntTy, UintTy};
60-
use syntax::codemap::{self, Span};
60+
use syntax::codemap::{self, Span, Pos};
6161
use syntax::errors::DiagnosticBuilder;
6262
use syntax::parse::token::{self, keywords};
6363
use syntax::util::lev_distance::find_best_match_for_name;
@@ -1260,7 +1260,10 @@ impl<'a> Resolver<'a> {
12601260
Failed(None) => {
12611261
let segment_name = name.as_str();
12621262
let module_name = module_to_string(search_module);
1263+
let mut span = span;
12631264
let msg = if "???" == &module_name {
1265+
span.hi = span.lo + Pos::from_usize(segment_name.len());
1266+
12641267
match search_parent_externals(name, &self.current_module) {
12651268
Some(module) => {
12661269
let path_str = names_to_string(module_path);

trunk/src/librustc_trans/back/write.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -639,8 +639,7 @@ pub fn run_passes(sess: &Session,
639639
}
640640

641641
// Sanity check
642-
assert!(trans.modules.len() == sess.opts.cg.codegen_units ||
643-
sess.opts.debugging_opts.incremental.is_some());
642+
assert!(trans.modules.len() == sess.opts.cg.codegen_units);
644643

645644
let tm = create_target_machine(sess);
646645

trunk/src/librustc_trans/base.rs

Lines changed: 42 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ use common::{node_id_type, fulfill_obligation};
6868
use common::{type_is_immediate, type_is_zero_size, val_ty};
6969
use common;
7070
use consts;
71-
use context::{SharedCrateContext, CrateContextList};
71+
use context::SharedCrateContext;
7272
use controlflow;
7373
use datum;
7474
use debuginfo::{self, DebugLoc, ToDebugLoc};
@@ -81,7 +81,7 @@ use machine::{llalign_of_min, llsize_of, llsize_of_real};
8181
use meth;
8282
use mir;
8383
use monomorphize::{self, Instance};
84-
use partitioning::{self, PartitioningStrategy, InstantiationMode, CodegenUnit};
84+
use partitioning::{self, PartitioningStrategy, InstantiationMode};
8585
use symbol_names_test;
8686
use tvec;
8787
use type_::Type;
@@ -664,7 +664,7 @@ pub fn coerce_unsized_into<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
664664
}
665665
}
666666

667-
pub fn custom_coerce_unsize_info<'scx, 'tcx>(scx: &SharedCrateContext<'scx, 'tcx>,
667+
pub fn custom_coerce_unsize_info<'ccx, 'tcx>(ccx: &CrateContext<'ccx, 'tcx>,
668668
source_ty: Ty<'tcx>,
669669
target_ty: Ty<'tcx>)
670670
-> CustomCoerceUnsized {
@@ -674,13 +674,13 @@ pub fn custom_coerce_unsize_info<'scx, 'tcx>(scx: &SharedCrateContext<'scx, 'tcx
674674
subst::VecPerParamSpace::empty());
675675

676676
let trait_ref = ty::Binder(ty::TraitRef {
677-
def_id: scx.tcx().lang_items.coerce_unsized_trait().unwrap(),
678-
substs: scx.tcx().mk_substs(trait_substs)
677+
def_id: ccx.tcx().lang_items.coerce_unsized_trait().unwrap(),
678+
substs: ccx.tcx().mk_substs(trait_substs)
679679
});
680680

681-
match fulfill_obligation(scx, DUMMY_SP, trait_ref) {
681+
match fulfill_obligation(ccx, DUMMY_SP, trait_ref) {
682682
traits::VtableImpl(traits::VtableImplData { impl_def_id, .. }) => {
683-
scx.tcx().custom_coerce_unsized_kind(impl_def_id)
683+
ccx.tcx().custom_coerce_unsized_kind(impl_def_id)
684684
}
685685
vtable => {
686686
bug!("invalid CoerceUnsized vtable: {:?}", vtable);
@@ -1824,7 +1824,7 @@ pub fn trans_closure<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
18241824
closure_env: closure::ClosureEnv) {
18251825
ccx.stats().n_closures.set(ccx.stats().n_closures.get() + 1);
18261826

1827-
if collector::collecting_debug_information(ccx.shared()) {
1827+
if collector::collecting_debug_information(ccx) {
18281828
ccx.record_translation_item_as_generated(TransItem::Fn(instance));
18291829
}
18301830

@@ -2188,8 +2188,7 @@ pub fn update_linkage(ccx: &CrateContext,
21882188
// `llval` is a translation of an item defined in a separate
21892189
// compilation unit. This only makes sense if there are at least
21902190
// two compilation units.
2191-
assert!(ccx.sess().opts.cg.codegen_units > 1 ||
2192-
ccx.sess().opts.debugging_opts.incremental.is_some());
2191+
assert!(ccx.sess().opts.cg.codegen_units > 1);
21932192
// `llval` is a copy of something defined elsewhere, so use
21942193
// `AvailableExternallyLinkage` to avoid duplicating code in the
21952194
// output.
@@ -2525,7 +2524,7 @@ pub fn write_metadata<'a, 'tcx>(cx: &SharedCrateContext<'a, 'tcx>,
25252524

25262525
/// Find any symbols that are defined in one compilation unit, but not declared
25272526
/// in any other compilation unit. Give these symbols internal linkage.
2528-
fn internalize_symbols(cx: &CrateContextList, reachable: &HashSet<&str>) {
2527+
fn internalize_symbols(cx: &SharedCrateContext, reachable: &HashSet<&str>) {
25292528
unsafe {
25302529
let mut declared = HashSet::new();
25312530

@@ -2580,12 +2579,12 @@ fn internalize_symbols(cx: &CrateContextList, reachable: &HashSet<&str>) {
25802579
// when using MSVC linker. We do this only for data, as linker can fix up
25812580
// code references on its own.
25822581
// See #26591, #27438
2583-
fn create_imps(cx: &CrateContextList) {
2582+
fn create_imps(cx: &SharedCrateContext) {
25842583
// The x86 ABI seems to require that leading underscores are added to symbol
25852584
// names, so we need an extra underscore on 32-bit. There's also a leading
25862585
// '\x01' here which disables LLVM's symbol mangling (e.g. no extra
25872586
// underscores added in front).
2588-
let prefix = if cx.shared().sess().target.target.target_pointer_width == "32" {
2587+
let prefix = if cx.sess().target.target.target_pointer_width == "32" {
25892588
"\x01__imp__"
25902589
} else {
25912590
"\x01__imp_"
@@ -2662,10 +2661,10 @@ fn iter_functions(llmod: llvm::ModuleRef) -> ValueIter {
26622661
///
26632662
/// This list is later used by linkers to determine the set of symbols needed to
26642663
/// be exposed from a dynamic library and it's also encoded into the metadata.
2665-
pub fn filter_reachable_ids(scx: &SharedCrateContext) -> NodeSet {
2666-
scx.reachable().iter().map(|x| *x).filter(|id| {
2664+
pub fn filter_reachable_ids(ccx: &SharedCrateContext) -> NodeSet {
2665+
ccx.reachable().iter().map(|x| *x).filter(|id| {
26672666
// First, only worry about nodes which have a symbol name
2668-
scx.item_symbols().borrow().contains_key(id)
2667+
ccx.item_symbols().borrow().contains_key(id)
26692668
}).filter(|&id| {
26702669
// Next, we want to ignore some FFI functions that are not exposed from
26712670
// this crate. Reachable FFI functions can be lumped into two
@@ -2680,9 +2679,9 @@ pub fn filter_reachable_ids(scx: &SharedCrateContext) -> NodeSet {
26802679
//
26812680
// As a result, if this id is an FFI item (foreign item) then we only
26822681
// let it through if it's included statically.
2683-
match scx.tcx().map.get(id) {
2682+
match ccx.tcx().map.get(id) {
26842683
hir_map::NodeForeignItem(..) => {
2685-
scx.sess().cstore.is_statically_included_foreign_item(id)
2684+
ccx.sess().cstore.is_statically_included_foreign_item(id)
26862685
}
26872686
_ => true,
26882687
}
@@ -2717,7 +2716,10 @@ pub fn trans_crate<'tcx>(tcx: &TyCtxt<'tcx>,
27172716

27182717
let link_meta = link::build_link_meta(&tcx, name);
27192718

2720-
let shared_ccx = SharedCrateContext::new(tcx,
2719+
let codegen_units = tcx.sess.opts.cg.codegen_units;
2720+
let shared_ccx = SharedCrateContext::new(&link_meta.crate_name,
2721+
codegen_units,
2722+
tcx,
27212723
&mir_map,
27222724
export_map,
27232725
Sha256::new(),
@@ -2726,15 +2728,9 @@ pub fn trans_crate<'tcx>(tcx: &TyCtxt<'tcx>,
27262728
check_overflow,
27272729
check_dropflag);
27282730

2729-
let codegen_units = collect_and_partition_translation_items(&shared_ccx);
2730-
let codegen_unit_count = codegen_units.len();
2731-
assert!(tcx.sess.opts.cg.codegen_units == codegen_unit_count ||
2732-
tcx.sess.opts.debugging_opts.incremental.is_some());
2733-
2734-
let crate_context_list = CrateContextList::new(&shared_ccx, codegen_units);
2735-
27362731
{
2737-
let ccx = crate_context_list.get_ccx(0);
2732+
let ccx = shared_ccx.get_ccx(0);
2733+
collect_translation_items(&ccx);
27382734

27392735
// Translate all items. See `TransModVisitor` for
27402736
// details on why we walk in this particular way.
@@ -2744,12 +2740,12 @@ pub fn trans_crate<'tcx>(tcx: &TyCtxt<'tcx>,
27442740
krate.visit_all_items(&mut TransModVisitor { ccx: &ccx });
27452741
}
27462742

2747-
collector::print_collection_results(ccx.shared());
2743+
collector::print_collection_results(&ccx);
27482744

27492745
symbol_names_test::report_symbol_names(&ccx);
27502746
}
27512747

2752-
for ccx in crate_context_list.iter() {
2748+
for ccx in shared_ccx.iter() {
27532749
if ccx.sess().opts.debuginfo != NoDebugInfo {
27542750
debuginfo::finalize(&ccx);
27552751
}
@@ -2798,7 +2794,7 @@ pub fn trans_crate<'tcx>(tcx: &TyCtxt<'tcx>,
27982794
}
27992795
}
28002796

2801-
let modules = crate_context_list.iter()
2797+
let modules = shared_ccx.iter()
28022798
.map(|ccx| ModuleTranslation { llcx: ccx.llcx(), llmod: ccx.llmod() })
28032799
.collect();
28042800

@@ -2824,14 +2820,14 @@ pub fn trans_crate<'tcx>(tcx: &TyCtxt<'tcx>,
28242820
}
28252821
}
28262822

2827-
if codegen_unit_count > 1 {
2828-
internalize_symbols(&crate_context_list,
2823+
if codegen_units > 1 {
2824+
internalize_symbols(&shared_ccx,
28292825
&reachable_symbols.iter().map(|x| &x[..]).collect());
28302826
}
28312827

28322828
if sess.target.target.options.is_like_msvc &&
28332829
sess.crate_types.borrow().iter().any(|ct| *ct == config::CrateTypeRlib) {
2834-
create_imps(&crate_context_list);
2830+
create_imps(&shared_ccx);
28352831
}
28362832

28372833
let metadata_module = ModuleTranslation {
@@ -2916,11 +2912,10 @@ impl<'a, 'tcx, 'v> Visitor<'v> for TransItemsWithinModVisitor<'a, 'tcx> {
29162912
}
29172913
}
29182914

2919-
fn collect_and_partition_translation_items<'a, 'tcx>(scx: &SharedCrateContext<'a, 'tcx>)
2920-
-> Vec<CodegenUnit<'tcx>> {
2921-
let time_passes = scx.sess().time_passes();
2915+
fn collect_translation_items<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>) {
2916+
let time_passes = ccx.sess().time_passes();
29222917

2923-
let collection_mode = match scx.sess().opts.debugging_opts.print_trans_items {
2918+
let collection_mode = match ccx.sess().opts.debugging_opts.print_trans_items {
29242919
Some(ref s) => {
29252920
let mode_string = s.to_lowercase();
29262921
let mode_string = mode_string.trim();
@@ -2931,7 +2926,7 @@ fn collect_and_partition_translation_items<'a, 'tcx>(scx: &SharedCrateContext<'a
29312926
let message = format!("Unknown codegen-item collection mode '{}'. \
29322927
Falling back to 'lazy' mode.",
29332928
mode_string);
2934-
scx.sess().warn(&message);
2929+
ccx.sess().warn(&message);
29352930
}
29362931

29372932
TransItemCollectionMode::Lazy
@@ -2941,27 +2936,27 @@ fn collect_and_partition_translation_items<'a, 'tcx>(scx: &SharedCrateContext<'a
29412936
};
29422937

29432938
let (items, reference_map) = time(time_passes, "translation item collection", || {
2944-
collector::collect_crate_translation_items(scx, collection_mode)
2939+
collector::collect_crate_translation_items(&ccx, collection_mode)
29452940
});
29462941

2947-
let strategy = if scx.sess().opts.debugging_opts.incremental.is_some() {
2942+
let strategy = if ccx.sess().opts.debugging_opts.incremental.is_some() {
29482943
PartitioningStrategy::PerModule
29492944
} else {
2950-
PartitioningStrategy::FixedUnitCount(scx.sess().opts.cg.codegen_units)
2945+
PartitioningStrategy::FixedUnitCount(ccx.sess().opts.cg.codegen_units)
29512946
};
29522947

29532948
let codegen_units = time(time_passes, "codegen unit partitioning", || {
2954-
partitioning::partition(scx.tcx(),
2949+
partitioning::partition(ccx.tcx(),
29552950
items.iter().cloned(),
29562951
strategy,
29572952
&reference_map)
29582953
});
29592954

2960-
if scx.sess().opts.debugging_opts.print_trans_items.is_some() {
2955+
if ccx.sess().opts.debugging_opts.print_trans_items.is_some() {
29612956
let mut item_to_cgus = HashMap::new();
29622957

2963-
for cgu in &codegen_units {
2964-
for (&trans_item, &linkage) in &cgu.items {
2958+
for cgu in codegen_units {
2959+
for (trans_item, linkage) in cgu.items {
29652960
item_to_cgus.entry(trans_item)
29662961
.or_insert(Vec::new())
29672962
.push((cgu.name.clone(), linkage));
@@ -2971,7 +2966,7 @@ fn collect_and_partition_translation_items<'a, 'tcx>(scx: &SharedCrateContext<'a
29712966
let mut item_keys: Vec<_> = items
29722967
.iter()
29732968
.map(|i| {
2974-
let mut output = i.to_string(scx.tcx());
2969+
let mut output = i.to_string(ccx);
29752970
output.push_str(" @@");
29762971
let mut empty = Vec::new();
29772972
let mut cgus = item_to_cgus.get_mut(i).unwrap_or(&mut empty);
@@ -3010,12 +3005,10 @@ fn collect_and_partition_translation_items<'a, 'tcx>(scx: &SharedCrateContext<'a
30103005
println!("TRANS_ITEM {}", item);
30113006
}
30123007

3013-
let mut ccx_map = scx.translation_items().borrow_mut();
3008+
let mut ccx_map = ccx.translation_items().borrow_mut();
30143009

30153010
for cgi in items {
30163011
ccx_map.insert(cgi, TransItemState::PredictedButNotGenerated);
30173012
}
30183013
}
3019-
3020-
codegen_units
30213014
}

trunk/src/librustc_trans/callee.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ impl<'tcx> Callee<'tcx> {
156156
let trait_id = method_item.container().id();
157157
let trait_ref = ty::Binder(substs.to_trait_ref(tcx, trait_id));
158158
let trait_ref = infer::normalize_associated_type(tcx, &trait_ref);
159-
match common::fulfill_obligation(ccx.shared(), DUMMY_SP, trait_ref) {
159+
match common::fulfill_obligation(ccx, DUMMY_SP, trait_ref) {
160160
traits::VtableImpl(vtable_impl) => {
161161
let impl_did = vtable_impl.impl_def_id;
162162
let mname = tcx.item_name(def_id);

0 commit comments

Comments
 (0)