diff --git a/src/librustc_infer/infer/combine.rs b/src/librustc_infer/infer/combine.rs index 4ef4ed47cb11a..70a2122a9ea5d 100644 --- a/src/librustc_infer/infer/combine.rs +++ b/src/librustc_infer/infer/combine.rs @@ -307,7 +307,7 @@ impl<'infcx, 'tcx> CombineFields<'infcx, 'tcx> { self.obligations.push(Obligation::new( self.trace.cause.clone(), self.param_env, - ty::PredicateKind::WellFormed(b_ty.into()).to_predicate(self.infcx.tcx), + ty::PredicateKind::WellFormed(b_ty).to_predicate(self.infcx.tcx), )); } diff --git a/src/librustc_middle/ty/mod.rs b/src/librustc_middle/ty/mod.rs index 00c00a63b6b5d..6d9b9ad9b5ef8 100644 --- a/src/librustc_middle/ty/mod.rs +++ b/src/librustc_middle/ty/mod.rs @@ -14,7 +14,7 @@ use crate::mir::Body; use crate::mir::GeneratorLayout; use crate::traits::{self, Reveal}; use crate::ty; -use crate::ty::subst::{GenericArg, InternalSubsts, Subst, SubstsRef}; +use crate::ty::subst::{InternalSubsts, Subst, SubstsRef}; use crate::ty::util::{Discr, IntTypeExt}; use rustc_ast::ast; use rustc_attr as attr; @@ -1061,7 +1061,7 @@ pub enum PredicateKind<'tcx> { Projection(PolyProjectionPredicate<'tcx>), /// No syntax: `T` well-formed. - WellFormed(GenericArg<'tcx>), + WellFormed(Ty<'tcx>), /// Trait must be object-safe. ObjectSafe(DefId), diff --git a/src/librustc_middle/ty/print/pretty.rs b/src/librustc_middle/ty/print/pretty.rs index 90fb198161793..6a11e775c8c5a 100644 --- a/src/librustc_middle/ty/print/pretty.rs +++ b/src/librustc_middle/ty/print/pretty.rs @@ -2031,7 +2031,7 @@ define_print_and_forward_display! { ty::PredicateKind::RegionOutlives(predicate) => p!(print(predicate)), ty::PredicateKind::TypeOutlives(predicate) => p!(print(predicate)), ty::PredicateKind::Projection(predicate) => p!(print(predicate)), - ty::PredicateKind::WellFormed(arg) => p!(print(arg), write(" well-formed")), + ty::PredicateKind::WellFormed(ty) => p!(print(ty), write(" well-formed")), &ty::PredicateKind::ObjectSafe(trait_def_id) => { p!(write("the trait `"), print_def_path(trait_def_id, &[]), diff --git a/src/librustc_middle/ty/structural_impls.rs b/src/librustc_middle/ty/structural_impls.rs index f6f5dfd651612..5512bd63a07c5 100644 --- a/src/librustc_middle/ty/structural_impls.rs +++ b/src/librustc_middle/ty/structural_impls.rs @@ -236,7 +236,7 @@ impl fmt::Debug for ty::PredicateKind<'tcx> { ty::PredicateKind::RegionOutlives(ref pair) => pair.fmt(f), ty::PredicateKind::TypeOutlives(ref pair) => pair.fmt(f), ty::PredicateKind::Projection(ref pair) => pair.fmt(f), - ty::PredicateKind::WellFormed(data) => write!(f, "WellFormed({:?})", data), + ty::PredicateKind::WellFormed(ty) => write!(f, "WellFormed({:?})", ty), ty::PredicateKind::ObjectSafe(trait_def_id) => { write!(f, "ObjectSafe({:?})", trait_def_id) } diff --git a/src/librustc_mir/borrow_check/type_check/mod.rs b/src/librustc_mir/borrow_check/type_check/mod.rs index 377a0b6f25cab..fdc3b291ba44a 100644 --- a/src/librustc_mir/borrow_check/type_check/mod.rs +++ b/src/librustc_mir/borrow_check/type_check/mod.rs @@ -1016,7 +1016,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { } self.prove_predicate( - ty::PredicateKind::WellFormed(inferred_ty.into()).to_predicate(self.tcx()), + ty::PredicateKind::WellFormed(inferred_ty).to_predicate(self.tcx()), Locations::All(span), ConstraintCategory::TypeAnnotation, ); @@ -1268,7 +1268,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { obligations.obligations.push(traits::Obligation::new( ObligationCause::dummy(), param_env, - ty::PredicateKind::WellFormed(revealed_ty.into()).to_predicate(infcx.tcx), + ty::PredicateKind::WellFormed(revealed_ty).to_predicate(infcx.tcx), )); obligations.add( infcx @@ -1612,7 +1612,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { self.check_call_dest(body, term, &sig, destination, term_location); self.prove_predicates( - sig.inputs_and_output.iter().map(|ty| ty::PredicateKind::WellFormed(ty.into())), + sig.inputs_and_output.iter().map(|ty| ty::PredicateKind::WellFormed(ty)), term_location.to_locations(), ConstraintCategory::Boring, ); diff --git a/src/librustc_trait_selection/traits/error_reporting/mod.rs b/src/librustc_trait_selection/traits/error_reporting/mod.rs index 41811bf44b1af..f8b33b782c017 100644 --- a/src/librustc_trait_selection/traits/error_reporting/mod.rs +++ b/src/librustc_trait_selection/traits/error_reporting/mod.rs @@ -19,7 +19,6 @@ use rustc_hir::Node; use rustc_middle::mir::interpret::ErrorHandled; use rustc_middle::ty::error::ExpectedFound; use rustc_middle::ty::fold::TypeFolder; -use rustc_middle::ty::subst::GenericArgKind; use rustc_middle::ty::{ self, fast_reject, AdtKind, SubtypePredicate, ToPolyTraitRef, ToPredicate, Ty, TyCtxt, TypeFoldable, WithConstness, @@ -1532,24 +1531,13 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> { err } - ty::PredicateKind::WellFormed(arg) => { + ty::PredicateKind::WellFormed(ty) => { // Same hacky approach as above to avoid deluging user // with error messages. - if arg.references_error() || self.tcx.sess.has_errors() { + if ty.references_error() || self.tcx.sess.has_errors() { return; } - - match arg.unpack() { - GenericArgKind::Lifetime(lt) => { - span_bug!(span, "unexpected well formed predicate: {:?}", lt) - } - GenericArgKind::Type(ty) => { - self.need_type_info_err(body_id, span, ty, ErrorCode::E0282) - } - GenericArgKind::Const(ct) => { - self.need_type_info_err_const(body_id, span, ct, ErrorCode::E0282) - } - } + self.need_type_info_err(body_id, span, ty, ErrorCode::E0282) } ty::PredicateKind::Subtype(ref data) => { diff --git a/src/librustc_trait_selection/traits/fulfill.rs b/src/librustc_trait_selection/traits/fulfill.rs index 51c62dbb88c84..c1d9b0a2d88e6 100644 --- a/src/librustc_trait_selection/traits/fulfill.rs +++ b/src/librustc_trait_selection/traits/fulfill.rs @@ -459,17 +459,17 @@ impl<'a, 'b, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'b, 'tcx> { } } - &ty::PredicateKind::WellFormed(arg) => { + &ty::PredicateKind::WellFormed(ty) => { match wf::obligations( self.selcx.infcx(), obligation.param_env, obligation.cause.body_id, - arg, + ty, obligation.cause.span, ) { None => { pending_obligation.stalled_on = - vec![TyOrConstInferVar::maybe_from_generic_arg(arg).unwrap()]; + vec![TyOrConstInferVar::maybe_from_ty(ty).unwrap()]; ProcessResult::Unchanged } Some(os) => ProcessResult::Changed(mk_pending(os)), diff --git a/src/librustc_trait_selection/traits/select/mod.rs b/src/librustc_trait_selection/traits/select/mod.rs index def99a7b5b528..c594cccb9a1ee 100644 --- a/src/librustc_trait_selection/traits/select/mod.rs +++ b/src/librustc_trait_selection/traits/select/mod.rs @@ -422,11 +422,11 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { } } - &ty::PredicateKind::WellFormed(arg) => match wf::obligations( + &ty::PredicateKind::WellFormed(ty) => match wf::obligations( self.infcx, obligation.param_env, obligation.cause.body_id, - arg, + ty, obligation.cause.span, ) { Some(mut obligations) => { diff --git a/src/librustc_trait_selection/traits/wf.rs b/src/librustc_trait_selection/traits/wf.rs index 5024392a0f98d..39c7528a63240 100644 --- a/src/librustc_trait_selection/traits/wf.rs +++ b/src/librustc_trait_selection/traits/wf.rs @@ -4,14 +4,14 @@ use crate::traits; use rustc_hir as hir; use rustc_hir::def_id::DefId; use rustc_hir::lang_items; -use rustc_middle::ty::subst::{GenericArg, GenericArgKind, SubstsRef}; +use rustc_middle::ty::subst::{GenericArgKind, SubstsRef}; use rustc_middle::ty::{self, ToPredicate, Ty, TyCtxt, TypeFoldable, WithConstness}; use rustc_span::Span; use std::rc::Rc; -/// Returns the set of obligations needed to make `arg` well-formed. -/// If `arg` contains unresolved inference variables, this may include -/// further WF obligations. However, if `arg` IS an unresolved +/// Returns the set of obligations needed to make `ty` well-formed. +/// If `ty` contains unresolved inference variables, this may include +/// further WF obligations. However, if `ty` IS an unresolved /// inference variable, returns `None`, because we are not able to /// make any progress at all. This is to prevent "livelock" where we /// say "$0 is WF if $0 is WF". @@ -19,51 +19,29 @@ pub fn obligations<'a, 'tcx>( infcx: &InferCtxt<'a, 'tcx>, param_env: ty::ParamEnv<'tcx>, body_id: hir::HirId, - arg: GenericArg<'tcx>, + ty: Ty<'tcx>, span: Span, ) -> Option>> { // Handle the "livelock" case (see comment above) by bailing out if necessary. - let arg = match arg.unpack() { - GenericArgKind::Type(ty) => { - match ty.kind { - ty::Infer(ty::TyVar(_)) => { - let resolved_ty = infcx.shallow_resolve(ty); - if resolved_ty == ty { - // No progress, bail out to prevent "livelock". - return None; - } - - resolved_ty - } - _ => ty, + let ty = match ty.kind { + ty::Infer(ty::TyVar(_)) => { + let resolved_ty = infcx.shallow_resolve(ty); + if resolved_ty == ty { + // No progress, bail out to prevent "livelock". + return None; } - .into() - } - GenericArgKind::Const(ct) => { - match ct.val { - ty::ConstKind::Infer(infer) => { - let resolved = infcx.shallow_resolve(infer); - if resolved == infer { - // No progress. - return None; - } - infcx.tcx.mk_const(ty::Const { val: ty::ConstKind::Infer(resolved), ty: ct.ty }) - } - _ => ct, - } - .into() + resolved_ty } - // There is nothing we have to do for lifetimes. - GenericArgKind::Lifetime(..) => return Some(Vec::new()), + _ => ty, }; let mut wf = WfPredicates { infcx, param_env, body_id, span, out: vec![], item: None }; - wf.compute(arg); - debug!("wf::obligations({:?}, body_id={:?}) = {:?}", arg, body_id, wf.out); + wf.compute(ty); + debug!("wf::obligations({:?}, body_id={:?}) = {:?}", ty, body_id, wf.out); let result = wf.normalize(); - debug!("wf::obligations({:?}, body_id={:?}) ~~> {:?}", arg, body_id, result); + debug!("wf::obligations({:?}, body_id={:?}) ~~> {:?}", ty, body_id, result); Some(result) } @@ -100,33 +78,33 @@ pub fn predicate_obligations<'a, 'tcx>( } ty::PredicateKind::RegionOutlives(..) => {} ty::PredicateKind::TypeOutlives(t) => { - wf.compute(t.skip_binder().0.into()); + wf.compute(t.skip_binder().0); } ty::PredicateKind::Projection(t) => { let t = t.skip_binder(); // (*) wf.compute_projection(t.projection_ty); - wf.compute(t.ty.into()); + wf.compute(t.ty); } - &ty::PredicateKind::WellFormed(arg) => { - wf.compute(arg); + &ty::PredicateKind::WellFormed(t) => { + wf.compute(t); } ty::PredicateKind::ObjectSafe(_) => {} ty::PredicateKind::ClosureKind(..) => {} ty::PredicateKind::Subtype(data) => { - wf.compute(data.skip_binder().a.into()); // (*) - wf.compute(data.skip_binder().b.into()); // (*) + wf.compute(data.skip_binder().a); // (*) + wf.compute(data.skip_binder().b); // (*) } &ty::PredicateKind::ConstEvaluatable(def_id, substs) => { let obligations = wf.nominal_obligations(def_id, substs); wf.out.extend(obligations); - for arg in substs.iter() { - wf.compute(arg); + for ty in substs.types() { + wf.compute(ty); } } - &ty::PredicateKind::ConstEquate(c1, c2) => { - wf.compute(c1.into()); - wf.compute(c2.into()); + ty::PredicateKind::ConstEquate(c1, c2) => { + wf.compute(c1.ty); + wf.compute(c2.ty); } } @@ -235,7 +213,7 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> { self.infcx.tcx } - fn cause(&self, code: traits::ObligationCauseCode<'tcx>) -> traits::ObligationCause<'tcx> { + fn cause(&mut self, code: traits::ObligationCauseCode<'tcx>) -> traits::ObligationCause<'tcx> { traits::ObligationCause::new(self.span, self.body_id, code) } @@ -295,22 +273,15 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> { } let tcx = self.tcx(); - self.out.extend( - trait_ref - .substs - .iter() - .filter(|arg| { - matches!(arg.unpack(), GenericArgKind::Type(..) | GenericArgKind::Const(..)) - }) - .filter(|arg| !arg.has_escaping_bound_vars()) - .map(|arg| { - traits::Obligation::new( - cause.clone(), - param_env, - ty::PredicateKind::WellFormed(arg).to_predicate(tcx), - ) - }), - ); + self.out.extend(trait_ref.substs.types().filter(|ty| !ty.has_escaping_bound_vars()).map( + |ty| { + traits::Obligation::new( + cause.clone(), + param_env, + ty::PredicateKind::WellFormed(ty).to_predicate(tcx), + ) + }, + )); } /// Pushes the obligations required for `trait_ref::Item` to be WF @@ -329,6 +300,22 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> { } } + /// Pushes the obligations required for an array length to be WF + /// into `self.out`. + fn compute_array_len(&mut self, constant: ty::Const<'tcx>) { + if let ty::ConstKind::Unevaluated(def_id, substs, promoted) = constant.val { + assert!(promoted.is_none()); + + let obligations = self.nominal_obligations(def_id, substs); + self.out.extend(obligations); + + let predicate = + ty::PredicateKind::ConstEvaluatable(def_id, substs).to_predicate(self.tcx()); + let cause = self.cause(traits::MiscObligation); + self.out.push(traits::Obligation::new(cause, self.param_env, predicate)); + } + } + fn require_sized(&mut self, subty: Ty<'tcx>, cause: traits::ObligationCauseCode<'tcx>) { if !subty.has_escaping_bound_vars() { let cause = self.cause(cause); @@ -345,8 +332,8 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> { } /// Pushes all the predicates needed to validate that `ty` is WF into `out`. - fn compute(&mut self, arg: GenericArg<'tcx>) { - let mut walker = arg.walk(); + fn compute(&mut self, ty: Ty<'tcx>) { + let mut walker = ty.walk(); let param_env = self.param_env; while let Some(arg) = walker.next() { let ty = match arg.unpack() { @@ -356,53 +343,9 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> { // obligations are handled by the parent (e.g. `ty::Ref`). GenericArgKind::Lifetime(_) => continue, - GenericArgKind::Const(constant) => { - match constant.val { - ty::ConstKind::Unevaluated(def_id, substs, promoted) => { - assert!(promoted.is_none()); - - let obligations = self.nominal_obligations(def_id, substs); - self.out.extend(obligations); - - let predicate = ty::PredicateKind::ConstEvaluatable(def_id, substs) - .to_predicate(self.tcx()); - let cause = self.cause(traits::MiscObligation); - self.out.push(traits::Obligation::new( - cause, - self.param_env, - predicate, - )); - } - ty::ConstKind::Infer(infer) => { - let resolved = self.infcx.shallow_resolve(infer); - // the `InferConst` changed, meaning that we made progress. - if resolved != infer { - let cause = self.cause(traits::MiscObligation); - - let resolved_constant = self.infcx.tcx.mk_const(ty::Const { - val: ty::ConstKind::Infer(resolved), - ..*constant - }); - self.out.push(traits::Obligation::new( - cause, - self.param_env, - ty::PredicateKind::WellFormed(resolved_constant.into()) - .to_predicate(self.tcx()), - )); - } - } - ty::ConstKind::Error - | ty::ConstKind::Param(_) - | ty::ConstKind::Bound(..) - | ty::ConstKind::Placeholder(..) => { - // These variants are trivially WF, so nothing to do here. - } - ty::ConstKind::Value(..) => { - // FIXME: Enforce that values are structurally-matchable. - } - } - continue; - } + // FIXME(eddyb) this is wrong and needs to be replaced + // (see https://github.com/rust-lang/rust/pull/70107). + GenericArgKind::Const(_) => continue, }; match ty.kind { @@ -432,9 +375,10 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> { self.require_sized(subty, traits::SliceOrArrayElem); } - ty::Array(subty, _) => { + ty::Array(subty, len) => { self.require_sized(subty, traits::SliceOrArrayElem); - // Note that we handle the len is implicitly checked while walking `arg`. + // FIXME(eddyb) handle `GenericArgKind::Const` above instead. + self.compute_array_len(*len); } ty::Tuple(ref tys) => { @@ -446,11 +390,11 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> { } ty::RawPtr(_) => { - // Simple cases that are WF if their type args are WF. + // simple cases that are WF if their type args are WF } ty::Projection(data) => { - walker.skip_current_subtree(); // Subtree handled by compute_projection. + walker.skip_current_subtree(); // subtree handled by compute_projection self.compute_projection(data); } @@ -523,7 +467,7 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> { walker.skip_current_subtree(); // subtree handled below for upvar_ty in substs.as_closure().upvar_tys() { // FIXME(eddyb) add the type to `walker` instead of recursing. - self.compute(upvar_ty.into()); + self.compute(upvar_ty); } } @@ -591,12 +535,12 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> { self.out.push(traits::Obligation::new( cause, param_env, - ty::PredicateKind::WellFormed(ty.into()).to_predicate(self.tcx()), + ty::PredicateKind::WellFormed(ty).to_predicate(self.tcx()), )); } else { // Yes, resolved, proceed with the result. // FIXME(eddyb) add the type to `walker` instead of recursing. - self.compute(ty.into()); + self.compute(ty); } } } diff --git a/src/librustc_traits/chalk/lowering.rs b/src/librustc_traits/chalk/lowering.rs index 9530b07e47cdb..a33ada2fb6ef1 100644 --- a/src/librustc_traits/chalk/lowering.rs +++ b/src/librustc_traits/chalk/lowering.rs @@ -36,7 +36,7 @@ use rustc_middle::traits::{ ChalkRustInterner as RustInterner, }; use rustc_middle::ty::fold::TypeFolder; -use rustc_middle::ty::subst::{GenericArg, GenericArgKind, SubstsRef}; +use rustc_middle::ty::subst::{GenericArg, SubstsRef}; use rustc_middle::ty::{ self, Binder, BoundRegion, Region, RegionKind, Ty, TyCtxt, TyKind, TypeFoldable, TypeVisitor, }; @@ -77,7 +77,7 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::InEnvironment chalk_ir::InEnvironment>> { let clauses = self.environment.into_iter().filter_map(|clause| match clause { ChalkEnvironmentClause::Predicate(predicate) => { - match predicate.kind() { + match &predicate.kind() { ty::PredicateKind::Trait(predicate, _) => { let (predicate, binders, _named_regions) = collect_bound_vars(interner, interner.tcx, predicate); @@ -165,31 +165,24 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::GoalData>> for ty::Predi chalk_ir::GoalData::All(chalk_ir::Goals::new(interner)) } ty::PredicateKind::Projection(predicate) => predicate.lower_into(interner), - ty::PredicateKind::WellFormed(arg) => match arg.unpack() { - GenericArgKind::Type(ty) => match ty.kind { - // These types are always WF. - ty::Str | ty::Placeholder(..) | ty::Error | ty::Never => { - chalk_ir::GoalData::All(chalk_ir::Goals::new(interner)) - } + ty::PredicateKind::WellFormed(ty) => match ty.kind { + // These types are always WF. + ty::Str | ty::Placeholder(..) | ty::Error | ty::Never => { + chalk_ir::GoalData::All(chalk_ir::Goals::new(interner)) + } - // FIXME(chalk): Well-formed only if ref lifetime outlives type - ty::Ref(..) => chalk_ir::GoalData::All(chalk_ir::Goals::new(interner)), + // FIXME(chalk): Well-formed only if ref lifetime outlives type + ty::Ref(..) => chalk_ir::GoalData::All(chalk_ir::Goals::new(interner)), - ty::Param(..) => panic!("No Params expected."), + ty::Param(..) => panic!("No Params expected."), - // FIXME(chalk) -- ultimately I think this is what we - // want to do, and we just have rules for how to prove - // `WellFormed` for everything above, instead of - // inlining a bit the rules of the proof here. - _ => chalk_ir::GoalData::DomainGoal(chalk_ir::DomainGoal::WellFormed( - chalk_ir::WellFormed::Ty(ty.lower_into(interner)), - )), - }, - // FIXME(chalk): handle well formed consts - GenericArgKind::Const(..) => { - chalk_ir::GoalData::All(chalk_ir::Goals::new(interner)) - } - GenericArgKind::Lifetime(lt) => bug!("unexpect well formed predicate: {:?}", lt), + // FIXME(chalk) -- ultimately I think this is what we + // want to do, and we just have rules for how to prove + // `WellFormed` for everything above, instead of + // inlining a bit the rules of the proof here. + _ => chalk_ir::GoalData::DomainGoal(chalk_ir::DomainGoal::WellFormed( + chalk_ir::WellFormed::Ty(ty.lower_into(interner)), + )), }, // FIXME(chalk): other predicates diff --git a/src/librustc_traits/implied_outlives_bounds.rs b/src/librustc_traits/implied_outlives_bounds.rs index 651596d0379bb..5dee71a2338cc 100644 --- a/src/librustc_traits/implied_outlives_bounds.rs +++ b/src/librustc_traits/implied_outlives_bounds.rs @@ -47,14 +47,14 @@ fn compute_implied_outlives_bounds<'tcx>( // process it next. Currently (at least) these resulting // predicates are always guaranteed to be a subset of the original // type, so we need not fear non-termination. - let mut wf_args = vec![ty.into()]; + let mut wf_types = vec![ty]; let mut implied_bounds = vec![]; let mut fulfill_cx = FulfillmentContext::new(); - while let Some(arg) = wf_args.pop() { - // Compute the obligations for `arg` to be well-formed. If `arg` is + while let Some(ty) = wf_types.pop() { + // Compute the obligations for `ty` to be well-formed. If `ty` is // an unresolved inference variable, just substituted an empty set // -- because the return type here is going to be things we *add* // to the environment, it's always ok for this set to be smaller @@ -62,7 +62,7 @@ fn compute_implied_outlives_bounds<'tcx>( // unresolved inference variables here anyway, but there might be // during typeck under some circumstances.) let obligations = - wf::obligations(infcx, param_env, hir::CRATE_HIR_ID, arg, DUMMY_SP).unwrap_or(vec![]); + wf::obligations(infcx, param_env, hir::CRATE_HIR_ID, ty, DUMMY_SP).unwrap_or(vec![]); // N.B., all of these predicates *ought* to be easily proven // true. In fact, their correctness is (mostly) implied by @@ -103,8 +103,8 @@ fn compute_implied_outlives_bounds<'tcx>( | ty::PredicateKind::ConstEvaluatable(..) | ty::PredicateKind::ConstEquate(..) => vec![], - &ty::PredicateKind::WellFormed(arg) => { - wf_args.push(arg); + ty::PredicateKind::WellFormed(subty) => { + wf_types.push(subty); vec![] } diff --git a/src/librustc_traits/type_op.rs b/src/librustc_traits/type_op.rs index 374ef3fc9c783..22077b49c3b77 100644 --- a/src/librustc_traits/type_op.rs +++ b/src/librustc_traits/type_op.rs @@ -140,7 +140,7 @@ impl AscribeUserTypeCx<'me, 'tcx> { self.relate(self_ty, Variance::Invariant, impl_self_ty)?; self.prove_predicate( - ty::PredicateKind::WellFormed(impl_self_ty.into()).to_predicate(self.tcx()), + ty::PredicateKind::WellFormed(impl_self_ty).to_predicate(self.tcx()), ); } @@ -155,7 +155,7 @@ impl AscribeUserTypeCx<'me, 'tcx> { // them? This would only be relevant if some input // type were ill-formed but did not appear in `ty`, // which...could happen with normalization... - self.prove_predicate(ty::PredicateKind::WellFormed(ty.into()).to_predicate(self.tcx())); + self.prove_predicate(ty::PredicateKind::WellFormed(ty).to_predicate(self.tcx())); Ok(()) } } diff --git a/src/librustc_typeck/check/callee.rs b/src/librustc_typeck/check/callee.rs index aa316105f7f11..f4e46a0493151 100644 --- a/src/librustc_typeck/check/callee.rs +++ b/src/librustc_typeck/check/callee.rs @@ -94,7 +94,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { }; // we must check that return type of called functions is WF: - self.register_wf_obligation(output.into(), call_expr.span, traits::MiscObligation); + self.register_wf_obligation(output, call_expr.span, traits::MiscObligation); output } diff --git a/src/librustc_typeck/check/method/confirm.rs b/src/librustc_typeck/check/method/confirm.rs index 007794ce1b7ff..48d27387476a2 100644 --- a/src/librustc_typeck/check/method/confirm.rs +++ b/src/librustc_typeck/check/method/confirm.rs @@ -413,7 +413,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> { // the function type must also be well-formed (this is not // implied by the substs being well-formed because of inherent // impls and late-bound regions - see issue #28609). - self.register_wf_obligation(fty.into(), self.span, traits::MiscObligation); + self.register_wf_obligation(fty, self.span, traits::MiscObligation); } /////////////////////////////////////////////////////////////////////////// diff --git a/src/librustc_typeck/check/method/mod.rs b/src/librustc_typeck/check/method/mod.rs index ac3fa15417e9c..aae02ea0273f9 100644 --- a/src/librustc_typeck/check/method/mod.rs +++ b/src/librustc_typeck/check/method/mod.rs @@ -401,7 +401,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { obligations.push(traits::Obligation::new( cause, self.param_env, - ty::PredicateKind::WellFormed(method_ty.into()).to_predicate(tcx), + ty::PredicateKind::WellFormed(method_ty).to_predicate(tcx), )); let callee = MethodCallee { def_id, substs: trait_ref.substs, sig: fn_sig }; diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 634f2f78c7000..995ba728e9a0c 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -121,8 +121,9 @@ use rustc_middle::ty::adjustment::{ }; use rustc_middle::ty::fold::{TypeFoldable, TypeFolder}; use rustc_middle::ty::query::Providers; -use rustc_middle::ty::subst::{self, InternalSubsts, Subst, SubstsRef}; -use rustc_middle::ty::subst::{GenericArgKind, UserSelfTy, UserSubsts}; +use rustc_middle::ty::subst::{ + GenericArgKind, InternalSubsts, Subst, SubstsRef, UserSelfTy, UserSubsts, +}; use rustc_middle::ty::util::{Discr, IntTypeExt, Representability}; use rustc_middle::ty::{ self, AdtKind, CanonicalUserType, Const, GenericParamDefKind, RegionKind, ToPolyTraitRef, @@ -3352,7 +3353,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { pub fn to_ty(&self, ast_t: &hir::Ty<'_>) -> Ty<'tcx> { let t = AstConv::ast_ty_to_ty(self, ast_t); - self.register_wf_obligation(t.into(), ast_t.span, traits::MiscObligation); + self.register_wf_obligation(t, ast_t.span, traits::MiscObligation); t } @@ -3372,11 +3373,28 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { pub fn to_const(&self, ast_c: &hir::AnonConst) -> &'tcx ty::Const<'tcx> { let const_def_id = self.tcx.hir().local_def_id(ast_c.hir_id); let c = ty::Const::from_anon_const(self.tcx, const_def_id); - self.register_wf_obligation( - c.into(), - self.tcx.hir().span(ast_c.hir_id), - ObligationCauseCode::MiscObligation, - ); + + // HACK(eddyb) emulate what a `WellFormedConst` obligation would do. + // This code should be replaced with the proper WF handling ASAP. + if let ty::ConstKind::Unevaluated(def_id, substs, promoted) = c.val { + assert!(promoted.is_none()); + + // HACK(eddyb) let's hope these are always empty. + // let obligations = self.nominal_obligations(def_id, substs); + // self.out.extend(obligations); + + let cause = traits::ObligationCause::new( + self.tcx.def_span(const_def_id.to_def_id()), + self.body_id, + traits::MiscObligation, + ); + self.register_predicate(traits::Obligation::new( + cause, + self.param_env, + ty::PredicateKind::ConstEvaluatable(def_id, substs).to_predicate(self.tcx), + )); + } + c } @@ -3409,10 +3427,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } } - /// Registers an obligation for checking later, during regionck, that `arg` is well-formed. + /// Registers an obligation for checking later, during regionck, that the type `ty` must + /// outlive the region `r`. pub fn register_wf_obligation( &self, - arg: subst::GenericArg<'tcx>, + ty: Ty<'tcx>, span: Span, code: traits::ObligationCauseCode<'tcx>, ) { @@ -3421,16 +3440,16 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { self.register_predicate(traits::Obligation::new( cause, self.param_env, - ty::PredicateKind::WellFormed(arg).to_predicate(self.tcx), + ty::PredicateKind::WellFormed(ty).to_predicate(self.tcx), )); } - /// Registers obligations that all `substs` are well-formed. + /// Registers obligations that all types appearing in `substs` are well-formed. pub fn add_wf_bounds(&self, substs: SubstsRef<'tcx>, expr: &hir::Expr<'_>) { - for arg in substs.iter().filter(|arg| { - matches!(arg.unpack(), GenericArgKind::Type(..) | GenericArgKind::Const(..)) - }) { - self.register_wf_obligation(arg, expr.span, traits::MiscObligation); + for ty in substs.types() { + if !ty.references_error() { + self.register_wf_obligation(ty, expr.span, traits::MiscObligation); + } } } @@ -3902,8 +3921,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // All the input types from the fn signature must outlive the call // so as to validate implied bounds. - for (&fn_input_ty, arg_expr) in fn_inputs.iter().zip(args.iter()) { - self.register_wf_obligation(fn_input_ty.into(), arg_expr.span, traits::MiscObligation); + for (fn_input_ty, arg_expr) in fn_inputs.iter().zip(args.iter()) { + self.register_wf_obligation(fn_input_ty, arg_expr.span, traits::MiscObligation); } let expected_arg_count = fn_inputs.len(); diff --git a/src/librustc_typeck/check/wfcheck.rs b/src/librustc_typeck/check/wfcheck.rs index 7d9bf975c6913..e154184f1822c 100644 --- a/src/librustc_typeck/check/wfcheck.rs +++ b/src/librustc_typeck/check/wfcheck.rs @@ -292,7 +292,7 @@ fn check_associated_item( ty::AssocKind::Const => { let ty = fcx.tcx.type_of(item.def_id); let ty = fcx.normalize_associated_types_in(span, &ty); - fcx.register_wf_obligation(ty.into(), span, code.clone()); + fcx.register_wf_obligation(ty, span, code.clone()); } ty::AssocKind::Fn => { let sig = fcx.tcx.fn_sig(item.def_id); @@ -313,7 +313,7 @@ fn check_associated_item( if item.defaultness.has_value() { let ty = fcx.tcx.type_of(item.def_id); let ty = fcx.normalize_associated_types_in(span, &ty); - fcx.register_wf_obligation(ty.into(), span, code.clone()); + fcx.register_wf_obligation(ty, span, code.clone()); } } ty::AssocKind::OpaqueTy => { @@ -406,7 +406,7 @@ fn check_type_defn<'tcx, F>( // All field types must be well-formed. for field in &variant.fields { fcx.register_wf_obligation( - field.ty.into(), + field.ty, field.span, ObligationCauseCode::MiscObligation, ) @@ -601,7 +601,7 @@ fn check_item_type(tcx: TyCtxt<'_>, item_id: hir::HirId, ty_span: Span, allow_fo } } - fcx.register_wf_obligation(item_ty.into(), ty_span, ObligationCauseCode::MiscObligation); + fcx.register_wf_obligation(item_ty, ty_span, ObligationCauseCode::MiscObligation); if forbid_unsized { fcx.register_bound( item_ty, @@ -650,7 +650,7 @@ fn check_impl<'tcx>( let self_ty = fcx.tcx.type_of(item_def_id); let self_ty = fcx.normalize_associated_types_in(item.span, &self_ty); fcx.register_wf_obligation( - self_ty.into(), + self_ty, ast_self_ty.span, ObligationCauseCode::MiscObligation, ); @@ -698,7 +698,7 @@ fn check_where_clauses<'tcx, 'fcx>( // be sure if it will error or not as user might always specify the other. if !ty.needs_subst() { fcx.register_wf_obligation( - ty.into(), + ty, fcx.tcx.def_span(param.def_id), ObligationCauseCode::MiscObligation, ); @@ -841,13 +841,13 @@ fn check_fn_or_method<'fcx, 'tcx>( let sig = fcx.normalize_associated_types_in(span, &sig); let sig = fcx.tcx.liberate_late_bound_regions(def_id, &sig); - for (&input_ty, span) in sig.inputs().iter().zip(hir_sig.decl.inputs.iter().map(|t| t.span)) { - fcx.register_wf_obligation(input_ty.into(), span, ObligationCauseCode::MiscObligation); + for (input_ty, span) in sig.inputs().iter().zip(hir_sig.decl.inputs.iter().map(|t| t.span)) { + fcx.register_wf_obligation(&input_ty, span, ObligationCauseCode::MiscObligation); } implied_bounds.extend(sig.inputs()); fcx.register_wf_obligation( - sig.output().into(), + sig.output(), hir_sig.decl.output.span(), ObligationCauseCode::ReturnType, ); diff --git a/src/librustc_typeck/impl_wf_check/min_specialization.rs b/src/librustc_typeck/impl_wf_check/min_specialization.rs index e4bffedd620b9..bf9a4d1cb6ca9 100644 --- a/src/librustc_typeck/impl_wf_check/min_specialization.rs +++ b/src/librustc_typeck/impl_wf_check/min_specialization.rs @@ -332,12 +332,12 @@ fn check_predicates<'tcx>( }); // Include the well-formed predicates of the type parameters of the impl. - for arg in tcx.impl_trait_ref(impl1_def_id).unwrap().substs { + for ty in tcx.impl_trait_ref(impl1_def_id).unwrap().substs.types() { if let Some(obligations) = wf::obligations( infcx, tcx.param_env(impl1_def_id), tcx.hir().as_local_hir_id(impl1_def_id), - arg, + ty, span, ) { impl2_predicates diff --git a/src/test/ui/const-generics/cannot-infer-const-args.stderr b/src/test/ui/const-generics/cannot-infer-const-args.stderr index b29d27e524751..6696b025855a8 100644 --- a/src/test/ui/const-generics/cannot-infer-const-args.stderr +++ b/src/test/ui/const-generics/cannot-infer-const-args.stderr @@ -11,9 +11,7 @@ error[E0282]: type annotations needed --> $DIR/cannot-infer-const-args.rs:9:5 | LL | foo(); - | ^^^ - | - = note: unable to infer the value of a const parameter + | ^^^ cannot infer type for fn item `fn() -> usize {foo::<{_: usize}>}` error: aborting due to previous error; 1 warning emitted diff --git a/src/test/ui/const-generics/issues/issue-61747.rs b/src/test/ui/const-generics/issues/issue-61747.rs index cc671163e85a1..9e0572d3568cb 100644 --- a/src/test/ui/const-generics/issues/issue-61747.rs +++ b/src/test/ui/const-generics/issues/issue-61747.rs @@ -1,3 +1,5 @@ +// check-pass + #![feature(const_generics)] //~^ WARN the feature `const_generics` is incomplete @@ -5,7 +7,6 @@ struct Const; impl Const<{C}> { fn successor() -> Const<{C + 1}> { - //~^ ERROR constant expression depends on a generic parameter Const } } diff --git a/src/test/ui/const-generics/issues/issue-61747.stderr b/src/test/ui/const-generics/issues/issue-61747.stderr index 2685d9fdf167c..2e405370dc0df 100644 --- a/src/test/ui/const-generics/issues/issue-61747.stderr +++ b/src/test/ui/const-generics/issues/issue-61747.stderr @@ -1,5 +1,5 @@ warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/issue-61747.rs:1:12 + --> $DIR/issue-61747.rs:3:12 | LL | #![feature(const_generics)] | ^^^^^^^^^^^^^^ @@ -7,13 +7,5 @@ LL | #![feature(const_generics)] = note: `#[warn(incomplete_features)]` on by default = note: see issue #44580 for more information -error: constant expression depends on a generic parameter - --> $DIR/issue-61747.rs:7:23 - | -LL | fn successor() -> Const<{C + 1}> { - | ^^^^^^^^^^^^^^ - | - = note: this may fail depending on what value the parameter takes - -error: aborting due to previous error; 1 warning emitted +warning: 1 warning emitted diff --git a/src/test/ui/const-generics/issues/issue-61935.rs b/src/test/ui/const-generics/issues/issue-61935.rs index 0d42ff1895cdb..5c987e63a9e07 100644 --- a/src/test/ui/const-generics/issues/issue-61935.rs +++ b/src/test/ui/const-generics/issues/issue-61935.rs @@ -1,3 +1,5 @@ +// check-pass + #![feature(const_generics)] //~^ WARN the feature `const_generics` is incomplete @@ -6,7 +8,6 @@ trait Foo {} impl Foo for [(); N] where Self:FooImpl<{N==0}> -//~^ERROR constant expression depends on a generic parameter {} trait FooImpl{} diff --git a/src/test/ui/const-generics/issues/issue-61935.stderr b/src/test/ui/const-generics/issues/issue-61935.stderr index a785af5f008ea..cf0c0e24a7604 100644 --- a/src/test/ui/const-generics/issues/issue-61935.stderr +++ b/src/test/ui/const-generics/issues/issue-61935.stderr @@ -1,5 +1,5 @@ warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/issue-61935.rs:1:12 + --> $DIR/issue-61935.rs:3:12 | LL | #![feature(const_generics)] | ^^^^^^^^^^^^^^ @@ -7,13 +7,5 @@ LL | #![feature(const_generics)] = note: `#[warn(incomplete_features)]` on by default = note: see issue #44580 for more information -error: constant expression depends on a generic parameter - --> $DIR/issue-61935.rs:8:14 - | -LL | Self:FooImpl<{N==0}> - | ^^^^^^^^^^^^^^^ - | - = note: this may fail depending on what value the parameter takes - -error: aborting due to previous error; 1 warning emitted +warning: 1 warning emitted diff --git a/src/test/ui/const-generics/issues/issue-62220.rs b/src/test/ui/const-generics/issues/issue-62220.rs index 5c4a0d31a895d..c95b306320175 100644 --- a/src/test/ui/const-generics/issues/issue-62220.rs +++ b/src/test/ui/const-generics/issues/issue-62220.rs @@ -1,6 +1,7 @@ +// build-pass #![allow(incomplete_features)] -#![feature(const_generics)] +#![feature(const_generics)] pub struct Vector([T; N]); pub type TruncatedVector = Vector; @@ -8,7 +9,6 @@ pub type TruncatedVector = Vector; impl Vector { /// Drop the last component and return the vector with one fewer dimension. pub fn trunc(self) -> (TruncatedVector, T) { - //~^ ERROR constant expression depends on a generic parameter unimplemented!() } } diff --git a/src/test/ui/const-generics/issues/issue-62220.stderr b/src/test/ui/const-generics/issues/issue-62220.stderr deleted file mode 100644 index d91d2bb326fc5..0000000000000 --- a/src/test/ui/const-generics/issues/issue-62220.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error: constant expression depends on a generic parameter - --> $DIR/issue-62220.rs:10:27 - | -LL | pub fn trunc(self) -> (TruncatedVector, T) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: this may fail depending on what value the parameter takes - -error: aborting due to previous error - diff --git a/src/test/ui/const-generics/issues/issue-66205.rs b/src/test/ui/const-generics/issues/issue-66205.rs index 7cedf51ca0404..76bde1815be18 100644 --- a/src/test/ui/const-generics/issues/issue-66205.rs +++ b/src/test/ui/const-generics/issues/issue-66205.rs @@ -1,6 +1,6 @@ -#![allow(dead_code, unconditional_recursion)] +#![allow(incomplete_features, dead_code, unconditional_recursion)] #![feature(const_generics)] -//~^ WARN the feature `const_generics` is incomplete +#![feature(lazy_normalization_consts)] fn fact() { fact::<{ N - 1 }>(); diff --git a/src/test/ui/const-generics/issues/issue-66205.stderr b/src/test/ui/const-generics/issues/issue-66205.stderr index 1e9c0f2f3d9eb..416b675b56d28 100644 --- a/src/test/ui/const-generics/issues/issue-66205.stderr +++ b/src/test/ui/const-generics/issues/issue-66205.stderr @@ -1,12 +1,3 @@ -warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/issue-66205.rs:2:12 - | -LL | #![feature(const_generics)] - | ^^^^^^^^^^^^^^ - | - = note: `#[warn(incomplete_features)]` on by default - = note: see issue #44580 for more information - error: constant expression depends on a generic parameter --> $DIR/issue-66205.rs:6:12 | @@ -15,5 +6,5 @@ LL | fact::<{ N - 1 }>(); | = note: this may fail depending on what value the parameter takes -error: aborting due to previous error; 1 warning emitted +error: aborting due to previous error diff --git a/src/test/ui/const-generics/issues/issue-68977.rs b/src/test/ui/const-generics/issues/issue-68977.rs deleted file mode 100644 index 346ea3c204244..0000000000000 --- a/src/test/ui/const-generics/issues/issue-68977.rs +++ /dev/null @@ -1,40 +0,0 @@ -#![feature(const_generics)] -//~^ WARN the feature `const_generics` is incomplete - -struct PhantomU8; - -trait FxpStorage { - type SInt; // Add arithmetic traits as needed. -} - -macro_rules! fxp_storage_impls { - ($($($n:literal)|+ => $sint:ty),* $(,)?) => { - $($(impl FxpStorage for PhantomU8<$n> { - type SInt = $sint; - })*)* - } -} - -fxp_storage_impls! { - 1 => i8, - 2 => i16, - 3 | 4 => i32, - 5 | 6 | 7 | 8 => i64, - 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 => i128, -} - -type FxpStorageHelper = - PhantomU8<{(INT_BITS + FRAC_BITS + 7) / 8}>; - -struct Fxp -where - FxpStorageHelper: FxpStorage, - //~^ ERROR constant expression depends on a generic parameter -{ - storage: as FxpStorage>::SInt, -} - -fn main() { - Fxp::<1, 15> { storage: 0i16 }; - Fxp::<2, 15> { storage: 0i32 }; -} diff --git a/src/test/ui/const-generics/issues/issue-68977.stderr b/src/test/ui/const-generics/issues/issue-68977.stderr deleted file mode 100644 index e1190d9026da9..0000000000000 --- a/src/test/ui/const-generics/issues/issue-68977.stderr +++ /dev/null @@ -1,19 +0,0 @@ -warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/issue-68977.rs:1:12 - | -LL | #![feature(const_generics)] - | ^^^^^^^^^^^^^^ - | - = note: `#[warn(incomplete_features)]` on by default - = note: see issue #44580 for more information - -error: constant expression depends on a generic parameter - --> $DIR/issue-68977.rs:31:44 - | -LL | FxpStorageHelper: FxpStorage, - | ^^^^^^^^^^ - | - = note: this may fail depending on what value the parameter takes - -error: aborting due to previous error; 1 warning emitted - diff --git a/src/test/ui/const-generics/lazy-normalization/issue-71922.rs b/src/test/ui/const-generics/lazy-normalization/issue-71922.rs index 0d392ddcaedcc..36513f94a9e97 100644 --- a/src/test/ui/const-generics/lazy-normalization/issue-71922.rs +++ b/src/test/ui/const-generics/lazy-normalization/issue-71922.rs @@ -1,9 +1,9 @@ +// run-pass #![feature(const_generics)] -//~^ WARN the feature `const_generics` is incomplete +#![allow(incomplete_features)] trait Foo {} impl Foo for [(); N] where Self: FooImpl<{ N == 0 }> {} -//~^ ERROR constant expression depends on a generic parameter trait FooImpl {} diff --git a/src/test/ui/const-generics/lazy-normalization/issue-71922.stderr b/src/test/ui/const-generics/lazy-normalization/issue-71922.stderr deleted file mode 100644 index 00917571e716d..0000000000000 --- a/src/test/ui/const-generics/lazy-normalization/issue-71922.stderr +++ /dev/null @@ -1,19 +0,0 @@ -warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/issue-71922.rs:1:12 - | -LL | #![feature(const_generics)] - | ^^^^^^^^^^^^^^ - | - = note: `#[warn(incomplete_features)]` on by default - = note: see issue #44580 for more information - -error: constant expression depends on a generic parameter - --> $DIR/issue-71922.rs:5:50 - | -LL | impl Foo for [(); N] where Self: FooImpl<{ N == 0 }> {} - | ^^^^^^^^^^^^^^^^^^^ - | - = note: this may fail depending on what value the parameter takes - -error: aborting due to previous error; 1 warning emitted - diff --git a/src/test/ui/const-generics/wf-misc.rs b/src/test/ui/const-generics/wf-misc.rs deleted file mode 100644 index 4ff1b9e2da5b2..0000000000000 --- a/src/test/ui/const-generics/wf-misc.rs +++ /dev/null @@ -1,16 +0,0 @@ -#![feature(const_generics)] -//~^ WARN the feature `const_generics` is incomplete - -pub fn arr_len() { - let _: [u8; N + 1]; - //~^ ERROR constant expression depends on a generic parameter -} - -struct Const; - -pub fn func_call() { - let _: Const::<{N + 1}>; - //~^ ERROR constant expression depends on a generic parameter -} - -fn main() {} diff --git a/src/test/ui/const-generics/wf-misc.stderr b/src/test/ui/const-generics/wf-misc.stderr deleted file mode 100644 index 03f2bf3f52699..0000000000000 --- a/src/test/ui/const-generics/wf-misc.stderr +++ /dev/null @@ -1,27 +0,0 @@ -warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/wf-misc.rs:1:12 - | -LL | #![feature(const_generics)] - | ^^^^^^^^^^^^^^ - | - = note: `#[warn(incomplete_features)]` on by default - = note: see issue #44580 for more information - -error: constant expression depends on a generic parameter - --> $DIR/wf-misc.rs:5:12 - | -LL | let _: [u8; N + 1]; - | ^^^^^^^^^^^ - | - = note: this may fail depending on what value the parameter takes - -error: constant expression depends on a generic parameter - --> $DIR/wf-misc.rs:12:12 - | -LL | let _: Const::<{N + 1}>; - | ^^^^^^^^^^^^^^^^ - | - = note: this may fail depending on what value the parameter takes - -error: aborting due to 2 previous errors; 1 warning emitted -