Skip to content

Rollup of 7 pull requests #33680

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

Closed
wants to merge 25 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
6508553
IntelliJ support, ordering, cleanup
May 13, 2016
391ae7f
Add lifetime's bounds in doc generation
GuillaumeGomez May 15, 2016
bbb7844
Add descriptive error explanation for E0502
May 15, 2016
899cbb3
rustc: use a simpler scheme for plugin registrar symbol names.
eddyb May 10, 2016
222832f
trans: remove unused symbol_names::exported_name_with_suffix.
eddyb May 10, 2016
8e582a6
trans: move exported_name's logic into symbol_names.
eddyb May 11, 2016
92dca92
trans: force absolute item paths within symbols.
eddyb May 11, 2016
3e01c10
trans: move exported_symbol to Instance::symbol_name.
eddyb May 12, 2016
2d08063
trans: move the MSVC linker to compute symbols on-demand.
eddyb May 12, 2016
4c6c881
trans: remove item_symbols from metadata and CrateContext.
eddyb May 12, 2016
b5a5be7
trans: save metadata even with -Z no-trans.
eddyb May 12, 2016
3d67a1a
rustc: Add a new crate type, cdylib
alexcrichton May 10, 2016
067284b
syntax_ext: format: nest_level's are no more
xen0n May 16, 2016
2ea6c70
syntax_ext: format: remove reference to methods in comment
xen0n May 16, 2016
dc1ebae
Mark the metadata symbol as reachable to fix OSX not finding dylibs.
eddyb May 16, 2016
b261302
Fix selected item background style
GuillaumeGomez May 16, 2016
f3c63d2
Add missing code fence to `diagnostics.rs`
apasel422 May 16, 2016
07e8975
Use the original crate name in absolute paths.
eddyb May 17, 2016
62ee403
Rollup merge of #33353 - timothy-mcroy:E0502, r=steveklabnik
eddyb May 17, 2016
6388b91
Rollup merge of #33602 - eddyb:no-trans--check, r=michaelwoerister
eddyb May 17, 2016
86df075
Rollup merge of #33617 - sanmai-NL:gitignore_IntelliJ, r=nikomatsakis
eddyb May 17, 2016
9a5104d
Rollup merge of #33656 - GuillaumeGomez:lifetime_bound, r=steveklabnik
eddyb May 17, 2016
479c4be
Rollup merge of #33666 - xen0n:no-more-nest-levels, r=nikomatsakis
eddyb May 17, 2016
5bc1f65
Rollup merge of #33673 - GuillaumeGomez:fix-selected-item-style, r=st…
eddyb May 17, 2016
a8c9eb6
Rollup merge of #33675 - apasel422:issue-33662, r=pnkfelix
eddyb May 17, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
*.elc
*.epub
*.exe
*.pdb
*.fn
*.html
*.kdev4
Expand All @@ -29,6 +28,7 @@
*.orig
*.out
*.patch
*.pdb
*.pdf
*.pg
*.pot
Expand All @@ -50,6 +50,10 @@
.cproject
.hg/
.hgignore
.idea
__pycache__/
*.py[cod]
*$py.class
.project
.settings/
.valgrindrc
Expand All @@ -65,6 +69,7 @@
/llvm/
/mingw-build/
/nd/
/obj/
/rt/
/rustllvm/
/src/libunicode/DerivedCoreProperties.txt
Expand All @@ -73,13 +78,10 @@
/src/libunicode/PropList.txt
/src/libunicode/Scripts.txt
/src/libunicode/UnicodeData.txt
/stage0/
/stage1/
/stage2/
/stage3/
/stage[0-9]+/
/target
/test/
/tmp/
/obj/
TAGS
TAGS.emacs
TAGS.vi
Expand All @@ -89,11 +91,9 @@ config.mk
config.stamp
keywords.md
lexer.ml
src/.DS_Store
src/etc/dl
src/librustc_llvm/llvmdeps.rs
tmp.*.rs
version.md
version.ml
version.texi
/target
9 changes: 3 additions & 6 deletions src/librustc/middle/cstore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,8 @@ use mir::mir_map::MirMap;
use session::Session;
use session::config::PanicStrategy;
use session::search_paths::PathKind;
use util::nodemap::{FnvHashMap, NodeMap, NodeSet, DefIdMap};
use util::nodemap::{FnvHashMap, NodeSet, DefIdMap};
use std::any::Any;
use std::cell::RefCell;
use std::rc::Rc;
use std::path::PathBuf;
use syntax::ast;
Expand Down Expand Up @@ -174,7 +173,6 @@ pub trait CrateStore<'tcx> : Any {
fn item_super_predicates<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)
-> ty::GenericPredicates<'tcx>;
fn item_attrs(&self, def_id: DefId) -> Vec<ast::Attribute>;
fn item_symbol(&self, def: DefId) -> String;
fn trait_def<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)-> ty::TraitDef<'tcx>;
fn adt_def<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId) -> ty::AdtDefMaster<'tcx>;
fn method_arg_names(&self, did: DefId) -> Vec<String>;
Expand Down Expand Up @@ -210,6 +208,7 @@ pub trait CrateStore<'tcx> : Any {
fn is_impl(&self, did: DefId) -> bool;
fn is_default_impl(&self, impl_did: DefId) -> bool;
fn is_extern_item<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, did: DefId) -> bool;
fn is_foreign_item(&self, did: DefId) -> bool;
fn is_static_method(&self, did: DefId) -> bool;
fn is_statically_included_foreign_item(&self, id: ast::NodeId) -> bool;
fn is_typedef(&self, did: DefId) -> bool;
Expand Down Expand Up @@ -275,7 +274,6 @@ pub trait CrateStore<'tcx> : Any {
fn extern_mod_stmt_cnum(&self, emod_id: ast::NodeId) -> Option<ast::CrateNum>;
fn encode_metadata<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>,
reexports: &def::ExportMap,
item_symbols: &RefCell<NodeMap<String>>,
link_meta: &LinkMeta,
reachable: &NodeSet,
mir_map: &MirMap<'tcx>,
Expand Down Expand Up @@ -353,7 +351,6 @@ impl<'tcx> CrateStore<'tcx> for DummyCrateStore {
fn item_super_predicates<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)
-> ty::GenericPredicates<'tcx> { bug!("item_super_predicates") }
fn item_attrs(&self, def_id: DefId) -> Vec<ast::Attribute> { bug!("item_attrs") }
fn item_symbol(&self, def: DefId) -> String { bug!("item_symbol") }
fn trait_def<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)-> ty::TraitDef<'tcx>
{ bug!("trait_def") }
fn adt_def<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId) -> ty::AdtDefMaster<'tcx>
Expand Down Expand Up @@ -394,6 +391,7 @@ impl<'tcx> CrateStore<'tcx> for DummyCrateStore {
fn is_default_impl(&self, impl_did: DefId) -> bool { bug!("is_default_impl") }
fn is_extern_item<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, did: DefId) -> bool
{ bug!("is_extern_item") }
fn is_foreign_item(&self, did: DefId) -> bool { bug!("is_foreign_item") }
fn is_static_method(&self, did: DefId) -> bool { bug!("is_static_method") }
fn is_statically_included_foreign_item(&self, id: ast::NodeId) -> bool { false }
fn is_typedef(&self, did: DefId) -> bool { bug!("is_typedef") }
Expand Down Expand Up @@ -476,7 +474,6 @@ impl<'tcx> CrateStore<'tcx> for DummyCrateStore {
fn extern_mod_stmt_cnum(&self, emod_id: ast::NodeId) -> Option<ast::CrateNum> { None }
fn encode_metadata<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>,
reexports: &def::ExportMap,
item_symbols: &RefCell<NodeMap<String>>,
link_meta: &LinkMeta,
reachable: &NodeSet,
mir_map: &MirMap<'tcx>,
Expand Down
7 changes: 4 additions & 3 deletions src/librustc/middle/dependency_format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,10 @@ fn calculate_type(sess: &session::Session,
// got long ago), so don't bother with anything.
config::CrateTypeRlib => return Vec::new(),

// Staticlibs must have all static dependencies. If any fail to be
// found, we generate some nice pretty errors.
config::CrateTypeStaticlib => {
// Staticlibs and cdylibs must have all static dependencies. If any fail
// to be found, we generate some nice pretty errors.
config::CrateTypeStaticlib |
config::CrateTypeCdylib => {
match attempt_static(sess) {
Some(v) => return v,
None => {}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/reachable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
// Creates a new reachability computation context.
fn new(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> ReachableContext<'a, 'tcx> {
let any_library = tcx.sess.crate_types.borrow().iter().any(|ty| {
*ty != config::CrateTypeExecutable
*ty == config::CrateTypeRlib || *ty == config::CrateTypeDylib
});
ReachableContext {
tcx: tcx,
Expand Down
1 change: 1 addition & 0 deletions src/librustc/middle/weak_lang_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ fn verify(sess: &Session, items: &lang_items::LanguageItems) {
let needs_check = sess.crate_types.borrow().iter().any(|kind| {
match *kind {
config::CrateTypeDylib |
config::CrateTypeCdylib |
config::CrateTypeExecutable |
config::CrateTypeStaticlib => true,
config::CrateTypeRlib => false,
Expand Down
7 changes: 5 additions & 2 deletions src/librustc/session/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ pub enum CrateType {
CrateTypeDylib,
CrateTypeRlib,
CrateTypeStaticlib,
CrateTypeCdylib,
}

#[derive(Clone)]
Expand Down Expand Up @@ -1103,7 +1104,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
let no_analysis = debugging_opts.no_analysis;

let mut output_types = HashMap::new();
if !debugging_opts.parse_only && !no_trans {
if !debugging_opts.parse_only {
for list in matches.opt_strs("emit") {
for output_type in list.split(',') {
let mut parts = output_type.splitn(2, '=');
Expand Down Expand Up @@ -1326,6 +1327,7 @@ pub fn parse_crate_types_from_list(list_list: Vec<String>) -> Result<Vec<CrateTy
"rlib" => CrateTypeRlib,
"staticlib" => CrateTypeStaticlib,
"dylib" => CrateTypeDylib,
"cdylib" => CrateTypeCdylib,
"bin" => CrateTypeExecutable,
_ => {
return Err(format!("unknown crate type: `{}`",
Expand Down Expand Up @@ -1413,7 +1415,8 @@ impl fmt::Display for CrateType {
CrateTypeExecutable => "bin".fmt(f),
CrateTypeDylib => "dylib".fmt(f),
CrateTypeRlib => "rlib".fmt(f),
CrateTypeStaticlib => "staticlib".fmt(f)
CrateTypeStaticlib => "staticlib".fmt(f),
CrateTypeCdylib => "cdylib".fmt(f),
}
}
}
Expand Down
10 changes: 10 additions & 0 deletions src/librustc/session/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use hir::def_id::DefIndex;
use hir::svh::Svh;
use lint;
use middle::cstore::CrateStore;
use middle::dependency_format;
Expand Down Expand Up @@ -310,6 +312,14 @@ impl Session {
pub fn nonzeroing_move_hints(&self) -> bool {
self.opts.debugging_opts.enable_nonzeroing_move_hints
}

/// Returns the symbol name for the registrar function,
/// given the crate Svh and the function DefIndex.
pub fn generate_plugin_registrar_symbol(&self, svh: &Svh, index: DefIndex)
-> String {
format!("__rustc_plugin_registrar__{}_{}", svh, index.as_usize())
}

pub fn sysroot<'a>(&'a self) -> &'a Path {
match self.opts.maybe_sysroot {
Some (ref sysroot) => sysroot,
Expand Down
36 changes: 33 additions & 3 deletions src/librustc/ty/item_path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,38 @@ use hir::def_id::{DefId, CRATE_DEF_INDEX};
use ty::{self, Ty, TyCtxt};
use syntax::ast;

use std::cell::Cell;

thread_local! {
static FORCE_ABSOLUTE: Cell<bool> = Cell::new(false)
}

/// Enforces that item_path_str always returns an absolute path.
/// This is useful when building symbols that contain types,
/// where we want the crate name to be part of the symbol.
pub fn with_forced_absolute_paths<F: FnOnce() -> R, R>(f: F) -> R {
FORCE_ABSOLUTE.with(|force| {
let old = force.get();
force.set(true);
let result = f();
force.set(old);
result
})
}

impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
/// Returns a string identifying this def-id. This string is
/// suitable for user output. It is relative to the current crate
/// root.
/// root, unless with_forced_absolute_paths was used.
pub fn item_path_str(self, def_id: DefId) -> String {
let mut buffer = LocalPathBuffer::new(RootMode::Local);
let mode = FORCE_ABSOLUTE.with(|force| {
if force.get() {
RootMode::Absolute
} else {
RootMode::Local
}
});
let mut buffer = LocalPathBuffer::new(mode);
self.push_item_path(&mut buffer, def_id);
buffer.into_string()
}
Expand Down Expand Up @@ -75,7 +101,11 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
RootMode::Absolute => {
// In absolute mode, just write the crate name
// unconditionally.
buffer.push(&self.crate_name(cnum));
if cnum == LOCAL_CRATE {
buffer.push(&self.crate_name(cnum));
} else {
buffer.push(&self.sess.cstore.original_crate_name(cnum));
}
}
}
}
Expand Down
28 changes: 28 additions & 0 deletions src/librustc_borrowck/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,7 @@ fn you_know_nothing(jon_snow: &mut i32) {
// but it is already borrowed
};
}
```

In here, `jon_snow` is already borrowed by the `nights_watch` closure, so it
cannot be borrowed by the `starks` closure at the same time. To fix this issue,
Expand Down Expand Up @@ -501,6 +502,33 @@ fn foo(a: &mut i32) {
```
"##,

E0502: r##"
This error indicates that you are trying to borrow a variable as mutable when it
has already been borrowed as immutable.

Example of erroneous code:

```compile_fail
fn bar(x: &mut i32) {}
fn foo(a: &mut i32) {
let ref y = a; // a is borrowed as immutable.
bar(a); // error: cannot borrow `*a` as mutable because `a` is also borrowed
// as immutable
}
```
To fix this error, ensure that you don't have any other references to the
variable before trying to access it mutably:
```
fn bar(x: &mut i32) {}
fn foo(a: &mut i32) {
bar(a);
let ref y = a; // ok!
}
```
For more information on the rust ownership system, take a look at
https://doc.rust-lang.org/stable/book/references-and-borrowing.html.
"##,

E0504: r##"
This error occurs when an attempt is made to move a borrowed variable into a
closure.
Expand Down
3 changes: 3 additions & 0 deletions src/librustc_driver/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1175,6 +1175,9 @@ pub fn collect_crate_types(session: &Session, attrs: &[ast::Attribute]) -> Vec<c
Some(ref n) if *n == "dylib" => {
Some(config::CrateTypeDylib)
}
Some(ref n) if *n == "cdylib" => {
Some(config::CrateTypeCdylib)
}
Some(ref n) if *n == "lib" => {
Some(config::default_lib_output())
}
Expand Down
4 changes: 0 additions & 4 deletions src/librustc_driver/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -504,10 +504,6 @@ impl<'a> CompilerCalls<'a> for RustcDefaultCalls {
control.after_write_deps.stop = Compilation::Stop;
}

if sess.opts.no_trans {
control.after_analysis.stop = Compilation::Stop;
}

if !sess.opts.output_types.keys().any(|&i| i == OutputType::Exe) {
control.after_llvm.stop = Compilation::Stop;
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_metadata/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub const tag_items_data_item_family: usize = 0x24;

pub const tag_items_data_item_type: usize = 0x25;

pub const tag_items_data_item_symbol: usize = 0x26;
// GAP 0x26

pub const tag_items_data_item_variant: usize = 0x27;

Expand Down
15 changes: 10 additions & 5 deletions src/librustc_metadata/creader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use cstore::{self, CStore, CrateSource, MetadataBlob};
use decoder;
use loader::{self, CratePaths};

use rustc::hir::def_id::DefIndex;
use rustc::hir::svh::Svh;
use rustc::dep_graph::{DepGraph, DepNode};
use rustc::session::{config, Session};
Expand Down Expand Up @@ -578,9 +579,10 @@ impl<'a> CrateReader<'a> {
macros
}

/// Look for a plugin registrar. Returns library path and symbol name.
/// Look for a plugin registrar. Returns library path, crate
/// SVH and DefIndex of the registrar function.
pub fn find_plugin_registrar(&mut self, span: Span, name: &str)
-> Option<(PathBuf, String)> {
-> Option<(PathBuf, Svh, DefIndex)> {
let ekrate = self.read_extension_crate(span, &CrateInfo {
name: name.to_string(),
ident: name.to_string(),
Expand All @@ -598,12 +600,14 @@ impl<'a> CrateReader<'a> {
span_fatal!(self.sess, span, E0456, "{}", &message[..]);
}

let svh = decoder::get_crate_hash(ekrate.metadata.as_slice());
let registrar =
decoder::get_plugin_registrar_fn(ekrate.metadata.as_slice())
.map(|id| decoder::get_symbol_from_buf(ekrate.metadata.as_slice(), id));
decoder::get_plugin_registrar_fn(ekrate.metadata.as_slice());

match (ekrate.dylib.as_ref(), registrar) {
(Some(dylib), Some(reg)) => Some((dylib.to_path_buf(), reg)),
(Some(dylib), Some(reg)) => {
Some((dylib.to_path_buf(), svh, reg))
}
(None, Some(_)) => {
span_err!(self.sess, span, E0457,
"plugin `{}` only found in rlib format, but must be available \
Expand Down Expand Up @@ -743,6 +747,7 @@ impl<'a> CrateReader<'a> {
match *ct {
config::CrateTypeExecutable => need_exe_alloc = true,
config::CrateTypeDylib |
config::CrateTypeCdylib |
config::CrateTypeStaticlib => need_lib_alloc = true,
config::CrateTypeRlib => {}
}
Expand Down
Loading