Auto merge of #115758 - matthiaskrgr:rollup-khwbjj7, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - #115335 (fix overflow in array length computation) - #115440 (bootstrap/format: remove unnecessary paths.push) - #115702 (Update mailmap) - #115727 (Implement fallback for effect param) - #115739 (Call `LateLintPass::check_attribute` from `with_lint_attrs`) - #115743 (Point out if a local trait has no implementations) - #115744 (Improve diagnostic for generic params from outer items (E0401)) - #115752 (rustdoc: Add missing "Aliased type" title in the sidebar) r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
0a199e4e93
140 changed files with 1415 additions and 301 deletions
4
.mailmap
4
.mailmap
|
@ -205,6 +205,10 @@ Gareth Daniel Smith <garethdanielsmith@gmail.com> gareth <gareth@gareth-N56VM.(n
|
|||
Gareth Daniel Smith <garethdanielsmith@gmail.com> Gareth Smith <garethdanielsmith@gmail.com>
|
||||
Gauri Kholkar <f2013002@goa.bits-pilani.ac.in>
|
||||
Georges Dubus <georges.dubus@gmail.com> <georges.dubus@compiletoi.net>
|
||||
Ghost <ghost> <jonasschievink@gmail.com>
|
||||
Ghost <ghost> <jonas.schievink@ferrous-systems.com>
|
||||
Ghost <ghost> <jonas@schievink.net>
|
||||
Ghost <ghost> <Jonas.Schievink@sony.com>
|
||||
Giles Cope <gilescope@gmail.com>
|
||||
Glen De Cauwsemaecker <decauwsemaecker.glen@gmail.com>
|
||||
Graham Fawcett <graham.fawcett@gmail.com> Graham Fawcett <fawcett@uwindsor.ca>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
Inner items do not inherit type or const parameters from the functions
|
||||
Inner items do not inherit the generic parameters from the items
|
||||
they are embedded in.
|
||||
|
||||
Erroneous code example:
|
||||
|
@ -32,8 +32,8 @@ fn foo<T>(x: T) {
|
|||
}
|
||||
```
|
||||
|
||||
Items inside functions are basically just like top-level items, except
|
||||
that they can only be used from the function they are in.
|
||||
Items nested inside other items are basically just like top-level items, except
|
||||
that they can only be used from the item they are in.
|
||||
|
||||
There are a couple of solutions for this.
|
||||
|
||||
|
|
|
@ -523,7 +523,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
Ty::new_misc_error(tcx).into()
|
||||
}
|
||||
}
|
||||
GenericParamDefKind::Const { has_default } => {
|
||||
GenericParamDefKind::Const { has_default, .. } => {
|
||||
let ty = tcx
|
||||
.at(self.span)
|
||||
.type_of(param.def_id)
|
||||
|
|
|
@ -1255,7 +1255,7 @@ fn check_where_clauses<'tcx>(wfcx: &WfCheckingCtxt<'_, 'tcx>, span: Span, def_id
|
|||
|
||||
let is_our_default = |def: &ty::GenericParamDef| match def.kind {
|
||||
GenericParamDefKind::Type { has_default, .. }
|
||||
| GenericParamDefKind::Const { has_default } => {
|
||||
| GenericParamDefKind::Const { has_default, .. } => {
|
||||
has_default && def.index >= generics.parent_count as u32
|
||||
}
|
||||
GenericParamDefKind::Lifetime => unreachable!(),
|
||||
|
|
|
@ -328,7 +328,10 @@ pub(super) fn generics_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Generics {
|
|||
name: param.name.ident().name,
|
||||
def_id: param.def_id.to_def_id(),
|
||||
pure_wrt_drop: param.pure_wrt_drop,
|
||||
kind: ty::GenericParamDefKind::Const { has_default: default.is_some() },
|
||||
kind: ty::GenericParamDefKind::Const {
|
||||
has_default: default.is_some(),
|
||||
is_host_effect: is_host_param,
|
||||
},
|
||||
})
|
||||
}
|
||||
}));
|
||||
|
|
|
@ -4,6 +4,7 @@ use rustc_data_structures::{
|
|||
graph::{iterate::DepthFirstSearch, vec_graph::VecGraph},
|
||||
unord::{UnordBag, UnordMap, UnordSet},
|
||||
};
|
||||
use rustc_infer::infer::{DefineOpaqueTypes, InferOk};
|
||||
use rustc_middle::ty::{self, Ty};
|
||||
|
||||
impl<'tcx> FnCtxt<'_, 'tcx> {
|
||||
|
@ -23,22 +24,12 @@ impl<'tcx> FnCtxt<'_, 'tcx> {
|
|||
self.fulfillment_cx.borrow_mut().pending_obligations()
|
||||
);
|
||||
|
||||
// Check if we have any unsolved variables. If not, no need for fallback.
|
||||
let unsolved_variables = self.unsolved_variables();
|
||||
if unsolved_variables.is_empty() {
|
||||
let fallback_occured = self.fallback_types() || self.fallback_effects();
|
||||
|
||||
if !fallback_occured {
|
||||
return;
|
||||
}
|
||||
|
||||
let diverging_fallback = self.calculate_diverging_fallback(&unsolved_variables);
|
||||
|
||||
// We do fallback in two passes, to try to generate
|
||||
// better error messages.
|
||||
// The first time, we do *not* replace opaque types.
|
||||
for ty in unsolved_variables {
|
||||
debug!("unsolved_variable = {:?}", ty);
|
||||
self.fallback_if_possible(ty, &diverging_fallback);
|
||||
}
|
||||
|
||||
// We now see if we can make progress. This might cause us to
|
||||
// unify inference variables for opaque types, since we may
|
||||
// have unified some other type variables during the first
|
||||
|
@ -65,6 +56,53 @@ impl<'tcx> FnCtxt<'_, 'tcx> {
|
|||
self.select_obligations_where_possible(|_| {});
|
||||
}
|
||||
|
||||
fn fallback_types(&self) -> bool {
|
||||
// Check if we have any unsolved variables. If not, no need for fallback.
|
||||
let unsolved_variables = self.unsolved_variables();
|
||||
|
||||
if unsolved_variables.is_empty() {
|
||||
return false;
|
||||
}
|
||||
|
||||
let diverging_fallback = self.calculate_diverging_fallback(&unsolved_variables);
|
||||
|
||||
// We do fallback in two passes, to try to generate
|
||||
// better error messages.
|
||||
// The first time, we do *not* replace opaque types.
|
||||
for ty in unsolved_variables {
|
||||
debug!("unsolved_variable = {:?}", ty);
|
||||
self.fallback_if_possible(ty, &diverging_fallback);
|
||||
}
|
||||
|
||||
true
|
||||
}
|
||||
|
||||
fn fallback_effects(&self) -> bool {
|
||||
let unsolved_effects = self.unsolved_effects();
|
||||
|
||||
if unsolved_effects.is_empty() {
|
||||
return false;
|
||||
}
|
||||
|
||||
// not setting `fallback_has_occured` here because that field is only used for type fallback
|
||||
// diagnostics.
|
||||
|
||||
for effect in unsolved_effects {
|
||||
let expected = self.tcx.consts.true_;
|
||||
let cause = self.misc(rustc_span::DUMMY_SP);
|
||||
match self.at(&cause, self.param_env).eq(DefineOpaqueTypes::Yes, expected, effect) {
|
||||
Ok(InferOk { obligations, value: () }) => {
|
||||
self.register_predicates(obligations);
|
||||
}
|
||||
Err(e) => {
|
||||
bug!("cannot eq unsolved effect: {e:?}")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
true
|
||||
}
|
||||
|
||||
// Tries to apply a fallback to `ty` if it is an unsolved variable.
|
||||
//
|
||||
// - Unconstrained ints are replaced with `i32`.
|
||||
|
|
|
@ -1295,17 +1295,25 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
(GenericParamDefKind::Type { .. }, GenericArg::Infer(inf)) => {
|
||||
self.fcx.ty_infer(Some(param), inf.span).into()
|
||||
}
|
||||
(GenericParamDefKind::Const { .. }, GenericArg::Infer(inf)) => {
|
||||
(
|
||||
&GenericParamDefKind::Const { has_default, is_host_effect },
|
||||
GenericArg::Infer(inf),
|
||||
) => {
|
||||
let tcx = self.fcx.tcx();
|
||||
self.fcx
|
||||
.ct_infer(
|
||||
tcx.type_of(param.def_id)
|
||||
.no_bound_vars()
|
||||
.expect("const parameter types cannot be generic"),
|
||||
Some(param),
|
||||
inf.span,
|
||||
)
|
||||
.into()
|
||||
|
||||
if has_default && is_host_effect {
|
||||
self.fcx.var_for_effect(param)
|
||||
} else {
|
||||
self.fcx
|
||||
.ct_infer(
|
||||
tcx.type_of(param.def_id)
|
||||
.no_bound_vars()
|
||||
.expect("const parameter types cannot be generic"),
|
||||
Some(param),
|
||||
inf.span,
|
||||
)
|
||||
.into()
|
||||
}
|
||||
}
|
||||
_ => unreachable!(),
|
||||
}
|
||||
|
@ -1324,7 +1332,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
}
|
||||
GenericParamDefKind::Type { has_default, .. } => {
|
||||
if !infer_args && has_default {
|
||||
// If we have a default, then we it doesn't matter that we're not
|
||||
// If we have a default, then it doesn't matter that we're not
|
||||
// inferring the type arguments: we provide the default where any
|
||||
// is missing.
|
||||
tcx.type_of(param.def_id).instantiate(tcx, args.unwrap()).into()
|
||||
|
@ -1336,17 +1344,28 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
self.fcx.var_for_def(self.span, param)
|
||||
}
|
||||
}
|
||||
GenericParamDefKind::Const { has_default } => {
|
||||
if !infer_args
|
||||
&& has_default
|
||||
&& !tcx.has_attr(param.def_id, sym::rustc_host)
|
||||
{
|
||||
tcx.const_param_default(param.def_id)
|
||||
.instantiate(tcx, args.unwrap())
|
||||
.into()
|
||||
} else {
|
||||
self.fcx.var_for_def(self.span, param)
|
||||
GenericParamDefKind::Const { has_default, is_host_effect } => {
|
||||
if has_default {
|
||||
// N.B. this is a bit of a hack. `infer_args` is passed depending on
|
||||
// whether the user has provided generic args. E.g. for `Vec::new`
|
||||
// we would have to infer the generic types. However, for `Vec::<T>::new`
|
||||
// where the allocator param `A` has a default we will *not* infer. But
|
||||
// for effect params this is a different story: if the user has not written
|
||||
// anything explicit for the effect param, we always need to try to infer
|
||||
// it before falling back to default, such that a `const fn` such as
|
||||
// `needs_drop::<()>` can still be called in const contexts. (if we defaulted
|
||||
// instead of inferred, typeck would error)
|
||||
if is_host_effect {
|
||||
return self.fcx.var_for_effect(param);
|
||||
} else if !infer_args {
|
||||
return tcx
|
||||
.const_param_default(param.def_id)
|
||||
.instantiate(tcx, args.unwrap())
|
||||
.into();
|
||||
}
|
||||
}
|
||||
|
||||
self.fcx.var_for_def(self.span, param)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -266,7 +266,14 @@ impl<'a, 'tcx> AstConv<'tcx> for FnCtxt<'a, 'tcx> {
|
|||
param: Option<&ty::GenericParamDef>,
|
||||
span: Span,
|
||||
) -> Const<'tcx> {
|
||||
// FIXME ideally this shouldn't use unwrap
|
||||
match param {
|
||||
Some(
|
||||
param @ ty::GenericParamDef {
|
||||
kind: ty::GenericParamDefKind::Const { is_host_effect: true, .. },
|
||||
..
|
||||
},
|
||||
) => self.var_for_effect(param).as_const().unwrap(),
|
||||
Some(param) => self.var_for_def(span, param).as_const().unwrap(),
|
||||
None => self.next_const_var(
|
||||
ty,
|
||||
|
|
|
@ -643,17 +643,14 @@ fn check_must_not_suspend_ty<'tcx>(
|
|||
}
|
||||
ty::Array(ty, len) => {
|
||||
let descr_pre = &format!("{}array{} of ", data.descr_pre, plural_suffix);
|
||||
let target_usize =
|
||||
len.try_eval_target_usize(fcx.tcx, fcx.param_env).unwrap_or(0) as usize;
|
||||
let plural_len = target_usize.saturating_add(1);
|
||||
check_must_not_suspend_ty(
|
||||
fcx,
|
||||
ty,
|
||||
hir_id,
|
||||
SuspendCheckData {
|
||||
descr_pre,
|
||||
plural_len: len.try_eval_target_usize(fcx.tcx, fcx.param_env).unwrap_or(0)
|
||||
as usize
|
||||
+ 1,
|
||||
..data
|
||||
},
|
||||
SuspendCheckData { descr_pre, plural_len, ..data },
|
||||
)
|
||||
}
|
||||
// If drop tracking is enabled, we want to look through references, since the referent
|
||||
|
|
|
@ -522,6 +522,17 @@ impl<'cx, 'tcx> TypeFolder<TyCtxt<'tcx>> for Canonicalizer<'cx, 'tcx> {
|
|||
}
|
||||
}
|
||||
}
|
||||
ty::ConstKind::Infer(InferConst::EffectVar(vid)) => {
|
||||
match self.infcx.probe_effect_var(vid) {
|
||||
Some(value) => return self.fold_const(value.as_const(self.infcx.tcx)),
|
||||
None => {
|
||||
return self.canonicalize_const_var(
|
||||
CanonicalVarInfo { kind: CanonicalVarKind::Effect },
|
||||
ct,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
ty::ConstKind::Infer(InferConst::Fresh(_)) => {
|
||||
bug!("encountered a fresh const during canonicalization")
|
||||
}
|
||||
|
@ -690,7 +701,8 @@ impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx> {
|
|||
.iter()
|
||||
.map(|v| CanonicalVarInfo {
|
||||
kind: match v.kind {
|
||||
CanonicalVarKind::Ty(CanonicalTyVarKind::Int | CanonicalTyVarKind::Float) => {
|
||||
CanonicalVarKind::Ty(CanonicalTyVarKind::Int | CanonicalTyVarKind::Float)
|
||||
| CanonicalVarKind::Effect => {
|
||||
return *v;
|
||||
}
|
||||
CanonicalVarKind::Ty(CanonicalTyVarKind::General(u)) => {
|
||||
|
|
|
@ -151,7 +151,11 @@ impl<'tcx> InferCtxt<'tcx> {
|
|||
universe_map(ui),
|
||||
)
|
||||
.into(),
|
||||
|
||||
CanonicalVarKind::Effect => {
|
||||
let vid = self.inner.borrow_mut().effect_unification_table().new_key(None);
|
||||
ty::Const::new_infer(self.tcx, ty::InferConst::EffectVar(vid), self.tcx.types.bool)
|
||||
.into()
|
||||
}
|
||||
CanonicalVarKind::PlaceholderConst(ty::PlaceholderConst { universe, bound }, ty) => {
|
||||
let universe_mapped = universe_map(universe);
|
||||
let placeholder_mapped = ty::PlaceholderConst { universe: universe_mapped, bound };
|
||||
|
|
|
@ -30,7 +30,7 @@ use super::{DefineOpaqueTypes, InferCtxt, TypeTrace};
|
|||
use crate::infer::generalize::{self, CombineDelegate, Generalization};
|
||||
use crate::traits::{Obligation, PredicateObligations};
|
||||
use rustc_middle::infer::canonical::OriginalQueryValues;
|
||||
use rustc_middle::infer::unify_key::{ConstVarValue, ConstVariableValue};
|
||||
use rustc_middle::infer::unify_key::{ConstVarValue, ConstVariableValue, EffectVarValue};
|
||||
use rustc_middle::infer::unify_key::{ConstVariableOrigin, ConstVariableOriginKind};
|
||||
use rustc_middle::ty::error::{ExpectedFound, TypeError};
|
||||
use rustc_middle::ty::relate::{RelateResult, TypeRelation};
|
||||
|
@ -91,7 +91,7 @@ impl<'tcx> InferCtxt<'tcx> {
|
|||
.borrow_mut()
|
||||
.float_unification_table()
|
||||
.unify_var_var(a_id, b_id)
|
||||
.map_err(|e| float_unification_error(relation.a_is_expected(), e))?;
|
||||
.map_err(|e| float_unification_error(a_is_expected, e))?;
|
||||
Ok(a)
|
||||
}
|
||||
(&ty::Infer(ty::FloatVar(v_id)), &ty::Float(v)) => {
|
||||
|
@ -210,10 +210,30 @@ impl<'tcx> InferCtxt<'tcx> {
|
|||
return Ok(a);
|
||||
}
|
||||
|
||||
(
|
||||
ty::ConstKind::Infer(InferConst::EffectVar(a_vid)),
|
||||
ty::ConstKind::Infer(InferConst::EffectVar(b_vid)),
|
||||
) => {
|
||||
self.inner
|
||||
.borrow_mut()
|
||||
.effect_unification_table()
|
||||
.unify_var_var(a_vid, b_vid)
|
||||
.map_err(|a| effect_unification_error(self.tcx, relation.a_is_expected(), a))?;
|
||||
return Ok(a);
|
||||
}
|
||||
|
||||
// All other cases of inference with other variables are errors.
|
||||
(ty::ConstKind::Infer(InferConst::Var(_)), ty::ConstKind::Infer(_))
|
||||
| (ty::ConstKind::Infer(_), ty::ConstKind::Infer(InferConst::Var(_))) => {
|
||||
bug!("tried to combine ConstKind::Infer/ConstKind::Infer(InferConst::Var)")
|
||||
(
|
||||
ty::ConstKind::Infer(InferConst::Var(_) | InferConst::EffectVar(_)),
|
||||
ty::ConstKind::Infer(_),
|
||||
)
|
||||
| (
|
||||
ty::ConstKind::Infer(_),
|
||||
ty::ConstKind::Infer(InferConst::Var(_) | InferConst::EffectVar(_)),
|
||||
) => {
|
||||
bug!(
|
||||
"tried to combine ConstKind::Infer/ConstKind::Infer(InferConst::Var): {a:?} and {b:?}"
|
||||
)
|
||||
}
|
||||
|
||||
(ty::ConstKind::Infer(InferConst::Var(vid)), _) => {
|
||||
|
@ -223,6 +243,23 @@ impl<'tcx> InferCtxt<'tcx> {
|
|||
(_, ty::ConstKind::Infer(InferConst::Var(vid))) => {
|
||||
return self.unify_const_variable(vid, a, relation.param_env());
|
||||
}
|
||||
|
||||
(ty::ConstKind::Infer(InferConst::EffectVar(vid)), _) => {
|
||||
return self.unify_effect_variable(
|
||||
relation.a_is_expected(),
|
||||
vid,
|
||||
EffectVarValue::Const(b),
|
||||
);
|
||||
}
|
||||
|
||||
(_, ty::ConstKind::Infer(InferConst::EffectVar(vid))) => {
|
||||
return self.unify_effect_variable(
|
||||
!relation.a_is_expected(),
|
||||
vid,
|
||||
EffectVarValue::Const(a),
|
||||
);
|
||||
}
|
||||
|
||||
(ty::ConstKind::Unevaluated(..), _) | (_, ty::ConstKind::Unevaluated(..))
|
||||
if self.tcx.features().generic_const_exprs || self.next_trait_solver() =>
|
||||
{
|
||||
|
@ -340,6 +377,20 @@ impl<'tcx> InferCtxt<'tcx> {
|
|||
.map_err(|e| float_unification_error(vid_is_expected, e))?;
|
||||
Ok(Ty::new_float(self.tcx, val))
|
||||
}
|
||||
|
||||
fn unify_effect_variable(
|
||||
&self,
|
||||
vid_is_expected: bool,
|
||||
vid: ty::EffectVid<'tcx>,
|
||||
val: EffectVarValue<'tcx>,
|
||||
) -> RelateResult<'tcx, ty::Const<'tcx>> {
|
||||
self.inner
|
||||
.borrow_mut()
|
||||
.effect_unification_table()
|
||||
.unify_var_value(vid, Some(val))
|
||||
.map_err(|e| effect_unification_error(self.tcx, vid_is_expected, e))?;
|
||||
Ok(val.as_const(self.tcx))
|
||||
}
|
||||
}
|
||||
|
||||
impl<'infcx, 'tcx> CombineFields<'infcx, 'tcx> {
|
||||
|
@ -493,3 +544,11 @@ fn float_unification_error<'tcx>(
|
|||
let (ty::FloatVarValue(a), ty::FloatVarValue(b)) = v;
|
||||
TypeError::FloatMismatch(ExpectedFound::new(a_is_expected, a, b))
|
||||
}
|
||||
|
||||
fn effect_unification_error<'tcx>(
|
||||
_tcx: TyCtxt<'tcx>,
|
||||
_a_is_expected: bool,
|
||||
(_a, _b): (EffectVarValue<'tcx>, EffectVarValue<'tcx>),
|
||||
) -> TypeError<'tcx> {
|
||||
bug!("unexpected effect unification error")
|
||||
}
|
||||
|
|
|
@ -156,6 +156,21 @@ impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for TypeFreshener<'a, 'tcx> {
|
|||
.known();
|
||||
self.freshen_const(opt_ct, ty::InferConst::Var(v), ty::InferConst::Fresh, ct.ty())
|
||||
}
|
||||
ty::ConstKind::Infer(ty::InferConst::EffectVar(v)) => {
|
||||
let opt_ct = self
|
||||
.infcx
|
||||
.inner
|
||||
.borrow_mut()
|
||||
.effect_unification_table()
|
||||
.probe_value(v)
|
||||
.map(|effect| effect.as_const(self.infcx.tcx));
|
||||
self.freshen_const(
|
||||
opt_ct,
|
||||
ty::InferConst::EffectVar(v),
|
||||
ty::InferConst::Fresh,
|
||||
ct.ty(),
|
||||
)
|
||||
}
|
||||
ty::ConstKind::Infer(ty::InferConst::Fresh(i)) => {
|
||||
if i >= self.const_freshen_count {
|
||||
bug!(
|
||||
|
|
|
@ -403,6 +403,7 @@ where
|
|||
}
|
||||
}
|
||||
}
|
||||
ty::ConstKind::Infer(InferConst::EffectVar(_)) => Ok(c),
|
||||
// FIXME: remove this branch once `structurally_relate_consts` is fully
|
||||
// structural.
|
||||
ty::ConstKind::Unevaluated(ty::UnevaluatedConst { def, args }) => {
|
||||
|
|
|
@ -21,7 +21,7 @@ use rustc_data_structures::unify as ut;
|
|||
use rustc_errors::{DiagnosticBuilder, ErrorGuaranteed};
|
||||
use rustc_hir::def_id::{DefId, LocalDefId};
|
||||
use rustc_middle::infer::canonical::{Canonical, CanonicalVarValues};
|
||||
use rustc_middle::infer::unify_key::{ConstVarValue, ConstVariableValue};
|
||||
use rustc_middle::infer::unify_key::{ConstVarValue, ConstVariableValue, EffectVarValue};
|
||||
use rustc_middle::infer::unify_key::{ConstVariableOrigin, ConstVariableOriginKind, ToType};
|
||||
use rustc_middle::mir::interpret::{ErrorHandled, EvalToValTreeResult};
|
||||
use rustc_middle::mir::ConstraintCategory;
|
||||
|
@ -33,13 +33,14 @@ use rustc_middle::ty::relate::RelateResult;
|
|||
use rustc_middle::ty::visit::{TypeVisitable, TypeVisitableExt};
|
||||
pub use rustc_middle::ty::IntVarValue;
|
||||
use rustc_middle::ty::{self, GenericParamDefKind, InferConst, InferTy, Ty, TyCtxt};
|
||||
use rustc_middle::ty::{ConstVid, FloatVid, IntVid, TyVid};
|
||||
use rustc_middle::ty::{ConstVid, EffectVid, FloatVid, IntVid, TyVid};
|
||||
use rustc_middle::ty::{GenericArg, GenericArgKind, GenericArgs, GenericArgsRef};
|
||||
use rustc_span::symbol::Symbol;
|
||||
use rustc_span::Span;
|
||||
|
||||
use std::cell::{Cell, RefCell};
|
||||
use std::fmt;
|
||||
use std::marker::PhantomData;
|
||||
|
||||
use self::combine::CombineFields;
|
||||
use self::error_reporting::TypeErrCtxt;
|
||||
|
@ -115,6 +116,9 @@ pub struct InferCtxtInner<'tcx> {
|
|||
/// Map from floating variable to the kind of float it represents.
|
||||
float_unification_storage: ut::UnificationTableStorage<ty::FloatVid>,
|
||||
|
||||
/// Map from effect variable to the effect param it represents.
|
||||
effect_unification_storage: ut::UnificationTableStorage<ty::EffectVid<'tcx>>,
|
||||
|
||||
/// Tracks the set of region variables and the constraints between them.
|
||||
///
|
||||
/// This is initially `Some(_)` but when
|
||||
|
@ -172,6 +176,7 @@ impl<'tcx> InferCtxtInner<'tcx> {
|
|||
const_unification_storage: ut::UnificationTableStorage::new(),
|
||||
int_unification_storage: ut::UnificationTableStorage::new(),
|
||||
float_unification_storage: ut::UnificationTableStorage::new(),
|
||||
effect_unification_storage: ut::UnificationTableStorage::new(),
|
||||
region_constraint_storage: Some(RegionConstraintStorage::new()),
|
||||
region_obligations: vec![],
|
||||
opaque_type_storage: Default::default(),
|
||||
|
@ -223,6 +228,10 @@ impl<'tcx> InferCtxtInner<'tcx> {
|
|||
self.const_unification_storage.with_log(&mut self.undo_log)
|
||||
}
|
||||
|
||||
fn effect_unification_table(&mut self) -> UnificationTable<'_, 'tcx, ty::EffectVid<'tcx>> {
|
||||
self.effect_unification_storage.with_log(&mut self.undo_log)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn unwrap_region_constraints(&mut self) -> RegionConstraintCollector<'_, 'tcx> {
|
||||
self.region_constraint_storage
|
||||
|
@ -356,6 +365,7 @@ impl<'tcx> ty::InferCtxtLike<TyCtxt<'tcx>> for InferCtxt<'tcx> {
|
|||
Err(universe) => Some(universe),
|
||||
Ok(_) => None,
|
||||
},
|
||||
EffectVar(_) => None,
|
||||
Fresh(_) => None,
|
||||
}
|
||||
}
|
||||
|
@ -777,6 +787,19 @@ impl<'tcx> InferCtxt<'tcx> {
|
|||
vars
|
||||
}
|
||||
|
||||
pub fn unsolved_effects(&self) -> Vec<ty::Const<'tcx>> {
|
||||
let mut inner = self.inner.borrow_mut();
|
||||
let mut table = inner.effect_unification_table();
|
||||
|
||||
(0..table.len())
|
||||
.map(|i| ty::EffectVid { index: i as u32, phantom: PhantomData })
|
||||
.filter(|&vid| table.probe_value(vid).is_none())
|
||||
.map(|v| {
|
||||
ty::Const::new_infer(self.tcx, ty::InferConst::EffectVar(v), self.tcx.types.bool)
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn combine_fields<'a>(
|
||||
&'a self,
|
||||
trace: TypeTrace<'tcx>,
|
||||
|
@ -1158,7 +1181,10 @@ impl<'tcx> InferCtxt<'tcx> {
|
|||
|
||||
Ty::new_var(self.tcx, ty_var_id).into()
|
||||
}
|
||||
GenericParamDefKind::Const { .. } => {
|
||||
GenericParamDefKind::Const { is_host_effect, .. } => {
|
||||
if is_host_effect {
|
||||
return self.var_for_effect(param);
|
||||
}
|
||||
let origin = ConstVariableOrigin {
|
||||
kind: ConstVariableOriginKind::ConstParameterDefinition(
|
||||
param.name,
|
||||
|
@ -1184,6 +1210,17 @@ impl<'tcx> InferCtxt<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn var_for_effect(&self, param: &ty::GenericParamDef) -> GenericArg<'tcx> {
|
||||
let effect_vid = self.inner.borrow_mut().effect_unification_table().new_key(None);
|
||||
let ty = self
|
||||
.tcx
|
||||
.type_of(param.def_id)
|
||||
.no_bound_vars()
|
||||
.expect("const parameter types cannot be generic");
|
||||
debug_assert_eq!(self.tcx.types.bool, ty);
|
||||
ty::Const::new_infer(self.tcx, ty::InferConst::EffectVar(effect_vid), ty).into()
|
||||
}
|
||||
|
||||
/// Given a set of generics defined on a type or impl, returns a substitution mapping each
|
||||
/// type/region parameter to a fresh inference variable.
|
||||
pub fn fresh_args_for_item(&self, span: Span, def_id: DefId) -> GenericArgsRef<'tcx> {
|
||||
|
@ -1369,6 +1406,10 @@ impl<'tcx> InferCtxt<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn probe_effect_var(&self, vid: EffectVid<'tcx>) -> Option<EffectVarValue<'tcx>> {
|
||||
self.inner.borrow_mut().effect_unification_table().probe_value(vid)
|
||||
}
|
||||
|
||||
/// Attempts to resolve all type/region/const variables in
|
||||
/// `value`. Region inference must have been run already (e.g.,
|
||||
/// by calling `resolve_regions_and_report_errors`). If some
|
||||
|
@ -1649,6 +1690,14 @@ impl<'tcx> InferCtxt<'tcx> {
|
|||
ConstVariableValue::Known { .. } => true,
|
||||
}
|
||||
}
|
||||
|
||||
TyOrConstInferVar::Effect(v) => {
|
||||
// If `probe_value` returns `Some`, it never equals
|
||||
// `ty::ConstKind::Infer(ty::InferConst::Effect(v))`.
|
||||
//
|
||||
// Not `inlined_probe_value(v)` because this call site is colder.
|
||||
self.probe_effect_var(v).is_some()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1720,6 +1769,8 @@ pub enum TyOrConstInferVar<'tcx> {
|
|||
|
||||
/// Equivalent to `ty::ConstKind::Infer(ty::InferConst::Var(_))`.
|
||||
Const(ConstVid<'tcx>),
|
||||
/// Equivalent to `ty::ConstKind::Infer(ty::InferConst::EffectVar(_))`.
|
||||
Effect(EffectVid<'tcx>),
|
||||
}
|
||||
|
||||
impl<'tcx> TyOrConstInferVar<'tcx> {
|
||||
|
@ -1750,6 +1801,7 @@ impl<'tcx> TyOrConstInferVar<'tcx> {
|
|||
fn maybe_from_const(ct: ty::Const<'tcx>) -> Option<Self> {
|
||||
match ct.kind() {
|
||||
ty::ConstKind::Infer(InferConst::Var(v)) => Some(TyOrConstInferVar::Const(v)),
|
||||
ty::ConstKind::Infer(InferConst::EffectVar(v)) => Some(TyOrConstInferVar::Effect(v)),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
@ -1793,17 +1845,24 @@ impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for ShallowResolver<'a, 'tcx> {
|
|||
}
|
||||
|
||||
fn fold_const(&mut self, ct: ty::Const<'tcx>) -> ty::Const<'tcx> {
|
||||
if let ty::ConstKind::Infer(InferConst::Var(vid)) = ct.kind() {
|
||||
self.infcx
|
||||
match ct.kind() {
|
||||
ty::ConstKind::Infer(InferConst::Var(vid)) => self
|
||||
.infcx
|
||||
.inner
|
||||
.borrow_mut()
|
||||
.const_unification_table()
|
||||
.probe_value(vid)
|
||||
.val
|
||||
.known()
|
||||
.unwrap_or(ct)
|
||||
} else {
|
||||
ct
|
||||
.unwrap_or(ct),
|
||||
ty::ConstKind::Infer(InferConst::EffectVar(vid)) => self
|
||||
.infcx
|
||||
.inner
|
||||
.borrow_mut()
|
||||
.effect_unification_table()
|
||||
.probe_value(vid)
|
||||
.map_or(ct, |val| val.as_const(self.infcx.tcx)),
|
||||
_ => ct,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ pub(crate) enum UndoLog<'tcx> {
|
|||
ConstUnificationTable(sv::UndoLog<ut::Delegate<ty::ConstVid<'tcx>>>),
|
||||
IntUnificationTable(sv::UndoLog<ut::Delegate<ty::IntVid>>),
|
||||
FloatUnificationTable(sv::UndoLog<ut::Delegate<ty::FloatVid>>),
|
||||
EffectUnificationTable(sv::UndoLog<ut::Delegate<ty::EffectVid<'tcx>>>),
|
||||
RegionConstraintCollector(region_constraints::UndoLog<'tcx>),
|
||||
RegionUnificationTable(sv::UndoLog<ut::Delegate<RegionVidKey<'tcx>>>),
|
||||
ProjectionCache(traits::UndoLog<'tcx>),
|
||||
|
@ -55,6 +56,7 @@ impl_from! {
|
|||
IntUnificationTable(sv::UndoLog<ut::Delegate<ty::IntVid>>),
|
||||
|
||||
FloatUnificationTable(sv::UndoLog<ut::Delegate<ty::FloatVid>>),
|
||||
EffectUnificationTable(sv::UndoLog<ut::Delegate<ty::EffectVid<'tcx>>>),
|
||||
|
||||
ConstUnificationTable(sv::UndoLog<ut::Delegate<ty::ConstVid<'tcx>>>),
|
||||
|
||||
|
@ -71,6 +73,7 @@ impl<'tcx> Rollback<UndoLog<'tcx>> for InferCtxtInner<'tcx> {
|
|||
UndoLog::ConstUnificationTable(undo) => self.const_unification_storage.reverse(undo),
|
||||
UndoLog::IntUnificationTable(undo) => self.int_unification_storage.reverse(undo),
|
||||
UndoLog::FloatUnificationTable(undo) => self.float_unification_storage.reverse(undo),
|
||||
UndoLog::EffectUnificationTable(undo) => self.effect_unification_storage.reverse(undo),
|
||||
UndoLog::RegionConstraintCollector(undo) => {
|
||||
self.region_constraint_storage.as_mut().unwrap().reverse(undo)
|
||||
}
|
||||
|
|
|
@ -21,7 +21,6 @@ use rustc_data_structures::sync::join;
|
|||
use rustc_hir as hir;
|
||||
use rustc_hir::def_id::{LocalDefId, LocalModDefId};
|
||||
use rustc_hir::intravisit as hir_visit;
|
||||
use rustc_hir::intravisit::Visitor;
|
||||
use rustc_middle::hir::nested_filter;
|
||||
use rustc_middle::ty::{self, TyCtxt};
|
||||
use rustc_session::lint::LintPass;
|
||||
|
@ -61,6 +60,9 @@ impl<'tcx, T: LateLintPass<'tcx>> LateContextAndPass<'tcx, T> {
|
|||
self.context.last_node_with_lint_attrs = id;
|
||||
debug!("late context: enter_attrs({:?})", attrs);
|
||||
lint_callback!(self, enter_lint_attrs, attrs);
|
||||
for attr in attrs {
|
||||
lint_callback!(self, check_attribute, attr);
|
||||
}
|
||||
f(self);
|
||||
debug!("late context: exit_attrs({:?})", attrs);
|
||||
lint_callback!(self, exit_lint_attrs, attrs);
|
||||
|
@ -377,20 +379,18 @@ fn late_lint_mod_inner<'tcx, T: LateLintPass<'tcx>>(
|
|||
|
||||
let (module, _span, hir_id) = tcx.hir().get_module(module_def_id);
|
||||
|
||||
// There is no module lint that will have the crate itself as an item, so check it here.
|
||||
if hir_id == hir::CRATE_HIR_ID {
|
||||
lint_callback!(cx, check_crate,);
|
||||
}
|
||||
|
||||
cx.process_mod(module, hir_id);
|
||||
|
||||
// Visit the crate attributes
|
||||
if hir_id == hir::CRATE_HIR_ID {
|
||||
for attr in tcx.hir().attrs(hir::CRATE_HIR_ID).iter() {
|
||||
cx.visit_attribute(attr)
|
||||
cx.with_lint_attrs(hir_id, |cx| {
|
||||
// There is no module lint that will have the crate itself as an item, so check it here.
|
||||
if hir_id == hir::CRATE_HIR_ID {
|
||||
lint_callback!(cx, check_crate,);
|
||||
}
|
||||
lint_callback!(cx, check_crate_post,);
|
||||
}
|
||||
|
||||
cx.process_mod(module, hir_id);
|
||||
|
||||
if hir_id == hir::CRATE_HIR_ID {
|
||||
lint_callback!(cx, check_crate_post,);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
fn late_lint_crate<'tcx>(tcx: TyCtxt<'tcx>) {
|
||||
|
@ -431,7 +431,6 @@ fn late_lint_crate_inner<'tcx, T: LateLintPass<'tcx>>(
|
|||
// item), warn for it here.
|
||||
lint_callback!(cx, check_crate,);
|
||||
tcx.hir().walk_toplevel_module(cx);
|
||||
tcx.hir().walk_attributes(cx);
|
||||
lint_callback!(cx, check_crate_post,);
|
||||
})
|
||||
}
|
||||
|
|
|
@ -184,6 +184,7 @@ impl<'tcx> CanonicalVarInfo<'tcx> {
|
|||
CanonicalVarKind::PlaceholderRegion(..) => false,
|
||||
CanonicalVarKind::Const(..) => true,
|
||||
CanonicalVarKind::PlaceholderConst(_, _) => false,
|
||||
CanonicalVarKind::Effect => true,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -193,7 +194,8 @@ impl<'tcx> CanonicalVarInfo<'tcx> {
|
|||
CanonicalVarKind::Ty(_)
|
||||
| CanonicalVarKind::PlaceholderTy(_)
|
||||
| CanonicalVarKind::Const(_, _)
|
||||
| CanonicalVarKind::PlaceholderConst(_, _) => false,
|
||||
| CanonicalVarKind::PlaceholderConst(_, _)
|
||||
| CanonicalVarKind::Effect => false,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -201,7 +203,8 @@ impl<'tcx> CanonicalVarInfo<'tcx> {
|
|||
match self.kind {
|
||||
CanonicalVarKind::Ty(_)
|
||||
| CanonicalVarKind::Region(_)
|
||||
| CanonicalVarKind::Const(_, _) => bug!("expected placeholder: {self:?}"),
|
||||
| CanonicalVarKind::Const(_, _)
|
||||
| CanonicalVarKind::Effect => bug!("expected placeholder: {self:?}"),
|
||||
|
||||
CanonicalVarKind::PlaceholderRegion(placeholder) => placeholder.bound.var.as_usize(),
|
||||
CanonicalVarKind::PlaceholderTy(placeholder) => placeholder.bound.var.as_usize(),
|
||||
|
@ -233,6 +236,9 @@ pub enum CanonicalVarKind<'tcx> {
|
|||
/// Some kind of const inference variable.
|
||||
Const(ty::UniverseIndex, Ty<'tcx>),
|
||||
|
||||
/// Effect variable `'?E`.
|
||||
Effect,
|
||||
|
||||
/// A "placeholder" that represents "any const".
|
||||
PlaceholderConst(ty::PlaceholderConst<'tcx>, Ty<'tcx>),
|
||||
}
|
||||
|
@ -240,11 +246,11 @@ pub enum CanonicalVarKind<'tcx> {
|
|||
impl<'tcx> CanonicalVarKind<'tcx> {
|
||||
pub fn universe(self) -> ty::UniverseIndex {
|
||||
match self {
|
||||
CanonicalVarKind::Ty(kind) => match kind {
|
||||
CanonicalTyVarKind::General(ui) => ui,
|
||||
CanonicalTyVarKind::Float | CanonicalTyVarKind::Int => ty::UniverseIndex::ROOT,
|
||||
},
|
||||
|
||||
CanonicalVarKind::Ty(CanonicalTyVarKind::General(ui)) => ui,
|
||||
CanonicalVarKind::Ty(CanonicalTyVarKind::Float | CanonicalTyVarKind::Int) => {
|
||||
ty::UniverseIndex::ROOT
|
||||
}
|
||||
CanonicalVarKind::Effect => ty::UniverseIndex::ROOT,
|
||||
CanonicalVarKind::PlaceholderTy(placeholder) => placeholder.universe,
|
||||
CanonicalVarKind::Region(ui) => ui,
|
||||
CanonicalVarKind::PlaceholderRegion(placeholder) => placeholder.universe,
|
||||
|
@ -259,15 +265,14 @@ impl<'tcx> CanonicalVarKind<'tcx> {
|
|||
/// the updated universe is not the root.
|
||||
pub fn with_updated_universe(self, ui: ty::UniverseIndex) -> CanonicalVarKind<'tcx> {
|
||||
match self {
|
||||
CanonicalVarKind::Ty(kind) => match kind {
|
||||
CanonicalTyVarKind::General(_) => {
|
||||
CanonicalVarKind::Ty(CanonicalTyVarKind::General(ui))
|
||||
}
|
||||
CanonicalTyVarKind::Int | CanonicalTyVarKind::Float => {
|
||||
assert_eq!(ui, ty::UniverseIndex::ROOT);
|
||||
CanonicalVarKind::Ty(kind)
|
||||
}
|
||||
},
|
||||
CanonicalVarKind::Ty(CanonicalTyVarKind::General(_)) => {
|
||||
CanonicalVarKind::Ty(CanonicalTyVarKind::General(ui))
|
||||
}
|
||||
CanonicalVarKind::Ty(CanonicalTyVarKind::Int | CanonicalTyVarKind::Float)
|
||||
| CanonicalVarKind::Effect => {
|
||||
assert_eq!(ui, ty::UniverseIndex::ROOT);
|
||||
self
|
||||
}
|
||||
CanonicalVarKind::PlaceholderTy(placeholder) => {
|
||||
CanonicalVarKind::PlaceholderTy(ty::Placeholder { universe: ui, ..placeholder })
|
||||
}
|
||||
|
@ -454,6 +459,13 @@ impl<'tcx> CanonicalVarValues<'tcx> {
|
|||
};
|
||||
ty::Region::new_late_bound(tcx, ty::INNERMOST, br).into()
|
||||
}
|
||||
CanonicalVarKind::Effect => ty::Const::new_bound(
|
||||
tcx,
|
||||
ty::INNERMOST,
|
||||
ty::BoundVar::from_usize(i),
|
||||
tcx.types.bool,
|
||||
)
|
||||
.into(),
|
||||
CanonicalVarKind::Const(_, ty)
|
||||
| CanonicalVarKind::PlaceholderConst(_, ty) => ty::Const::new_bound(
|
||||
tcx,
|
||||
|
|
|
@ -188,3 +188,53 @@ impl<'tcx> UnifyValue for ConstVarValue<'tcx> {
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
/// values for the effect inference variable
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub enum EffectVarValue<'tcx> {
|
||||
/// The host effect is on, enabling access to syscalls, filesystem access, etc.
|
||||
Host,
|
||||
/// The host effect is off. Execution is restricted to const operations only.
|
||||
NoHost,
|
||||
Const(ty::Const<'tcx>),
|
||||
}
|
||||
|
||||
impl<'tcx> EffectVarValue<'tcx> {
|
||||
pub fn as_const(self, tcx: TyCtxt<'tcx>) -> ty::Const<'tcx> {
|
||||
match self {
|
||||
EffectVarValue::Host => tcx.consts.true_,
|
||||
EffectVarValue::NoHost => tcx.consts.false_,
|
||||
EffectVarValue::Const(c) => c,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> UnifyValue for EffectVarValue<'tcx> {
|
||||
type Error = (EffectVarValue<'tcx>, EffectVarValue<'tcx>);
|
||||
fn unify_values(value1: &Self, value2: &Self) -> Result<Self, Self::Error> {
|
||||
match (value1, value2) {
|
||||
(EffectVarValue::Host, EffectVarValue::Host) => Ok(EffectVarValue::Host),
|
||||
(EffectVarValue::NoHost, EffectVarValue::NoHost) => Ok(EffectVarValue::NoHost),
|
||||
(EffectVarValue::NoHost | EffectVarValue::Host, _)
|
||||
| (_, EffectVarValue::NoHost | EffectVarValue::Host) => Err((*value1, *value2)),
|
||||
(EffectVarValue::Const(_), EffectVarValue::Const(_)) => {
|
||||
bug!("equating two const variables, both of which have known values")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> UnifyKey for ty::EffectVid<'tcx> {
|
||||
type Value = Option<EffectVarValue<'tcx>>;
|
||||
#[inline]
|
||||
fn index(&self) -> u32 {
|
||||
self.index
|
||||
}
|
||||
#[inline]
|
||||
fn from_index(i: u32) -> Self {
|
||||
ty::EffectVid { index: i, phantom: PhantomData }
|
||||
}
|
||||
fn tag() -> &'static str {
|
||||
"EffectVid"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,6 +55,11 @@ static_assert_size!(super::ConstKind<'_>, 32);
|
|||
pub enum InferConst<'tcx> {
|
||||
/// Infer the value of the const.
|
||||
Var(ty::ConstVid<'tcx>),
|
||||
/// Infer the value of the effect.
|
||||
///
|
||||
/// For why this is separate from the `Var` variant above, see the
|
||||
/// documentation on `EffectVid`.
|
||||
EffectVar(ty::EffectVid<'tcx>),
|
||||
/// A fresh const variable. See `infer::freshen` for more details.
|
||||
Fresh(u32),
|
||||
}
|
||||
|
@ -62,7 +67,9 @@ pub enum InferConst<'tcx> {
|
|||
impl<CTX> HashStable<CTX> for InferConst<'_> {
|
||||
fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) {
|
||||
match self {
|
||||
InferConst::Var(_) => panic!("const variables should not be hashed: {self:?}"),
|
||||
InferConst::Var(_) | InferConst::EffectVar(_) => {
|
||||
panic!("const variables should not be hashed: {self:?}")
|
||||
}
|
||||
InferConst::Fresh(i) => i.hash_stable(hcx, hasher),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -324,7 +324,9 @@ impl FlagComputation {
|
|||
self.add_flags(TypeFlags::STILL_FURTHER_SPECIALIZABLE);
|
||||
match infer {
|
||||
InferConst::Fresh(_) => self.add_flags(TypeFlags::HAS_CT_FRESH),
|
||||
InferConst::Var(_) => self.add_flags(TypeFlags::HAS_CT_INFER),
|
||||
InferConst::Var(_) | InferConst::EffectVar(_) => {
|
||||
self.add_flags(TypeFlags::HAS_CT_INFER)
|
||||
}
|
||||
}
|
||||
}
|
||||
ty::ConstKind::Bound(debruijn, _) => {
|
||||
|
|
|
@ -12,7 +12,7 @@ use super::{Clause, EarlyBoundRegion, InstantiatedPredicates, ParamConst, ParamT
|
|||
pub enum GenericParamDefKind {
|
||||
Lifetime,
|
||||
Type { has_default: bool, synthetic: bool },
|
||||
Const { has_default: bool },
|
||||
Const { has_default: bool, is_host_effect: bool },
|
||||
}
|
||||
|
||||
impl GenericParamDefKind {
|
||||
|
@ -87,7 +87,7 @@ impl GenericParamDef {
|
|||
GenericParamDefKind::Type { has_default, .. } if has_default => {
|
||||
Some(tcx.type_of(self.def_id).map_bound(|t| t.into()))
|
||||
}
|
||||
GenericParamDefKind::Const { has_default } if has_default => {
|
||||
GenericParamDefKind::Const { has_default, .. } if has_default => {
|
||||
Some(tcx.const_param_default(self.def_id).map_bound(|c| c.into()))
|
||||
}
|
||||
_ => None,
|
||||
|
@ -187,7 +187,7 @@ impl<'tcx> Generics {
|
|||
GenericParamDefKind::Type { has_default, .. } => {
|
||||
own_defaults.types += has_default as usize;
|
||||
}
|
||||
GenericParamDefKind::Const { has_default } => {
|
||||
GenericParamDefKind::Const { has_default, .. } => {
|
||||
own_defaults.consts += has_default as usize;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -98,9 +98,9 @@ pub use self::sty::BoundRegionKind::*;
|
|||
pub use self::sty::{
|
||||
AliasTy, Article, Binder, BoundRegion, BoundRegionKind, BoundTy, BoundTyKind, BoundVar,
|
||||
BoundVariableKind, CanonicalPolyFnSig, ClosureArgs, ClosureArgsParts, ConstKind, ConstVid,
|
||||
EarlyBoundRegion, ExistentialPredicate, ExistentialProjection, ExistentialTraitRef, FnSig,
|
||||
FreeRegion, GenSig, GeneratorArgs, GeneratorArgsParts, InlineConstArgs, InlineConstArgsParts,
|
||||
ParamConst, ParamTy, PolyExistentialPredicate, PolyExistentialProjection,
|
||||
EarlyBoundRegion, EffectVid, ExistentialPredicate, ExistentialProjection, ExistentialTraitRef,
|
||||
FnSig, FreeRegion, GenSig, GeneratorArgs, GeneratorArgsParts, InlineConstArgs,
|
||||
InlineConstArgsParts, ParamConst, ParamTy, PolyExistentialPredicate, PolyExistentialProjection,
|
||||
PolyExistentialTraitRef, PolyFnSig, PolyGenSig, PolyTraitRef, Region, RegionKind, RegionVid,
|
||||
TraitRef, TyKind, TypeAndMut, UpvarArgs, VarianceDiagInfo,
|
||||
};
|
||||
|
|
|
@ -138,6 +138,12 @@ impl<'tcx> fmt::Debug for ty::ConstVid<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
impl fmt::Debug for ty::EffectVid<'_> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "?{}e", self.index)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> fmt::Debug for ty::TraitRef<'tcx> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
with_no_trimmed_paths!(fmt::Display::fmt(self, f))
|
||||
|
@ -253,6 +259,7 @@ impl<'tcx> fmt::Debug for ty::InferConst<'tcx> {
|
|||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
InferConst::Var(var) => write!(f, "{var:?}"),
|
||||
InferConst::EffectVar(var) => write!(f, "{var:?}"),
|
||||
InferConst::Fresh(var) => write!(f, "Fresh({var:?})"),
|
||||
}
|
||||
}
|
||||
|
@ -267,6 +274,7 @@ impl<'tcx> DebugWithInfcx<TyCtxt<'tcx>> for ty::InferConst<'tcx> {
|
|||
None => write!(f, "{:?}", this.data),
|
||||
Some(universe) => match *this.data {
|
||||
Var(vid) => write!(f, "?{}_{}c", vid.index, universe.index()),
|
||||
EffectVar(vid) => write!(f, "?{}_{}e", vid.index, universe.index()),
|
||||
Fresh(_) => {
|
||||
unreachable!()
|
||||
}
|
||||
|
|
|
@ -1577,6 +1577,20 @@ pub struct ConstVid<'tcx> {
|
|||
pub phantom: PhantomData<&'tcx ()>,
|
||||
}
|
||||
|
||||
/// An **effect** **v**ariable **ID**.
|
||||
///
|
||||
/// Handling effect infer variables happens separately from const infer variables
|
||||
/// because we do not want to reuse any of the const infer machinery. If we try to
|
||||
/// relate an effect variable with a normal one, we would ICE, which can catch bugs
|
||||
/// where we are not correctly using the effect var for an effect param. Fallback
|
||||
/// is also implemented on top of having separate effect and normal const variables.
|
||||
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
#[derive(TyEncodable, TyDecodable)]
|
||||
pub struct EffectVid<'tcx> {
|
||||
pub index: u32,
|
||||
pub phantom: PhantomData<&'tcx ()>,
|
||||
}
|
||||
|
||||
rustc_index::newtype_index! {
|
||||
/// A **region** (lifetime) **v**ariable **ID**.
|
||||
#[derive(HashStable)]
|
||||
|
|
|
@ -90,6 +90,10 @@ pub struct TraitImpls {
|
|||
}
|
||||
|
||||
impl TraitImpls {
|
||||
pub fn is_empty(&self) -> bool {
|
||||
self.blanket_impls.is_empty() && self.non_blanket_impls.is_empty()
|
||||
}
|
||||
|
||||
pub fn blanket_impls(&self) -> &[DefId] {
|
||||
self.blanket_impls.as_slice()
|
||||
}
|
||||
|
|
|
@ -836,7 +836,7 @@ impl ReachEverythingInTheInterfaceVisitor<'_, '_> {
|
|||
self.visit(self.ev.tcx.type_of(param.def_id).instantiate_identity());
|
||||
}
|
||||
}
|
||||
GenericParamDefKind::Const { has_default } => {
|
||||
GenericParamDefKind::Const { has_default, .. } => {
|
||||
self.visit(self.ev.tcx.type_of(param.def_id).instantiate_identity());
|
||||
if has_default {
|
||||
self.visit(
|
||||
|
|
|
@ -68,9 +68,6 @@ resolve_cannot_find_ident_in_this_scope =
|
|||
resolve_cannot_glob_import_possible_crates =
|
||||
cannot glob-import all possible crates
|
||||
|
||||
resolve_cannot_use_self_type_here =
|
||||
can't use `Self` here
|
||||
|
||||
resolve_change_import_binding =
|
||||
you can use `as` to change the binding name of the import
|
||||
|
||||
|
@ -90,9 +87,6 @@ resolve_const_not_member_of_trait =
|
|||
const `{$const_}` is not a member of trait `{$trait_}`
|
||||
.label = not a member of trait `{$trait_}`
|
||||
|
||||
resolve_const_param_from_outer_fn =
|
||||
const parameter from outer function
|
||||
|
||||
resolve_const_param_in_enum_discriminant =
|
||||
const parameters may not be used in enum discriminant values
|
||||
|
||||
|
@ -119,10 +113,19 @@ resolve_forward_declared_generic_param =
|
|||
generic parameters with a default cannot use forward declared identifiers
|
||||
.label = defaulted generic parameters cannot be forward declared
|
||||
|
||||
resolve_generic_params_from_outer_function =
|
||||
can't use generic parameters from outer function
|
||||
.label = use of generic parameter from outer function
|
||||
.suggestion = try using a local generic parameter instead
|
||||
resolve_generic_params_from_outer_item =
|
||||
can't use generic parameters from outer item
|
||||
.label = use of generic parameter from outer item
|
||||
.refer_to_type_directly = refer to the type directly here instead
|
||||
.suggestion = try introducing a local generic parameter here
|
||||
|
||||
resolve_generic_params_from_outer_item_const_param = const parameter from outer item
|
||||
|
||||
resolve_generic_params_from_outer_item_self_ty_alias = `Self` type implicitly declared here, by this `impl`
|
||||
|
||||
resolve_generic_params_from_outer_item_self_ty_param = can't use `Self` here
|
||||
|
||||
resolve_generic_params_from_outer_item_ty_param = type parameter from outer item
|
||||
|
||||
resolve_glob_import_doesnt_reexport =
|
||||
glob import doesn't reexport anything because no candidate is public enough
|
||||
|
@ -277,9 +280,6 @@ resolve_type_not_member_of_trait =
|
|||
type `{$type_}` is not a member of trait `{$trait_}`
|
||||
.label = not a member of trait `{$trait_}`
|
||||
|
||||
resolve_type_param_from_outer_fn =
|
||||
type parameter from outer function
|
||||
|
||||
resolve_type_param_in_enum_discriminant =
|
||||
type parameters may not be used in enum discriminant values
|
||||
|
||||
|
@ -315,9 +315,6 @@ resolve_unreachable_label_suggestion_use_similarly_named =
|
|||
resolve_unreachable_label_with_similar_name_exists =
|
||||
a label with a similar name exists but is unreachable
|
||||
|
||||
resolve_use_a_type_here_instead =
|
||||
use a type here instead
|
||||
|
||||
resolve_variable_bound_with_different_mode =
|
||||
variable `{$variable_name}` is bound inconsistently across alternatives separated by `|`
|
||||
.label = bound in different ways
|
||||
|
|
|
@ -553,43 +553,40 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
resolution_error: ResolutionError<'a>,
|
||||
) -> DiagnosticBuilder<'_, ErrorGuaranteed> {
|
||||
match resolution_error {
|
||||
ResolutionError::GenericParamsFromOuterFunction(outer_res, has_generic_params) => {
|
||||
let mut err = struct_span_err!(
|
||||
self.tcx.sess,
|
||||
ResolutionError::GenericParamsFromOuterItem(outer_res, has_generic_params) => {
|
||||
use errs::GenericParamsFromOuterItemLabel as Label;
|
||||
let mut err = errs::GenericParamsFromOuterItem {
|
||||
span,
|
||||
E0401,
|
||||
"can't use generic parameters from outer function",
|
||||
);
|
||||
err.span_label(span, "use of generic parameter from outer function");
|
||||
label: None,
|
||||
refer_to_type_directly: None,
|
||||
sugg: None,
|
||||
};
|
||||
|
||||
let sm = self.tcx.sess.source_map();
|
||||
let def_id = match outer_res {
|
||||
Res::SelfTyParam { .. } => {
|
||||
err.span_label(span, "can't use `Self` here");
|
||||
return err;
|
||||
err.label = Some(Label::SelfTyParam(span));
|
||||
return self.tcx.sess.create_err(err);
|
||||
}
|
||||
Res::SelfTyAlias { alias_to: def_id, .. } => {
|
||||
err.span_label(
|
||||
reduce_impl_span_to_impl_keyword(sm, self.def_span(def_id)),
|
||||
"`Self` type implicitly declared here, by this `impl`",
|
||||
);
|
||||
err.span_label(span, "use a type here instead");
|
||||
return err;
|
||||
err.label = Some(Label::SelfTyAlias(reduce_impl_span_to_impl_keyword(
|
||||
sm,
|
||||
self.def_span(def_id),
|
||||
)));
|
||||
err.refer_to_type_directly = Some(span);
|
||||
return self.tcx.sess.create_err(err);
|
||||
}
|
||||
Res::Def(DefKind::TyParam, def_id) => {
|
||||
err.span_label(self.def_span(def_id), "type parameter from outer function");
|
||||
err.label = Some(Label::TyParam(self.def_span(def_id)));
|
||||
def_id
|
||||
}
|
||||
Res::Def(DefKind::ConstParam, def_id) => {
|
||||
err.span_label(
|
||||
self.def_span(def_id),
|
||||
"const parameter from outer function",
|
||||
);
|
||||
err.label = Some(Label::ConstParam(self.def_span(def_id)));
|
||||
def_id
|
||||
}
|
||||
_ => {
|
||||
bug!(
|
||||
"GenericParamsFromOuterFunction should only be used with \
|
||||
"GenericParamsFromOuterItem should only be used with \
|
||||
Res::SelfTyParam, Res::SelfTyAlias, DefKind::TyParam or \
|
||||
DefKind::ConstParam"
|
||||
);
|
||||
|
@ -597,9 +594,6 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
};
|
||||
|
||||
if let HasGenericParams::Yes(span) = has_generic_params {
|
||||
// Try to retrieve the span of the function signature and generate a new
|
||||
// message with a local type or const parameter.
|
||||
let sugg_msg = "try using a local generic parameter instead";
|
||||
let name = self.tcx.item_name(def_id);
|
||||
let (span, snippet) = if span.is_empty() {
|
||||
let snippet = format!("<{name}>");
|
||||
|
@ -609,11 +603,10 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
let snippet = format!("{name}, ");
|
||||
(span, snippet)
|
||||
};
|
||||
// Suggest the modification to the user
|
||||
err.span_suggestion(span, sugg_msg, snippet, Applicability::MaybeIncorrect);
|
||||
err.sugg = Some(errs::GenericParamsFromOuterItemSugg { span, snippet });
|
||||
}
|
||||
|
||||
err
|
||||
self.tcx.sess.create_err(err)
|
||||
}
|
||||
ResolutionError::NameAlreadyUsedInParameterList(name, first_use_span) => self
|
||||
.tcx
|
||||
|
|
|
@ -32,6 +32,40 @@ pub(crate) struct CrateRootNamesMustBeNamedExplicitly(#[primary_span] pub(crate)
|
|||
#[diag(resolve_crate_root_imports_must_be_named_explicitly)]
|
||||
pub(crate) struct ResolutionError(#[primary_span] pub(crate) Span);
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(resolve_generic_params_from_outer_item, code = "E0401")]
|
||||
pub(crate) struct GenericParamsFromOuterItem {
|
||||
#[primary_span]
|
||||
#[label]
|
||||
pub(crate) span: Span,
|
||||
#[subdiagnostic]
|
||||
pub(crate) label: Option<GenericParamsFromOuterItemLabel>,
|
||||
#[label(resolve_refer_to_type_directly)]
|
||||
pub(crate) refer_to_type_directly: Option<Span>,
|
||||
#[subdiagnostic]
|
||||
pub(crate) sugg: Option<GenericParamsFromOuterItemSugg>,
|
||||
}
|
||||
|
||||
#[derive(Subdiagnostic)]
|
||||
pub(crate) enum GenericParamsFromOuterItemLabel {
|
||||
#[label(resolve_generic_params_from_outer_item_self_ty_param)]
|
||||
SelfTyParam(#[primary_span] Span),
|
||||
#[label(resolve_generic_params_from_outer_item_self_ty_alias)]
|
||||
SelfTyAlias(#[primary_span] Span),
|
||||
#[label(resolve_generic_params_from_outer_item_ty_param)]
|
||||
TyParam(#[primary_span] Span),
|
||||
#[label(resolve_generic_params_from_outer_item_const_param)]
|
||||
ConstParam(#[primary_span] Span),
|
||||
}
|
||||
|
||||
#[derive(Subdiagnostic)]
|
||||
#[suggestion(resolve_suggestion, code = "{snippet}", applicability = "maybe-incorrect")]
|
||||
pub(crate) struct GenericParamsFromOuterItemSugg {
|
||||
#[primary_span]
|
||||
pub(crate) span: Span,
|
||||
pub(crate) snippet: String,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(resolve_name_is_already_used_as_generic_parameter, code = "E0403")]
|
||||
pub(crate) struct NameAlreadyUsedInParameterList {
|
||||
|
|
|
@ -1229,10 +1229,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
if let Some(span) = finalize {
|
||||
self.report_error(
|
||||
span,
|
||||
ResolutionError::GenericParamsFromOuterFunction(
|
||||
res,
|
||||
has_generic_params,
|
||||
),
|
||||
ResolutionError::GenericParamsFromOuterItem(res, has_generic_params),
|
||||
);
|
||||
}
|
||||
return Res::Err;
|
||||
|
@ -1296,10 +1293,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
if let Some(span) = finalize {
|
||||
self.report_error(
|
||||
span,
|
||||
ResolutionError::GenericParamsFromOuterFunction(
|
||||
res,
|
||||
has_generic_params,
|
||||
),
|
||||
ResolutionError::GenericParamsFromOuterItem(res, has_generic_params),
|
||||
);
|
||||
}
|
||||
return Res::Err;
|
||||
|
|
|
@ -2450,7 +2450,11 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
|
|||
ItemKind::Const(box ast::ConstItem { ref generics, ref ty, ref expr, .. }) => {
|
||||
self.with_generic_param_rib(
|
||||
&generics.params,
|
||||
RibKind::Item(HasGenericParams::Yes(generics.span)),
|
||||
RibKind::Item(if self.r.tcx.features().generic_const_items {
|
||||
HasGenericParams::Yes(generics.span)
|
||||
} else {
|
||||
HasGenericParams::No
|
||||
}),
|
||||
LifetimeRibKind::Generics {
|
||||
binder: item.id,
|
||||
kind: LifetimeBinderKind::ConstItem,
|
||||
|
|
|
@ -186,8 +186,8 @@ struct BindingError {
|
|||
|
||||
#[derive(Debug)]
|
||||
enum ResolutionError<'a> {
|
||||
/// Error E0401: can't use type or const parameters from outer function.
|
||||
GenericParamsFromOuterFunction(Res, HasGenericParams),
|
||||
/// Error E0401: can't use type or const parameters from outer item.
|
||||
GenericParamsFromOuterItem(Res, HasGenericParams),
|
||||
/// Error E0403: the name is already used for a type or const parameter in this generic
|
||||
/// parameter list.
|
||||
NameAlreadyUsedInParameterList(Symbol, Span),
|
||||
|
|
|
@ -1297,7 +1297,7 @@ impl<'tcx> Stable<'tcx> for rustc_middle::ty::GenericParamDefKind {
|
|||
ty::GenericParamDefKind::Type { has_default, synthetic } => {
|
||||
GenericParamDefKind::Type { has_default: *has_default, synthetic: *synthetic }
|
||||
}
|
||||
ty::GenericParamDefKind::Const { has_default } => {
|
||||
ty::GenericParamDefKind::Const { has_default, is_host_effect: _ } => {
|
||||
GenericParamDefKind::Const { has_default: *has_default }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,5 +40,7 @@ trait_selection_no_value_in_rustc_on_unimplemented = this attribute must have a
|
|||
.label = expected value here
|
||||
.note = eg `#[rustc_on_unimplemented(message="foo")]`
|
||||
|
||||
trait_selection_trait_has_no_impls = this trait has no implementations, consider adding one
|
||||
|
||||
trait_selection_ty_alias_overflow = in case this is a recursive type alias, consider using a struct, enum, or union instead
|
||||
trait_selection_unable_to_construct_constant_value = unable to construct a constant value for the unevaluated constant {$unevaluated}
|
||||
|
|
|
@ -365,6 +365,9 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for Canonicalizer<'_, 'tcx> {
|
|||
// FIXME: we should fold this ty eventually
|
||||
CanonicalVarKind::Const(ui, c.ty())
|
||||
}
|
||||
ty::ConstKind::Infer(ty::InferConst::EffectVar(_)) => {
|
||||
bug!("effect var has no universe")
|
||||
}
|
||||
ty::ConstKind::Infer(ty::InferConst::Fresh(_)) => {
|
||||
bug!("fresh var during canonicalization: {c:?}")
|
||||
}
|
||||
|
|
|
@ -3009,10 +3009,10 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
// Try to report a help message
|
||||
if is_fn_trait
|
||||
&& let Ok((implemented_kind, params)) = self.type_implements_fn_trait(
|
||||
obligation.param_env,
|
||||
trait_ref.self_ty(),
|
||||
trait_predicate.skip_binder().polarity,
|
||||
)
|
||||
obligation.param_env,
|
||||
trait_ref.self_ty(),
|
||||
trait_predicate.skip_binder().polarity,
|
||||
)
|
||||
{
|
||||
self.add_help_message_for_fn_trait(trait_ref, err, implemented_kind, params);
|
||||
} else if !trait_ref.has_non_region_infer()
|
||||
|
@ -3031,6 +3031,15 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
None,
|
||||
obligation.cause.body_id,
|
||||
);
|
||||
} else if trait_ref.def_id().is_local()
|
||||
&& self.tcx.trait_impls_of(trait_ref.def_id()).is_empty()
|
||||
&& !self.tcx.trait_is_auto(trait_ref.def_id())
|
||||
&& !self.tcx.trait_is_alias(trait_ref.def_id())
|
||||
{
|
||||
err.span_help(
|
||||
self.tcx.def_span(trait_ref.def_id()),
|
||||
crate::fluent_generated::trait_selection_trait_has_no_impls,
|
||||
);
|
||||
} else if !suggested && !unsatisfied_const {
|
||||
// Can't show anything else useful, try to find similar impls.
|
||||
let impl_candidates = self.find_similar_impl_candidates(*trait_predicate);
|
||||
|
@ -3041,7 +3050,12 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
err,
|
||||
true,
|
||||
) {
|
||||
self.report_similar_impl_candidates_for_root_obligation(&obligation, *trait_predicate, body_def_id, err);
|
||||
self.report_similar_impl_candidates_for_root_obligation(
|
||||
&obligation,
|
||||
*trait_predicate,
|
||||
body_def_id,
|
||||
err,
|
||||
);
|
||||
}
|
||||
|
||||
self.suggest_convert_to_slice(
|
||||
|
|
|
@ -127,8 +127,6 @@ pub fn format(build: &Builder<'_>, check: bool, paths: &[PathBuf]) {
|
|||
Err(_) => false,
|
||||
};
|
||||
|
||||
let mut paths = paths.to_vec();
|
||||
|
||||
if git_available {
|
||||
let in_working_tree = match build
|
||||
.config
|
||||
|
@ -201,8 +199,6 @@ pub fn format(build: &Builder<'_>, check: bool, paths: &[PathBuf]) {
|
|||
"WARN: Something went wrong when running git commands:\n{err}\n\
|
||||
Falling back to formatting all files."
|
||||
);
|
||||
// Something went wrong when getting the version. Just format all the files.
|
||||
paths.push(".".into());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -542,7 +542,7 @@ fn clean_generic_param_def<'tcx>(
|
|||
},
|
||||
)
|
||||
}
|
||||
ty::GenericParamDefKind::Const { has_default } => (
|
||||
ty::GenericParamDefKind::Const { has_default, .. } => (
|
||||
def.name,
|
||||
GenericParamDefKind::Const {
|
||||
ty: Box::new(clean_middle_ty(
|
||||
|
|
|
@ -1609,6 +1609,7 @@ fn init_id_map() -> FxHashMap<Cow<'static, str>, usize> {
|
|||
map.insert("blanket-implementations-list".into(), 1);
|
||||
map.insert("deref-methods".into(), 1);
|
||||
map.insert("layout".into(), 1);
|
||||
map.insert("aliased-type".into(), 1);
|
||||
map
|
||||
}
|
||||
|
||||
|
|
|
@ -237,6 +237,7 @@ fn sidebar_type_alias<'a>(
|
|||
) -> Vec<LinkBlock<'a>> {
|
||||
let mut items = vec![];
|
||||
if let Some(inner_type) = &t.inner_type {
|
||||
items.push(LinkBlock::forced(Link::new("aliased-type", "Aliased type")));
|
||||
match inner_type {
|
||||
clean::TypeAliasInnerType::Enum { variants, is_non_exhaustive: _ } => {
|
||||
let mut variants = variants
|
||||
|
|
|
@ -22,6 +22,13 @@ struct T4;
|
|||
#[cfg_attr(panic = "unwind", expect(dead_code))]
|
||||
struct CfgT;
|
||||
|
||||
#[allow(clippy::allow_attributes, unused)]
|
||||
struct Allowed;
|
||||
|
||||
#[expect(clippy::allow_attributes)]
|
||||
#[allow(unused)]
|
||||
struct Expected;
|
||||
|
||||
fn ignore_external() {
|
||||
external! {
|
||||
#[allow(clippy::needless_borrow)] // Should not lint
|
||||
|
|
|
@ -22,6 +22,13 @@ struct T4;
|
|||
#[cfg_attr(panic = "unwind", allow(dead_code))]
|
||||
struct CfgT;
|
||||
|
||||
#[allow(clippy::allow_attributes, unused)]
|
||||
struct Allowed;
|
||||
|
||||
#[expect(clippy::allow_attributes)]
|
||||
#[allow(unused)]
|
||||
struct Expected;
|
||||
|
||||
fn ignore_external() {
|
||||
external! {
|
||||
#[allow(clippy::needless_borrow)] // Should not lint
|
||||
|
|
|
@ -1,10 +1,3 @@
|
|||
error: `clippy::restriction` is not meant to be enabled as a group
|
||||
|
|
||||
= note: because of the command line `--warn clippy::restriction`
|
||||
= help: enable the restriction lints you need individually
|
||||
= note: `-D clippy::blanket-clippy-restriction-lints` implied by `-D warnings`
|
||||
= help: to override `-D warnings` add `#[allow(clippy::blanket_clippy_restriction_lints)]`
|
||||
|
||||
error: `clippy::restriction` is not meant to be enabled as a group
|
||||
--> $DIR/blanket_clippy_restriction_lints.rs:6:9
|
||||
|
|
||||
|
@ -12,6 +5,8 @@ LL | #![warn(clippy::restriction)]
|
|||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: enable the restriction lints you need individually
|
||||
= note: `-D clippy::blanket-clippy-restriction-lints` implied by `-D warnings`
|
||||
= help: to override `-D warnings` add `#[allow(clippy::blanket_clippy_restriction_lints)]`
|
||||
|
||||
error: `clippy::restriction` is not meant to be enabled as a group
|
||||
--> $DIR/blanket_clippy_restriction_lints.rs:8:9
|
||||
|
@ -29,5 +24,10 @@ LL | #![forbid(clippy::restriction)]
|
|||
|
|
||||
= help: enable the restriction lints you need individually
|
||||
|
||||
error: `clippy::restriction` is not meant to be enabled as a group
|
||||
|
|
||||
= note: because of the command line `--warn clippy::restriction`
|
||||
= help: enable the restriction lints you need individually
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
|
|
|
@ -19,6 +19,8 @@ impl<T> Foo for GenericStruct<T> {}
|
|||
impl Bar for GenericStruct<u32> {}
|
||||
|
||||
// @has 'foo/type.TypedefStruct.html'
|
||||
// We check that "Aliased type" is also present as a title in the sidebar.
|
||||
// @has - '//*[@class="sidebar-elems"]//h3/a[@href="#aliased-type"]' 'Aliased type'
|
||||
// We check that we have the implementation of the type alias itself.
|
||||
// @has - '//*[@id="impl-TypedefStruct"]/h3' 'impl TypedefStruct'
|
||||
// @has - '//*[@id="method.on_alias"]/h4' 'pub fn on_alias()'
|
||||
|
|
|
@ -3,6 +3,12 @@ error[E0277]: the trait bound `i32: Foo` is not satisfied
|
|||
|
|
||||
LL | const X: [i32; <i32 as Foo>::ID] = [0, 1, 2];
|
||||
| ^^^ the trait `Foo` is not implemented for `i32`
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/associated-const-array-len.rs:1:1
|
||||
|
|
||||
LL | trait Foo {
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -51,6 +51,11 @@ error[E0277]: the trait bound `Demo: TraitWAssocConst` is not satisfied
|
|||
LL | foo::<Demo>()();
|
||||
| ^^^^ the trait `TraitWAssocConst` is not implemented for `Demo`
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/issue-105330.rs:1:1
|
||||
|
|
||||
LL | pub trait TraitWAssocConst {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
note: required by a bound in `foo`
|
||||
--> $DIR/issue-105330.rs:11:11
|
||||
|
|
||||
|
@ -87,6 +92,11 @@ error[E0277]: the trait bound `Demo: TraitWAssocConst` is not satisfied
|
|||
LL | foo::<Demo>();
|
||||
| ^^^^ the trait `TraitWAssocConst` is not implemented for `Demo`
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/issue-105330.rs:1:1
|
||||
|
|
||||
LL | pub trait TraitWAssocConst {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
note: required by a bound in `foo`
|
||||
--> $DIR/issue-105330.rs:11:11
|
||||
|
|
||||
|
|
|
@ -3,6 +3,12 @@ error[E0277]: the trait bound `(): Add<A>` is not satisfied
|
|||
|
|
||||
LL | r = r + a;
|
||||
| ^ the trait `Add<A>` is not implemented for `()`
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/associated-types-ICE-when-projecting-out-of-err.rs:15:1
|
||||
|
|
||||
LL | trait Add<RHS=Self> {
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -3,6 +3,12 @@ error[E0277]: the trait bound `(T, U): Get` is not satisfied
|
|||
|
|
||||
LL | fn uhoh<U:Get>(&self, foo: U, bar: <(T, U) as Get>::Value) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ the trait `Get` is not implemented for `(T, U)`
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/associated-types-no-suitable-supertrait.rs:12:1
|
||||
|
|
||||
LL | trait Get {
|
||||
| ^^^^^^^^^
|
||||
|
||||
error[E0277]: the trait bound `Self: Get` is not satisfied
|
||||
--> $DIR/associated-types-no-suitable-supertrait.rs:17:40
|
||||
|
|
|
@ -58,6 +58,11 @@ error[E0277]: the trait bound `(): Foo<Self>` is not satisfied
|
|||
LL | type Assoc: Foo<Self> = ();
|
||||
| ^^ the trait `Foo<Self>` is not implemented for `()`
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/defaults-suitability.rs:27:1
|
||||
|
|
||||
LL | trait Foo<T> {
|
||||
| ^^^^^^^^^^^^
|
||||
note: required by a bound in `Bar::Assoc`
|
||||
--> $DIR/defaults-suitability.rs:34:17
|
||||
|
|
||||
|
|
|
@ -48,6 +48,12 @@ error[E0277]: the trait bound `(): Foo` is not satisfied
|
|||
|
|
||||
LL | fn with_factory<H>(factory: dyn ThriftService<()>) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `()`
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/issue-59324.rs:3:1
|
||||
|
|
||||
LL | pub trait Foo: NotFoo {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0277]: the trait bound `Bug: Foo` is not satisfied
|
||||
--> $DIR/issue-59324.rs:19:10
|
||||
|
|
|
@ -3,6 +3,12 @@ error[E0277]: the trait bound `Bar<T>: Foo` is not satisfied
|
|||
|
|
||||
LL | pub struct Bar<T>(<Self as Foo>::Type) where Self: ;
|
||||
| ^^^^^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `Bar<T>`
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/issue-64855.rs:1:1
|
||||
|
|
||||
LL | pub trait Foo {
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -4,6 +4,11 @@ error[E0277]: the trait bound `bool: Bar` is not satisfied
|
|||
LL | type Assoc = bool;
|
||||
| ^^^^ the trait `Bar` is not implemented for `bool`
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/point-at-type-on-obligation-failure-2.rs:1:1
|
||||
|
|
||||
LL | trait Bar {}
|
||||
| ^^^^^^^^^
|
||||
note: required by a bound in `Foo::Assoc`
|
||||
--> $DIR/point-at-type-on-obligation-failure-2.rs:4:17
|
||||
|
|
||||
|
@ -16,6 +21,11 @@ error[E0277]: the trait bound `bool: Bar` is not satisfied
|
|||
LL | type Assoc = bool;
|
||||
| ^^^^ the trait `Bar` is not implemented for `bool`
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/point-at-type-on-obligation-failure-2.rs:1:1
|
||||
|
|
||||
LL | trait Bar {}
|
||||
| ^^^^^^^^^
|
||||
note: required by a bound in `Baz::Assoc`
|
||||
--> $DIR/point-at-type-on-obligation-failure-2.rs:13:18
|
||||
|
|
||||
|
@ -31,6 +41,11 @@ error[E0277]: the trait bound `bool: Bar` is not satisfied
|
|||
LL | type Assoc = bool;
|
||||
| ^^^^ the trait `Bar` is not implemented for `bool`
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/point-at-type-on-obligation-failure-2.rs:1:1
|
||||
|
|
||||
LL | trait Bar {}
|
||||
| ^^^^^^^^^
|
||||
note: required by a bound in `Bat::Assoc`
|
||||
--> $DIR/point-at-type-on-obligation-failure-2.rs:24:27
|
||||
|
|
||||
|
|
|
@ -6,6 +6,11 @@ LL | takes_t(t);
|
|||
| |
|
||||
| required by a bound introduced by this call
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/coherence-unsafe-trait-object-impl.rs:6:1
|
||||
|
|
||||
LL | trait Trait: Sized {
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
note: required by a bound in `takes_t`
|
||||
--> $DIR/coherence-unsafe-trait-object-impl.rs:10:15
|
||||
|
|
||||
|
|
|
@ -3,6 +3,12 @@ error[E0277]: the trait bound `[Adt; std::mem::size_of::<Self::Assoc>()]: Foo` i
|
|||
|
|
||||
LL | <[Adt; std::mem::size_of::<Self::Assoc>()] as Foo>::bar()
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `[Adt; std::mem::size_of::<Self::Assoc>()]`
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/dont-evaluate-array-len-on-err-1.rs:9:1
|
||||
|
|
||||
LL | trait Foo {
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
fn foo<const X: u32>() {
|
||||
fn bar() -> u32 {
|
||||
X //~ ERROR can't use generic parameters from outer function
|
||||
X //~ ERROR can't use generic parameters from outer item
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
error[E0401]: can't use generic parameters from outer function
|
||||
error[E0401]: can't use generic parameters from outer item
|
||||
--> $DIR/const-param-from-outer-fn.rs:3:9
|
||||
|
|
||||
LL | fn foo<const X: u32>() {
|
||||
| - const parameter from outer function
|
||||
| - const parameter from outer item
|
||||
LL | fn bar() -> u32 {
|
||||
| - help: try using a local generic parameter instead: `<X>`
|
||||
| - help: try introducing a local generic parameter here: `<X>`
|
||||
LL | X
|
||||
| ^ use of generic parameter from outer function
|
||||
| ^ use of generic parameter from outer item
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -6,7 +6,11 @@ LL | writes_to_specific_path(&cap);
|
|||
| |
|
||||
| required by a bound introduced by this call
|
||||
|
|
||||
= help: the trait `Delegates<U>` is implemented for `T`
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/issue-85848.rs:4:1
|
||||
|
|
||||
LL | trait _Contains<T> {
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
note: required for `&C` to implement `Contains<(), true>`
|
||||
--> $DIR/issue-85848.rs:21:12
|
||||
|
|
||||
|
|
|
@ -6,6 +6,11 @@ LL | z(" ");
|
|||
| |
|
||||
| required by a bound introduced by this call
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/issue-86530.rs:4:1
|
||||
|
|
||||
LL | pub trait X {
|
||||
| ^^^^^^^^^^^
|
||||
note: required by a bound in `z`
|
||||
--> $DIR/issue-86530.rs:10:8
|
||||
|
|
||||
|
|
|
@ -4,6 +4,11 @@ error[E0277]: the trait bound `i32: Bar<u32>` is not satisfied
|
|||
LL | where i32: Foo<u32, A>
|
||||
| ^^^^^^^^^^^^^^^^ the trait `Bar<u32>` is not implemented for `i32`
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/cross-fn-cache-hole.rs:11:1
|
||||
|
|
||||
LL | trait Bar<X> { }
|
||||
| ^^^^^^^^^^^^
|
||||
= help: see issue #48214
|
||||
= help: add `#![feature(trivial_bounds)]` to the crate attributes to enable
|
||||
|
||||
|
|
|
@ -15,6 +15,11 @@ error[E0277]: the trait bound `Foo: Bar` is not satisfied
|
|||
LL | let f3: &Fat<dyn Bar> = f2;
|
||||
| ^^ the trait `Bar` is not implemented for `Foo`
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/dst-bad-coerce1.rs:10:1
|
||||
|
|
||||
LL | trait Bar { fn bar(&self) {} }
|
||||
| ^^^^^^^^^
|
||||
= note: required for the cast from `&Fat<Foo>` to `&Fat<dyn Bar>`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
|
@ -34,6 +39,11 @@ error[E0277]: the trait bound `Foo: Bar` is not satisfied
|
|||
LL | let f3: &(dyn Bar,) = f2;
|
||||
| ^^ the trait `Bar` is not implemented for `Foo`
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/dst-bad-coerce1.rs:10:1
|
||||
|
|
||||
LL | trait Bar { fn bar(&self) {} }
|
||||
| ^^^^^^^^^
|
||||
= note: required for the cast from `&(Foo,)` to `&(dyn Bar,)`
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
|
|
@ -3,6 +3,12 @@ error[E0277]: the trait bound `{integer}: Foo` is not satisfied
|
|||
|
|
||||
LL | let dyn_i: dyn* Foo = i;
|
||||
| ^ the trait `Foo` is not implemented for `{integer}`
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/error.rs:6:1
|
||||
|
|
||||
LL | trait Foo {}
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -21,6 +21,11 @@ LL | some_func(5i32);
|
|||
| |
|
||||
| required by a bound introduced by this call
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/E0277.rs:3:1
|
||||
|
|
||||
LL | trait Foo {
|
||||
| ^^^^^^^^^
|
||||
note: required by a bound in `some_func`
|
||||
--> $DIR/E0277.rs:7:17
|
||||
|
|
||||
|
|
|
@ -1,26 +1,26 @@
|
|||
error[E0401]: can't use generic parameters from outer function
|
||||
error[E0401]: can't use generic parameters from outer item
|
||||
--> $DIR/E0401.rs:4:39
|
||||
|
|
||||
LL | fn foo<T>(x: T) {
|
||||
| - type parameter from outer function
|
||||
| - type parameter from outer item
|
||||
LL | fn bfnr<U, V: Baz<U>, W: Fn()>(y: T) {
|
||||
| - ^ use of generic parameter from outer function
|
||||
| - ^ use of generic parameter from outer item
|
||||
| |
|
||||
| help: try using a local generic parameter instead: `T,`
|
||||
| help: try introducing a local generic parameter here: `T,`
|
||||
|
||||
error[E0401]: can't use generic parameters from outer function
|
||||
error[E0401]: can't use generic parameters from outer item
|
||||
--> $DIR/E0401.rs:9:16
|
||||
|
|
||||
LL | fn foo<T>(x: T) {
|
||||
| - type parameter from outer function
|
||||
| - type parameter from outer item
|
||||
...
|
||||
LL | fn baz<U,
|
||||
| - help: try using a local generic parameter instead: `T,`
|
||||
| - help: try introducing a local generic parameter here: `T,`
|
||||
...
|
||||
LL | (y: T) {
|
||||
| ^ use of generic parameter from outer function
|
||||
| ^ use of generic parameter from outer item
|
||||
|
||||
error[E0401]: can't use generic parameters from outer function
|
||||
error[E0401]: can't use generic parameters from outer item
|
||||
--> $DIR/E0401.rs:24:25
|
||||
|
|
||||
LL | impl<T> Iterator for A<T> {
|
||||
|
@ -29,8 +29,8 @@ LL | impl<T> Iterator for A<T> {
|
|||
LL | fn helper(sel: &Self) -> u8 {
|
||||
| ^^^^
|
||||
| |
|
||||
| use of generic parameter from outer function
|
||||
| use a type here instead
|
||||
| use of generic parameter from outer item
|
||||
| refer to the type directly here instead
|
||||
|
||||
error[E0282]: type annotations needed
|
||||
--> $DIR/E0401.rs:11:5
|
||||
|
|
|
@ -4,6 +4,11 @@ error[E0277]: the trait bound `for<'a> &'a mut (): Foo<&'a mut ()>` is not satis
|
|||
LL | (&mut EmptyIter).consume(());
|
||||
| ^^^^^^^ the trait `for<'a> Foo<&'a mut ()>` is not implemented for `&'a mut ()`
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/issue-101020.rs:28:1
|
||||
|
|
||||
LL | trait Foo<T> {}
|
||||
| ^^^^^^^^^^^^
|
||||
note: required for `&'a mut ()` to implement `for<'a> FuncInput<'a, &'a mut ()>`
|
||||
--> $DIR/issue-101020.rs:27:20
|
||||
|
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
fn<EFBFBD>a<e>(){fn<EFBFBD>p(){e}} //~ ERROR unknown start of token: \u{fffd}
|
||||
//~^ ERROR unknown start of token: \u{fffd}
|
||||
//~^^ ERROR can't use generic parameters from outer function [E0401]
|
||||
//~^^ ERROR can't use generic parameters from outer item [E0401]
|
||||
//~^^^ WARN type parameter `e` should have an upper camel case name
|
||||
|
||||
fn main(){}
|
||||
|
|
|
@ -2,7 +2,7 @@ struct Struct<T>(T);
|
|||
|
||||
impl<T> Struct<T> {
|
||||
const CONST: fn() = || {
|
||||
struct _Obligation where T:; //~ ERROR can't use generic parameters from outer function
|
||||
struct _Obligation where T:; //~ ERROR can't use generic parameters from outer item
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
error[E0401]: can't use generic parameters from outer function
|
||||
error[E0401]: can't use generic parameters from outer item
|
||||
--> $DIR/issue-98432.rs:5:34
|
||||
|
|
||||
LL | impl<T> Struct<T> {
|
||||
| - type parameter from outer function
|
||||
| - type parameter from outer item
|
||||
LL | const CONST: fn() = || {
|
||||
LL | struct _Obligation where T:;
|
||||
| - ^ use of generic parameter from outer function
|
||||
| - ^ use of generic parameter from outer item
|
||||
| |
|
||||
| help: try using a local generic parameter instead: `<T>`
|
||||
| help: try introducing a local generic parameter here: `<T>`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -4,6 +4,11 @@ error[E0277]: the trait bound `for<'a> &'a (): BufferMut` is not satisfied
|
|||
LL | C: StackContext,
|
||||
| ^^^^^^^^^^^^ the trait `for<'a> BufferMut` is not implemented for `&'a ()`
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/issue-89118.rs:1:1
|
||||
|
|
||||
LL | trait BufferMut {}
|
||||
| ^^^^^^^^^^^^^^^
|
||||
note: required for `Ctx<()>` to implement `for<'a> BufferUdpStateContext<&'a ()>`
|
||||
--> $DIR/issue-89118.rs:5:23
|
||||
|
|
||||
|
@ -26,6 +31,11 @@ error[E0277]: the trait bound `for<'a> &'a (): BufferMut` is not satisfied
|
|||
LL | impl<C> EthernetWorker<C> {}
|
||||
| ^^^^^^^^^^^^^^^^^ the trait `for<'a> BufferMut` is not implemented for `&'a ()`
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/issue-89118.rs:1:1
|
||||
|
|
||||
LL | trait BufferMut {}
|
||||
| ^^^^^^^^^^^^^^^
|
||||
note: required for `Ctx<()>` to implement `for<'a> BufferUdpStateContext<&'a ()>`
|
||||
--> $DIR/issue-89118.rs:5:23
|
||||
|
|
||||
|
@ -48,6 +58,11 @@ error[E0277]: the trait bound `for<'a> &'a (): BufferMut` is not satisfied
|
|||
LL | type Handler = Ctx<C::Dispatcher>;
|
||||
| ^^^^^^^^^^^^^^^^^^ the trait `for<'a> BufferMut` is not implemented for `&'a ()`
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/issue-89118.rs:1:1
|
||||
|
|
||||
LL | trait BufferMut {}
|
||||
| ^^^^^^^^^^^^^^^
|
||||
note: required for `Ctx<()>` to implement `for<'a> BufferUdpStateContext<&'a ()>`
|
||||
--> $DIR/issue-89118.rs:5:23
|
||||
|
|
||||
|
|
|
@ -4,7 +4,7 @@ enum Bar<T> { What } //~ ERROR parameter `T` is never used
|
|||
|
||||
fn foo<T>() {
|
||||
static a: Bar<T> = Bar::What;
|
||||
//~^ ERROR can't use generic parameters from outer function
|
||||
//~^ ERROR can't use generic parameters from outer item
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
error[E0401]: can't use generic parameters from outer function
|
||||
error[E0401]: can't use generic parameters from outer item
|
||||
--> $DIR/inner-static-type-parameter.rs:6:19
|
||||
|
|
||||
LL | fn foo<T>() {
|
||||
| - type parameter from outer function
|
||||
| - type parameter from outer item
|
||||
LL | static a: Bar<T> = Bar::What;
|
||||
| ^ use of generic parameter from outer function
|
||||
| ^ use of generic parameter from outer item
|
||||
|
||||
error[E0392]: parameter `T` is never used
|
||||
--> $DIR/inner-static-type-parameter.rs:3:10
|
||||
|
|
|
@ -3,6 +3,12 @@ error[E0277]: the trait bound `isize: HasState` is not satisfied
|
|||
|
|
||||
LL | fn add_state(op: <isize as HasState>::State) {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `HasState` is not implemented for `isize`
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/issue-18611.rs:5:1
|
||||
|
|
||||
LL | trait HasState {
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -6,6 +6,11 @@ LL | do_fold(bot(), ());
|
|||
| |
|
||||
| required by a bound introduced by this call
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/issue-25076.rs:3:1
|
||||
|
|
||||
LL | trait InOut<T> { type Out; }
|
||||
| ^^^^^^^^^^^^^^
|
||||
note: required by a bound in `do_fold`
|
||||
--> $DIR/issue-25076.rs:5:18
|
||||
|
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
fn foo<T>() {
|
||||
struct Foo {
|
||||
x: T, //~ ERROR can't use generic parameters from outer function
|
||||
x: T, //~ ERROR can't use generic parameters from outer item
|
||||
}
|
||||
|
||||
impl<T> Drop for Foo<T> {
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
error[E0401]: can't use generic parameters from outer function
|
||||
error[E0401]: can't use generic parameters from outer item
|
||||
--> $DIR/issue-3214.rs:3:12
|
||||
|
|
||||
LL | fn foo<T>() {
|
||||
| - type parameter from outer function
|
||||
| - type parameter from outer item
|
||||
LL | struct Foo {
|
||||
| - help: try using a local generic parameter instead: `<T>`
|
||||
| - help: try introducing a local generic parameter here: `<T>`
|
||||
LL | x: T,
|
||||
| ^ use of generic parameter from outer function
|
||||
| ^ use of generic parameter from outer item
|
||||
|
||||
error[E0107]: struct takes 0 generic arguments but 1 generic argument was supplied
|
||||
--> $DIR/issue-3214.rs:6:22
|
||||
|
|
|
@ -3,6 +3,12 @@ error[E0277]: the trait bound `for<'a> (): Trait2<'a>` is not satisfied
|
|||
|
|
||||
LL | fn _ice(param: Box<dyn for <'a> Trait1<<() as Trait2<'a>>::Ty>>) {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ the trait `for<'a> Trait2<'a>` is not implemented for `()`
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/issue-35570.rs:4:1
|
||||
|
|
||||
LL | trait Trait2<'a> {
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
fn f<Z>() -> bool {
|
||||
enum E { V(Z) }
|
||||
//~^ ERROR can't use generic parameters from outer function
|
||||
//~^ ERROR can't use generic parameters from outer item
|
||||
true
|
||||
}
|
||||
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
error[E0401]: can't use generic parameters from outer function
|
||||
error[E0401]: can't use generic parameters from outer item
|
||||
--> $DIR/issue-5997-enum.rs:2:16
|
||||
|
|
||||
LL | fn f<Z>() -> bool {
|
||||
| - type parameter from outer function
|
||||
| - type parameter from outer item
|
||||
LL | enum E { V(Z) }
|
||||
| - ^ use of generic parameter from outer function
|
||||
| - ^ use of generic parameter from outer item
|
||||
| |
|
||||
| help: try using a local generic parameter instead: `<Z>`
|
||||
| help: try introducing a local generic parameter here: `<Z>`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
fn f<T>() -> bool {
|
||||
struct S(T); //~ ERROR can't use generic parameters from outer function
|
||||
struct S(T); //~ ERROR can't use generic parameters from outer item
|
||||
|
||||
true
|
||||
}
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
error[E0401]: can't use generic parameters from outer function
|
||||
error[E0401]: can't use generic parameters from outer item
|
||||
--> $DIR/issue-5997-struct.rs:2:14
|
||||
|
|
||||
LL | fn f<T>() -> bool {
|
||||
| - type parameter from outer function
|
||||
| - type parameter from outer item
|
||||
LL | struct S(T);
|
||||
| -^ use of generic parameter from outer function
|
||||
| -^ use of generic parameter from outer item
|
||||
| |
|
||||
| help: try using a local generic parameter instead: `<T>`
|
||||
| help: try introducing a local generic parameter here: `<T>`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -6,6 +6,11 @@ LL | trigger_error(vec![], |x: &u32| x)
|
|||
| |
|
||||
| required by a bound introduced by this call
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/issue-60218.rs:7:1
|
||||
|
|
||||
LL | pub trait Foo {}
|
||||
| ^^^^^^^^^^^^^
|
||||
note: required by a bound in `trigger_error`
|
||||
--> $DIR/issue-60218.rs:13:72
|
||||
|
|
||||
|
|
|
@ -3,6 +3,12 @@ error[E0277]: the trait bound `(): _A` is not satisfied
|
|||
|
|
||||
LL | _Func::< <() as _A>::AssocT >::func(());
|
||||
| ^^ the trait `_A` is not implemented for `()`
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/issue-66353.rs:7:1
|
||||
|
|
||||
LL | trait _A {
|
||||
| ^^^^^^^^
|
||||
|
||||
error[E0277]: the trait bound `(): _Func<_>` is not satisfied
|
||||
--> $DIR/issue-66353.rs:12:41
|
||||
|
@ -11,6 +17,12 @@ LL | _Func::< <() as _A>::AssocT >::func(());
|
|||
| ----------------------------------- ^^ the trait `_Func<_>` is not implemented for `()`
|
||||
| |
|
||||
| required by a bound introduced by this call
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/issue-66353.rs:3:1
|
||||
|
|
||||
LL | trait _Func<T> {
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
|
@ -3,6 +3,12 @@ error[E0277]: the trait bound `Result<(), _>: Future` is not satisfied
|
|||
|
|
||||
LL | fn foo() -> impl Future<Item=(), Error=Box<dyn Error>> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Future` is not implemented for `Result<(), _>`
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/lifetime-elision-return-type-trait.rs:1:1
|
||||
|
|
||||
LL | trait Future {
|
||||
| ^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -114,6 +114,11 @@ LL | check(m1::S{});
|
|||
| |
|
||||
| required by a bound introduced by this call
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/namespace-mix.rs:20:1
|
||||
|
|
||||
LL | trait Impossible {}
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
note: required by a bound in `check`
|
||||
--> $DIR/namespace-mix.rs:21:13
|
||||
|
|
||||
|
@ -128,6 +133,11 @@ LL | check(m2::S{});
|
|||
| |
|
||||
| required by a bound introduced by this call
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/namespace-mix.rs:20:1
|
||||
|
|
||||
LL | trait Impossible {}
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
note: required by a bound in `check`
|
||||
--> $DIR/namespace-mix.rs:21:13
|
||||
|
|
||||
|
@ -142,6 +152,11 @@ LL | check(m2::S);
|
|||
| |
|
||||
| required by a bound introduced by this call
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/namespace-mix.rs:20:1
|
||||
|
|
||||
LL | trait Impossible {}
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
note: required by a bound in `check`
|
||||
--> $DIR/namespace-mix.rs:21:13
|
||||
|
|
||||
|
@ -156,6 +171,11 @@ LL | check(xm1::S{});
|
|||
| |
|
||||
| required by a bound introduced by this call
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/namespace-mix.rs:20:1
|
||||
|
|
||||
LL | trait Impossible {}
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
note: required by a bound in `check`
|
||||
--> $DIR/namespace-mix.rs:21:13
|
||||
|
|
||||
|
@ -170,6 +190,11 @@ LL | check(xm2::S{});
|
|||
| |
|
||||
| required by a bound introduced by this call
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/namespace-mix.rs:20:1
|
||||
|
|
||||
LL | trait Impossible {}
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
note: required by a bound in `check`
|
||||
--> $DIR/namespace-mix.rs:21:13
|
||||
|
|
||||
|
@ -184,6 +209,11 @@ LL | check(xm2::S);
|
|||
| |
|
||||
| required by a bound introduced by this call
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/namespace-mix.rs:20:1
|
||||
|
|
||||
LL | trait Impossible {}
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
note: required by a bound in `check`
|
||||
--> $DIR/namespace-mix.rs:21:13
|
||||
|
|
||||
|
@ -198,6 +228,11 @@ LL | check(m3::TS{});
|
|||
| |
|
||||
| required by a bound introduced by this call
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/namespace-mix.rs:20:1
|
||||
|
|
||||
LL | trait Impossible {}
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
note: required by a bound in `check`
|
||||
--> $DIR/namespace-mix.rs:21:13
|
||||
|
|
||||
|
@ -212,6 +247,11 @@ LL | check(m3::TS);
|
|||
| |
|
||||
| required by a bound introduced by this call
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/namespace-mix.rs:20:1
|
||||
|
|
||||
LL | trait Impossible {}
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
note: required by a bound in `check`
|
||||
--> $DIR/namespace-mix.rs:21:13
|
||||
|
|
||||
|
@ -226,6 +266,11 @@ LL | check(m4::TS{});
|
|||
| |
|
||||
| required by a bound introduced by this call
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/namespace-mix.rs:20:1
|
||||
|
|
||||
LL | trait Impossible {}
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
note: required by a bound in `check`
|
||||
--> $DIR/namespace-mix.rs:21:13
|
||||
|
|
||||
|
@ -240,6 +285,11 @@ LL | check(m4::TS);
|
|||
| |
|
||||
| required by a bound introduced by this call
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/namespace-mix.rs:20:1
|
||||
|
|
||||
LL | trait Impossible {}
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
note: required by a bound in `check`
|
||||
--> $DIR/namespace-mix.rs:21:13
|
||||
|
|
||||
|
@ -254,6 +304,11 @@ LL | check(xm3::TS{});
|
|||
| |
|
||||
| required by a bound introduced by this call
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/namespace-mix.rs:20:1
|
||||
|
|
||||
LL | trait Impossible {}
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
note: required by a bound in `check`
|
||||
--> $DIR/namespace-mix.rs:21:13
|
||||
|
|
||||
|
@ -268,6 +323,11 @@ LL | check(xm3::TS);
|
|||
| |
|
||||
| required by a bound introduced by this call
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/namespace-mix.rs:20:1
|
||||
|
|
||||
LL | trait Impossible {}
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
note: required by a bound in `check`
|
||||
--> $DIR/namespace-mix.rs:21:13
|
||||
|
|
||||
|
@ -282,6 +342,11 @@ LL | check(xm4::TS{});
|
|||
| |
|
||||
| required by a bound introduced by this call
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/namespace-mix.rs:20:1
|
||||
|
|
||||
LL | trait Impossible {}
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
note: required by a bound in `check`
|
||||
--> $DIR/namespace-mix.rs:21:13
|
||||
|
|
||||
|
@ -296,6 +361,11 @@ LL | check(xm4::TS);
|
|||
| |
|
||||
| required by a bound introduced by this call
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/namespace-mix.rs:20:1
|
||||
|
|
||||
LL | trait Impossible {}
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
note: required by a bound in `check`
|
||||
--> $DIR/namespace-mix.rs:21:13
|
||||
|
|
||||
|
@ -310,6 +380,11 @@ LL | check(m5::US{});
|
|||
| |
|
||||
| required by a bound introduced by this call
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/namespace-mix.rs:20:1
|
||||
|
|
||||
LL | trait Impossible {}
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
note: required by a bound in `check`
|
||||
--> $DIR/namespace-mix.rs:21:13
|
||||
|
|
||||
|
@ -324,6 +399,11 @@ LL | check(m5::US);
|
|||
| |
|
||||
| required by a bound introduced by this call
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/namespace-mix.rs:20:1
|
||||
|
|
||||
LL | trait Impossible {}
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
note: required by a bound in `check`
|
||||
--> $DIR/namespace-mix.rs:21:13
|
||||
|
|
||||
|
@ -338,6 +418,11 @@ LL | check(m6::US{});
|
|||
| |
|
||||
| required by a bound introduced by this call
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/namespace-mix.rs:20:1
|
||||
|
|
||||
LL | trait Impossible {}
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
note: required by a bound in `check`
|
||||
--> $DIR/namespace-mix.rs:21:13
|
||||
|
|
||||
|
@ -352,6 +437,11 @@ LL | check(m6::US);
|
|||
| |
|
||||
| required by a bound introduced by this call
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/namespace-mix.rs:20:1
|
||||
|
|
||||
LL | trait Impossible {}
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
note: required by a bound in `check`
|
||||
--> $DIR/namespace-mix.rs:21:13
|
||||
|
|
||||
|
@ -366,6 +456,11 @@ LL | check(xm5::US{});
|
|||
| |
|
||||
| required by a bound introduced by this call
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/namespace-mix.rs:20:1
|
||||
|
|
||||
LL | trait Impossible {}
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
note: required by a bound in `check`
|
||||
--> $DIR/namespace-mix.rs:21:13
|
||||
|
|
||||
|
@ -380,6 +475,11 @@ LL | check(xm5::US);
|
|||
| |
|
||||
| required by a bound introduced by this call
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/namespace-mix.rs:20:1
|
||||
|
|
||||
LL | trait Impossible {}
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
note: required by a bound in `check`
|
||||
--> $DIR/namespace-mix.rs:21:13
|
||||
|
|
||||
|
@ -394,6 +494,11 @@ LL | check(xm6::US{});
|
|||
| |
|
||||
| required by a bound introduced by this call
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/namespace-mix.rs:20:1
|
||||
|
|
||||
LL | trait Impossible {}
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
note: required by a bound in `check`
|
||||
--> $DIR/namespace-mix.rs:21:13
|
||||
|
|
||||
|
@ -408,6 +513,11 @@ LL | check(xm6::US);
|
|||
| |
|
||||
| required by a bound introduced by this call
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/namespace-mix.rs:20:1
|
||||
|
|
||||
LL | trait Impossible {}
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
note: required by a bound in `check`
|
||||
--> $DIR/namespace-mix.rs:21:13
|
||||
|
|
||||
|
@ -422,6 +532,11 @@ LL | check(m7::V{});
|
|||
| |
|
||||
| required by a bound introduced by this call
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/namespace-mix.rs:20:1
|
||||
|
|
||||
LL | trait Impossible {}
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
note: required by a bound in `check`
|
||||
--> $DIR/namespace-mix.rs:21:13
|
||||
|
|
||||
|
@ -436,6 +551,11 @@ LL | check(m8::V{});
|
|||
| |
|
||||
| required by a bound introduced by this call
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/namespace-mix.rs:20:1
|
||||
|
|
||||
LL | trait Impossible {}
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
note: required by a bound in `check`
|
||||
--> $DIR/namespace-mix.rs:21:13
|
||||
|
|
||||
|
@ -450,6 +570,11 @@ LL | check(m8::V);
|
|||
| |
|
||||
| required by a bound introduced by this call
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/namespace-mix.rs:20:1
|
||||
|
|
||||
LL | trait Impossible {}
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
note: required by a bound in `check`
|
||||
--> $DIR/namespace-mix.rs:21:13
|
||||
|
|
||||
|
@ -464,6 +589,11 @@ LL | check(xm7::V{});
|
|||
| |
|
||||
| required by a bound introduced by this call
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/namespace-mix.rs:20:1
|
||||
|
|
||||
LL | trait Impossible {}
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
note: required by a bound in `check`
|
||||
--> $DIR/namespace-mix.rs:21:13
|
||||
|
|
||||
|
@ -478,6 +608,11 @@ LL | check(xm8::V{});
|
|||
| |
|
||||
| required by a bound introduced by this call
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/namespace-mix.rs:20:1
|
||||
|
|
||||
LL | trait Impossible {}
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
note: required by a bound in `check`
|
||||
--> $DIR/namespace-mix.rs:21:13
|
||||
|
|
||||
|
@ -492,6 +627,11 @@ LL | check(xm8::V);
|
|||
| |
|
||||
| required by a bound introduced by this call
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/namespace-mix.rs:20:1
|
||||
|
|
||||
LL | trait Impossible {}
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
note: required by a bound in `check`
|
||||
--> $DIR/namespace-mix.rs:21:13
|
||||
|
|
||||
|
@ -506,6 +646,11 @@ LL | check(m9::TV{});
|
|||
| |
|
||||
| required by a bound introduced by this call
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/namespace-mix.rs:20:1
|
||||
|
|
||||
LL | trait Impossible {}
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
note: required by a bound in `check`
|
||||
--> $DIR/namespace-mix.rs:21:13
|
||||
|
|
||||
|
@ -520,6 +665,11 @@ LL | check(m9::TV);
|
|||
| |
|
||||
| required by a bound introduced by this call
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/namespace-mix.rs:20:1
|
||||
|
|
||||
LL | trait Impossible {}
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
note: required by a bound in `check`
|
||||
--> $DIR/namespace-mix.rs:21:13
|
||||
|
|
||||
|
@ -534,6 +684,11 @@ LL | check(mA::TV{});
|
|||
| |
|
||||
| required by a bound introduced by this call
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/namespace-mix.rs:20:1
|
||||
|
|
||||
LL | trait Impossible {}
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
note: required by a bound in `check`
|
||||
--> $DIR/namespace-mix.rs:21:13
|
||||
|
|
||||
|
@ -548,6 +703,11 @@ LL | check(mA::TV);
|
|||
| |
|
||||
| required by a bound introduced by this call
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/namespace-mix.rs:20:1
|
||||
|
|
||||
LL | trait Impossible {}
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
note: required by a bound in `check`
|
||||
--> $DIR/namespace-mix.rs:21:13
|
||||
|
|
||||
|
@ -562,6 +722,11 @@ LL | check(xm9::TV{});
|
|||
| |
|
||||
| required by a bound introduced by this call
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/namespace-mix.rs:20:1
|
||||
|
|
||||
LL | trait Impossible {}
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
note: required by a bound in `check`
|
||||
--> $DIR/namespace-mix.rs:21:13
|
||||
|
|
||||
|
@ -576,6 +741,11 @@ LL | check(xm9::TV);
|
|||
| |
|
||||
| required by a bound introduced by this call
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/namespace-mix.rs:20:1
|
||||
|
|
||||
LL | trait Impossible {}
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
note: required by a bound in `check`
|
||||
--> $DIR/namespace-mix.rs:21:13
|
||||
|
|
||||
|
@ -590,6 +760,11 @@ LL | check(xmA::TV{});
|
|||
| |
|
||||
| required by a bound introduced by this call
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/namespace-mix.rs:20:1
|
||||
|
|
||||
LL | trait Impossible {}
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
note: required by a bound in `check`
|
||||
--> $DIR/namespace-mix.rs:21:13
|
||||
|
|
||||
|
@ -604,6 +779,11 @@ LL | check(xmA::TV);
|
|||
| |
|
||||
| required by a bound introduced by this call
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/namespace-mix.rs:20:1
|
||||
|
|
||||
LL | trait Impossible {}
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
note: required by a bound in `check`
|
||||
--> $DIR/namespace-mix.rs:21:13
|
||||
|
|
||||
|
@ -618,6 +798,11 @@ LL | check(mB::UV{});
|
|||
| |
|
||||
| required by a bound introduced by this call
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/namespace-mix.rs:20:1
|
||||
|
|
||||
LL | trait Impossible {}
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
note: required by a bound in `check`
|
||||
--> $DIR/namespace-mix.rs:21:13
|
||||
|
|
||||
|
@ -632,6 +817,11 @@ LL | check(mB::UV);
|
|||
| |
|
||||
| required by a bound introduced by this call
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/namespace-mix.rs:20:1
|
||||
|
|
||||
LL | trait Impossible {}
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
note: required by a bound in `check`
|
||||
--> $DIR/namespace-mix.rs:21:13
|
||||
|
|
||||
|
@ -646,6 +836,11 @@ LL | check(mC::UV{});
|
|||
| |
|
||||
| required by a bound introduced by this call
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/namespace-mix.rs:20:1
|
||||
|
|
||||
LL | trait Impossible {}
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
note: required by a bound in `check`
|
||||
--> $DIR/namespace-mix.rs:21:13
|
||||
|
|
||||
|
@ -660,6 +855,11 @@ LL | check(mC::UV);
|
|||
| |
|
||||
| required by a bound introduced by this call
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/namespace-mix.rs:20:1
|
||||
|
|
||||
LL | trait Impossible {}
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
note: required by a bound in `check`
|
||||
--> $DIR/namespace-mix.rs:21:13
|
||||
|
|
||||
|
@ -674,6 +874,11 @@ LL | check(xmB::UV{});
|
|||
| |
|
||||
| required by a bound introduced by this call
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/namespace-mix.rs:20:1
|
||||
|
|
||||
LL | trait Impossible {}
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
note: required by a bound in `check`
|
||||
--> $DIR/namespace-mix.rs:21:13
|
||||
|
|
||||
|
@ -688,6 +893,11 @@ LL | check(xmB::UV);
|
|||
| |
|
||||
| required by a bound introduced by this call
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/namespace-mix.rs:20:1
|
||||
|
|
||||
LL | trait Impossible {}
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
note: required by a bound in `check`
|
||||
--> $DIR/namespace-mix.rs:21:13
|
||||
|
|
||||
|
@ -702,6 +912,11 @@ LL | check(xmC::UV{});
|
|||
| |
|
||||
| required by a bound introduced by this call
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/namespace-mix.rs:20:1
|
||||
|
|
||||
LL | trait Impossible {}
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
note: required by a bound in `check`
|
||||
--> $DIR/namespace-mix.rs:21:13
|
||||
|
|
||||
|
@ -716,6 +931,11 @@ LL | check(xmC::UV);
|
|||
| |
|
||||
| required by a bound introduced by this call
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/namespace-mix.rs:20:1
|
||||
|
|
||||
LL | trait Impossible {}
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
note: required by a bound in `check`
|
||||
--> $DIR/namespace-mix.rs:21:13
|
||||
|
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// error-pattern:can't use generic parameters from outer function
|
||||
// error-pattern:can't use generic parameters from outer item
|
||||
fn hd<U>(v: Vec<U> ) -> U {
|
||||
fn hd1(w: [U]) -> U { return w[0]; }
|
||||
|
||||
|
|
|
@ -1,22 +1,22 @@
|
|||
error[E0401]: can't use generic parameters from outer function
|
||||
error[E0401]: can't use generic parameters from outer item
|
||||
--> $DIR/nested-ty-params.rs:3:16
|
||||
|
|
||||
LL | fn hd<U>(v: Vec<U> ) -> U {
|
||||
| - type parameter from outer function
|
||||
| - type parameter from outer item
|
||||
LL | fn hd1(w: [U]) -> U { return w[0]; }
|
||||
| - ^ use of generic parameter from outer function
|
||||
| - ^ use of generic parameter from outer item
|
||||
| |
|
||||
| help: try using a local generic parameter instead: `<U>`
|
||||
| help: try introducing a local generic parameter here: `<U>`
|
||||
|
||||
error[E0401]: can't use generic parameters from outer function
|
||||
error[E0401]: can't use generic parameters from outer item
|
||||
--> $DIR/nested-ty-params.rs:3:23
|
||||
|
|
||||
LL | fn hd<U>(v: Vec<U> ) -> U {
|
||||
| - type parameter from outer function
|
||||
| - type parameter from outer item
|
||||
LL | fn hd1(w: [U]) -> U { return w[0]; }
|
||||
| - ^ use of generic parameter from outer function
|
||||
| - ^ use of generic parameter from outer item
|
||||
| |
|
||||
| help: try using a local generic parameter instead: `<U>`
|
||||
| help: try introducing a local generic parameter here: `<U>`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
|
@ -8,6 +8,11 @@ LL | foo(panic!())
|
|||
| | this tail expression is of type `()`
|
||||
| required by a bound introduced by this call
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/feature-gate-never_type_fallback.rs:7:1
|
||||
|
|
||||
LL | trait T {}
|
||||
| ^^^^^^^
|
||||
note: required by a bound in `foo`
|
||||
--> $DIR/feature-gate-never_type_fallback.rs:13:16
|
||||
|
|
||||
|
|
|
@ -3,6 +3,12 @@ error[E0277]: the trait bound `(): T` is not satisfied
|
|||
|
|
||||
LL | fn a() -> Foo {
|
||||
| ^^^ the trait `T` is not implemented for `()`
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/impl_trait_fallback3.rs:5:1
|
||||
|
|
||||
LL | trait T {
|
||||
| ^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -3,6 +3,12 @@ error[E0277]: the trait bound `(): T` is not satisfied
|
|||
|
|
||||
LL | fn foo() -> impl T {
|
||||
| ^^^^^^ the trait `T` is not implemented for `()`
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/impl_trait_fallback4.rs:3:1
|
||||
|
|
||||
LL | trait T {
|
||||
| ^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -5,6 +5,11 @@ LL | let y: Option<Vec<u8>> = collect(x.iter()); // this should give approxi
|
|||
| ^^^^^^^ a collection of type `Option<Vec<u8>>` cannot be built from an iterator over elements of type `&u8`
|
||||
|
|
||||
= help: the trait `MyFromIterator<&u8>` is not implemented for `Option<Vec<u8>>`
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/on-trait.rs:17:1
|
||||
|
|
||||
LL | trait MyFromIterator<A> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^
|
||||
note: required by a bound in `collect`
|
||||
--> $DIR/on-trait.rs:22:39
|
||||
|
|
||||
|
@ -18,6 +23,11 @@ LL | let x: String = foobar();
|
|||
| ^^^^^^ test error `String` with `u8` `_` `u32` in `Foo`
|
||||
|
|
||||
= help: the trait `Foo<u8, _, u32>` is not implemented for `String`
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/on-trait.rs:7:3
|
||||
|
|
||||
LL | pub trait Foo<Bar, Baz, Quux> {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
note: required by a bound in `foobar`
|
||||
--> $DIR/on-trait.rs:12:24
|
||||
|
|
||||
|
|
|
@ -8,6 +8,11 @@ LL | f(Foo {});
|
|||
| |
|
||||
| required by a bound introduced by this call
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/parent-label.rs:6:1
|
||||
|
|
||||
LL | trait Trait {}
|
||||
| ^^^^^^^^^^^
|
||||
note: required by a bound in `f`
|
||||
--> $DIR/parent-label.rs:10:9
|
||||
|
|
||||
|
@ -24,6 +29,11 @@ LL | f(Foo {});
|
|||
| |
|
||||
| required by a bound introduced by this call
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/parent-label.rs:6:1
|
||||
|
|
||||
LL | trait Trait {}
|
||||
| ^^^^^^^^^^^
|
||||
note: required by a bound in `f`
|
||||
--> $DIR/parent-label.rs:10:9
|
||||
|
|
||||
|
@ -41,6 +51,11 @@ LL | f(Foo {});
|
|||
| |
|
||||
| required by a bound introduced by this call
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/parent-label.rs:6:1
|
||||
|
|
||||
LL | trait Trait {}
|
||||
| ^^^^^^^^^^^
|
||||
note: required by a bound in `f`
|
||||
--> $DIR/parent-label.rs:10:9
|
||||
|
|
||||
|
@ -58,6 +73,11 @@ LL | f(Foo {});
|
|||
| |
|
||||
| required by a bound introduced by this call
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/parent-label.rs:6:1
|
||||
|
|
||||
LL | trait Trait {}
|
||||
| ^^^^^^^^^^^
|
||||
note: required by a bound in `f`
|
||||
--> $DIR/parent-label.rs:10:9
|
||||
|
|
||||
|
|
|
@ -3,6 +3,12 @@ error[E0277]: the trait bound `(): Project` is not satisfied
|
|||
|
|
||||
LL | pub fn uwu() -> <() as Project>::Assoc {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ the trait `Project` is not implemented for `()`
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/bad-projection.rs:9:1
|
||||
|
|
||||
LL | trait Project {
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
error[E0401]: can't use generic parameters from outer function
|
||||
error[E0401]: can't use generic parameters from outer item
|
||||
--> $DIR/bad-type-env-capture.rs:2:15
|
||||
|
|
||||
LL | fn foo<T>() {
|
||||
| - type parameter from outer function
|
||||
| - type parameter from outer item
|
||||
LL | fn bar(b: T) { }
|
||||
| - ^ use of generic parameter from outer function
|
||||
| - ^ use of generic parameter from outer item
|
||||
| |
|
||||
| help: try using a local generic parameter instead: `<T>`
|
||||
| help: try introducing a local generic parameter here: `<T>`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
error[E0401]: can't use generic parameters from outer item
|
||||
--> $DIR/generic-params-from-outer-item-in-const-item.rs:12:20
|
||||
|
|
||||
LL | fn outer<T: Tr>() { // outer function
|
||||
| - type parameter from outer item
|
||||
LL | const K: u32 = T::C;
|
||||
| ^^^^ use of generic parameter from outer item
|
||||
|
||||
error[E0401]: can't use generic parameters from outer item
|
||||
--> $DIR/generic-params-from-outer-item-in-const-item.rs:19:24
|
||||
|
|
||||
LL | impl<T> Tr for T { // outer impl block
|
||||
| - type parameter from outer item
|
||||
LL | const C: u32 = {
|
||||
LL | const I: u32 = T::C;
|
||||
| ^^^^ use of generic parameter from outer item
|
||||
|
||||
error[E0401]: can't use generic parameters from outer item
|
||||
--> $DIR/generic-params-from-outer-item-in-const-item.rs:27:20
|
||||
|
|
||||
LL | struct S<T: Tr>(U32<{ // outer struct
|
||||
| - type parameter from outer item
|
||||
LL | const _: u32 = T::C;
|
||||
| ^^^^ use of generic parameter from outer item
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0401`.
|
|
@ -0,0 +1,34 @@
|
|||
error[E0401]: can't use generic parameters from outer item
|
||||
--> $DIR/generic-params-from-outer-item-in-const-item.rs:12:20
|
||||
|
|
||||
LL | fn outer<T: Tr>() { // outer function
|
||||
| - type parameter from outer item
|
||||
LL | const K: u32 = T::C;
|
||||
| - ^^^^ use of generic parameter from outer item
|
||||
| |
|
||||
| help: try introducing a local generic parameter here: `<T>`
|
||||
|
||||
error[E0401]: can't use generic parameters from outer item
|
||||
--> $DIR/generic-params-from-outer-item-in-const-item.rs:19:24
|
||||
|
|
||||
LL | impl<T> Tr for T { // outer impl block
|
||||
| - type parameter from outer item
|
||||
LL | const C: u32 = {
|
||||
LL | const I: u32 = T::C;
|
||||
| - ^^^^ use of generic parameter from outer item
|
||||
| |
|
||||
| help: try introducing a local generic parameter here: `<T>`
|
||||
|
||||
error[E0401]: can't use generic parameters from outer item
|
||||
--> $DIR/generic-params-from-outer-item-in-const-item.rs:27:20
|
||||
|
|
||||
LL | struct S<T: Tr>(U32<{ // outer struct
|
||||
| - type parameter from outer item
|
||||
LL | const _: u32 = T::C;
|
||||
| - ^^^^ use of generic parameter from outer item
|
||||
| |
|
||||
| help: try introducing a local generic parameter here: `<T>`
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0401`.
|
|
@ -0,0 +1,39 @@
|
|||
// Regression test for issue #115720.
|
||||
// If a const item contains generic params from an outer items, only suggest
|
||||
// turning the const item generic if the feature `generic_const_items` is enabled.
|
||||
|
||||
// revisions: default generic_const_items
|
||||
|
||||
#![cfg_attr(generic_const_items, feature(generic_const_items))]
|
||||
#![feature(generic_const_exprs)] // only used for the test case "outer struct"
|
||||
#![allow(incomplete_features)]
|
||||
|
||||
fn outer<T: Tr>() { // outer function
|
||||
const K: u32 = T::C;
|
||||
//~^ ERROR can't use generic parameters from outer item
|
||||
//[generic_const_items]~| HELP try introducing a local generic parameter here
|
||||
}
|
||||
|
||||
impl<T> Tr for T { // outer impl block
|
||||
const C: u32 = {
|
||||
const I: u32 = T::C;
|
||||
//~^ ERROR can't use generic parameters from outer item
|
||||
//[generic_const_items]~| HELP try introducing a local generic parameter here
|
||||
I
|
||||
};
|
||||
}
|
||||
|
||||
struct S<T: Tr>(U32<{ // outer struct
|
||||
const _: u32 = T::C;
|
||||
//~^ ERROR can't use generic parameters from outer item
|
||||
//[generic_const_items]~| HELP try introducing a local generic parameter here
|
||||
0
|
||||
}>);
|
||||
|
||||
trait Tr {
|
||||
const C: u32;
|
||||
}
|
||||
|
||||
struct U32<const N: u32>;
|
||||
|
||||
fn main() {}
|
|
@ -1,7 +1,7 @@
|
|||
trait Trait {
|
||||
fn outer(&self) {
|
||||
fn inner(_: &Self) {
|
||||
//~^ ERROR can't use generic parameters from outer function
|
||||
//~^ ERROR can't use generic parameters from outer item
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
error[E0401]: can't use generic parameters from outer function
|
||||
error[E0401]: can't use generic parameters from outer item
|
||||
--> $DIR/issue-12796.rs:3:22
|
||||
|
|
||||
LL | fn inner(_: &Self) {
|
||||
| ^^^^
|
||||
| |
|
||||
| use of generic parameter from outer function
|
||||
| use of generic parameter from outer item
|
||||
| can't use `Self` here
|
||||
|
||||
error: aborting due to previous error
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
fn siphash<T>() {
|
||||
|
||||
trait U {
|
||||
fn g(&self, x: T) -> T; //~ ERROR can't use generic parameters from outer function
|
||||
//~^ ERROR can't use generic parameters from outer function
|
||||
fn g(&self, x: T) -> T; //~ ERROR can't use generic parameters from outer item
|
||||
//~^ ERROR can't use generic parameters from outer item
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,24 +1,24 @@
|
|||
error[E0401]: can't use generic parameters from outer function
|
||||
error[E0401]: can't use generic parameters from outer item
|
||||
--> $DIR/issue-3021-c.rs:4:24
|
||||
|
|
||||
LL | fn siphash<T>() {
|
||||
| - type parameter from outer function
|
||||
| - type parameter from outer item
|
||||
LL |
|
||||
LL | trait U {
|
||||
| - help: try using a local generic parameter instead: `<T>`
|
||||
| - help: try introducing a local generic parameter here: `<T>`
|
||||
LL | fn g(&self, x: T) -> T;
|
||||
| ^ use of generic parameter from outer function
|
||||
| ^ use of generic parameter from outer item
|
||||
|
||||
error[E0401]: can't use generic parameters from outer function
|
||||
error[E0401]: can't use generic parameters from outer item
|
||||
--> $DIR/issue-3021-c.rs:4:30
|
||||
|
|
||||
LL | fn siphash<T>() {
|
||||
| - type parameter from outer function
|
||||
| - type parameter from outer item
|
||||
LL |
|
||||
LL | trait U {
|
||||
| - help: try using a local generic parameter instead: `<T>`
|
||||
| - help: try introducing a local generic parameter here: `<T>`
|
||||
LL | fn g(&self, x: T) -> T;
|
||||
| ^ use of generic parameter from outer function
|
||||
| ^ use of generic parameter from outer item
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue