Co-Authored-By: Gabriel Smith <yodaldevoid@users.noreply.github.com>
search_stack.push((ty, hir_ty));
}
search_stack.push((ty, hir_ty));
}
- (UnpackedKind::Lifetime(_), _) | (UnpackedKind::Type(_), _) => {
+ (UnpackedKind::Const(_ct), hir::GenericArg::Const(_hir_ct)) => {
+ // Lifetimes cannot be found in consts, so we don't need
+ // to search anything here.
+ }
+
+ (UnpackedKind::Lifetime(_), _)
+ | (UnpackedKind::Type(_), _)
+ | (UnpackedKind::Const(_), _) => {
// I *think* that HIR lowering should ensure this
// doesn't happen, even in erroneous
// programs. Else we should use delay-span-bug.
// I *think* that HIR lowering should ensure this
// doesn't happen, even in erroneous
// programs. Else we should use delay-span-bug.
param_env,
).type_must_outlive(origin, t1, r2);
}
param_env,
).type_must_outlive(origin, t1, r2);
}
+
+ UnpackedKind::Const(_) => {
+ // Consts cannot outlive one another, so we
+ // don't need to handle any relations here.
+ }
- UnpackedKind::Type(_) => None,
+ UnpackedKind::Type(_) | UnpackedKind::Const(_) => None,
self.layout_of(ty)
})?;
let op = match val.val {
self.layout_of(ty)
})?;
let op = match val.val {
+ ConstValue::Param(_) => Err(EvalErrorKind::TooGeneric.into()),
+ ConstValue::Infer(_) => bug!(),
ConstValue::ByRef(ptr, alloc) => {
// We rely on mutability being set correctly in that allocation to prevent writes
// where none should happen -- and for `static mut`, we copy on demand anyway.
ConstValue::ByRef(ptr, alloc) => {
// We rely on mutability being set correctly in that allocation to prevent writes
// where none should happen -- and for `static mut`, we copy on demand anyway.
use rustc::hir::def_id::DefId;
use rustc::infer;
use rustc::mir::*;
use rustc::hir::def_id::DefId;
use rustc::infer;
use rustc::mir::*;
-use rustc::ty::{self, Ty, TyCtxt, GenericParamDefKind};
+use rustc::ty::{self, Ty, TyCtxt};
use rustc::ty::layout::VariantIdx;
use rustc::ty::subst::{Subst, InternalSubsts};
use rustc::ty::query::Providers;
use rustc::ty::layout::VariantIdx;
use rustc::ty::subst::{Subst, InternalSubsts};
use rustc::ty::query::Providers;
- let substs = InternalSubsts::for_item(tcx, self.def_id, |param, _| {
- match param.kind {
- GenericParamDefKind::Lifetime => tcx.types.re_erased.into(),
- GenericParamDefKind::Type {..} => ty.into(),
- }
- });
+ let substs = tcx.mk_substs_trait(ty, &[]);
// `func == Clone::clone(&ty) -> ty`
let func_ty = tcx.mk_fn_def(self.def_id, substs);
// `func == Clone::clone(&ty) -> ty`
let func_ty = tcx.mk_fn_def(self.def_id, substs);
// FIXME: when we make this a hard error, this should have its
// own error code.
// FIXME: when we make this a hard error, this should have its
// own error code.
- let message = if tcx.generics_of(def_id).own_counts().types != 0 {
+ let counts = tcx.generics_of(def_id).own_counts();
+ let message = if counts.types + counts.consts != 0 {
"#[derive] can't be used on a #[repr(packed)] struct with \
"#[derive] can't be used on a #[repr(packed)] struct with \
- type parameters (error E0133)".to_string()
+ type or const parameters (error E0133)".to_string()
} else {
"#[derive] can't be used on a #[repr(packed)] struct that \
does not derive Copy (error E0133)".to_string()
} else {
"#[derive] can't be used on a #[repr(packed)] struct that \
does not derive Copy (error E0133)".to_string()
// inlining. This is to ensure that the final crate doesn't have MIR that
// reference unexported symbols
if callsite.callee.is_local() {
// inlining. This is to ensure that the final crate doesn't have MIR that
// reference unexported symbols
if callsite.callee.is_local() {
- if callsite.substs.types().count() == 0 && !hinted {
+ if callsite.substs.non_erasable_generics().count() == 0 && !hinted {
debug!(" callee is an exported function - not inlining");
return false;
}
debug!(" callee is an exported function - not inlining");
return false;
}