parent
54ef80043a
commit
019a23ec85
3 changed files with 47 additions and 7 deletions
|
|
@ -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,
|
||||
|
|
|
|||
15
src/test/compile-fail/auxiliary/issue_41549.rs
Normal file
15
src/test/compile-fail/auxiliary/issue_41549.rs
Normal file
|
|
@ -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;
|
||||
}
|
||||
23
src/test/compile-fail/issue-41549.rs
Normal file
23
src/test/compile-fail/issue-41549.rs
Normal file
|
|
@ -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() {}
|
||||
Loading…
Add table
Add a link
Reference in a new issue