mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-05 19:58:32 +00:00
Rollup merge of #98305 - klensy:no-err-alloc, r=compiler-errors
prohibit_generics: don't alloc error string if no error emitted Noticed unreaded allocs in DHAT.
This commit is contained in:
commit
0ed2feca61
@ -2111,6 +2111,16 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||
extend: impl Fn(&mut DiagnosticBuilder<'tcx, ErrorGuaranteed>),
|
||||
) -> bool {
|
||||
let args = segments.clone().flat_map(|segment| segment.args().args);
|
||||
|
||||
let (lt, ty, ct, inf) =
|
||||
args.clone().fold((false, false, false, false), |(lt, ty, ct, inf), arg| match arg {
|
||||
hir::GenericArg::Lifetime(_) => (true, ty, ct, inf),
|
||||
hir::GenericArg::Type(_) => (lt, true, ct, inf),
|
||||
hir::GenericArg::Const(_) => (lt, ty, true, inf),
|
||||
hir::GenericArg::Infer(_) => (lt, ty, ct, true),
|
||||
});
|
||||
let mut emitted = false;
|
||||
if lt || ty || ct || inf {
|
||||
let types_and_spans: Vec<_> = segments
|
||||
.clone()
|
||||
.flat_map(|segment| {
|
||||
@ -2147,15 +2157,6 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||
[] => "this type".to_string(),
|
||||
};
|
||||
|
||||
let (lt, ty, ct, inf) =
|
||||
args.clone().fold((false, false, false, false), |(lt, ty, ct, inf), arg| match arg {
|
||||
hir::GenericArg::Lifetime(_) => (true, ty, ct, inf),
|
||||
hir::GenericArg::Type(_) => (lt, true, ct, inf),
|
||||
hir::GenericArg::Const(_) => (lt, ty, true, inf),
|
||||
hir::GenericArg::Infer(_) => (lt, ty, ct, true),
|
||||
});
|
||||
let mut emitted = false;
|
||||
if lt || ty || ct || inf {
|
||||
let arg_spans: Vec<Span> = args.map(|arg| arg.span()).collect();
|
||||
|
||||
let mut kinds = Vec::with_capacity(4);
|
||||
|
Loading…
Reference in New Issue
Block a user