diff options
| author | bors <bors@rust-lang.org> | 2017-04-28 04:31:27 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2017-04-28 04:31:27 +0000 |
| commit | ace517da0d1e356aa5b42f4cdee6854538591ef2 (patch) | |
| tree | 9ed83d9cf54dcc965f0f62e288c7f9b3322bbec4 /src | |
| parent | 70baf4f13ec70cb17942704849b0f3c047ad347b (diff) | |
| parent | d21c9b921d9a26d8d697f3e4fbe7ff99ed3b1ed3 (diff) | |
| download | rust-ace517da0d1e356aa5b42f4cdee6854538591ef2.tar.gz rust-ace517da0d1e356aa5b42f4cdee6854538591ef2.zip | |
Auto merge of #41598 - frewsxcv:rollup, r=frewsxcv
Rollup of 4 pull requests - Successful merges: #41534, #41546, #41571, #41583 - Failed merges:
Diffstat (limited to 'src')
| -rw-r--r-- | src/etc/make-win-dist.py | 3 | ||||
| -rw-r--r-- | src/librustc/middle/cstore.rs | 4 | ||||
| -rw-r--r-- | src/librustc/middle/stability.rs | 2 | ||||
| -rw-r--r-- | src/librustc/ty/maps.rs | 15 | ||||
| -rw-r--r-- | src/librustc/ty/mod.rs | 2 | ||||
| -rw-r--r-- | src/librustc_const_eval/eval.rs | 2 | ||||
| -rw-r--r-- | src/librustc_metadata/cstore_impl.rs | 8 | ||||
| -rw-r--r-- | src/librustc_typeck/check/compare_method.rs | 16 | ||||
| -rw-r--r-- | src/test/compile-fail/auxiliary/issue_41549.rs | 15 | ||||
| -rw-r--r-- | src/test/compile-fail/issue-41549.rs | 23 |
10 files changed, 69 insertions, 21 deletions
diff --git a/src/etc/make-win-dist.py b/src/etc/make-win-dist.py index 394ff97d845..4699fefbb20 100644 --- a/src/etc/make-win-dist.py +++ b/src/etc/make-win-dist.py @@ -49,7 +49,8 @@ def make_win_dist(rust_root, plat_root, target_triple): elif key == "libraries": lib_path.extend(val.lstrip(' =').split(';')) - target_tools = ["gcc.exe", "ld.exe", "ar.exe", "dlltool.exe"] + target_tools = ["gcc.exe", "ld.exe", "ar.exe", "dlltool.exe", + "libwinpthread-1.dll"] rustc_dlls = ["libstdc++-6.dll", "libwinpthread-1.dll"] if target_triple.startswith("i686-"): diff --git a/src/librustc/middle/cstore.rs b/src/librustc/middle/cstore.rs index 60171f1a428..03583192567 100644 --- a/src/librustc/middle/cstore.rs +++ b/src/librustc/middle/cstore.rs @@ -22,7 +22,7 @@ // are *mostly* used as a part of that interface, but these should // probably get a better home if someone can find one. -use hir::def::{self, Def}; +use hir::def; use hir::def_id::{CrateNum, DefId, DefIndex}; use hir::map as hir_map; use hir::map::definitions::{Definitions, DefKey, DisambiguatedDefPathData}; @@ -181,7 +181,6 @@ pub trait CrateStore { fn crate_data_as_rc_any(&self, krate: CrateNum) -> Rc<Any>; // item info - fn describe_def(&self, def: DefId) -> Option<Def>; fn def_span(&self, sess: &Session, def: DefId) -> Span; fn stability(&self, def: DefId) -> Option<attr::Stability>; fn deprecation(&self, def: DefId) -> Option<attr::Deprecation>; @@ -313,7 +312,6 @@ impl CrateStore for DummyCrateStore { fn crate_data_as_rc_any(&self, krate: CrateNum) -> Rc<Any> { bug!("crate_data_as_rc_any") } // item info - fn describe_def(&self, def: DefId) -> Option<Def> { bug!("describe_def") } fn def_span(&self, sess: &Session, def: DefId) -> Span { bug!("def_span") } fn stability(&self, def: DefId) -> Option<attr::Stability> { bug!("stability") } fn deprecation(&self, def: DefId) -> Option<attr::Deprecation> { bug!("deprecation") } diff --git a/src/librustc/middle/stability.rs b/src/librustc/middle/stability.rs index 7431eb3fe96..1ac7f4fcc95 100644 --- a/src/librustc/middle/stability.rs +++ b/src/librustc/middle/stability.rs @@ -432,7 +432,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { // (See issue #38412) fn skip_stability_check_due_to_privacy(self, mut def_id: DefId) -> bool { // Check if `def_id` is a trait method. - match self.sess.cstore.describe_def(def_id) { + match self.describe_def(def_id) { Some(Def::Method(_)) | Some(Def::AssociatedTy(_)) | Some(Def::AssociatedConst(_)) => { diff --git a/src/librustc/ty/maps.rs b/src/librustc/ty/maps.rs index c80ae87d941..096d69aa376 100644 --- a/src/librustc/ty/maps.rs +++ b/src/librustc/ty/maps.rs @@ -10,6 +10,7 @@ use dep_graph::{DepGraph, DepNode, DepTrackingMap, DepTrackingMapConfig}; use hir::def_id::{CrateNum, DefId, LOCAL_CRATE}; +use hir::def::Def; use hir; use middle::const_val; use middle::privacy::AccessLevels; @@ -264,6 +265,12 @@ impl<'tcx> QueryDescription for queries::symbol_name<'tcx> { } } +impl<'tcx> QueryDescription for queries::describe_def<'tcx> { + fn describe(_: TyCtxt, _: DefId) -> String { + bug!("describe_def") + } +} + macro_rules! define_maps { (<$tcx:tt> $($(#[$attr:meta])* @@ -538,7 +545,9 @@ define_maps! { <'tcx> pub mir_shims: mir_shim_dep_node(ty::InstanceDef<'tcx>) -> &'tcx RefCell<mir::Mir<'tcx>>, pub def_symbol_name: SymbolName(DefId) -> ty::SymbolName, - pub symbol_name: symbol_name_dep_node(ty::Instance<'tcx>) -> ty::SymbolName + pub symbol_name: symbol_name_dep_node(ty::Instance<'tcx>) -> ty::SymbolName, + + pub describe_def: meta_data_node(DefId) -> Option<Def> } fn coherent_trait_dep_node((_, def_id): (CrateNum, DefId)) -> DepNode<DefId> { @@ -570,3 +579,7 @@ fn typeck_item_bodies_dep_node(_: CrateNum) -> DepNode<DefId> { fn const_eval_dep_node((def_id, _): (DefId, &Substs)) -> DepNode<DefId> { DepNode::ConstEval(def_id) } + +fn meta_data_node(def_id: DefId) -> DepNode<DefId> { + DepNode::MetaData(def_id) +} \ No newline at end of file diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index de207df7d15..238791fb6ed 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -2385,7 +2385,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { /// ID of the impl that the method belongs to. Otherwise, return `None`. pub fn impl_of_method(self, def_id: DefId) -> Option<DefId> { let item = if def_id.krate != LOCAL_CRATE { - if let Some(Def::Method(_)) = self.sess.cstore.describe_def(def_id) { + if let Some(Def::Method(_)) = self.describe_def(def_id) { Some(self.associated_item(def_id)) } else { None diff --git a/src/librustc_const_eval/eval.rs b/src/librustc_const_eval/eval.rs index 9470316c7e7..8b1aa070880 100644 --- a/src/librustc_const_eval/eval.rs +++ b/src/librustc_const_eval/eval.rs @@ -68,7 +68,7 @@ pub fn lookup_const_by_id<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, _ => Some((def_id, substs)) } } else { - match tcx.sess.cstore.describe_def(def_id) { + match tcx.describe_def(def_id) { Some(Def::AssociatedConst(_)) => { // As mentioned in the comments above for in-crate // constants, we only try to find the expression for a diff --git a/src/librustc_metadata/cstore_impl.rs b/src/librustc_metadata/cstore_impl.rs index ddb3332be37..839caca2ee9 100644 --- a/src/librustc_metadata/cstore_impl.rs +++ b/src/librustc_metadata/cstore_impl.rs @@ -17,7 +17,7 @@ use rustc::dep_graph::DepTrackingMapConfig; use rustc::middle::cstore::{CrateStore, CrateSource, LibSource, DepKind, ExternCrate, NativeLibrary, LinkMeta, LinkagePreference, LoadedMacro, EncodedMetadata}; -use rustc::hir::def::{self, Def}; +use rustc::hir::def; use rustc::middle::lang_items; use rustc::session::Session; use rustc::ty::{self, TyCtxt}; @@ -113,6 +113,7 @@ provide! { <'tcx> tcx, def_id, cdata closure_type => { cdata.closure_ty(def_id.index, tcx) } inherent_impls => { Rc::new(cdata.get_inherent_implementations_for_type(def_id.index)) } is_foreign_item => { cdata.is_foreign_item(def_id.index) } + describe_def => { cdata.get_def(def_id.index) } } impl CrateStore for cstore::CStore { @@ -120,11 +121,6 @@ impl CrateStore for cstore::CStore { self.get_crate_data(krate) } - fn describe_def(&self, def: DefId) -> Option<Def> { - self.dep_graph.read(DepNode::MetaData(def)); - self.get_crate_data(def.krate).get_def(def.index) - } - fn def_span(&self, sess: &Session, def: DefId) -> Span { self.dep_graph.read(DepNode::MetaData(def)); self.get_crate_data(def.krate).get_span(def.index, sess) diff --git a/src/librustc_typeck/check/compare_method.rs b/src/librustc_typeck/check/compare_method.rs index a38840552c2..2e84aff4985 100644 --- a/src/librustc_typeck/check/compare_method.rs +++ b/src/librustc_typeck/check/compare_method.rs @@ -788,16 +788,18 @@ pub fn compare_const_impl<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, trait", trait_c.name); - // Add a label to the Span containing just the type of the item - let trait_c_node_id = tcx.hir.as_local_node_id(trait_c.def_id).unwrap(); - let trait_c_span = match tcx.hir.expect_trait_item(trait_c_node_id).node { - TraitItemKind::Const(ref ty, _) => ty.span, - _ => bug!("{:?} is not a trait const", trait_c), - }; + let trait_c_node_id = tcx.hir.as_local_node_id(trait_c.def_id); + let trait_c_span = trait_c_node_id.map(|trait_c_node_id| { + // Add a label to the Span containing just the type of the const + match tcx.hir.expect_trait_item(trait_c_node_id).node { + TraitItemKind::Const(ref ty, _) => ty.span, + _ => bug!("{:?} is not a trait const", trait_c), + } + }); infcx.note_type_err(&mut diag, &cause, - Some((trait_c_span, format!("type in trait"))), + trait_c_span.map(|span| (span, format!("type in trait"))), Some(infer::ValuePairs::Types(ExpectedFound { expected: trait_ty, found: impl_ty, diff --git a/src/test/compile-fail/auxiliary/issue_41549.rs b/src/test/compile-fail/auxiliary/issue_41549.rs new file mode 100644 index 00000000000..77b203997b4 --- /dev/null +++ b/src/test/compile-fail/auxiliary/issue_41549.rs @@ -0,0 +1,15 @@ +// 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. + +#![feature(associated_consts)] + +pub trait Trait { + const CONST: u32; +} diff --git a/src/test/compile-fail/issue-41549.rs b/src/test/compile-fail/issue-41549.rs new file mode 100644 index 00000000000..c4aab4bcabf --- /dev/null +++ b/src/test/compile-fail/issue-41549.rs @@ -0,0 +1,23 @@ +// 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. + +// aux-build:issue_41549.rs + +#![feature(associated_consts)] + +extern crate issue_41549; + +struct S; + +impl issue_41549::Trait for S { + const CONST: () = (); //~ ERROR incompatible type for trait +} + +fn main() {} |
