Skip to content

Commit 2fa819c

Browse files
authored
Merge pull request #19237 from BenjaminBrienen/doc-tests
Doc tests
2 parents 63138a9 + 07bf55f commit 2fa819c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+77
-93
lines changed

crates/base-db/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ license.workspace = true
1010
rust-version.workspace = true
1111

1212
[lib]
13-
doctest = false
1413

1514
[dependencies]
1615
lz4_flex = { version = "0.11", default-features = false }

crates/cfg/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ license.workspace = true
1010
rust-version.workspace = true
1111

1212
[lib]
13-
doctest = false
1413

1514
[dependencies]
1615
rustc-hash.workspace = true

crates/hir-def/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ license.workspace = true
1010
rust-version.workspace = true
1111

1212
[lib]
13-
doctest = false
1413

1514
[dependencies]
1615
arrayvec.workspace = true

crates/hir-def/src/dyn_map.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
//!
66
//! It is used like this:
77
//!
8-
//! ```
8+
//! ```ignore
9+
//! # use hir_def::dyn_map::DynMap;
10+
//! # use hir_def::dyn_map::Key;
911
//! // keys define submaps of a `DynMap`
1012
//! const STRING_TO_U32: Key<String, u32> = Key::new();
1113
//! const U32_TO_VEC: Key<u32, Vec<bool>> = Key::new();

