mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-23 07:14:28 +00:00
Don't actually make bound ty/const for RTN
This commit is contained in:
parent
ef71f1047e
commit
802d16ce3a
@ -329,7 +329,7 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
|
||||
}
|
||||
|
||||
let projection_ty = if let ty::AssocKind::Fn = assoc_kind {
|
||||
let mut emitted_bad_param_err = false;
|
||||
let mut emitted_bad_param_err = None;
|
||||
// If we have an method return type bound, then we need to substitute
|
||||
// the method's early bound params with suitable late-bound params.
|
||||
let mut num_bound_vars = candidate.bound_vars().len();
|
||||
@ -346,46 +346,30 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
|
||||
)
|
||||
.into(),
|
||||
ty::GenericParamDefKind::Type { .. } => {
|
||||
if !emitted_bad_param_err {
|
||||
let guar = *emitted_bad_param_err.get_or_insert_with(|| {
|
||||
tcx.dcx().emit_err(
|
||||
crate::errors::ReturnTypeNotationIllegalParam::Type {
|
||||
span: path_span,
|
||||
param_span: tcx.def_span(param.def_id),
|
||||
},
|
||||
);
|
||||
emitted_bad_param_err = true;
|
||||
}
|
||||
Ty::new_bound(
|
||||
tcx,
|
||||
ty::INNERMOST,
|
||||
ty::BoundTy {
|
||||
var: ty::BoundVar::from_usize(num_bound_vars),
|
||||
kind: ty::BoundTyKind::Param(param.def_id, param.name),
|
||||
},
|
||||
)
|
||||
.into()
|
||||
)
|
||||
});
|
||||
Ty::new_error(tcx, guar).into()
|
||||
}
|
||||
ty::GenericParamDefKind::Const { .. } => {
|
||||
if !emitted_bad_param_err {
|
||||
let guar = *emitted_bad_param_err.get_or_insert_with(|| {
|
||||
tcx.dcx().emit_err(
|
||||
crate::errors::ReturnTypeNotationIllegalParam::Const {
|
||||
span: path_span,
|
||||
param_span: tcx.def_span(param.def_id),
|
||||
},
|
||||
);
|
||||
emitted_bad_param_err = true;
|
||||
}
|
||||
)
|
||||
});
|
||||
let ty = tcx
|
||||
.type_of(param.def_id)
|
||||
.no_bound_vars()
|
||||
.expect("ct params cannot have early bound vars");
|
||||
ty::Const::new_bound(
|
||||
tcx,
|
||||
ty::INNERMOST,
|
||||
ty::BoundVar::from_usize(num_bound_vars),
|
||||
ty,
|
||||
)
|
||||
.into()
|
||||
ty::Const::new_error(tcx, guar, ty).into()
|
||||
}
|
||||
};
|
||||
num_bound_vars += 1;
|
||||
|
@ -0,0 +1,17 @@
|
||||
// edition: 2021
|
||||
|
||||
#![feature(return_type_notation)]
|
||||
//~^ WARN the feature `return_type_notation` is incomplete
|
||||
|
||||
trait HealthCheck {
|
||||
async fn check<const N: usize>() -> bool;
|
||||
}
|
||||
|
||||
async fn do_health_check_par<HC>(hc: HC)
|
||||
where
|
||||
HC: HealthCheck<check(): Send> + Send + 'static,
|
||||
//~^ ERROR return type notation is not allowed for functions that have const parameters
|
||||
{
|
||||
}
|
||||
|
||||
fn main() {}
|
@ -0,0 +1,20 @@
|
||||
warning: the feature `return_type_notation` is incomplete and may not be safe to use and/or cause compiler crashes
|
||||
--> $DIR/issue-120208-higher-ranked-const.rs:3:12
|
||||
|
|
||||
LL | #![feature(return_type_notation)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #109417 <https://github.com/rust-lang/rust/issues/109417> for more information
|
||||
= note: `#[warn(incomplete_features)]` on by default
|
||||
|
||||
error: return type notation is not allowed for functions that have const parameters
|
||||
--> $DIR/issue-120208-higher-ranked-const.rs:12:21
|
||||
|
|
||||
LL | async fn check<const N: usize>() -> bool;
|
||||
| -------------- const parameter declared here
|
||||
...
|
||||
LL | HC: HealthCheck<check(): Send> + Send + 'static,
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 1 previous error; 1 warning emitted
|
||||
|
Loading…
Reference in New Issue
Block a user