Rollup merge of #138685 - nnethercote:use-Option-Ident-for-lowered-param-names, r=compiler-errors
Use `Option<Ident>` for lowered param names. Parameter patterns are lowered to an `Ident` by `lower_fn_params_to_names`, which is used when lowering bare function types, trait methods, and foreign functions. Currently, there are two exceptional cases where the lowered param can become an empty `Ident`. - If the incoming pattern is an empty `Ident`. This occurs if the parameter is anonymous, e.g. in a bare function type. - If the incoming pattern is neither an ident nor an underscore. Any such parameter will have triggered a compile error (hence the `span_delayed_bug`), but lowering still occurs. This commit replaces these empty `Ident` results with `None`, which eliminates a number of `kw::Empty` uses, and makes it impossible to fail to check for these exceptional cases. Note: the `FIXME` comment in `is_unwrap_or_empty_symbol` is removed. It actually should have been removed in #138482, the precursor to this PR. That PR changed the lowering of wild patterns to `_` symbols instead of empty symbols, which made the mentioned underscore check load-bearing. r? ``@compiler-errors``
This commit is contained in:
commit
915576935a
20 changed files with 125 additions and 87 deletions
|
@ -1034,7 +1034,13 @@ fn report_trait_method_mismatch<'tcx>(
|
|||
let span = tcx
|
||||
.hir_body_param_names(body)
|
||||
.zip(sig.decl.inputs.iter())
|
||||
.map(|(param, ty)| param.span.to(ty.span))
|
||||
.map(|(param_name, ty)| {
|
||||
if let Some(param_name) = param_name {
|
||||
param_name.span.to(ty.span)
|
||||
} else {
|
||||
ty.span
|
||||
}
|
||||
})
|
||||
.next()
|
||||
.unwrap_or(impl_err_span);
|
||||
|
||||
|
|
|
@ -49,10 +49,12 @@ pub(crate) fn validate_cmse_abi<'tcx>(
|
|||
Ok(Err(index)) => {
|
||||
// fn(x: u32, u32, u32, u16, y: u16) -> u32,
|
||||
// ^^^^^^
|
||||
let span = bare_fn_ty.param_names[index]
|
||||
.span
|
||||
.to(bare_fn_ty.decl.inputs[index].span)
|
||||
.to(bare_fn_ty.decl.inputs.last().unwrap().span);
|
||||
let span = if let Some(ident) = bare_fn_ty.param_names[index] {
|
||||
ident.span.to(bare_fn_ty.decl.inputs[index].span)
|
||||
} else {
|
||||
bare_fn_ty.decl.inputs[index].span
|
||||
}
|
||||
.to(bare_fn_ty.decl.inputs.last().unwrap().span);
|
||||
let plural = bare_fn_ty.param_names.len() - index != 1;
|
||||
dcx.emit_err(errors::CmseInputsStackSpill { span, plural, abi });
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue