Skip to content

fix a few errant Krate edges #35960

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Sep 13, 2016
Prev Previous commit
Next Next commit
expanding a def-id is not a read
Across crates only, converting a def-id into its def-key or def-path was
considered a read. This caused spurious reads when computing the symbol
name for some item.
  • Loading branch information
nikomatsakis committed Sep 6, 2016
commit fe6557eb62c1f8856ed95c6998083d09e6ec470b
12 changes: 10 additions & 2 deletions src/librustc_metadata/csearch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -425,13 +425,21 @@ impl<'tcx> CrateStore<'tcx> for cstore::CStore {
/// parent `DefId` as well as some idea of what kind of data the
/// `DefId` refers to.
fn def_key(&self, def: DefId) -> hir_map::DefKey {
self.dep_graph.read(DepNode::MetaData(def));
// Note: loading the def-key (or def-path) for a def-id is not
// a *read* of its metadata. This is because the def-id is
// really just an interned shorthand for a def-path, which is the
// canonical name for an item.
//
// self.dep_graph.read(DepNode::MetaData(def));
let cdata = self.get_crate_data(def.krate);
decoder::def_key(&cdata, def.index)
}

fn relative_def_path(&self, def: DefId) -> hir_map::DefPath {
self.dep_graph.read(DepNode::MetaData(def));
// See `Note` above in `def_key()` for why this read is
// commented out:
//
// self.dep_graph.read(DepNode::MetaData(def));
let cdata = self.get_crate_data(def.krate);
decoder::def_path(&cdata, def.index)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// 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.

#![allow(warnings)]
#![crate_name = "a"]
#![crate_type = "rlib"]

pub fn foo(b: u8) -> u32 { b as u32 }

#[cfg(rpass1)]
fn bar() { }
28 changes: 28 additions & 0 deletions src/test/incremental/remove-private-item-cross-crate/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// 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.

// Test that we are able to reuse `main` even though a private
// item was removed from the root module of crate`a`.

// revisions:rpass1 rpass2
// aux-build:a.rs

#![feature(rustc_attrs)]
#![crate_type = "bin"]
#![rustc_partition_reused(module="main", cfg="rpass2")]

extern crate a;

pub fn main() {
let vec: Vec<u8> = vec![0, 1, 2, 3];
for &b in &vec {
println!("{}", a::foo(b));
}
}