review comments
This commit is contained in:
parent
ad63f907e9
commit
cd8cfbfb09
7 changed files with 47 additions and 59 deletions
|
@ -1816,7 +1816,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||||
// work for the `enum`, instead of just looking if it takes *any*.
|
// work for the `enum`, instead of just looking if it takes *any*.
|
||||||
err.span_suggestion_verbose(
|
err.span_suggestion_verbose(
|
||||||
args_span,
|
args_span,
|
||||||
&format!("{type_name} doesn't have type parameters"),
|
&format!("{type_name} doesn't have generic parameters"),
|
||||||
String::new(),
|
String::new(),
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
|
@ -2115,20 +2115,15 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||||
if segment.args().args.is_empty() {
|
if segment.args().args.is_empty() {
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
let mut desc = res.descr();
|
|
||||||
if desc == "unresolved item" {
|
|
||||||
desc = "this type";
|
|
||||||
};
|
|
||||||
|
|
||||||
let name = match res {
|
|
||||||
Res::PrimTy(ty) => Some(ty.name()),
|
|
||||||
Res::Def(_, def_id) => self.tcx().opt_item_name(def_id),
|
|
||||||
_ => None,
|
|
||||||
};
|
|
||||||
Some((
|
Some((
|
||||||
match name {
|
match res {
|
||||||
Some(ty) => format!("{desc} `{ty}`"),
|
Res::PrimTy(ty) => format!("{} `{}`", res.descr(), ty.name()),
|
||||||
None => desc.to_string(),
|
Res::Def(_, def_id)
|
||||||
|
if let Some(name) = self.tcx().opt_item_name(def_id) => {
|
||||||
|
format!("{} `{name}`", res.descr())
|
||||||
|
}
|
||||||
|
Res::Err => "this type".to_string(),
|
||||||
|
_ => res.descr().to_string(),
|
||||||
},
|
},
|
||||||
segment.ident.span,
|
segment.ident.span,
|
||||||
))
|
))
|
||||||
|
@ -2158,33 +2153,26 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||||
});
|
});
|
||||||
let mut emitted = false;
|
let mut emitted = false;
|
||||||
if lt || ty || ct || inf {
|
if lt || ty || ct || inf {
|
||||||
let arg_spans: Vec<Span> = args
|
let arg_spans: Vec<Span> = args.map(|arg| arg.span()).collect();
|
||||||
.map(|arg| match arg {
|
|
||||||
hir::GenericArg::Lifetime(lt) => lt.span,
|
|
||||||
hir::GenericArg::Type(ty) => ty.span,
|
|
||||||
hir::GenericArg::Const(ct) => ct.span,
|
|
||||||
hir::GenericArg::Infer(inf) => inf.span,
|
|
||||||
})
|
|
||||||
.collect();
|
|
||||||
|
|
||||||
let mut types = Vec::with_capacity(4);
|
let mut kinds = Vec::with_capacity(4);
|
||||||
if lt {
|
if lt {
|
||||||
types.push("lifetime");
|
kinds.push("lifetime");
|
||||||
}
|
}
|
||||||
if ty {
|
if ty {
|
||||||
types.push("type");
|
kinds.push("type");
|
||||||
}
|
}
|
||||||
if ct {
|
if ct {
|
||||||
types.push("const");
|
kinds.push("const");
|
||||||
}
|
}
|
||||||
if inf {
|
if inf {
|
||||||
types.push("generic");
|
kinds.push("generic");
|
||||||
}
|
}
|
||||||
let (kind, s) = match types[..] {
|
let (kind, s) = match kinds[..] {
|
||||||
[.., _, last] => (
|
[.., _, last] => (
|
||||||
format!(
|
format!(
|
||||||
"{} and {last}",
|
"{} and {last}",
|
||||||
types[..types.len() - 1]
|
kinds[..kinds.len() - 1]
|
||||||
.iter()
|
.iter()
|
||||||
.map(|&x| x)
|
.map(|&x| x)
|
||||||
.intersperse(", ")
|
.intersperse(", ")
|
||||||
|
@ -2464,7 +2452,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||||
);
|
);
|
||||||
let mut postfix = "";
|
let mut postfix = "";
|
||||||
if generics == 0 {
|
if generics == 0 {
|
||||||
postfix = ", which doesn't have type parameters";
|
postfix = ", which doesn't have generic parameters";
|
||||||
}
|
}
|
||||||
span.push_span_label(
|
span.push_span_label(
|
||||||
t_sp,
|
t_sp,
|
||||||
|
@ -2557,7 +2545,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||||
if let Some(args) = segment.args {
|
if let Some(args) = segment.args {
|
||||||
err.span_suggestion_verbose(
|
err.span_suggestion_verbose(
|
||||||
segment.ident.span.shrink_to_hi().to(args.span_ext),
|
segment.ident.span.shrink_to_hi().to(args.span_ext),
|
||||||
&format!("primitive type `{name}` doesn't have type parameters"),
|
&format!("primitive type `{name}` doesn't have generic parameters"),
|
||||||
String::new(),
|
String::new(),
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
|
|
|
@ -6,7 +6,7 @@ LL | type X = u32<i32>;
|
||||||
| |
|
| |
|
||||||
| not allowed on this
|
| not allowed on this
|
||||||
|
|
|
|
||||||
help: primitive type `u32` doesn't have type parameters
|
help: primitive type `u32` doesn't have generic parameters
|
||||||
|
|
|
|
||||||
LL - type X = u32<i32>;
|
LL - type X = u32<i32>;
|
||||||
LL + type X = u32;
|
LL + type X = u32;
|
||||||
|
|
|
@ -6,7 +6,7 @@ LL | type X = u32<'static>;
|
||||||
| |
|
| |
|
||||||
| not allowed on this
|
| not allowed on this
|
||||||
|
|
|
|
||||||
help: primitive type `u32` doesn't have type parameters
|
help: primitive type `u32` doesn't have generic parameters
|
||||||
|
|
|
|
||||||
LL - type X = u32<'static>;
|
LL - type X = u32<'static>;
|
||||||
LL + type X = u32;
|
LL + type X = u32;
|
||||||
|
|
|
@ -42,7 +42,7 @@ note: `Self` is of type `S`
|
||||||
--> $DIR/struct-path-self.rs:1:8
|
--> $DIR/struct-path-self.rs:1:8
|
||||||
|
|
|
|
||||||
LL | struct S;
|
LL | struct S;
|
||||||
| ^ `Self` corresponds to this type, which doesn't have type parameters
|
| ^ `Self` corresponds to this type, which doesn't have generic parameters
|
||||||
...
|
...
|
||||||
LL | impl Tr for S {
|
LL | impl Tr for S {
|
||||||
| ------------- `Self` is on type `S` in this `impl`
|
| ------------- `Self` is on type `S` in this `impl`
|
||||||
|
@ -64,7 +64,7 @@ note: `Self` is of type `S`
|
||||||
--> $DIR/struct-path-self.rs:1:8
|
--> $DIR/struct-path-self.rs:1:8
|
||||||
|
|
|
|
||||||
LL | struct S;
|
LL | struct S;
|
||||||
| ^ `Self` corresponds to this type, which doesn't have type parameters
|
| ^ `Self` corresponds to this type, which doesn't have generic parameters
|
||||||
...
|
...
|
||||||
LL | impl S {
|
LL | impl S {
|
||||||
| ------ `Self` is on type `S` in this `impl`
|
| ------ `Self` is on type `S` in this `impl`
|
||||||
|
|
|
@ -38,7 +38,7 @@ LL | 0: u8(ţ
|
||||||
| |
|
| |
|
||||||
| not allowed on this
|
| not allowed on this
|
||||||
|
|
|
|
||||||
help: primitive type `u8` doesn't have type parameters
|
help: primitive type `u8` doesn't have generic parameters
|
||||||
|
|
|
|
||||||
LL - 0: u8(ţ
|
LL - 0: u8(ţ
|
||||||
LL + 0: u8
|
LL + 0: u8
|
||||||
|
|
|
@ -6,7 +6,7 @@ LL | let _x: isize<isize>;
|
||||||
| |
|
| |
|
||||||
| not allowed on this
|
| not allowed on this
|
||||||
|
|
|
|
||||||
help: primitive type `isize` doesn't have type parameters
|
help: primitive type `isize` doesn't have generic parameters
|
||||||
|
|
|
|
||||||
LL - let _x: isize<isize>;
|
LL - let _x: isize<isize>;
|
||||||
LL + let _x: isize;
|
LL + let _x: isize;
|
||||||
|
@ -20,7 +20,7 @@ LL | let _x: i8<isize>;
|
||||||
| |
|
| |
|
||||||
| not allowed on this
|
| not allowed on this
|
||||||
|
|
|
|
||||||
help: primitive type `i8` doesn't have type parameters
|
help: primitive type `i8` doesn't have generic parameters
|
||||||
|
|
|
|
||||||
LL - let _x: i8<isize>;
|
LL - let _x: i8<isize>;
|
||||||
LL + let _x: i8;
|
LL + let _x: i8;
|
||||||
|
@ -34,7 +34,7 @@ LL | let _x: i16<isize>;
|
||||||
| |
|
| |
|
||||||
| not allowed on this
|
| not allowed on this
|
||||||
|
|
|
|
||||||
help: primitive type `i16` doesn't have type parameters
|
help: primitive type `i16` doesn't have generic parameters
|
||||||
|
|
|
|
||||||
LL - let _x: i16<isize>;
|
LL - let _x: i16<isize>;
|
||||||
LL + let _x: i16;
|
LL + let _x: i16;
|
||||||
|
@ -48,7 +48,7 @@ LL | let _x: i32<isize>;
|
||||||
| |
|
| |
|
||||||
| not allowed on this
|
| not allowed on this
|
||||||
|
|
|
|
||||||
help: primitive type `i32` doesn't have type parameters
|
help: primitive type `i32` doesn't have generic parameters
|
||||||
|
|
|
|
||||||
LL - let _x: i32<isize>;
|
LL - let _x: i32<isize>;
|
||||||
LL + let _x: i32;
|
LL + let _x: i32;
|
||||||
|
@ -62,7 +62,7 @@ LL | let _x: i64<isize>;
|
||||||
| |
|
| |
|
||||||
| not allowed on this
|
| not allowed on this
|
||||||
|
|
|
|
||||||
help: primitive type `i64` doesn't have type parameters
|
help: primitive type `i64` doesn't have generic parameters
|
||||||
|
|
|
|
||||||
LL - let _x: i64<isize>;
|
LL - let _x: i64<isize>;
|
||||||
LL + let _x: i64;
|
LL + let _x: i64;
|
||||||
|
@ -76,7 +76,7 @@ LL | let _x: usize<isize>;
|
||||||
| |
|
| |
|
||||||
| not allowed on this
|
| not allowed on this
|
||||||
|
|
|
|
||||||
help: primitive type `usize` doesn't have type parameters
|
help: primitive type `usize` doesn't have generic parameters
|
||||||
|
|
|
|
||||||
LL - let _x: usize<isize>;
|
LL - let _x: usize<isize>;
|
||||||
LL + let _x: usize;
|
LL + let _x: usize;
|
||||||
|
@ -90,7 +90,7 @@ LL | let _x: u8<isize>;
|
||||||
| |
|
| |
|
||||||
| not allowed on this
|
| not allowed on this
|
||||||
|
|
|
|
||||||
help: primitive type `u8` doesn't have type parameters
|
help: primitive type `u8` doesn't have generic parameters
|
||||||
|
|
|
|
||||||
LL - let _x: u8<isize>;
|
LL - let _x: u8<isize>;
|
||||||
LL + let _x: u8;
|
LL + let _x: u8;
|
||||||
|
@ -104,7 +104,7 @@ LL | let _x: u16<isize>;
|
||||||
| |
|
| |
|
||||||
| not allowed on this
|
| not allowed on this
|
||||||
|
|
|
|
||||||
help: primitive type `u16` doesn't have type parameters
|
help: primitive type `u16` doesn't have generic parameters
|
||||||
|
|
|
|
||||||
LL - let _x: u16<isize>;
|
LL - let _x: u16<isize>;
|
||||||
LL + let _x: u16;
|
LL + let _x: u16;
|
||||||
|
@ -118,7 +118,7 @@ LL | let _x: u32<isize>;
|
||||||
| |
|
| |
|
||||||
| not allowed on this
|
| not allowed on this
|
||||||
|
|
|
|
||||||
help: primitive type `u32` doesn't have type parameters
|
help: primitive type `u32` doesn't have generic parameters
|
||||||
|
|
|
|
||||||
LL - let _x: u32<isize>;
|
LL - let _x: u32<isize>;
|
||||||
LL + let _x: u32;
|
LL + let _x: u32;
|
||||||
|
@ -132,7 +132,7 @@ LL | let _x: u64<isize>;
|
||||||
| |
|
| |
|
||||||
| not allowed on this
|
| not allowed on this
|
||||||
|
|
|
|
||||||
help: primitive type `u64` doesn't have type parameters
|
help: primitive type `u64` doesn't have generic parameters
|
||||||
|
|
|
|
||||||
LL - let _x: u64<isize>;
|
LL - let _x: u64<isize>;
|
||||||
LL + let _x: u64;
|
LL + let _x: u64;
|
||||||
|
@ -146,7 +146,7 @@ LL | let _x: char<isize>;
|
||||||
| |
|
| |
|
||||||
| not allowed on this
|
| not allowed on this
|
||||||
|
|
|
|
||||||
help: primitive type `char` doesn't have type parameters
|
help: primitive type `char` doesn't have generic parameters
|
||||||
|
|
|
|
||||||
LL - let _x: char<isize>;
|
LL - let _x: char<isize>;
|
||||||
LL + let _x: char;
|
LL + let _x: char;
|
||||||
|
@ -160,7 +160,7 @@ LL | let _x: isize<'static>;
|
||||||
| |
|
| |
|
||||||
| not allowed on this
|
| not allowed on this
|
||||||
|
|
|
|
||||||
help: primitive type `isize` doesn't have type parameters
|
help: primitive type `isize` doesn't have generic parameters
|
||||||
|
|
|
|
||||||
LL - let _x: isize<'static>;
|
LL - let _x: isize<'static>;
|
||||||
LL + let _x: isize;
|
LL + let _x: isize;
|
||||||
|
@ -174,7 +174,7 @@ LL | let _x: i8<'static>;
|
||||||
| |
|
| |
|
||||||
| not allowed on this
|
| not allowed on this
|
||||||
|
|
|
|
||||||
help: primitive type `i8` doesn't have type parameters
|
help: primitive type `i8` doesn't have generic parameters
|
||||||
|
|
|
|
||||||
LL - let _x: i8<'static>;
|
LL - let _x: i8<'static>;
|
||||||
LL + let _x: i8;
|
LL + let _x: i8;
|
||||||
|
@ -188,7 +188,7 @@ LL | let _x: i16<'static>;
|
||||||
| |
|
| |
|
||||||
| not allowed on this
|
| not allowed on this
|
||||||
|
|
|
|
||||||
help: primitive type `i16` doesn't have type parameters
|
help: primitive type `i16` doesn't have generic parameters
|
||||||
|
|
|
|
||||||
LL - let _x: i16<'static>;
|
LL - let _x: i16<'static>;
|
||||||
LL + let _x: i16;
|
LL + let _x: i16;
|
||||||
|
@ -202,7 +202,7 @@ LL | let _x: i32<'static>;
|
||||||
| |
|
| |
|
||||||
| not allowed on this
|
| not allowed on this
|
||||||
|
|
|
|
||||||
help: primitive type `i32` doesn't have type parameters
|
help: primitive type `i32` doesn't have generic parameters
|
||||||
|
|
|
|
||||||
LL - let _x: i32<'static>;
|
LL - let _x: i32<'static>;
|
||||||
LL + let _x: i32;
|
LL + let _x: i32;
|
||||||
|
@ -216,7 +216,7 @@ LL | let _x: i64<'static>;
|
||||||
| |
|
| |
|
||||||
| not allowed on this
|
| not allowed on this
|
||||||
|
|
|
|
||||||
help: primitive type `i64` doesn't have type parameters
|
help: primitive type `i64` doesn't have generic parameters
|
||||||
|
|
|
|
||||||
LL - let _x: i64<'static>;
|
LL - let _x: i64<'static>;
|
||||||
LL + let _x: i64;
|
LL + let _x: i64;
|
||||||
|
@ -230,7 +230,7 @@ LL | let _x: usize<'static>;
|
||||||
| |
|
| |
|
||||||
| not allowed on this
|
| not allowed on this
|
||||||
|
|
|
|
||||||
help: primitive type `usize` doesn't have type parameters
|
help: primitive type `usize` doesn't have generic parameters
|
||||||
|
|
|
|
||||||
LL - let _x: usize<'static>;
|
LL - let _x: usize<'static>;
|
||||||
LL + let _x: usize;
|
LL + let _x: usize;
|
||||||
|
@ -244,7 +244,7 @@ LL | let _x: u8<'static>;
|
||||||
| |
|
| |
|
||||||
| not allowed on this
|
| not allowed on this
|
||||||
|
|
|
|
||||||
help: primitive type `u8` doesn't have type parameters
|
help: primitive type `u8` doesn't have generic parameters
|
||||||
|
|
|
|
||||||
LL - let _x: u8<'static>;
|
LL - let _x: u8<'static>;
|
||||||
LL + let _x: u8;
|
LL + let _x: u8;
|
||||||
|
@ -258,7 +258,7 @@ LL | let _x: u16<'static>;
|
||||||
| |
|
| |
|
||||||
| not allowed on this
|
| not allowed on this
|
||||||
|
|
|
|
||||||
help: primitive type `u16` doesn't have type parameters
|
help: primitive type `u16` doesn't have generic parameters
|
||||||
|
|
|
|
||||||
LL - let _x: u16<'static>;
|
LL - let _x: u16<'static>;
|
||||||
LL + let _x: u16;
|
LL + let _x: u16;
|
||||||
|
@ -272,7 +272,7 @@ LL | let _x: u32<'static>;
|
||||||
| |
|
| |
|
||||||
| not allowed on this
|
| not allowed on this
|
||||||
|
|
|
|
||||||
help: primitive type `u32` doesn't have type parameters
|
help: primitive type `u32` doesn't have generic parameters
|
||||||
|
|
|
|
||||||
LL - let _x: u32<'static>;
|
LL - let _x: u32<'static>;
|
||||||
LL + let _x: u32;
|
LL + let _x: u32;
|
||||||
|
@ -286,7 +286,7 @@ LL | let _x: u64<'static>;
|
||||||
| |
|
| |
|
||||||
| not allowed on this
|
| not allowed on this
|
||||||
|
|
|
|
||||||
help: primitive type `u64` doesn't have type parameters
|
help: primitive type `u64` doesn't have generic parameters
|
||||||
|
|
|
|
||||||
LL - let _x: u64<'static>;
|
LL - let _x: u64<'static>;
|
||||||
LL + let _x: u64;
|
LL + let _x: u64;
|
||||||
|
@ -300,7 +300,7 @@ LL | let _x: char<'static>;
|
||||||
| |
|
| |
|
||||||
| not allowed on this
|
| not allowed on this
|
||||||
|
|
|
|
||||||
help: primitive type `char` doesn't have type parameters
|
help: primitive type `char` doesn't have generic parameters
|
||||||
|
|
|
|
||||||
LL - let _x: char<'static>;
|
LL - let _x: char<'static>;
|
||||||
LL + let _x: char;
|
LL + let _x: char;
|
||||||
|
|
|
@ -6,7 +6,7 @@ LL | let x: usize<foo>;
|
||||||
| |
|
| |
|
||||||
| not allowed on this
|
| not allowed on this
|
||||||
|
|
|
|
||||||
help: primitive type `usize` doesn't have type parameters
|
help: primitive type `usize` doesn't have generic parameters
|
||||||
|
|
|
|
||||||
LL - let x: usize<foo>;
|
LL - let x: usize<foo>;
|
||||||
LL + let x: usize;
|
LL + let x: usize;
|
||||||
|
|
Loading…
Add table
Reference in a new issue