Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prohibit_generics: don't alloc error string if no error emitted #98305

Merged
merged 1 commit into from
Jun 24, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions compiler/rustc_typeck/src/astconv/mod.rs
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2111,6 +2111,16 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
extend: impl Fn(&mut DiagnosticBuilder<'tcx, ErrorGuaranteed>), extend: impl Fn(&mut DiagnosticBuilder<'tcx, ErrorGuaranteed>),
) -> bool { ) -> bool {
let args = segments.clone().flat_map(|segment| segment.args().args); 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 let types_and_spans: Vec<_> = segments
.clone() .clone()
.flat_map(|segment| { .flat_map(|segment| {
Expand Down Expand Up @@ -2147,15 +2157,6 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
[] => "this type".to_string(), [] => "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 arg_spans: Vec<Span> = args.map(|arg| arg.span()).collect();


let mut kinds = Vec::with_capacity(4); let mut kinds = Vec::with_capacity(4);
Expand Down