59 lines
2 KiB
Diff
59 lines
2 KiB
Diff
|
backported from
|
||
|
|
||
|
From 2efa106431e6fb15b73478f67e37cb307bac2be6 Mon Sep 17 00:00:00 2001
|
||
|
From: Simon Sapin <simon.sapin@exyr.org>
|
||
|
Date: Wed, 4 Jul 2018 22:18:36 +0200
|
||
|
Subject: [PATCH] Fix a lifetime bug uncovered by NLL, thanks @lqd
|
||
|
|
||
|
|
||
|
--- third_party/rust/url/src/lib.rs 2019-05-14 21:13:30.000000000 +0200
|
||
|
+++ third_party/rust/url/src/lib.rs 2019-05-14 21:13:30.000000000 +0200
|
||
|
@@ -1304,7 +1304,7 @@
|
||
|
self.serialization.push('?');
|
||
|
}
|
||
|
|
||
|
- let query = UrlQuery { url: self, fragment: fragment };
|
||
|
+ let query = UrlQuery { url: Some(self), fragment: fragment };
|
||
|
form_urlencoded::Serializer::for_suffix(query, query_start + "?".len())
|
||
|
}
|
||
|
|
||
|
@@ -2373,13 +2373,15 @@
|
||
|
/// Implementation detail of `Url::query_pairs_mut`. Typically not used directly.
|
||
|
#[derive(Debug)]
|
||
|
pub struct UrlQuery<'a> {
|
||
|
- url: &'a mut Url,
|
||
|
+ url: Option<&'a mut Url>,
|
||
|
fragment: Option<String>,
|
||
|
}
|
||
|
|
||
|
impl<'a> Drop for UrlQuery<'a> {
|
||
|
fn drop(&mut self) {
|
||
|
- self.url.restore_already_parsed_fragment(self.fragment.take())
|
||
|
+ if let Some(url) = self.url.take() {
|
||
|
+ url.restore_already_parsed_fragment(self.fragment.take())
|
||
|
+ }
|
||
|
}
|
||
|
}
|
||
|
|
||
|
--- third_party/rust/url/src/form_urlencoded.rs 2019-05-14 21:13:30.000000000 +0200
|
||
|
+++ third_party/rust/url/src/form_urlencoded.rs 2019-05-14 21:13:30.000000000 +0200
|
||
|
@@ -257,8 +257,16 @@
|
||
|
// * `Serializer` keeps its target in a private field
|
||
|
// * Unlike in other `Target` impls, `UrlQuery::finished` does not return `Self`.
|
||
|
impl<'a> Target for ::UrlQuery<'a> {
|
||
|
- fn as_mut_string(&mut self) -> &mut String { &mut self.url.serialization }
|
||
|
- fn finish(self) -> &'a mut ::Url { self.url }
|
||
|
+ fn as_mut_string(&mut self) -> &mut String {
|
||
|
+ &mut self.url.as_mut().unwrap().serialization
|
||
|
+ }
|
||
|
+
|
||
|
+ fn finish(mut self) -> &'a mut ::Url {
|
||
|
+ let url = self.url.take().unwrap();
|
||
|
+ url.restore_already_parsed_fragment(self.fragment.take());
|
||
|
+ url
|
||
|
+ }
|
||
|
+
|
||
|
type Finished = &'a mut ::Url;
|
||
|
}
|
||
|
|