Rollup merge of #108265 - lcnr:cg-error-msg, r=BoxyUwU
"`const` generic" -> "const parameter"
This commit is contained in:
commit
e4dadd6416
2 changed files with 9 additions and 12 deletions
|
@ -6,7 +6,7 @@ use crate::astconv::{
|
||||||
use crate::errors::AssocTypeBindingNotAllowed;
|
use crate::errors::AssocTypeBindingNotAllowed;
|
||||||
use crate::structured_errors::{GenericArgsInfo, StructuredDiagnostic, WrongNumberOfGenericArgs};
|
use crate::structured_errors::{GenericArgsInfo, StructuredDiagnostic, WrongNumberOfGenericArgs};
|
||||||
use rustc_ast::ast::ParamKindOrd;
|
use rustc_ast::ast::ParamKindOrd;
|
||||||
use rustc_errors::{struct_span_err, Applicability, Diagnostic, MultiSpan};
|
use rustc_errors::{struct_span_err, Applicability, Diagnostic, ErrorGuaranteed, MultiSpan};
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_hir::def::{DefKind, Res};
|
use rustc_hir::def::{DefKind, Res};
|
||||||
use rustc_hir::def_id::DefId;
|
use rustc_hir::def_id::DefId;
|
||||||
|
@ -26,7 +26,7 @@ fn generic_arg_mismatch_err(
|
||||||
param: &GenericParamDef,
|
param: &GenericParamDef,
|
||||||
possible_ordering_error: bool,
|
possible_ordering_error: bool,
|
||||||
help: Option<&str>,
|
help: Option<&str>,
|
||||||
) {
|
) -> ErrorGuaranteed {
|
||||||
let sess = tcx.sess;
|
let sess = tcx.sess;
|
||||||
let mut err = struct_span_err!(
|
let mut err = struct_span_err!(
|
||||||
sess,
|
sess,
|
||||||
|
@ -70,9 +70,9 @@ fn generic_arg_mismatch_err(
|
||||||
) => match path.res {
|
) => match path.res {
|
||||||
Res::Err => {
|
Res::Err => {
|
||||||
add_braces_suggestion(arg, &mut err);
|
add_braces_suggestion(arg, &mut err);
|
||||||
err.set_primary_message("unresolved item provided when a constant was expected")
|
return err
|
||||||
|
.set_primary_message("unresolved item provided when a constant was expected")
|
||||||
.emit();
|
.emit();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
Res::Def(DefKind::TyParam, src_def_id) => {
|
Res::Def(DefKind::TyParam, src_def_id) => {
|
||||||
if let Some(param_local_id) = param.def_id.as_local() {
|
if let Some(param_local_id) = param.def_id.as_local() {
|
||||||
|
@ -81,7 +81,7 @@ fn generic_arg_mismatch_err(
|
||||||
if param_type.is_suggestable(tcx, false) {
|
if param_type.is_suggestable(tcx, false) {
|
||||||
err.span_suggestion(
|
err.span_suggestion(
|
||||||
tcx.def_span(src_def_id),
|
tcx.def_span(src_def_id),
|
||||||
"consider changing this type parameter to be a `const` generic",
|
"consider changing this type parameter to a const parameter",
|
||||||
format!("const {}: {}", param_name, param_type),
|
format!("const {}: {}", param_name, param_type),
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
|
@ -137,7 +137,7 @@ fn generic_arg_mismatch_err(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
err.emit();
|
err.emit()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates the relevant generic argument substitutions
|
/// Creates the relevant generic argument substitutions
|
||||||
|
|
|
@ -49,12 +49,9 @@ error[E0747]: type provided when a constant was expected
|
||||||
--> $DIR/invalid-const-arguments.rs:10:19
|
--> $DIR/invalid-const-arguments.rs:10:19
|
||||||
|
|
|
|
||||||
LL | impl<N> Foo for B<N> {}
|
LL | impl<N> Foo for B<N> {}
|
||||||
| ^
|
| - ^
|
||||||
|
|
| |
|
||||||
help: consider changing this type parameter to be a `const` generic
|
| help: consider changing this type parameter to a const parameter: `const N: u8`
|
||||||
|
|
|
||||||
LL | impl<const N: u8> Foo for B<N> {}
|
|
||||||
| ~~~~~~~~~~~
|
|
||||||
|
|
||||||
error[E0747]: unresolved item provided when a constant was expected
|
error[E0747]: unresolved item provided when a constant was expected
|
||||||
--> $DIR/invalid-const-arguments.rs:14:32
|
--> $DIR/invalid-const-arguments.rs:14:32
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue