Skip to content

Doc tests #19237

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Feb 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion crates/base-db/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ license.workspace = true
rust-version.workspace = true

[lib]
doctest = false

[dependencies]
lz4_flex = { version = "0.11", default-features = false }
Expand Down
1 change: 0 additions & 1 deletion crates/cfg/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ license.workspace = true
rust-version.workspace = true

[lib]
doctest = false

[dependencies]
rustc-hash.workspace = true
Expand Down
1 change: 0 additions & 1 deletion crates/hir-def/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ license.workspace = true
rust-version.workspace = true

[lib]
doctest = false

[dependencies]
arrayvec.workspace = true
Expand Down
4 changes: 3 additions & 1 deletion crates/hir-def/src/dyn_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
//!
//! It is used like this:
//!
//! ```
//! ```ignore
//! # use hir_def::dyn_map::DynMap;
//! # use hir_def::dyn_map::Key;
//! // keys define submaps of a `DynMap`
//! const STRING_TO_U32: Key<String, u32> = Key::new();
//! const U32_TO_VEC: Key<u32, Vec<bool>> = Key::new();
Expand Down
6 changes: 3 additions & 3 deletions crates/hir-def/src/item_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -883,20 +883,20 @@ pub struct UseTree {

#[derive(Debug, Clone, Eq, PartialEq)]
pub enum UseTreeKind {
/// ```
/// ```ignore
/// use path::to::Item;
/// use path::to::Item as Renamed;
/// use path::to::Trait as _;
/// ```
Single { path: Interned<ModPath>, alias: Option<ImportAlias> },

/// ```
/// ```ignore
/// use *; // (invalid, but can occur in nested tree)
/// use path::*;
/// ```
Glob { path: Option<Interned<ModPath>> },

/// ```
/// ```ignore
/// use prefix::{self, Item, ...};
/// ```
Prefixed { prefix: Option<Interned<ModPath>>, list: Box<[UseTree]> },
Expand Down
2 changes: 1 addition & 1 deletion crates/hir-def/src/nameres/mod_resolution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ impl DirPath {
/// So this is the case which doesn't really work I think if we try to be
/// 100% platform agnostic:
///
/// ```
/// ```ignore
/// mod a {
/// #[path="C://sad/face"]
/// mod b { mod c; }
Expand Down
5 changes: 3 additions & 2 deletions crates/hir-def/src/resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -532,16 +532,17 @@
/// Note that in Rust one name can be bound to several items:
///
/// ```
/// # #![allow(non_camel_case_types)]
/// macro_rules! t { () => (()) }
/// type t = t!();
/// const t: t = t!()
/// const t: t = t!();

Check warning on line 538 in crates/hir-def/src/resolver.rs

View workflow job for this annotation

GitHub Actions / Rust (ubuntu-latest)

constant `t` should have an upper case name
/// ```
///
/// That's why we return a multimap.
///
/// The shadowing is accounted for: in
///
/// ```
/// ```ignore
/// let it = 92;
/// {
/// let it = 92;
Expand Down
1 change: 0 additions & 1 deletion crates/hir-expand/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ license.workspace = true
rust-version.workspace = true

[lib]
doctest = false

[dependencies]
cov-mark = "2.0.0-pre.1"
Expand Down
2 changes: 1 addition & 1 deletion crates/hir-expand/src/builtin/attr_macro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ fn dummy_gate_test_expand(
/// somewhat inconsistently resolve derive attributes.
///
/// As such, we expand `#[derive(Foo, bar::Bar)]` into
/// ```
/// ```ignore
/// #![Foo]
/// #![bar::Bar]
/// ```
Expand Down
1 change: 0 additions & 1 deletion crates/hir-ty/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ license.workspace = true
rust-version.workspace = true

[lib]
doctest = false

[dependencies]
cov-mark = "2.0.0-pre.1"
Expand Down
2 changes: 1 addition & 1 deletion crates/hir-ty/src/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ pub struct HirFormatter<'a> {
enum BoundsFormattingCtx {
Entered {
/// We can have recursive bounds like the following case:
/// ```rust
/// ```ignore
/// where
/// T: Foo,
/// T::FooAssoc: Baz<<T::FooAssoc as Bar>::BarAssoc> + Bar
Expand Down
9 changes: 5 additions & 4 deletions crates/hir-ty/src/infer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ impl Default for InternedStandardTypes {
/// sized struct to a dynamically sized one. E.g., &[i32; 4] -> &[i32] is
/// represented by:
///
/// ```
/// ```ignore
/// Deref(None) -> [i32; 4],
/// Borrow(AutoBorrow::Ref) -> &[i32; 4],
/// Unsize -> &[i32],
Expand Down Expand Up @@ -481,9 +481,10 @@ pub struct InferenceResult {
/// or pattern can have multiple binding modes. For example:
/// ```
/// fn foo(mut slice: &[u32]) -> usize {
/// slice = match slice {
/// [0, rest @ ..] | rest => rest,
/// };
/// slice = match slice {
/// [0, rest @ ..] | rest => rest,
/// };
/// 0
/// }
/// ```
/// the first `rest` has implicit `ref` binding mode, but the second `rest` binding mode is `move`.
Expand Down
1 change: 0 additions & 1 deletion crates/hir/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ license.workspace = true
rust-version.workspace = true

[lib]
doctest = false

[dependencies]
rustc-hash.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion crates/hir/src/semantics/source_to_def.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
//!
//! This module solves the following problem:
//!
//! Given a piece of syntax, find the corresponding semantic definition (def).
//! > Given a piece of syntax, find the corresponding semantic definition (def).
//!
//! This problem is a part of more-or-less every IDE feature implemented. Every
//! IDE functionality (like goto to definition), conceptually starts with a
Expand Down
2 changes: 1 addition & 1 deletion crates/hir/src/term_search/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ fn mod_item_path_str(
/// Type tree shows how can we get from set of types to some type.
///
/// Consider the following code as an example
/// ```
/// ```ignore
/// fn foo(x: i32, y: bool) -> Option<i32> { None }
/// fn bar() {
/// let a = 1;
Expand Down
1 change: 0 additions & 1 deletion crates/ide-assists/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ license.workspace = true
rust-version.workspace = true

[lib]
doctest = false

[dependencies]
cov-mark = "2.0.0-pre.1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ fn comment_to_doc(acc: &mut Assists, comment: ast::Comment, style: CommentPlacem

/// Not all comments are valid candidates for conversion into doc comments. For example, the
/// comments in the code:
/// ```rust
/// ```ignore
/// // Brilliant module right here
///
/// // Really good right
Expand All @@ -148,7 +148,7 @@ fn comment_to_doc(acc: &mut Assists, comment: ast::Comment, style: CommentPlacem
/// mod nice_module {}
/// ```
/// can be converted to doc comments. However, the comments in this example:
/// ```rust
/// ```ignore
/// fn foo_bar(foo: Foo /* not bar yet */) -> Bar {
/// foo.into_bar()
/// // Nicely done
Expand All @@ -162,7 +162,7 @@ fn comment_to_doc(acc: &mut Assists, comment: ast::Comment, style: CommentPlacem
/// are not allowed to become doc comments. Moreover, some comments _are_ allowed, but aren't common
/// style in Rust. For example, the following comments are allowed to be doc comments, but it is not
/// common style for them to be:
/// ```rust
/// ```ignore
/// fn foo_bar(foo: Foo) -> Bar {
/// // this could be an inner comment with //!
/// foo.into_bar()
Expand Down
4 changes: 2 additions & 2 deletions crates/ide-assists/src/handlers/extract_function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ fn make_function_name(semantics_scope: &hir::SemanticsScope<'_>) -> ast::NameRef
/// * We want whole node, like `loop {}`, `2 + 2`, `{ let n = 1; }` exprs.
/// Then we can use `ast::Expr`
/// * We want a few statements for a block. E.g.
/// ```rust,no_run
/// ```ignore
/// fn foo() -> i32 {
/// let m = 1;
/// $0
Expand Down Expand Up @@ -386,7 +386,7 @@ struct ContainerInfo {
/// Control flow that is exported from extracted function
///
/// E.g.:
/// ```rust,no_run
/// ```ignore
/// loop {
/// $0
/// if 42 == 42 {
Expand Down
2 changes: 1 addition & 1 deletion crates/ide-assists/src/handlers/generate_function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1037,7 +1037,7 @@ fn filter_bounds_in_scope(

/// Makes duplicate argument names unique by appending incrementing numbers.
///
/// ```
/// ```ignore
/// let mut names: Vec<String> =
/// vec!["foo".into(), "foo".into(), "bar".into(), "baz".into(), "bar".into()];
/// deduplicate_arg_names(&mut names);
Expand Down
2 changes: 1 addition & 1 deletion crates/ide-assists/src/handlers/inline_type_alias.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ impl ConstAndTypeMap {
/// 1. Map the provided instance's generic args to the type alias's generic
/// params:
///
/// ```
/// ```ignore
/// type A<'a, const N: usize, T = u64> = &'a [T; N];
/// ^ alias generic params
/// let a: A<100>;
Expand Down
1 change: 0 additions & 1 deletion crates/ide-completion/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ license.workspace = true
rust-version.workspace = true

[lib]
doctest = false

[dependencies]
cov-mark = "2.0.0-pre.1"
Expand Down
4 changes: 2 additions & 2 deletions crates/ide-completion/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,8 @@ pub(crate) enum Qualified {
/// This would be None, if path is not solely made of
/// `super` segments, e.g.
///
/// ```rust
/// use super::foo;
/// ```ignore
/// use super::foo;
/// ```
///
/// Otherwise it should be Some(count of `super`)
Expand Down
5 changes: 3 additions & 2 deletions crates/ide-completion/src/context/analysis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ fn token_at_offset_ignore_whitespace(file: &SyntaxNode, offset: TextSize) -> Opt
/// We do this by recursively expanding all macros and picking the best possible match. We cannot just
/// choose the first expansion each time because macros can expand to something that does not include
/// our completion marker, e.g.:
/// ```
///
/// ```ignore
/// macro_rules! helper { ($v:ident) => {} }
/// macro_rules! my_macro {
/// ($v:ident) => {
Expand All @@ -106,7 +107,7 @@ fn token_at_offset_ignore_whitespace(file: &SyntaxNode, offset: TextSize) -> Opt
/// };
/// }
///
/// my_macro!(complete_me_here)
/// my_macro!(complete_me_here);
/// ```
/// If we would expand the first thing we encounter only (which in fact this method used to do), we would
/// be unable to complete here, because we would be walking directly into the void. So we instead try
Expand Down
14 changes: 7 additions & 7 deletions crates/ide-completion/src/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,9 @@ pub struct CompletionRelevance {
/// This is set when the identifier being completed matches up with the name that is expected,
/// like in a function argument.
///
/// ```
/// ```ignore
/// fn f(spam: String) {}
/// fn main {
/// fn main() {
/// let spam = 92;
/// f($0) // name of local matches the name of param
/// }
Expand All @@ -161,7 +161,7 @@ pub struct CompletionRelevance {
pub type_match: Option<CompletionRelevanceTypeMatch>,
/// Set for local variables.
///
/// ```
/// ```ignore
/// fn foo(a: u32) {
/// let b = 0;
/// $0 // `a` and `b` are local
Expand Down Expand Up @@ -195,7 +195,7 @@ pub struct CompletionRelevanceTraitInfo {
pub enum CompletionRelevanceTypeMatch {
/// This is set in cases like these:
///
/// ```
/// ```ignore
/// enum Option<T> { Some(T), None }
/// fn f(a: Option<u32>) {}
/// fn main {
Expand All @@ -205,9 +205,9 @@ pub enum CompletionRelevanceTypeMatch {
CouldUnify,
/// This is set in cases where the type matches the expected type, like:
///
/// ```
/// ```ignore
/// fn f(spam: String) {}
/// fn main {
/// fn main() {
/// let foo = String::new();
/// f($0) // type of local matches the type of param
/// }
Expand All @@ -221,7 +221,7 @@ pub enum CompletionRelevancePostfixMatch {
NonExact,
/// This is set in cases like these:
///
/// ```
/// ```ignore
/// (a > b).not$0
/// ```
///
Expand Down
2 changes: 1 addition & 1 deletion crates/ide-completion/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ impl CompletionFieldsToResolve {
/// already present, it should give all possible variants for the identifier at
/// the caret. In other words, for
///
/// ```no_run
/// ```ignore
/// fn f() {
/// let foo = 92;
/// let _ = bar$0
Expand Down
1 change: 0 additions & 1 deletion crates/ide-db/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ license.workspace = true
rust-version.workspace = true

[lib]
doctest = false

[dependencies]
cov-mark = "2.0.0-pre.1"
Expand Down
2 changes: 1 addition & 1 deletion crates/ide-db/src/path_transform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type DefaultedParam = Either<hir::TypeParam, hir::ConstParam>;
/// block), you generally want to appropriately qualify the names, and sometimes
/// you might want to substitute generic parameters as well:
///
/// ```
/// ```ignore
/// mod x {
/// pub struct A<V>;
/// pub trait T<U> { fn foo(&self, _: U) -> A<U>; }
Expand Down
2 changes: 1 addition & 1 deletion crates/ide-db/src/source_change.rs
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ pub enum Snippet {
Placeholder(TextRange),
/// A group of placeholder snippets, e.g.
///
/// ```no_run
/// ```ignore
/// let ${0:new_var} = 4;
/// fun(1, 2, 3, ${0:new_var});
/// ```
Expand Down
4 changes: 3 additions & 1 deletion crates/ide-db/src/syntax_helpers/suggest_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ const USELESS_METHODS: &[&str] = &[
/// the name, e.g. `a`, `a1`, `a2`, ...
///
/// # Examples
/// ```rust
///
/// ```
/// # use ide_db::syntax_helpers::suggest_name::NameGenerator;
/// let mut generator = NameGenerator::new();
/// assert_eq!(generator.suggest_name("a"), "a");
/// assert_eq!(generator.suggest_name("a"), "a1");
Expand Down
1 change: 0 additions & 1 deletion crates/ide-diagnostics/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ license.workspace = true
rust-version.workspace = true

[lib]
doctest = false

[dependencies]
cov-mark = "2.0.0-pre.1"
Expand Down
2 changes: 1 addition & 1 deletion crates/ide-diagnostics/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,7 @@ struct SeverityAttr {
/// #[warn(non_snake_case)]
/// mod foo {
/// #[allow(nonstandard_style)]
/// mod bar;
/// mod bar {}
/// }
/// ```
/// We want to not warn on non snake case inside `bar`. If we are traversing this for the first
Expand Down
Loading
Loading