Skip to content

Commit f11e6f7

Browse files
committedJun 7, 2019
Fix issue with path segment lowering with const args
1 parent 7bb0a16 commit f11e6f7

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed
 

‎src/librustc/hir/lowering.rs

+9-8
Original file line numberDiff line numberDiff line change
@@ -2230,17 +2230,17 @@ impl<'a> LoweringContext<'a> {
22302230
.collect();
22312231
if expected_lifetimes > 0 && param_mode == ParamMode::Explicit {
22322232
let anon_lt_suggestion = vec!["'_"; expected_lifetimes].join(", ");
2233-
let no_ty_args = generic_args.args.len() == expected_lifetimes;
2233+
let no_non_lt_args = generic_args.args.len() == expected_lifetimes;
22342234
let no_bindings = generic_args.bindings.is_empty();
2235-
let (incl_angl_brckt, insertion_span, suggestion) = if no_ty_args && no_bindings {
2235+
let (incl_angl_brckt, insertion_sp, suggestion) = if no_non_lt_args && no_bindings {
22362236
// If there are no (non-implicit) generic args or associated type
22372237
// bindings, our suggestion includes the angle brackets.
22382238
(true, path_span.shrink_to_hi(), format!("<{}>", anon_lt_suggestion))
22392239
} else {
22402240
// Otherwise (sorry, this is kind of gross) we need to infer the
22412241
// place to splice in the `'_, ` from the generics that do exist.
22422242
let first_generic_span = first_generic_span
2243-
.expect("already checked that type args or bindings exist");
2243+
.expect("already checked that non-lifetime args or bindings exist");
22442244
(false, first_generic_span.shrink_to_lo(), format!("{}, ", anon_lt_suggestion))
22452245
};
22462246
match self.anonymous_lifetime_mode {
@@ -2263,7 +2263,7 @@ impl<'a> LoweringContext<'a> {
22632263
expected_lifetimes,
22642264
path_span,
22652265
incl_angl_brckt,
2266-
insertion_span,
2266+
insertion_sp,
22672267
suggestion,
22682268
);
22692269
err.emit();
@@ -2280,7 +2280,7 @@ impl<'a> LoweringContext<'a> {
22802280
expected_lifetimes,
22812281
path_span,
22822282
incl_angl_brckt,
2283-
insertion_span,
2283+
insertion_sp,
22842284
suggestion,
22852285
)
22862286
);
@@ -2316,9 +2316,10 @@ impl<'a> LoweringContext<'a> {
23162316
mut itctx: ImplTraitContext<'_>,
23172317
) -> (hir::GenericArgs, bool) {
23182318
let &AngleBracketedArgs { ref args, ref constraints, .. } = data;
2319-
let has_types = args.iter().any(|arg| match arg {
2319+
let has_non_lt_args = args.iter().any(|arg| match arg {
2320+
ast::GenericArg::Lifetime(_) => false,
23202321
ast::GenericArg::Type(_) => true,
2321-
_ => false,
2322+
ast::GenericArg::Const(_) => true,
23222323
});
23232324
(
23242325
hir::GenericArgs {
@@ -2328,7 +2329,7 @@ impl<'a> LoweringContext<'a> {
23282329
.collect(),
23292330
parenthesized: false,
23302331
},
2331-
!has_types && param_mode == ParamMode::Optional
2332+
!has_non_lt_args && param_mode == ParamMode::Optional
23322333
)
23332334
}
23342335

0 commit comments

Comments
 (0)