Skip to content

Commit 33c6410

Browse files
committed
Auto merge of #12055 - QiangHeisenberg:crates-io-doc-test, r=weihanglo
fix: doc-test failures ### What does this PR try to resolve? When I read the source code, I found that the `Registry::new_handle` document test failed and seemed to be missing parameters; There is no change in this [PR](https://github.com/rust-lang/cargo/pull/10592/files#diff-12973056cf99e8de997011a8738a6740a7dfd06142a73f122f3b35218db37351).
2 parents 6240788 + ff7ff7d commit 33c6410

File tree

4 files changed

+18
-9
lines changed

4 files changed

+18
-9
lines changed

crates/cargo-test-support/src/install.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,12 @@ use std::path::{Path, PathBuf};
44

55
/// Used by `cargo install` tests to assert an executable binary
66
/// has been installed. Example usage:
7+
/// ```no_run
8+
/// use cargo_test_support::install::assert_has_installed_exe;
9+
/// use cargo_test_support::install::cargo_home;
710
///
8-
/// assert_has_installed_exe(cargo_home(), "foo");
11+
/// assert_has_installed_exe(cargo_home(), "foo");
12+
/// ```
913
#[track_caller]
1014
pub fn assert_has_installed_exe<P: AsRef<Path>>(path: P, name: &'static str) {
1115
assert!(check_has_installed_exe(path, name));

crates/cargo-test-support/src/lib.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -700,13 +700,15 @@ impl Execs {
700700
/// The substrings are matched as `contains`. Example:
701701
///
702702
/// ```no_run
703-
/// execs.with_stderr_line_without(
703+
/// use cargo_test_support::execs;
704+
///
705+
/// execs().with_stderr_line_without(
704706
/// &[
705707
/// "[RUNNING] `rustc --crate-name build_script_build",
706708
/// "-C opt-level=3",
707709
/// ],
708710
/// &["-C debuginfo", "-C incremental"],
709-
/// )
711+
/// );
710712
/// ```
711713
///
712714
/// This will check that a build line includes `-C opt-level=3` but does

crates/cargo-test-support/src/registry.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,10 @@ impl RegistryBuilder {
450450
/// `VendorPackage` which implements directory sources.
451451
///
452452
/// # Example
453-
/// ```
453+
/// ```no_run
454+
/// use cargo_test_support::registry::Package;
455+
/// use cargo_test_support::project;
456+
///
454457
/// // Publish package "a" depending on "b".
455458
/// Package::new("a", "1.0.0")
456459
/// .dep("b", "1.0.0")
@@ -1241,7 +1244,7 @@ impl Package {
12411244
}
12421245

12431246
/// Adds a normal dependency. Example:
1244-
/// ```
1247+
/// ```toml
12451248
/// [dependencies]
12461249
/// foo = {version = "1.0"}
12471250
/// ```
@@ -1250,7 +1253,7 @@ impl Package {
12501253
}
12511254

12521255
/// Adds a dependency with the given feature. Example:
1253-
/// ```
1256+
/// ```toml
12541257
/// [dependencies]
12551258
/// foo = {version = "1.0", "features": ["feat1", "feat2"]}
12561259
/// ```
@@ -1273,7 +1276,7 @@ impl Package {
12731276
}
12741277

12751278
/// Adds a dev-dependency. Example:
1276-
/// ```
1279+
/// ```toml
12771280
/// [dev-dependencies]
12781281
/// foo = {version = "1.0"}
12791282
/// ```
@@ -1282,7 +1285,7 @@ impl Package {
12821285
}
12831286

12841287
/// Adds a build-dependency. Example:
1285-
/// ```
1288+
/// ```toml
12861289
/// [build-dependencies]
12871290
/// foo = {version = "1.0"}
12881291
/// ```

crates/crates-io/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ impl Registry {
200200
/// let mut handle = Easy::new();
201201
/// // If connecting to crates.io, a user-agent is required.
202202
/// handle.useragent("my_crawler (example.com/info)");
203-
/// let mut reg = Registry::new_handle(String::from("https://crates.io"), None, handle);
203+
/// let mut reg = Registry::new_handle(String::from("https://crates.io"), None, handle, true);
204204
/// ```
205205
pub fn new_handle(
206206
host: String,

0 commit comments

Comments
 (0)