mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-11-03 05:13:35 +00:00
Merge pull request #20192 from ChayimFriedman2/link-type-panic
Some checks are pending
metrics / build_metrics (push) Waiting to run
metrics / other_metrics (diesel-1.4.8) (push) Blocked by required conditions
metrics / other_metrics (hyper-0.14.18) (push) Blocked by required conditions
metrics / other_metrics (ripgrep-13.0.0) (push) Blocked by required conditions
metrics / other_metrics (self) (push) Blocked by required conditions
metrics / other_metrics (webrender-2022) (push) Blocked by required conditions
metrics / generate_final_metrics (push) Blocked by required conditions
rustdoc / rustdoc (push) Waiting to run
Some checks are pending
metrics / build_metrics (push) Waiting to run
metrics / other_metrics (diesel-1.4.8) (push) Blocked by required conditions
metrics / other_metrics (hyper-0.14.18) (push) Blocked by required conditions
metrics / other_metrics (ripgrep-13.0.0) (push) Blocked by required conditions
metrics / other_metrics (self) (push) Blocked by required conditions
metrics / other_metrics (webrender-2022) (push) Blocked by required conditions
metrics / generate_final_metrics (push) Blocked by required conditions
rustdoc / rustdoc (push) Waiting to run
fix: Fix a case where the link type was `None`
This commit is contained in:
commit
9a1fc3cdb8
2 changed files with 30 additions and 3 deletions
|
|
@ -505,7 +505,7 @@ fn map_links<'e>(
|
||||||
Event::End(Tag::Link(link_type, target, _)) => {
|
Event::End(Tag::Link(link_type, target, _)) => {
|
||||||
in_link = false;
|
in_link = false;
|
||||||
Event::End(Tag::Link(
|
Event::End(Tag::Link(
|
||||||
end_link_type.unwrap_or(link_type),
|
end_link_type.take().unwrap_or(link_type),
|
||||||
end_link_target.take().unwrap_or(target),
|
end_link_target.take().unwrap_or(target),
|
||||||
CowStr::Borrowed(""),
|
CowStr::Borrowed(""),
|
||||||
))
|
))
|
||||||
|
|
@ -514,7 +514,7 @@ fn map_links<'e>(
|
||||||
let (link_type, link_target_s, link_name) =
|
let (link_type, link_target_s, link_name) =
|
||||||
callback(&end_link_target.take().unwrap(), &s, range, end_link_type.unwrap());
|
callback(&end_link_target.take().unwrap(), &s, range, end_link_type.unwrap());
|
||||||
end_link_target = Some(CowStr::Boxed(link_target_s.into()));
|
end_link_target = Some(CowStr::Boxed(link_target_s.into()));
|
||||||
if !matches!(end_link_type, Some(LinkType::Autolink)) {
|
if !matches!(end_link_type, Some(LinkType::Autolink)) && link_type.is_some() {
|
||||||
end_link_type = link_type;
|
end_link_type = link_type;
|
||||||
}
|
}
|
||||||
Event::Text(CowStr::Boxed(link_name.into()))
|
Event::Text(CowStr::Boxed(link_name.into()))
|
||||||
|
|
@ -523,7 +523,7 @@ fn map_links<'e>(
|
||||||
let (link_type, link_target_s, link_name) =
|
let (link_type, link_target_s, link_name) =
|
||||||
callback(&end_link_target.take().unwrap(), &s, range, end_link_type.unwrap());
|
callback(&end_link_target.take().unwrap(), &s, range, end_link_type.unwrap());
|
||||||
end_link_target = Some(CowStr::Boxed(link_target_s.into()));
|
end_link_target = Some(CowStr::Boxed(link_target_s.into()));
|
||||||
if !matches!(end_link_type, Some(LinkType::Autolink)) {
|
if !matches!(end_link_type, Some(LinkType::Autolink)) && link_type.is_some() {
|
||||||
end_link_type = link_type;
|
end_link_type = link_type;
|
||||||
}
|
}
|
||||||
Event::Code(CowStr::Boxed(link_name.into()))
|
Event::Code(CowStr::Boxed(link_name.into()))
|
||||||
|
|
|
||||||
|
|
@ -10958,3 +10958,30 @@ fn bar$0() -> Foo {
|
||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn regression_20190() {
|
||||||
|
check(
|
||||||
|
r#"
|
||||||
|
struct Foo;
|
||||||
|
|
||||||
|
/// [`foo` bar](Foo).
|
||||||
|
fn has_docs$0() {}
|
||||||
|
"#,
|
||||||
|
expect.
|
||||||
|
"#]],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue