Commit b731964
authored
Rollup merge of rust-lang#69458 - Luro02:master, r=GuillaumeGomez,ollie27
improve folder name for persistent doc tests
This partially fixes rust-lang#69411 by using the entire path as folder name, but I do not know how to deal with the proc-macro problem, where a doc test is forwarded to multiple generated functions, which have the same line for the doc test (origin).
For example
```rust
#[derive(ShortHand)]
pub struct ExtXMedia {
/// The [`MediaType`] associated with this tag.
///
/// # Example
///
-> /// ``` <- this line is given to `run_test`
/// # use hls_m3u8::tags::ExtXMedia;
/// use hls_m3u8::types::MediaType;
///
/// let mut media = ExtXMedia::new(MediaType::Audio, "ag1", "english audio channel");
///
/// media.set_media_type(MediaType::Video);
///
/// assert_eq!(media.media_type(), MediaType::Video);
/// ```
///
/// # Note
///
/// This attribute is required.
#[shorthand(enable(copy))]
media_type: MediaType,
// the rest of the fields are omitted
}
```
and my proc macro generates
```rust
#[allow(dead_code)]
impl ExtXMedia {
/// The [`MediaType`] associated with this tag.
///
/// # Example
///
/// ```
/// # use hls_m3u8::tags::ExtXMedia;
/// use hls_m3u8::types::MediaType;
///
/// let mut media = ExtXMedia::new(MediaType::Audio, "ag1", "english audio channel");
///
/// media.set_media_type(MediaType::Video);
///
/// assert_eq!(media.media_type(), MediaType::Video);
/// ```
///
/// # Note
///
/// This attribute is required.
#[inline(always)]
#[must_use]
pub fn media_type(&self) -> MediaType {
struct _AssertCopy
where
MediaType: ::std::marker::Copy;
self.media_type
}
/// The [`MediaType`] associated with this tag.
///
/// # Example
///
/// ```
/// # use hls_m3u8::tags::ExtXMedia;
/// use hls_m3u8::types::MediaType;
///
/// let mut media = ExtXMedia::new(MediaType::Audio, "ag1", "english audio channel");
///
/// media.set_media_type(MediaType::Video);
///
/// assert_eq!(media.media_type(), MediaType::Video);
/// ```
///
/// # Note
///
/// This attribute is required.
#[inline(always)]
pub fn set_media_type<VALUE: ::std::convert::Into<MediaType>>(
&mut self,
value: VALUE,
) -> &mut Self {
self.media_type = value.into();
self
}
}
```
rustdoc then executes both tests with the same line (the line from the example above the field -> 2 different tests have the same name). We need a way to differentiate between the two tests generated by the proc-macro, so that they do not cause threading issues.1 file changed
+63
-40
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| |||
190 | 191 | | |
191 | 192 | | |
192 | 193 | | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
193 | 208 | | |
194 | 209 | | |
195 | 210 | | |
196 | | - | |
197 | 211 | | |
198 | 212 | | |
199 | 213 | | |
| |||
206 | 220 | | |
207 | 221 | | |
208 | 222 | | |
| 223 | + | |
| 224 | + | |
209 | 225 | | |
210 | 226 | | |
211 | 227 | | |
212 | | - | |
213 | | - | |
214 | | - | |
215 | | - | |
216 | | - | |
217 | | - | |
218 | | - | |
219 | | - | |
220 | | - | |
221 | | - | |
222 | | - | |
223 | | - | |
224 | | - | |
225 | | - | |
226 | | - | |
227 | | - | |
228 | | - | |
229 | | - | |
230 | | - | |
231 | | - | |
232 | | - | |
233 | | - | |
234 | | - | |
235 | | - | |
236 | | - | |
237 | | - | |
238 | | - | |
239 | | - | |
240 | | - | |
241 | | - | |
242 | | - | |
243 | | - | |
244 | | - | |
245 | | - | |
246 | | - | |
247 | | - | |
248 | | - | |
249 | | - | |
250 | 228 | | |
251 | 229 | | |
252 | 230 | | |
| |||
639 | 617 | | |
640 | 618 | | |
641 | 619 | | |
| 620 | + | |
642 | 621 | | |
643 | 622 | | |
644 | 623 | | |
| |||
662 | 641 | | |
663 | 642 | | |
664 | 643 | | |
| 644 | + | |
665 | 645 | | |
666 | 646 | | |
667 | 647 | | |
| |||
705 | 685 | | |
706 | 686 | | |
707 | 687 | | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
708 | 730 | | |
709 | 731 | | |
710 | 732 | | |
| |||
723 | 745 | | |
724 | 746 | | |
725 | 747 | | |
726 | | - | |
727 | 748 | | |
728 | 749 | | |
729 | 750 | | |
| |||
736 | 757 | | |
737 | 758 | | |
738 | 759 | | |
| 760 | + | |
| 761 | + | |
739 | 762 | | |
740 | 763 | | |
741 | 764 | | |
| |||
0 commit comments