Skip to content

Commit b345deb

Browse files
fix doc tests
1 parent 4a9d168 commit b345deb

File tree

37 files changed

+75
-61
lines changed

37 files changed

+75
-61
lines changed

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/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/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/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/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/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/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/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

crates/mbe/src/parser.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ use crate::ParseError;
1313
/// Consider
1414
///
1515
/// ```
16-
/// macro_rules! an_macro {
17-
/// ($x:expr + $y:expr) => ($y * $x)
16+
/// macro_rules! a_macro {
17+
/// ($x:expr, $y:expr) => ($y * $x)
1818
/// }
1919
/// ```
2020
///

crates/parser/src/input.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ impl Input {
3636
/// the *previous* token was joint, with mbe, you know whether the *current*
3737
/// one is joint. This API allows for styles of usage:
3838
///
39-
/// ```
39+
/// ```ignore
4040
/// // In text:
4141
/// tokens.was_joint(prev_joint);
4242
/// tokens.push(curr);

crates/parser/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ pub use crate::{
5959
///
6060
/// That is, for something like
6161
///
62-
/// ```
62+
/// ```ignore
6363
/// quick_check! {
6464
/// fn prop() {}
6565
/// }

crates/parser/src/output.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ pub struct Output {
1616
/// 32-bit encoding of events. If LSB is zero, then that's an index into the
1717
/// error vector. Otherwise, it's one of the thee other variants, with data encoded as
1818
///
19-
/// |16 bit kind|8 bit n_input_tokens|4 bit tag|4 bit leftover|
20-
///
19+
/// ```text
20+
/// |16 bit kind|8 bit n_input_tokens|4 bit tag|4 bit leftover|
21+
/// ``````
2122
event: Vec<u32>,
2223
error: Vec<String>,
2324
}

crates/rust-analyzer/src/op_queue.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ pub(crate) type Cause = String;
66
/// A single-item queue that allows callers to request an operation to
77
/// be performed later.
88
///
9-
/// ```
9+
/// ```ignore
1010
/// let queue = OpQueue::default();
1111
///
1212
/// // Request work to be done.

crates/rust-analyzer/src/tracing/config.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@ pub struct Config<T> {
3131
/// that specify level.
3232
pub chalk_filter: Option<String>,
3333
/// Filtering syntax, set in a shell:
34-
/// ```
34+
/// ```text
3535
/// env RA_PROFILE=* // dump everything
3636
/// env RA_PROFILE=foo|bar|baz // enabled only selected entries
3737
/// env RA_PROFILE=*@3>10 // dump everything, up to depth 3, if it takes more than 10
3838
/// ```
3939
pub profile_filter: Option<String>,
4040

4141
/// Filtering syntax, set in a shell:
42-
/// ```
42+
/// ```text
4343
/// env RA_PROFILE_JSON=foo|bar|baz
4444
/// ```
4545
pub json_profile_filter: Option<String>,

crates/rust-analyzer/src/tracing/hprof.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
//!
77
//! Usage:
88
//!
9-
//! ```rust
9+
//! ```ignore
10+
//! # use tracing_subscriber::Registry;
1011
//! let layer = hprof::SpanTree::default();
1112
//! Registry::default().with(layer).init();
1213
//! ```

0 commit comments

Comments
 (0)