1 //! Generated file, do not edit by hand, see `xtask/src/codegen`
3 use super::check_doc_test;
6 fn doctest_add_explicit_type() {
23 fn doctest_add_hash() {
40 fn doctest_add_impl_default_members() {
42 "add_impl_default_members",
74 fn doctest_add_impl_missing_members() {
76 "add_impl_missing_members",
84 impl Trait<u32> for () {$0
95 impl Trait<u32> for () {
98 fn foo(&self) -> u32 {
107 fn doctest_add_lifetime_to_type() {
109 "add_lifetime_to_type",
126 fn doctest_add_turbo_fish() {
130 fn make<T>() -> T { todo!() }
136 fn make<T>() -> T { todo!() }
138 let x = make::<${0:_}>();
145 fn doctest_apply_demorgan() {
150 if x != 4 ||$0 y < 3.14 {}
155 if !(x == 4 && !(y < 3.14)) {}
162 fn doctest_auto_import() {
167 let map = HashMap$0::new();
169 pub mod std { pub mod collections { pub struct HashMap { } } }
172 use std::collections::HashMap;
175 let map = HashMap::new();
177 pub mod std { pub mod collections { pub struct HashMap { } } }
183 fn doctest_change_visibility() {
190 pub(crate) fn frobnicate() {}
196 fn doctest_convert_integer_literal() {
198 "convert_integer_literal",
203 const _: i32 = 0b1010;
209 fn doctest_convert_iter_for_each_to_for() {
211 "convert_iter_for_each_to_for",
213 //- /lib.rs crate:core
214 pub mod iter { pub mod traits { pub mod iterator { pub trait Iterator {} } } }
216 impl self::iter::traits::iterator::Iterator for SomeIter {}
217 //- /lib.rs crate:main deps:core
221 iter.for_each$0(|(x, y)| {
222 println!("x: {}, y: {}", x, y);
231 println!("x: {}, y: {}", x, y);
239 fn doctest_convert_to_guarded_return() {
241 "convert_to_guarded_return",
263 fn doctest_expand_glob_import() {
265 "expand_glob_import",
274 fn qux(bar: Bar, baz: Baz) {}
284 fn qux(bar: Bar, baz: Baz) {}
290 fn doctest_extract_function() {
308 fn $0fun_name(n: i32) {
317 fn doctest_extract_struct_from_enum_variant() {
319 "extract_struct_from_enum_variant",
321 enum A { $0One(u32, u32) }
324 struct One(pub u32, pub u32);
332 fn doctest_extract_variable() {
342 let $0var_name = (1 + 2);
350 fn doctest_fill_match_arms() {
354 enum Action { Move { distance: u32 }, Stop }
356 fn handle(action: Action) {
363 enum Action { Move { distance: u32 }, Stop }
365 fn handle(action: Action) {
367 $0Action::Move { distance } => {}
376 fn doctest_fix_visibility() {
389 $0pub(crate) fn frobnicate() {}
399 fn doctest_flip_binexpr() {
416 fn doctest_flip_comma() {
433 fn doctest_flip_trait_bound() {
437 fn foo<T: Clone +$0 Copy>() { }
440 fn foo<T: Copy + Clone>() { }
446 fn doctest_generate_default_from_enum_variant() {
448 "generate_default_from_enum_variant",
463 impl Default for Version {
464 fn default() -> Self {
473 fn doctest_generate_default_from_new() {
475 "generate_default_from_new",
477 struct Example { _inner: () }
480 pub fn n$0ew() -> Self {
486 struct Example { _inner: () }
489 pub fn new() -> Self {
494 impl Default for Example {
495 fn default() -> Self {
504 fn doctest_generate_derive() {
524 fn doctest_generate_enum_as_method() {
526 "generate_enum_as_method",
540 fn as_text(&self) -> Option<&String> {
541 if let Self::Text(v) = self {
553 fn doctest_generate_enum_is_method() {
555 "generate_enum_is_method",
571 /// Returns `true` if the version is [`Minor`].
572 fn is_minor(&self) -> bool {
573 matches!(self, Self::Minor)
581 fn doctest_generate_enum_try_into_method() {
583 "generate_enum_try_into_method",
597 fn try_into_text(self) -> Result<String, Self> {
598 if let Self::Text(v) = self {
610 fn doctest_generate_from_impl_for_enum() {
612 "generate_from_impl_for_enum",
614 enum A { $0One(u32) }
619 impl From<u32> for A {
620 fn from(v: u32) -> Self {
629 fn doctest_generate_function() {
634 fn baz() -> Baz { Baz }
642 fn baz() -> Baz { Baz }
647 fn bar(arg: &str, baz: Baz) ${0:-> ()} {
656 fn doctest_generate_getter() {
670 /// Get a reference to the person's name.
671 fn name(&self) -> &String {
680 fn doctest_generate_getter_mut() {
682 "generate_getter_mut",
694 /// Get a mutable reference to the person's name.
695 fn name_mut(&mut self) -> &mut String {
704 fn doctest_generate_impl() {
708 struct Ctx<T: Clone> {
713 struct Ctx<T: Clone> {
717 impl<T: Clone> Ctx<T> {
725 fn doctest_generate_is_empty_from_len() {
727 "generate_is_empty_from_len",
729 struct MyStruct { data: Vec<String> }
732 p$0ub fn len(&self) -> usize {
738 struct MyStruct { data: Vec<String> }
741 pub fn len(&self) -> usize {
745 pub fn is_empty(&self) -> bool {
754 fn doctest_generate_new() {
758 struct Ctx<T: Clone> {
763 struct Ctx<T: Clone> {
767 impl<T: Clone> Ctx<T> {
768 fn $0new(data: T) -> Self { Self { data } }
775 fn doctest_generate_setter() {
789 /// Set the person's name.
790 fn set_name(&mut self, name: String) {
799 fn doctest_infer_function_return_type() {
801 "infer_function_return_type",
806 fn foo() -> i32 { 42i32 }
812 fn doctest_inline_function() {
816 fn add(a: u32, b: u32) -> u32 { a + b }
822 fn add(a: u32, b: u32) -> u32 { a + b }
835 fn doctest_inline_local_variable() {
837 "inline_local_variable",
853 fn doctest_introduce_named_lifetime() {
855 "introduce_named_lifetime",
858 fn node(self) -> &SyntaxNode {
860 Cursor::Replace(node) | Cursor::Before(node) => node,
866 impl<'a> Cursor<'a> {
867 fn node(self) -> &SyntaxNode {
869 Cursor::Replace(node) | Cursor::Before(node) => node,
878 fn doctest_invert_if() {
883 if$0 !y { A } else { B }
888 if y { B } else { A }
895 fn doctest_make_raw_string() {
912 fn doctest_make_usual_string() {
917 r#"Hello,$0 "World!""#;
929 fn doctest_merge_imports() {
933 use std::$0fmt::Formatter;
937 use std::{fmt::Formatter, io};
943 fn doctest_merge_match_arms() {
947 enum Action { Move { distance: u32 }, Stop }
949 fn handle(action: Action) {
951 $0Action::Move(..) => foo(),
952 Action::Stop => foo(),
957 enum Action { Move { distance: u32 }, Stop }
959 fn handle(action: Action) {
961 Action::Move(..) | Action::Stop => foo(),
969 fn doctest_move_arm_cond_to_match_guard() {
971 "move_arm_cond_to_match_guard",
973 enum Action { Move { distance: u32 }, Stop }
975 fn handle(action: Action) {
977 Action::Move { distance } => $0if distance > 10 { foo() },
983 enum Action { Move { distance: u32 }, Stop }
985 fn handle(action: Action) {
987 Action::Move { distance } if distance > 10 => foo(),
996 fn doctest_move_bounds_to_where_clause() {
998 "move_bounds_to_where_clause",
1000 fn apply<T, U, $0F: FnOnce(T) -> U>(f: F, x: T) -> U {
1005 fn apply<T, U, F>(f: F, x: T) -> U where F: FnOnce(T) -> U {
1013 fn doctest_move_guard_to_arm_body() {
1015 "move_guard_to_arm_body",
1017 enum Action { Move { distance: u32 }, Stop }
1019 fn handle(action: Action) {
1021 Action::Move { distance } $0if distance > 10 => foo(),
1027 enum Action { Move { distance: u32 }, Stop }
1029 fn handle(action: Action) {
1031 Action::Move { distance } => if distance > 10 {
1042 fn doctest_move_module_to_file() {
1044 "move_module_to_file",
1057 fn doctest_pull_assignment_up() {
1059 "pull_assignment_up",
1086 fn doctest_qualify_path() {
1091 let map = HashMap$0::new();
1093 pub mod std { pub mod collections { pub struct HashMap { } } }
1097 let map = std::collections::HashMap::new();
1099 pub mod std { pub mod collections { pub struct HashMap { } } }
1105 fn doctest_remove_dbg() {
1122 fn doctest_remove_hash() {
1127 r#"Hello,$0 World!"#;
1139 fn doctest_remove_mut() {
1144 fn feed(&mut$0 self, amount: u32) {}
1149 fn feed(&self, amount: u32) {}
1156 fn doctest_remove_unused_param() {
1158 "remove_unused_param",
1160 fn frobnicate(x: i32$0) {}
1177 fn doctest_reorder_fields() {
1181 struct Foo {foo: i32, bar: i32};
1182 const test: Foo = $0Foo {bar: 0, foo: 1}
1185 struct Foo {foo: i32, bar: i32};
1186 const test: Foo = Foo {foo: 1, bar: 0}
1192 fn doctest_reorder_impl() {
1203 $0impl Foo for Bar {
1227 fn doctest_replace_derive_with_manual_impl() {
1229 "replace_derive_with_manual_impl",
1231 trait Debug { fn fmt(&self, f: &mut Formatter) -> Result<()>; }
1232 #[derive(Deb$0ug, Display)]
1236 trait Debug { fn fmt(&self, f: &mut Formatter) -> Result<()>; }
1241 fn fmt(&self, f: &mut Formatter) -> Result<()> {
1250 fn doctest_replace_for_loop_with_for_each() {
1252 "replace_for_loop_with_for_each",
1255 let x = vec![1, 2, 3];
1263 let x = vec![1, 2, 3];
1264 x.into_iter().for_each(|v| {
1273 fn doctest_replace_if_let_with_match() {
1275 "replace_if_let_with_match",
1277 enum Action { Move { distance: u32 }, Stop }
1279 fn handle(action: Action) {
1280 $0if let Action::Move { distance } = action {
1288 enum Action { Move { distance: u32 }, Stop }
1290 fn handle(action: Action) {
1292 Action::Move { distance } => foo(distance),
1301 fn doctest_replace_impl_trait_with_generic() {
1303 "replace_impl_trait_with_generic",
1305 fn foo(bar: $0impl Bar) {}
1308 fn foo<B: Bar>(bar: B) {}
1314 fn doctest_replace_let_with_if_let() {
1316 "replace_let_with_if_let",
1318 enum Option<T> { Some(T), None }
1320 fn main(action: Action) {
1321 $0let x = compute();
1324 fn compute() -> Option<i32> { None }
1327 enum Option<T> { Some(T), None }
1329 fn main(action: Action) {
1330 if let Some(x) = compute() {
1334 fn compute() -> Option<i32> { None }
1340 fn doctest_replace_match_with_if_let() {
1342 "replace_match_with_if_let",
1344 enum Action { Move { distance: u32 }, Stop }
1346 fn handle(action: Action) {
1348 Action::Move { distance } => foo(distance),
1354 enum Action { Move { distance: u32 }, Stop }
1356 fn handle(action: Action) {
1357 if let Action::Move { distance } = action {
1368 fn doctest_replace_qualified_name_with_use() {
1370 "replace_qualified_name_with_use",
1372 fn process(map: std::collections::$0HashMap<String, String>) {}
1375 use std::collections::HashMap;
1377 fn process(map: HashMap<String, String>) {}
1383 fn doctest_replace_string_with_char() {
1385 "replace_string_with_char",
1400 fn doctest_replace_unwrap_with_match() {
1402 "replace_unwrap_with_match",
1404 enum Result<T, E> { Ok(T), Err(E) }
1406 let x: Result<i32, i32> = Result::Ok(92);
1407 let y = x.$0unwrap();
1411 enum Result<T, E> { Ok(T), Err(E) }
1413 let x: Result<i32, i32> = Result::Ok(92);
1416 $0_ => unreachable!(),
1424 fn doctest_split_import() {
1428 use std::$0collections::HashMap;
1431 use std::{collections::HashMap};
1437 fn doctest_toggle_ignore() {
1443 assert_eq!(2 + 2, 5);
1450 assert_eq!(2 + 2, 5);
1457 fn doctest_unmerge_use() {
1461 use std::fmt::{Debug, Display$0};
1464 use std::fmt::{Debug};
1465 use std::fmt::Display;
1471 fn doctest_unwrap_block() {
1490 fn doctest_wrap_return_type_in_result() {
1492 "wrap_return_type_in_result",
1494 fn foo() -> i32$0 { 42i32 }
1497 fn foo() -> Result<i32, ${0:_}> { Ok(42i32) }