crates/hir-def/src/item_tree.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -883,20 +883,20 @@ pub struct UseTree {
883883

884884
#[derive(Debug, Clone, Eq, PartialEq)]
885885
pub enum UseTreeKind {
886-
/// ```
886+
/// ```ignore
887887
/// use path::to::Item;
888888
/// use path::to::Item as Renamed;
889889
/// use path::to::Trait as _;
890890
/// ```
891891
Single { path: Interned<ModPath>, alias: Option<ImportAlias> },
892892

893-
/// ```
893+
/// ```ignore
894894
/// use *; // (invalid, but can occur in nested tree)
895895
/// use path::*;
896896
/// ```
897897
Glob { path: Option<Interned<ModPath>> },
898898

899-
/// ```
899+
/// ```ignore
900900
/// use prefix::{self, Item, ...};
901901
/// ```
902902
Prefixed { prefix: Option<Interned<ModPath>>, list: Box<[UseTree]> },

crates/hir-def/src/nameres/mod_resolution.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ impl DirPath {
134134
/// So this is the case which doesn't really work I think if we try to be
135135
/// 100% platform agnostic:
136136
///
137-
/// ```
137+
/// ```ignore
138138
/// mod a {
139139
/// #[path="C://sad/face"]
140140
/// mod b { mod c; }

crates/hir-def/src/resolver.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -532,16 +532,17 @@ impl Resolver {
532532
/// Note that in Rust one name can be bound to several items:
533533
///
534534
/// ```
535+
/// # #![allow(non_camel_case_types)]
535536
/// macro_rules! t { () => (()) }
536537
/// type t = t!();
537-
/// const t: t = t!()
538+
/// const t: t = t!();
538539
/// ```
539540
///
540541
/// That's why we return a multimap.
541542
///
542543
/// The shadowing is accounted for: in
543544
///
544-
/// ```
545+
/// ```ignore
545546
/// let it = 92;
546547
/// {
547548
/// let it = 92;

crates/hir-expand/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ license.workspace = true
1010
rust-version.workspace = true
1111

1212
[lib]
13-
doctest = false
1413

1514
[dependencies]
1615
cov-mark = "2.0.0-pre.1"

crates/hir-expand/src/builtin/attr_macro.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ fn dummy_gate_test_expand(
101101
/// somewhat inconsistently resolve derive attributes.
102102
///
103103
/// As such, we expand `#[derive(Foo, bar::Bar)]` into
104-
/// ```
104+
/// ```ignore
105105
/// #![Foo]
106106
/// #![bar::Bar]
107107
/// ```

crates/hir-ty/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ license.workspace = true
1010
rust-version.workspace = true
1111

1212
[lib]
13-
doctest = false
1413

1514
[dependencies]
1615
cov-mark = "2.0.0-pre.1"

crates/hir-ty/src/display.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ pub struct HirFormatter<'a> {
9595
enum BoundsFormattingCtx {
9696
Entered {
9797
/// We can have recursive bounds like the following case:
98-
/// ```rust
98+
/// ```ignore
9999
/// where
100100
/// T: Foo,
101101
/// T::FooAssoc: Baz<<T::FooAssoc as Bar>::BarAssoc> + Bar

crates/hir-ty/src/infer.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ impl Default for InternedStandardTypes {
335335
/// sized struct to a dynamically sized one. E.g., &[i32; 4] -> &[i32] is
336336
/// represented by:
337337
///
338-
/// ```
338+
/// ```ignore
339339
/// Deref(None) -> [i32; 4],
340340
/// Borrow(AutoBorrow::Ref) -> &[i32; 4],
341341
/// Unsize -> &[i32],
@@ -481,9 +481,10 @@ pub struct InferenceResult {
481481
/// or pattern can have multiple binding modes. For example:
482482
/// ```
483483
/// fn foo(mut slice: &[u32]) -> usize {
484-
/// slice = match slice {
485-
/// [0, rest @ ..] | rest => rest,
486-
/// };
484+
/// slice = match slice {
485+
/// [0, rest @ ..] | rest => rest,
486+
/// };
487+
/// 0
487488
/// }
488489
/// ```
489490
/// the first `rest` has implicit `ref` binding mode, but the second `rest` binding mode is `move`.

crates/hir/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ license.workspace = true
1010
rust-version.workspace = true
1111

1212
[lib]
13-
doctest = false
1413

1514
[dependencies]
1615
rustc-hash.workspace = true

crates/hir/src/semantics/source_to_def.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
//!
66
//! This module solves the following problem:
77
//!
8-
//! Given a piece of syntax, find the corresponding semantic definition (def).
8+
//! > Given a piece of syntax, find the corresponding semantic definition (def).
99
//!
1010
//! This problem is a part of more-or-less every IDE feature implemented. Every
1111
//! IDE functionality (like goto to definition), conceptually starts with a

crates/hir/src/term_search/expr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ fn mod_item_path_str(
4040
/// Type tree shows how can we get from set of types to some type.
4141
///
4242
/// Consider the following code as an example
43-
/// ```
43+
/// ```ignore
4444
/// fn foo(x: i32, y: bool) -> Option<i32> { None }
4545
/// fn bar() {
4646
/// let a = 1;

crates/ide-assists/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ license.workspace = true
1010
rust-version.workspace = true
1111

1212
[lib]
13-
doctest = false
1413

1514
[dependencies]
1615
cov-mark = "2.0.0-pre.1"

crates/ide-assists/src/handlers/convert_comment_from_or_to_doc.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ fn comment_to_doc(acc: &mut Assists, comment: ast::Comment, style: CommentPlacem
136136

137137
/// Not all comments are valid candidates for conversion into doc comments. For example, the
138138
/// comments in the code:
139-
/// ```rust
139+
/// ```ignore
140140
/// // Brilliant module right here
141141
///
142142
/// // Really good right
@@ -148,7 +148,7 @@ fn comment_to_doc(acc: &mut Assists, comment: ast::Comment, style: CommentPlacem
148148
/// mod nice_module {}
149149
/// ```
150150
/// can be converted to doc comments. However, the comments in this example:
151-
/// ```rust
151+
/// ```ignore
152152
/// fn foo_bar(foo: Foo /* not bar yet */) -> Bar {
153153
/// foo.into_bar()
154154
/// // Nicely done
@@ -162,7 +162,7 @@ fn comment_to_doc(acc: &mut Assists, comment: ast::Comment, style: CommentPlacem
162162
/// are not allowed to become doc comments. Moreover, some comments _are_ allowed, but aren't common
163163
/// style in Rust. For example, the following comments are allowed to be doc comments, but it is not
164164
/// common style for them to be:
165-
/// ```rust
165+
/// ```ignore
166166
/// fn foo_bar(foo: Foo) -> Bar {
167167
/// // this could be an inner comment with //!
168168
/// foo.into_bar()

crates/ide-assists/src/handlers/extract_function.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ fn make_function_name(semantics_scope: &hir::SemanticsScope<'_>) -> ast::NameRef
272272
/// * We want whole node, like `loop {}`, `2 + 2`, `{ let n = 1; }` exprs.
273273
/// Then we can use `ast::Expr`
274274
/// * We want a few statements for a block. E.g.
275-
/// ```rust,no_run
275+
/// ```ignore
276276
/// fn foo() -> i32 {
277277
/// let m = 1;
278278
/// $0
@@ -386,7 +386,7 @@ struct ContainerInfo {
386386
/// Control flow that is exported from extracted function
387387
///
388388
/// E.g.:
389-
/// ```rust,no_run
389+
/// ```ignore
390390
/// loop {
391391
/// $0
392392
/// if 42 == 42 {

crates/ide-assists/src/handlers/generate_function.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1037,7 +1037,7 @@ fn filter_bounds_in_scope(
10371037

10381038
/// Makes duplicate argument names unique by appending incrementing numbers.
10391039
///
1040-
/// ```
1040+
/// ```ignore
10411041
/// let mut names: Vec<String> =
10421042
/// vec!["foo".into(), "foo".into(), "bar".into(), "baz".into(), "bar".into()];
10431043
/// deduplicate_arg_names(&mut names);

crates/ide-assists/src/handlers/inline_type_alias.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ impl ConstAndTypeMap {
276276
/// 1. Map the provided instance's generic args to the type alias's generic
277277
/// params:
278278
///
279-
/// ```
279+
/// ```ignore
280280
/// type A<'a, const N: usize, T = u64> = &'a [T; N];
281281
/// ^ alias generic params
282282
/// let a: A<100>;

crates/ide-completion/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ license.workspace = true
1010
rust-version.workspace = true
1111

1212
[lib]
13-
doctest = false
1413

1514
[dependencies]
1615
cov-mark = "2.0.0-pre.1"

crates/ide-completion/src/context.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,8 @@ pub(crate) enum Qualified {
249249
/// This would be None, if path is not solely made of
250250
/// `super` segments, e.g.
251251
///
252-
/// ```rust
253-
/// use super::foo;
252+
/// ```ignore
253+
/// use super::foo;
254254
/// ```
255255
///
256256
/// Otherwise it should be Some(count of `super`)

crates/ide-completion/src/context/analysis.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ fn token_at_offset_ignore_whitespace(file: &SyntaxNode, offset: TextSize) -> Opt
9797
/// We do this by recursively expanding all macros and picking the best possible match. We cannot just
9898
/// choose the first expansion each time because macros can expand to something that does not include
9999
/// our completion marker, e.g.:
100-
/// ```
100+
///
101+
/// ```ignore
101102
/// macro_rules! helper { ($v:ident) => {} }
102103
/// macro_rules! my_macro {
103104
/// ($v:ident) => {
@@ -106,7 +107,7 @@ fn token_at_offset_ignore_whitespace(file: &SyntaxNode, offset: TextSize) -> Opt
106107
/// };
107108
/// }
108109
///
109-
/// my_macro!(complete_me_here)
110+
/// my_macro!(complete_me_here);
110111
/// ```
111112
/// If we would expand the first thing we encounter only (which in fact this method used to do), we would
112113
/// be unable to complete here, because we would be walking directly into the void. So we instead try

crates/ide-completion/src/item.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,9 @@ pub struct CompletionRelevance {
149149
/// This is set when the identifier being completed matches up with the name that is expected,
150150
/// like in a function argument.
151151
///
152-
/// ```
152+
/// ```ignore
153153
/// fn f(spam: String) {}
154-
/// fn main {
154+
/// fn main() {
155155
/// let spam = 92;
156156
/// f($0) // name of local matches the name of param
157157
/// }
@@ -161,7 +161,7 @@ pub struct CompletionRelevance {
161161
pub type_match: Option<CompletionRelevanceTypeMatch>,
162162
/// Set for local variables.
163163
///
164-
/// ```
164+
/// ```ignore
165165
/// fn foo(a: u32) {
166166
/// let b = 0;
167167
/// $0 // `a` and `b` are local
@@ -195,7 +195,7 @@ pub struct CompletionRelevanceTraitInfo {
195195
pub enum CompletionRelevanceTypeMatch {
196196
/// This is set in cases like these:
197197
///
198-
/// ```
198+
/// ```ignore
199199
/// enum Option<T> { Some(T), None }
200200
/// fn f(a: Option<u32>) {}
201201
/// fn main {
@@ -205,9 +205,9 @@ pub enum CompletionRelevanceTypeMatch {
205205
CouldUnify,
206206
/// This is set in cases where the type matches the expected type, like:
207207
///
208-
/// ```
208+
/// ```ignore
209209
/// fn f(spam: String) {}
210-
/// fn main {
210+
/// fn main() {
211211
/// let foo = String::new();
212212
/// f($0) // type of local matches the type of param
213213
/// }
@@ -221,7 +221,7 @@ pub enum CompletionRelevancePostfixMatch {
221221
NonExact,
222222
/// This is set in cases like these:
223223
///
224-
/// ```
224+
/// ```ignore
225225
/// (a > b).not$0
226226
/// ```
227227
///

crates/ide-completion/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ impl CompletionFieldsToResolve {
143143
/// already present, it should give all possible variants for the identifier at
144144
/// the caret. In other words, for
145145
///
146-
/// ```no_run
146+
/// ```ignore
147147
/// fn f() {
148148
/// let foo = 92;
149149
/// let _ = bar$0

crates/ide-db/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ license.workspace = true
1010
rust-version.workspace = true
1111

1212
[lib]
13-
doctest = false
1413

1514
[dependencies]
1615
cov-mark = "2.0.0-pre.1"

crates/ide-db/src/path_transform.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ type DefaultedParam = Either<hir::TypeParam, hir::ConstParam>;
3232
/// block), you generally want to appropriately qualify the names, and sometimes
3333
/// you might want to substitute generic parameters as well:
3434
///
35-
/// ```
35+
/// ```ignore
3636
/// mod x {
3737
/// pub struct A<V>;
3838
/// pub trait T<U> { fn foo(&self, _: U) -> A<U>; }

crates/ide-db/src/source_change.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ pub enum Snippet {
493493
Placeholder(TextRange),
494494
/// A group of placeholder snippets, e.g.
495495
///
496-
/// ```no_run
496+
/// ```ignore
497497
/// let ${0:new_var} = 4;
498498
/// fun(1, 2, 3, ${0:new_var});
499499
/// ```

crates/ide-db/src/syntax_helpers/suggest_name.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,9 @@ const USELESS_METHODS: &[&str] = &[
7979
/// the name, e.g. `a`, `a1`, `a2`, ...
8080
///
8181
/// # Examples
82-
/// ```rust
82+
///
83+
/// ```
84+
/// # use ide_db::syntax_helpers::suggest_name::NameGenerator;
8385
/// let mut generator = NameGenerator::new();
8486
/// assert_eq!(generator.suggest_name("a"), "a");
8587
/// assert_eq!(generator.suggest_name("a"), "a1");

crates/ide-diagnostics/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ license.workspace = true
1010
rust-version.workspace = true
1111

1212
[lib]
13-
doctest = false
1413

1514
[dependencies]
1615
cov-mark = "2.0.0-pre.1"

crates/ide-diagnostics/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,7 @@ struct SeverityAttr {
697697
/// #[warn(non_snake_case)]
698698
/// mod foo {
699699
/// #[allow(nonstandard_style)]
700-
/// mod bar;
700+
/// mod bar {}
701701
/// }
702702
/// ```
703703
/// We want to not warn on non snake case inside `bar`. If we are traversing this for the first

0 commit comments

Comments
 (0)