-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-NLLArea: Non-lexical lifetimes (NLL)Area: Non-lexical lifetimes (NLL)C-bugCategory: This is a bug.Category: This is a bug.
Description
#![feature(nll)]
trait Trait {
const ASSOC: usize;
}
struct Foo<'a, 'b: 'a>(&'a &'b ());
impl<'a, 'b> Trait for Foo<'a, 'b> {
const ASSOC: usize = 3;
}
fn foo<'a, 'b>() -> usize {
<Foo<'a, 'b> as Trait>::ASSOC
}
should error because 'b: 'a
is not met but needed by Foo<'a, 'b>::ASSOC
.
This happens because the predicates of constants are only checked for function definitions
while they have to also get checked for associated constants. I feel like we should really
just check the predicates for all constants instead of trying to safe some work here.
rust/compiler/rustc_borrowck/src/type_check/mod.rs
Lines 466 to 473 in d2df372
if let ty::FnDef(def_id, substs) = *constant.literal.ty().kind() { | |
let instantiated_predicates = tcx.predicates_of(def_id).instantiate(tcx, substs); | |
self.cx.normalize_and_prove_instantiated_predicates( | |
def_id, | |
instantiated_predicates, | |
location.to_locations(), | |
); | |
} |
compiler-errors and aliemjay
Metadata
Metadata
Assignees
Labels
A-NLLArea: Non-lexical lifetimes (NLL)Area: Non-lexical lifetimes (NLL)C-bugCategory: This is a bug.Category: This is a bug.