if !ctx.lifetime_allowed {
return;
}
+ let lp_string;
let param_lifetime = match (
&ctx.lifetime_syntax,
ctx.lifetime_param_syntax.as_ref().and_then(|lp| lp.lifetime()),
) {
(Some(lt), Some(lp)) if lp == lt.clone() => return,
- (Some(_), Some(lp)) => Some(lp.to_string()),
+ (Some(_), Some(lp)) => {
+ lp_string = lp.to_string();
+ Some(&lp_string)
+ }
_ => None,
};
ctx.scope.process_all_names(&mut |name, res| {
if let ScopeDef::GenericParam(hir::GenericParam::LifetimeParam(_)) = res {
- if param_lifetime != Some(name.to_string()) {
- acc.add_resolution(ctx, name.to_string(), &res);
+ let name = name.to_string();
+ if param_lifetime != Some(&name) {
+ acc.add_resolution(ctx, name, &res);
}
}
});
"#,
r#"
fn func<'lifetime>(foo: &'lifetime) {}
+"#,
+ );
+ cov_mark::check!(completes_if_lifetime_without_idents);
+ check_edit(
+ "'lifetime",
+ r#"
+fn func<'lifetime>(foo: &'$0) {}
+"#,
+ r#"
+fn func<'lifetime>(foo: &'lifetime) {}
"#,
);
}
);
}
+ #[test]
+ fn check_label_edit() {
+ check_edit(
+ "'label",
+ r#"
+fn foo() {
+ 'label: loop {
+ break '$0
+ }
+}
+"#,
+ r#"
+fn foo() {
+ 'label: loop {
+ break 'label
+ }
+}
+"#,
+ );
+ }
+
#[test]
fn complete_label_in_loop() {
check(