Skip to content

Commit ace517d

Browse files
committed
Auto merge of #41598 - frewsxcv:rollup, r=frewsxcv
Rollup of 4 pull requests - Successful merges: #41534, #41546, #41571, #41583 - Failed merges:
2 parents 70baf4f + d21c9b9 commit ace517d

File tree

10 files changed

+69
-21
lines changed

10 files changed

+69
-21
lines changed

src/etc/make-win-dist.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ def make_win_dist(rust_root, plat_root, target_triple):
4949
elif key == "libraries":
5050
lib_path.extend(val.lstrip(' =').split(';'))
5151

52-
target_tools = ["gcc.exe", "ld.exe", "ar.exe", "dlltool.exe"]
52+
target_tools = ["gcc.exe", "ld.exe", "ar.exe", "dlltool.exe",
53+
"libwinpthread-1.dll"]
5354

5455
rustc_dlls = ["libstdc++-6.dll", "libwinpthread-1.dll"]
5556
if target_triple.startswith("i686-"):

src/librustc/middle/cstore.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
// are *mostly* used as a part of that interface, but these should
2323
// probably get a better home if someone can find one.
2424

25-
use hir::def::{self, Def};
25+
use hir::def;
2626
use hir::def_id::{CrateNum, DefId, DefIndex};
2727
use hir::map as hir_map;
2828
use hir::map::definitions::{Definitions, DefKey, DisambiguatedDefPathData};
@@ -181,7 +181,6 @@ pub trait CrateStore {
181181
fn crate_data_as_rc_any(&self, krate: CrateNum) -> Rc<Any>;
182182

183183
// item info
184-
fn describe_def(&self, def: DefId) -> Option<Def>;
185184
fn def_span(&self, sess: &Session, def: DefId) -> Span;
186185
fn stability(&self, def: DefId) -> Option<attr::Stability>;
187186
fn deprecation(&self, def: DefId) -> Option<attr::Deprecation>;
@@ -313,7 +312,6 @@ impl CrateStore for DummyCrateStore {
313312
fn crate_data_as_rc_any(&self, krate: CrateNum) -> Rc<Any>
314313
{ bug!("crate_data_as_rc_any") }
315314
// item info
316-
fn describe_def(&self, def: DefId) -> Option<Def> { bug!("describe_def") }
317315
fn def_span(&self, sess: &Session, def: DefId) -> Span { bug!("def_span") }
318316
fn stability(&self, def: DefId) -> Option<attr::Stability> { bug!("stability") }
319317
fn deprecation(&self, def: DefId) -> Option<attr::Deprecation> { bug!("deprecation") }

src/librustc/middle/stability.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
432432
// (See issue #38412)
433433
fn skip_stability_check_due_to_privacy(self, mut def_id: DefId) -> bool {
434434
// Check if `def_id` is a trait method.
435-
match self.sess.cstore.describe_def(def_id) {
435+
match self.describe_def(def_id) {
436436
Some(Def::Method(_)) |
437437
Some(Def::AssociatedTy(_)) |
438438
Some(Def::AssociatedConst(_)) => {

src/librustc/ty/maps.rs

+14-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
use dep_graph::{DepGraph, DepNode, DepTrackingMap, DepTrackingMapConfig};
1212
use hir::def_id::{CrateNum, DefId, LOCAL_CRATE};
13+
use hir::def::Def;
1314
use hir;
1415
use middle::const_val;
1516
use middle::privacy::AccessLevels;
@@ -264,6 +265,12 @@ impl<'tcx> QueryDescription for queries::symbol_name<'tcx> {
264265
}
265266
}
266267

268+
impl<'tcx> QueryDescription for queries::describe_def<'tcx> {
269+
fn describe(_: TyCtxt, _: DefId) -> String {
270+
bug!("describe_def")
271+
}
272+
}
273+
267274
macro_rules! define_maps {
268275
(<$tcx:tt>
269276
$($(#[$attr:meta])*
@@ -538,7 +545,9 @@ define_maps! { <'tcx>
538545
pub mir_shims: mir_shim_dep_node(ty::InstanceDef<'tcx>) -> &'tcx RefCell<mir::Mir<'tcx>>,
539546

540547
pub def_symbol_name: SymbolName(DefId) -> ty::SymbolName,
541-
pub symbol_name: symbol_name_dep_node(ty::Instance<'tcx>) -> ty::SymbolName
548+
pub symbol_name: symbol_name_dep_node(ty::Instance<'tcx>) -> ty::SymbolName,
549+
550+
pub describe_def: meta_data_node(DefId) -> Option<Def>
542551
}
543552

544553
fn coherent_trait_dep_node((_, def_id): (CrateNum, DefId)) -> DepNode<DefId> {
@@ -570,3 +579,7 @@ fn typeck_item_bodies_dep_node(_: CrateNum) -> DepNode<DefId> {
570579
fn const_eval_dep_node((def_id, _): (DefId, &Substs)) -> DepNode<DefId> {
571580
DepNode::ConstEval(def_id)
572581
}
582+
583+
fn meta_data_node(def_id: DefId) -> DepNode<DefId> {
584+
DepNode::MetaData(def_id)
585+
}

src/librustc/ty/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2385,7 +2385,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
23852385
/// ID of the impl that the method belongs to. Otherwise, return `None`.
23862386
pub fn impl_of_method(self, def_id: DefId) -> Option<DefId> {
23872387
let item = if def_id.krate != LOCAL_CRATE {
2388-
if let Some(Def::Method(_)) = self.sess.cstore.describe_def(def_id) {
2388+
if let Some(Def::Method(_)) = self.describe_def(def_id) {
23892389
Some(self.associated_item(def_id))
23902390
} else {
23912391
None

src/librustc_const_eval/eval.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ pub fn lookup_const_by_id<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
6868
_ => Some((def_id, substs))
6969
}
7070
} else {
71-
match tcx.sess.cstore.describe_def(def_id) {
71+
match tcx.describe_def(def_id) {
7272
Some(Def::AssociatedConst(_)) => {
7373
// As mentioned in the comments above for in-crate
7474
// constants, we only try to find the expression for a

src/librustc_metadata/cstore_impl.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use rustc::dep_graph::DepTrackingMapConfig;
1717
use rustc::middle::cstore::{CrateStore, CrateSource, LibSource, DepKind,
1818
ExternCrate, NativeLibrary, LinkMeta,
1919
LinkagePreference, LoadedMacro, EncodedMetadata};
20-
use rustc::hir::def::{self, Def};
20+
use rustc::hir::def;
2121
use rustc::middle::lang_items;
2222
use rustc::session::Session;
2323
use rustc::ty::{self, TyCtxt};
@@ -113,18 +113,14 @@ provide! { <'tcx> tcx, def_id, cdata
113113
closure_type => { cdata.closure_ty(def_id.index, tcx) }
114114
inherent_impls => { Rc::new(cdata.get_inherent_implementations_for_type(def_id.index)) }
115115
is_foreign_item => { cdata.is_foreign_item(def_id.index) }
116+
describe_def => { cdata.get_def(def_id.index) }
116117
}
117118

118119
impl CrateStore for cstore::CStore {
119120
fn crate_data_as_rc_any(&self, krate: CrateNum) -> Rc<Any> {
120121
self.get_crate_data(krate)
121122
}
122123

123-
fn describe_def(&self, def: DefId) -> Option<Def> {
124-
self.dep_graph.read(DepNode::MetaData(def));
125-
self.get_crate_data(def.krate).get_def(def.index)
126-
}
127-
128124
fn def_span(&self, sess: &Session, def: DefId) -> Span {
129125
self.dep_graph.read(DepNode::MetaData(def));
130126
self.get_crate_data(def.krate).get_span(def.index, sess)

src/librustc_typeck/check/compare_method.rs

+9-7
Original file line numberDiff line numberDiff line change
@@ -788,16 +788,18 @@ pub fn compare_const_impl<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
788788
trait",
789789
trait_c.name);
790790

791-
// Add a label to the Span containing just the type of the item
792-
let trait_c_node_id = tcx.hir.as_local_node_id(trait_c.def_id).unwrap();
793-
let trait_c_span = match tcx.hir.expect_trait_item(trait_c_node_id).node {
794-
TraitItemKind::Const(ref ty, _) => ty.span,
795-
_ => bug!("{:?} is not a trait const", trait_c),
796-
};
791+
let trait_c_node_id = tcx.hir.as_local_node_id(trait_c.def_id);
792+
let trait_c_span = trait_c_node_id.map(|trait_c_node_id| {
793+
// Add a label to the Span containing just the type of the const
794+
match tcx.hir.expect_trait_item(trait_c_node_id).node {
795+
TraitItemKind::Const(ref ty, _) => ty.span,
796+
_ => bug!("{:?} is not a trait const", trait_c),
797+
}
798+
});
797799

798800
infcx.note_type_err(&mut diag,
799801
&cause,
800-
Some((trait_c_span, format!("type in trait"))),
802+
trait_c_span.map(|span| (span, format!("type in trait"))),
801803
Some(infer::ValuePairs::Types(ExpectedFound {
802804
expected: trait_ty,
803805
found: impl_ty,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![feature(associated_consts)]
12+
13+
pub trait Trait {
14+
const CONST: u32;
15+
}

src/test/compile-fail/issue-41549.rs

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// aux-build:issue_41549.rs
12+
13+
#![feature(associated_consts)]
14+
15+
extern crate issue_41549;
16+
17+
struct S;
18+
19+
impl issue_41549::Trait for S {
20+
const CONST: () = (); //~ ERROR incompatible type for trait
21+
}
22+
23+
fn main() {}

0 commit comments

Comments
 (0)