mirror of
https://git.proxmox.com/git/rustc
synced 2025-05-03 01:08:18 +00:00
New upstream version 1.43.0+dfsg1
This commit is contained in:
parent
dfeec24772
commit
74b04a01b7
@ -50,6 +50,9 @@ is a bug or not, feel free to file a bug anyway.
|
||||
**If you believe reporting your bug publicly represents a security risk to Rust users,
|
||||
please follow our [instructions for reporting security vulnerabilities](https://www.rust-lang.org/policies/security)**.
|
||||
|
||||
If you're using the nightly channel, please check if the bug exists in the
|
||||
latest toolchain before filing your bug. It might be fixed already.
|
||||
|
||||
If you have the chance, before reporting a bug, please [search existing
|
||||
issues](https://github.com/rust-lang/rust/search?q=&type=Issues&utf8=%E2%9C%93),
|
||||
as it's possible that someone else has already reported your error. This doesn't
|
||||
|
644
Cargo.lock
generated
644
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -31,13 +31,6 @@ exclude = [
|
||||
"obj",
|
||||
]
|
||||
|
||||
# Curiously, LLVM 7.0 will segfault if compiled with opt-level=3
|
||||
# See issue https://github.com/rust-lang/rust/issues/52378
|
||||
[profile.release]
|
||||
opt-level = 2
|
||||
[profile.bench]
|
||||
opt-level = 2
|
||||
|
||||
# These options are controlled from our rustc wrapper script, so turn them off
|
||||
# here and have them controlled elsewhere.
|
||||
[profile.dev]
|
||||
|
160
RELEASES.md
160
RELEASES.md
@ -1,3 +1,152 @@
|
||||
Version 1.43.0 (2020-04-23)
|
||||
==========================
|
||||
|
||||
Language
|
||||
--------
|
||||
- [Fixed using binary operations with `&{number}` (e.g. `&1.0`) not having
|
||||
the type inferred correctly.][68129]
|
||||
- [Attributes such as `#[cfg()]` can now be used on `if` expressions.][69201]
|
||||
|
||||
**Syntax only changes**
|
||||
- [Allow `type Foo: Ord` syntactically.][69361]
|
||||
- [Fuse associated and extern items up to defaultness.][69194]
|
||||
- [Syntactically allow `self` in all `fn` contexts.][68764]
|
||||
- [Merge `fn` syntax + cleanup item parsing.][68728]
|
||||
- [`item` macro fragments can be interpolated into `trait`s, `impl`s, and `extern` blocks.][69366]
|
||||
For example, you may now write:
|
||||
```rust
|
||||
macro_rules! mac_trait {
|
||||
($i:item) => {
|
||||
trait T { $i }
|
||||
}
|
||||
}
|
||||
mac_trait! {
|
||||
fn foo() {}
|
||||
}
|
||||
```
|
||||
|
||||
These are still rejected *semantically*, so you will likely receive an error but
|
||||
these changes can be seen and parsed by macros and
|
||||
conditional compilation.
|
||||
|
||||
|
||||
Compiler
|
||||
--------
|
||||
- [You can now pass multiple lint flags to rustc to override the previous
|
||||
flags.][67885] For example; `rustc -D unused -A unused-variables` denies
|
||||
everything in the `unused` lint group except `unused-variables` which
|
||||
is explicitly allowed. However, passing `rustc -A unused-variables -D unused` denies
|
||||
everything in the `unused` lint group **including** `unused-variables` since
|
||||
the allow flag is specified before the deny flag (and therefore overridden).
|
||||
- [rustc will now prefer your system MinGW libraries over its bundled libraries
|
||||
if they are available on `windows-gnu`.][67429]
|
||||
- [rustc now buffers errors/warnings printed in JSON.][69227]
|
||||
|
||||
Libraries
|
||||
---------
|
||||
- [`Arc<[T; N]>`, `Box<[T; N]>`, and `Rc<[T; N]>`, now implement
|
||||
`TryFrom<Arc<[T]>>`,`TryFrom<Box<[T]>>`, and `TryFrom<Rc<[T]>>`
|
||||
respectively.][69538] **Note** These conversions are only available when `N`
|
||||
is `0..=32`.
|
||||
- [You can now use associated constants on floats and integers directly, rather
|
||||
than having to import the module.][68952] e.g. You can now write `u32::MAX` or
|
||||
`f32::NAN` with no imports.
|
||||
- [`u8::is_ascii` is now `const`.][68984]
|
||||
- [`String` now implements `AsMut<str>`.][68742]
|
||||
- [Added the `primitive` module to `std` and `core`.][67637] This module
|
||||
reexports Rust's primitive types. This is mainly useful in macros
|
||||
where you want avoid these types being shadowed.
|
||||
- [Relaxed some of the trait bounds on `HashMap` and `HashSet`.][67642]
|
||||
- [`string::FromUtf8Error` now implements `Clone + Eq`.][68738]
|
||||
|
||||
Stabilized APIs
|
||||
---------------
|
||||
- [`Once::is_completed`]
|
||||
- [`f32::LOG10_2`]
|
||||
- [`f32::LOG2_10`]
|
||||
- [`f64::LOG10_2`]
|
||||
- [`f64::LOG2_10`]
|
||||
- [`iter::once_with`]
|
||||
|
||||
Cargo
|
||||
-----
|
||||
- [You can now set config `[profile]`s in your `.cargo/config`, or through
|
||||
your environment.][cargo/7823]
|
||||
- [Cargo will now set `CARGO_BIN_EXE_<name>` pointing to a binary's
|
||||
executable path when running integration tests or benchmarks.][cargo/7697]
|
||||
`<name>` is the name of your binary as-is e.g. If you wanted the executable
|
||||
path for a binary named `my-program`you would use `env!("CARGO_BIN_EXE_my-program")`.
|
||||
|
||||
Misc
|
||||
----
|
||||
- [Certain checks in the `const_err` lint were deemed unrelated to const
|
||||
evaluation][69185], and have been moved to the `unconditional_panic` and
|
||||
`arithmetic_overflow` lints.
|
||||
|
||||
Compatibility Notes
|
||||
-------------------
|
||||
|
||||
- [Having trailing syntax in the `assert!` macro is now a hard error.][69548] This
|
||||
has been a warning since 1.36.0.
|
||||
- [Fixed `Self` not having the correctly inferred type.][69340] This incorrectly
|
||||
led to some instances being accepted, and now correctly emits a hard error.
|
||||
|
||||
[69340]: https://github.com/rust-lang/rust/pull/69340
|
||||
|
||||
Internal Only
|
||||
-------------
|
||||
These changes provide no direct user facing benefits, but represent significant
|
||||
improvements to the internals and overall performance of `rustc` and
|
||||
related tools.
|
||||
|
||||
- [All components are now built with `opt-level=3` instead of `2`.][67878]
|
||||
- [Improved how rustc generates drop code.][67332]
|
||||
- [Improved performance from `#[inline]`-ing certain hot functions.][69256]
|
||||
- [traits: preallocate 2 Vecs of known initial size][69022]
|
||||
- [Avoid exponential behaviour when relating types][68772]
|
||||
- [Skip `Drop` terminators for enum variants without drop glue][68943]
|
||||
- [Improve performance of coherence checks][68966]
|
||||
- [Deduplicate types in the generator witness][68672]
|
||||
- [Invert control in struct_lint_level.][68725]
|
||||
|
||||
[67332]: https://github.com/rust-lang/rust/pull/67332/
|
||||
[67429]: https://github.com/rust-lang/rust/pull/67429/
|
||||
[67637]: https://github.com/rust-lang/rust/pull/67637/
|
||||
[67642]: https://github.com/rust-lang/rust/pull/67642/
|
||||
[67878]: https://github.com/rust-lang/rust/pull/67878/
|
||||
[67885]: https://github.com/rust-lang/rust/pull/67885/
|
||||
[68129]: https://github.com/rust-lang/rust/pull/68129/
|
||||
[68672]: https://github.com/rust-lang/rust/pull/68672/
|
||||
[68725]: https://github.com/rust-lang/rust/pull/68725/
|
||||
[68728]: https://github.com/rust-lang/rust/pull/68728/
|
||||
[68738]: https://github.com/rust-lang/rust/pull/68738/
|
||||
[68742]: https://github.com/rust-lang/rust/pull/68742/
|
||||
[68764]: https://github.com/rust-lang/rust/pull/68764/
|
||||
[68772]: https://github.com/rust-lang/rust/pull/68772/
|
||||
[68943]: https://github.com/rust-lang/rust/pull/68943/
|
||||
[68952]: https://github.com/rust-lang/rust/pull/68952/
|
||||
[68966]: https://github.com/rust-lang/rust/pull/68966/
|
||||
[68984]: https://github.com/rust-lang/rust/pull/68984/
|
||||
[69022]: https://github.com/rust-lang/rust/pull/69022/
|
||||
[69185]: https://github.com/rust-lang/rust/pull/69185/
|
||||
[69194]: https://github.com/rust-lang/rust/pull/69194/
|
||||
[69201]: https://github.com/rust-lang/rust/pull/69201/
|
||||
[69227]: https://github.com/rust-lang/rust/pull/69227/
|
||||
[69548]: https://github.com/rust-lang/rust/pull/69548/
|
||||
[69256]: https://github.com/rust-lang/rust/pull/69256/
|
||||
[69361]: https://github.com/rust-lang/rust/pull/69361/
|
||||
[69366]: https://github.com/rust-lang/rust/pull/69366/
|
||||
[69538]: https://github.com/rust-lang/rust/pull/69538/
|
||||
[cargo/7823]: https://github.com/rust-lang/cargo/pull/7823
|
||||
[cargo/7697]: https://github.com/rust-lang/cargo/pull/7697
|
||||
[`Once::is_completed`]: https://doc.rust-lang.org/std/sync/struct.Once.html#method.is_completed
|
||||
[`f32::LOG10_2`]: https://doc.rust-lang.org/std/f32/consts/constant.LOG10_2.html
|
||||
[`f32::LOG2_10`]: https://doc.rust-lang.org/std/f32/consts/constant.LOG2_10.html
|
||||
[`f64::LOG10_2`]: https://doc.rust-lang.org/std/f64/consts/constant.LOG10_2.html
|
||||
[`f64::LOG2_10`]: https://doc.rust-lang.org/std/f64/consts/constant.LOG2_10.html
|
||||
[`iter::once_with`]: https://doc.rust-lang.org/std/iter/fn.once_with.html
|
||||
|
||||
|
||||
Version 1.42.0 (2020-03-12)
|
||||
==========================
|
||||
|
||||
@ -71,15 +220,7 @@ Compatibility Notes
|
||||
-------------------
|
||||
- [`Error::description` has been deprecated, and its use will now produce a
|
||||
warning.][66919] It's recommended to use `Display`/`to_string` instead.
|
||||
- [`use $crate;` inside macros is now a hard error.][37390] The compiler
|
||||
emitted forward compatibility warnings since Rust 1.14.0.
|
||||
- [As previously announced, this release reduces the level of support for
|
||||
32-bit Apple targets to tier 3.][apple-32bit-drop]. This means that the
|
||||
source code is still available to build, but the targets are no longer tested
|
||||
and no release binary is distributed by the Rust project. Please refer to the
|
||||
linked blog post for more information.
|
||||
|
||||
[37390]: https://github.com/rust-lang/rust/issues/37390/
|
||||
[68253]: https://github.com/rust-lang/rust/pull/68253/
|
||||
[68348]: https://github.com/rust-lang/rust/pull/68348/
|
||||
[67935]: https://github.com/rust-lang/rust/pull/67935/
|
||||
@ -4846,7 +4987,6 @@ Version 1.11.0 (2016-08-18)
|
||||
Language
|
||||
--------
|
||||
|
||||
* [`cfg_attr` works on `path` attributes](https://github.com/rust-lang/rust/pull/34546)
|
||||
* [Support nested `cfg_attr` attributes](https://github.com/rust-lang/rust/pull/34216)
|
||||
* [Allow statement-generating braced macro invocations at the end of blocks](https://github.com/rust-lang/rust/pull/34436)
|
||||
* [Macros can be expanded inside of trait definitions](https://github.com/rust-lang/rust/pull/34213)
|
||||
@ -4965,8 +5105,6 @@ Version 1.10.0 (2016-07-07)
|
||||
Language
|
||||
--------
|
||||
|
||||
* [Allow `concat_idents!` in type positions as well as in expression
|
||||
positions](https://github.com/rust-lang/rust/pull/33735).
|
||||
* [`Copy` types are required to have a trivial implementation of `Clone`](https://github.com/rust-lang/rust/pull/33420).
|
||||
[RFC 1521](https://github.com/rust-lang/rfcs/blob/master/text/1521-copy-clone-semantics.md).
|
||||
* [Single-variant enums support the `#[repr(..)]` attribute](https://github.com/rust-lang/rust/pull/33355).
|
||||
|
@ -315,7 +315,7 @@
|
||||
# `0` - no debug info
|
||||
# `1` - line tables only
|
||||
# `2` - full debug info with variable and type information
|
||||
# Can be overriden for specific subsets of Rust code (rustc, std or tools).
|
||||
# Can be overridden for specific subsets of Rust code (rustc, std or tools).
|
||||
# Debuginfo for tests run with compiletest is not controlled by this option
|
||||
# and needs to be enabled separately with `debuginfo-level-tests`.
|
||||
#debuginfo-level = if debug { 2 } else { 0 }
|
||||
@ -395,6 +395,15 @@
|
||||
# rustc to execute.
|
||||
#lld = false
|
||||
|
||||
# Indicates whether LLD will be used to link Rust crates during bootstrap on
|
||||
# supported platforms. The LLD from the bootstrap distribution will be used
|
||||
# and not the LLD compiled during the bootstrap.
|
||||
#
|
||||
# LLD will not be used if we're cross linking or running tests.
|
||||
#
|
||||
# Explicitly setting the linker for a target will override this option.
|
||||
#use-lld = false
|
||||
|
||||
# Indicates whether some LLVM tools, like llvm-objdump, will be made available in the
|
||||
# sysroot.
|
||||
#llvm-tools = false
|
||||
@ -435,6 +444,10 @@
|
||||
# Use LLVM libunwind as the implementation for Rust's unwinder.
|
||||
#llvm-libunwind = false
|
||||
|
||||
# Enable Windows Control Flow Guard checks in the standard library.
|
||||
# This only applies from stage 1 onwards, and only for Windows targets.
|
||||
#control-flow-guard = false
|
||||
|
||||
# =============================================================================
|
||||
# Options for specific targets
|
||||
#
|
||||
@ -463,6 +476,7 @@
|
||||
# Linker to be used to link Rust code. Note that the
|
||||
# default value is platform specific, and if not specified it may also depend on
|
||||
# what platform is crossing to what platform.
|
||||
# Setting this will override the `use-lld` option for Rust code.
|
||||
#linker = "cc"
|
||||
|
||||
# Path to the `llvm-config` binary of the installation of a custom LLVM to link
|
||||
|
@ -1 +1 @@
|
||||
b8cedc00407a4c56a3bda1ed605c6fc166655447
|
||||
4fb7144ed159f94491249e86d5bbd033b5d60550
|
@ -47,7 +47,7 @@ fn main() {
|
||||
};
|
||||
let stage = env::var("RUSTC_STAGE").expect("RUSTC_STAGE was not set");
|
||||
let sysroot = env::var_os("RUSTC_SYSROOT").expect("RUSTC_SYSROOT was not set");
|
||||
let on_fail = env::var_os("RUSTC_ON_FAIL").map(|of| Command::new(of));
|
||||
let on_fail = env::var_os("RUSTC_ON_FAIL").map(Command::new);
|
||||
|
||||
let rustc = env::var_os(rustc).unwrap_or_else(|| panic!("{:?} was not set", rustc));
|
||||
let libdir = env::var_os(libdir).unwrap_or_else(|| panic!("{:?} was not set", libdir));
|
||||
@ -64,7 +64,7 @@ fn main() {
|
||||
if let Some(crate_name) = crate_name {
|
||||
if let Some(target) = env::var_os("RUSTC_TIME") {
|
||||
if target == "all"
|
||||
|| target.into_string().unwrap().split(",").any(|c| c.trim() == crate_name)
|
||||
|| target.into_string().unwrap().split(',').any(|c| c.trim() == crate_name)
|
||||
{
|
||||
cmd.arg("-Ztime");
|
||||
}
|
||||
@ -134,6 +134,11 @@ fn main() {
|
||||
cmd.arg(format!("-Clinker={}", host_linker));
|
||||
}
|
||||
|
||||
// Override linker flavor if necessary.
|
||||
if let Ok(host_linker_flavor) = env::var("RUSTC_HOST_LINKER_FLAVOR") {
|
||||
cmd.arg(format!("-Clinker-flavor={}", host_linker_flavor));
|
||||
}
|
||||
|
||||
if let Ok(s) = env::var("RUSTC_HOST_CRT_STATIC") {
|
||||
if s == "true" {
|
||||
cmd.arg("-C").arg("target-feature=+crt-static");
|
||||
@ -189,7 +194,7 @@ fn main() {
|
||||
crate_name,
|
||||
is_test,
|
||||
dur.as_secs(),
|
||||
dur.subsec_nanos() / 1_000_000
|
||||
dur.subsec_millis()
|
||||
);
|
||||
|
||||
match status.code() {
|
||||
|
@ -61,7 +61,7 @@ fn main() {
|
||||
}
|
||||
|
||||
// Needed to be able to run all rustdoc tests.
|
||||
if let Some(_) = env::var_os("RUSTDOC_GENERATE_REDIRECT_PAGES") {
|
||||
if env::var_os("RUSTDOC_GENERATE_REDIRECT_PAGES").is_some() {
|
||||
// This "unstable-options" can be removed when `--generate-redirect-pages` is stabilized
|
||||
if !has_unstable {
|
||||
cmd.arg("-Z").arg("unstable-options");
|
||||
|
@ -80,7 +80,7 @@ def _download(path, url, probably_big, verbose, exception):
|
||||
option = "-s"
|
||||
run(["curl", option,
|
||||
"-y", "30", "-Y", "10", # timeout if speed is < 10 bytes/sec for > 30 seconds
|
||||
"--connect-timeout", "30", # timeout if cannot connect within 30 seconds
|
||||
"--connect-timeout", "30", # timeout if cannot connect within 30 seconds
|
||||
"--retry", "3", "-Sf", "-o", path, url],
|
||||
verbose=verbose,
|
||||
exception=exception)
|
||||
@ -332,7 +332,6 @@ class RustBuild(object):
|
||||
self.use_vendored_sources = ''
|
||||
self.verbose = False
|
||||
|
||||
|
||||
def download_stage0(self):
|
||||
"""Fetch the build system for Rust, written in Rust
|
||||
|
||||
@ -351,7 +350,7 @@ class RustBuild(object):
|
||||
try:
|
||||
with tempfile.NamedTemporaryFile(delete=False) as temp_file:
|
||||
temp_path = temp_file.name
|
||||
with tarfile.open(temp_path, "w:xz") as tar:
|
||||
with tarfile.open(temp_path, "w:xz"):
|
||||
pass
|
||||
return True
|
||||
except tarfile.CompressionError:
|
||||
@ -397,7 +396,7 @@ class RustBuild(object):
|
||||
|
||||
if self.rustfmt() and self.rustfmt().startswith(self.bin_root()) and (
|
||||
not os.path.exists(self.rustfmt())
|
||||
or self.program_out_of_date(self.rustfmt_stamp())
|
||||
or self.program_out_of_date(self.rustfmt_stamp(), self.rustfmt_channel)
|
||||
):
|
||||
if rustfmt_channel:
|
||||
tarball_suffix = '.tar.xz' if support_xz() else '.tar.gz'
|
||||
@ -407,7 +406,7 @@ class RustBuild(object):
|
||||
self.fix_executable("{}/bin/rustfmt".format(self.bin_root()))
|
||||
self.fix_executable("{}/bin/cargo-fmt".format(self.bin_root()))
|
||||
with output(self.rustfmt_stamp()) as rustfmt_stamp:
|
||||
rustfmt_stamp.write(self.date)
|
||||
rustfmt_stamp.write(self.date + self.rustfmt_channel)
|
||||
|
||||
def _download_stage0_helper(self, filename, pattern, tarball_suffix, date=None):
|
||||
if date is None:
|
||||
@ -521,12 +520,12 @@ class RustBuild(object):
|
||||
"""
|
||||
return os.path.join(self.bin_root(), '.rustfmt-stamp')
|
||||
|
||||
def program_out_of_date(self, stamp_path):
|
||||
def program_out_of_date(self, stamp_path, extra=""):
|
||||
"""Check if the given program stamp is out of date"""
|
||||
if not os.path.exists(stamp_path) or self.clean:
|
||||
return True
|
||||
with open(stamp_path, 'r') as stamp:
|
||||
return self.date != stamp.read()
|
||||
return (self.date + extra) != stamp.read()
|
||||
|
||||
def bin_root(self):
|
||||
"""Return the binary root directory
|
||||
@ -825,7 +824,7 @@ class RustBuild(object):
|
||||
if not os.path.exists(vendor_dir):
|
||||
print('error: vendoring required, but vendor directory does not exist.')
|
||||
print(' Run `cargo vendor` without sudo to initialize the '
|
||||
'vendor directory.')
|
||||
'vendor directory.')
|
||||
raise Exception("{} not found".format(vendor_dir))
|
||||
|
||||
if self.use_vendored_sources:
|
||||
@ -839,7 +838,7 @@ class RustBuild(object):
|
||||
"\n"
|
||||
"[source.vendored-sources]\n"
|
||||
"directory = '{}/vendor'\n"
|
||||
.format(self.rust_root))
|
||||
.format(self.rust_root))
|
||||
else:
|
||||
if os.path.exists('.cargo'):
|
||||
shutil.rmtree('.cargo')
|
||||
|
@ -510,7 +510,7 @@ impl<'a> Builder<'a> {
|
||||
Subcommand::Format { .. } | Subcommand::Clean { .. } => panic!(),
|
||||
};
|
||||
|
||||
let builder = Builder {
|
||||
Builder {
|
||||
build,
|
||||
top_stage: build.config.stage.unwrap_or(2),
|
||||
kind,
|
||||
@ -518,9 +518,7 @@ impl<'a> Builder<'a> {
|
||||
stack: RefCell::new(Vec::new()),
|
||||
time_spent_on_dependencies: Cell::new(Duration::new(0, 0)),
|
||||
paths: paths.to_owned(),
|
||||
};
|
||||
|
||||
builder
|
||||
}
|
||||
}
|
||||
|
||||
pub fn execute_cli(&self) {
|
||||
@ -694,7 +692,7 @@ impl<'a> Builder<'a> {
|
||||
cmd.env_remove("MAKEFLAGS");
|
||||
cmd.env_remove("MFLAGS");
|
||||
|
||||
if let Some(linker) = self.linker(compiler.host) {
|
||||
if let Some(linker) = self.linker(compiler.host, true) {
|
||||
cmd.env("RUSTC_TARGET_LINKER", linker);
|
||||
}
|
||||
cmd
|
||||
@ -727,7 +725,11 @@ impl<'a> Builder<'a> {
|
||||
self.clear_if_dirty(&my_out, &rustdoc);
|
||||
}
|
||||
|
||||
cargo.env("CARGO_TARGET_DIR", &out_dir).arg(cmd).arg("-Zconfig-profile");
|
||||
cargo.env("CARGO_TARGET_DIR", &out_dir).arg(cmd);
|
||||
|
||||
if !self.local_rebuild {
|
||||
cargo.arg("-Zconfig-profile");
|
||||
}
|
||||
|
||||
let profile_var = |name: &str| {
|
||||
let profile = if self.config.rust_optimize { "RELEASE" } else { "DEV" };
|
||||
@ -753,13 +755,12 @@ impl<'a> Builder<'a> {
|
||||
cargo.env("RUST_CHECK", "1");
|
||||
}
|
||||
|
||||
let stage;
|
||||
if compiler.stage == 0 && self.local_rebuild {
|
||||
let stage = if compiler.stage == 0 && self.local_rebuild {
|
||||
// Assume the local-rebuild rustc already has stage1 features.
|
||||
stage = 1;
|
||||
1
|
||||
} else {
|
||||
stage = compiler.stage;
|
||||
}
|
||||
compiler.stage
|
||||
};
|
||||
|
||||
let mut rustflags = Rustflags::new(&target);
|
||||
if stage != 0 {
|
||||
@ -850,7 +851,13 @@ impl<'a> Builder<'a> {
|
||||
rustflags.arg("-Zforce-unstable-if-unmarked");
|
||||
}
|
||||
|
||||
rustflags.arg("-Zexternal-macro-backtrace");
|
||||
// cfg(bootstrap): the flag was renamed from `-Zexternal-macro-backtrace`
|
||||
// to `-Zmacro-backtrace`, keep only the latter after beta promotion.
|
||||
if stage == 0 {
|
||||
rustflags.arg("-Zexternal-macro-backtrace");
|
||||
} else {
|
||||
rustflags.arg("-Zmacro-backtrace");
|
||||
}
|
||||
|
||||
let want_rustdoc = self.doc_tests != DocTests::No;
|
||||
|
||||
@ -949,10 +956,31 @@ impl<'a> Builder<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(host_linker) = self.linker(compiler.host) {
|
||||
// FIXME: Don't use LLD if we're compiling libtest, since it fails to link it.
|
||||
// See https://github.com/rust-lang/rust/issues/68647.
|
||||
let can_use_lld = mode != Mode::Std;
|
||||
|
||||
// FIXME: The beta compiler doesn't pick the `lld-link` flavor for `*-pc-windows-msvc`
|
||||
// Remove `RUSTC_HOST_LINKER_FLAVOR` when this is fixed
|
||||
let lld_linker_flavor = |linker: &Path, target: Interned<String>| {
|
||||
compiler.stage == 0
|
||||
&& linker.file_name() == Some(OsStr::new("rust-lld"))
|
||||
&& target.contains("pc-windows-msvc")
|
||||
};
|
||||
|
||||
if let Some(host_linker) = self.linker(compiler.host, can_use_lld) {
|
||||
if lld_linker_flavor(host_linker, compiler.host) {
|
||||
cargo.env("RUSTC_HOST_LINKER_FLAVOR", "lld-link");
|
||||
}
|
||||
|
||||
cargo.env("RUSTC_HOST_LINKER", host_linker);
|
||||
}
|
||||
if let Some(target_linker) = self.linker(target) {
|
||||
|
||||
if let Some(target_linker) = self.linker(target, can_use_lld) {
|
||||
if lld_linker_flavor(target_linker, target) {
|
||||
rustflags.arg("-Clinker-flavor=lld-link");
|
||||
}
|
||||
|
||||
let target = crate::envify(&target);
|
||||
cargo.env(&format!("CARGO_TARGET_{}_LINKER", target), target_linker);
|
||||
}
|
||||
@ -1111,6 +1139,20 @@ impl<'a> Builder<'a> {
|
||||
);
|
||||
}
|
||||
|
||||
// If Control Flow Guard is enabled, pass the `control_flow_guard=checks` flag to rustc
|
||||
// when compiling the standard library, since this might be linked into the final outputs
|
||||
// produced by rustc. Since this mitigation is only available on Windows, only enable it
|
||||
// for the standard library in case the compiler is run on a non-Windows platform.
|
||||
// This is not needed for stage 0 artifacts because these will only be used for building
|
||||
// the stage 1 compiler.
|
||||
if cfg!(windows)
|
||||
&& mode == Mode::Std
|
||||
&& self.config.control_flow_guard
|
||||
&& compiler.stage >= 1
|
||||
{
|
||||
rustflags.arg("-Zcontrol_flow_guard=checks");
|
||||
}
|
||||
|
||||
// For `cargo doc` invocations, make rustdoc print the Rust version into the docs
|
||||
cargo.env("RUSTDOC_CRATE_VERSION", self.rust_version());
|
||||
|
||||
@ -1252,12 +1294,7 @@ impl<'a> Builder<'a> {
|
||||
};
|
||||
|
||||
if self.config.print_step_timings && dur > Duration::from_millis(100) {
|
||||
println!(
|
||||
"[TIMING] {:?} -- {}.{:03}",
|
||||
step,
|
||||
dur.as_secs(),
|
||||
dur.subsec_nanos() / 1_000_000
|
||||
);
|
||||
println!("[TIMING] {:?} -- {}.{:03}", step, dur.as_secs(), dur.subsec_millis());
|
||||
}
|
||||
|
||||
{
|
||||
@ -1302,7 +1339,7 @@ impl Rustflags {
|
||||
|
||||
fn arg(&mut self, arg: &str) -> &mut Self {
|
||||
assert_eq!(arg.split_whitespace().count(), 1);
|
||||
if self.0.len() > 0 {
|
||||
if !self.0.is_empty() {
|
||||
self.0.push_str(" ");
|
||||
}
|
||||
self.0.push_str(arg);
|
||||
|
@ -19,7 +19,6 @@ fn configure(host: &[&str], target: &[&str]) -> Config {
|
||||
config.out = dir;
|
||||
config.build = INTERNER.intern_str("A");
|
||||
config.hosts = vec![config.build]
|
||||
.clone()
|
||||
.into_iter()
|
||||
.chain(host.iter().map(|s| INTERNER.intern_str(s)))
|
||||
.collect::<Vec<_>>();
|
||||
|
@ -13,7 +13,7 @@ use build_helper::output;
|
||||
use crate::Build;
|
||||
|
||||
// The version number
|
||||
pub const CFG_RELEASE_NUM: &str = "1.42.0";
|
||||
pub const CFG_RELEASE_NUM: &str = "1.43.0";
|
||||
|
||||
pub struct GitInfo {
|
||||
inner: Option<Info>,
|
||||
|
@ -18,7 +18,6 @@ use std::str;
|
||||
use build_helper::{output, t, up_to_date};
|
||||
use filetime::FileTime;
|
||||
use serde::Deserialize;
|
||||
use serde_json;
|
||||
|
||||
use crate::builder::Cargo;
|
||||
use crate::dist;
|
||||
@ -142,14 +141,15 @@ fn copy_third_party_objects(
|
||||
copy_and_stamp(&srcdir, "crt1.o");
|
||||
}
|
||||
|
||||
// Copies libunwind.a compiled to be linked wit x86_64-fortanix-unknown-sgx.
|
||||
// Copies libunwind.a compiled to be linked with x86_64-fortanix-unknown-sgx.
|
||||
//
|
||||
// This target needs to be linked to Fortanix's port of llvm's libunwind.
|
||||
// libunwind requires support for rwlock and printing to stderr,
|
||||
// which is provided by std for this target.
|
||||
if target == "x86_64-fortanix-unknown-sgx" {
|
||||
let src_path_env = "X86_FORTANIX_SGX_LIBS";
|
||||
let src = env::var(src_path_env).expect(&format!("{} not found in env", src_path_env));
|
||||
let src =
|
||||
env::var(src_path_env).unwrap_or_else(|_| panic!("{} not found in env", src_path_env));
|
||||
copy_and_stamp(Path::new(&src), "libunwind.a");
|
||||
}
|
||||
|
||||
@ -361,7 +361,7 @@ impl Step for StartupObjects {
|
||||
);
|
||||
}
|
||||
|
||||
let target = sysroot_dir.join(file.to_string() + ".o");
|
||||
let target = sysroot_dir.join((*file).to_string() + ".o");
|
||||
builder.copy(dst_file, &target);
|
||||
target_deps.push(target);
|
||||
}
|
||||
@ -515,7 +515,7 @@ pub fn rustc_cargo_env(builder: &Builder<'_>, cargo: &mut Cargo, target: Interne
|
||||
.env("CFG_VERSION", builder.rust_version())
|
||||
.env("CFG_PREFIX", builder.config.prefix.clone().unwrap_or_default());
|
||||
|
||||
let libdir_relative = builder.config.libdir_relative().unwrap_or(Path::new("lib"));
|
||||
let libdir_relative = builder.config.libdir_relative().unwrap_or_else(|| Path::new("lib"));
|
||||
cargo.env("CFG_LIBDIR_RELATIVE", libdir_relative);
|
||||
|
||||
if let Some(ref ver_date) = builder.rust_info.commit_date() {
|
||||
@ -843,11 +843,11 @@ pub fn run_cargo(
|
||||
};
|
||||
for filename in filenames {
|
||||
// Skip files like executables
|
||||
if !filename.ends_with(".rlib")
|
||||
&& !filename.ends_with(".lib")
|
||||
&& !filename.ends_with(".a")
|
||||
&& !is_dylib(&filename)
|
||||
&& !(is_check && filename.ends_with(".rmeta"))
|
||||
if !(filename.ends_with(".rlib")
|
||||
|| filename.ends_with(".lib")
|
||||
|| filename.ends_with(".a")
|
||||
|| is_dylib(&filename)
|
||||
|| (is_check && filename.ends_with(".rmeta")))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -905,7 +905,7 @@ pub fn run_cargo(
|
||||
for (prefix, extension, expected_len) in toplevel {
|
||||
let candidates = contents.iter().filter(|&&(_, ref filename, ref meta)| {
|
||||
filename.starts_with(&prefix[..])
|
||||
&& filename[prefix.len()..].starts_with("-")
|
||||
&& filename[prefix.len()..].starts_with('-')
|
||||
&& filename.ends_with(&extension[..])
|
||||
&& meta.len() == expected_len
|
||||
});
|
||||
|
@ -16,7 +16,6 @@ use crate::flags::Flags;
|
||||
pub use crate::flags::Subcommand;
|
||||
use build_helper::t;
|
||||
use serde::Deserialize;
|
||||
use toml;
|
||||
|
||||
/// Global configuration for the entire build and/or bootstrap.
|
||||
///
|
||||
@ -83,6 +82,7 @@ pub struct Config {
|
||||
pub llvm_use_linker: Option<String>,
|
||||
pub llvm_allow_old_toolchain: Option<bool>,
|
||||
|
||||
pub use_lld: bool,
|
||||
pub lld_enabled: bool,
|
||||
pub lldb_enabled: bool,
|
||||
pub llvm_tools_enabled: bool,
|
||||
@ -116,6 +116,7 @@ pub struct Config {
|
||||
pub targets: Vec<Interned<String>>,
|
||||
pub local_rebuild: bool,
|
||||
pub jemalloc: bool,
|
||||
pub control_flow_guard: bool,
|
||||
|
||||
// dist misc
|
||||
pub dist_sign_folder: Option<PathBuf>,
|
||||
@ -176,6 +177,15 @@ pub struct Target {
|
||||
pub no_std: bool,
|
||||
}
|
||||
|
||||
impl Target {
|
||||
pub fn from_triple(triple: &str) -> Self {
|
||||
let mut target: Self = Default::default();
|
||||
if triple.contains("-none") || triple.contains("nvptx") {
|
||||
target.no_std = true;
|
||||
}
|
||||
target
|
||||
}
|
||||
}
|
||||
/// Structure of the `config.toml` file that configuration is read from.
|
||||
///
|
||||
/// This structure uses `Decodable` to automatically decode a TOML configuration
|
||||
@ -322,6 +332,7 @@ struct Rust {
|
||||
save_toolstates: Option<String>,
|
||||
codegen_backends: Option<Vec<String>>,
|
||||
lld: Option<bool>,
|
||||
use_lld: Option<bool>,
|
||||
llvm_tools: Option<bool>,
|
||||
lldb: Option<bool>,
|
||||
deny_warnings: Option<bool>,
|
||||
@ -332,6 +343,7 @@ struct Rust {
|
||||
jemalloc: Option<bool>,
|
||||
test_compare_mode: Option<bool>,
|
||||
llvm_libunwind: Option<bool>,
|
||||
control_flow_guard: Option<bool>,
|
||||
}
|
||||
|
||||
/// TOML representation of how each build target is configured.
|
||||
@ -350,6 +362,7 @@ struct TomlTarget {
|
||||
musl_root: Option<String>,
|
||||
wasi_root: Option<String>,
|
||||
qemu_rootfs: Option<String>,
|
||||
no_std: Option<bool>,
|
||||
}
|
||||
|
||||
impl Config {
|
||||
@ -440,7 +453,7 @@ impl Config {
|
||||
}
|
||||
}
|
||||
})
|
||||
.unwrap_or_else(|| TomlConfig::default());
|
||||
.unwrap_or_else(TomlConfig::default);
|
||||
|
||||
let build = toml.build.clone().unwrap_or_default();
|
||||
// set by bootstrap.py
|
||||
@ -539,7 +552,7 @@ impl Config {
|
||||
config.llvm_ldflags = llvm.ldflags.clone();
|
||||
set(&mut config.llvm_use_libcxx, llvm.use_libcxx);
|
||||
config.llvm_use_linker = llvm.use_linker.clone();
|
||||
config.llvm_allow_old_toolchain = llvm.allow_old_toolchain.clone();
|
||||
config.llvm_allow_old_toolchain = llvm.allow_old_toolchain;
|
||||
}
|
||||
|
||||
if let Some(ref rust) = toml.rust {
|
||||
@ -566,6 +579,7 @@ impl Config {
|
||||
if let Some(true) = rust.incremental {
|
||||
config.incremental = true;
|
||||
}
|
||||
set(&mut config.use_lld, rust.use_lld);
|
||||
set(&mut config.lld_enabled, rust.lld);
|
||||
set(&mut config.lldb_enabled, rust.lldb);
|
||||
set(&mut config.llvm_tools_enabled, rust.llvm_tools);
|
||||
@ -578,6 +592,7 @@ impl Config {
|
||||
set(&mut config.rust_verify_llvm_ir, rust.verify_llvm_ir);
|
||||
config.rust_thin_lto_import_instr_limit = rust.thin_lto_import_instr_limit;
|
||||
set(&mut config.rust_remap_debuginfo, rust.remap_debuginfo);
|
||||
set(&mut config.control_flow_guard, rust.control_flow_guard);
|
||||
|
||||
if let Some(ref backends) = rust.codegen_backends {
|
||||
config.rust_codegen_backends =
|
||||
@ -590,7 +605,7 @@ impl Config {
|
||||
|
||||
if let Some(ref t) = toml.target {
|
||||
for (triple, cfg) in t {
|
||||
let mut target = Target::default();
|
||||
let mut target = Target::from_triple(triple);
|
||||
|
||||
if let Some(ref s) = cfg.llvm_config {
|
||||
target.llvm_config = Some(config.src.join(s));
|
||||
@ -601,12 +616,15 @@ impl Config {
|
||||
if let Some(ref s) = cfg.android_ndk {
|
||||
target.ndk = Some(config.src.join(s));
|
||||
}
|
||||
if let Some(s) = cfg.no_std {
|
||||
target.no_std = s;
|
||||
}
|
||||
target.cc = cfg.cc.clone().map(PathBuf::from);
|
||||
target.cxx = cfg.cxx.clone().map(PathBuf::from);
|
||||
target.ar = cfg.ar.clone().map(PathBuf::from);
|
||||
target.ranlib = cfg.ranlib.clone().map(PathBuf::from);
|
||||
target.linker = cfg.linker.clone().map(PathBuf::from);
|
||||
target.crt_static = cfg.crt_static.clone();
|
||||
target.crt_static = cfg.crt_static;
|
||||
target.musl_root = cfg.musl_root.clone().map(PathBuf::from);
|
||||
target.wasi_root = cfg.wasi_root.clone().map(PathBuf::from);
|
||||
target.qemu_rootfs = cfg.qemu_rootfs.clone().map(PathBuf::from);
|
||||
|
@ -60,10 +60,11 @@ o("lld", "rust.lld", "build lld")
|
||||
o("lldb", "rust.lldb", "build lldb")
|
||||
o("missing-tools", "dist.missing-tools", "allow failures when building tools")
|
||||
o("use-libcxx", "llvm.use-libcxx", "build LLVM with libc++")
|
||||
o("control-flow-guard", "rust.control-flow-guard", "Enable Control Flow Guard")
|
||||
|
||||
o("cflags", "llvm.cflags", "build LLVM with these extra compiler flags")
|
||||
o("cxxflags", "llvm.cxxflags", "build LLVM with these extra compiler flags")
|
||||
o("ldflags", "llvm.ldflags", "build LLVM with these extra linker flags")
|
||||
v("llvm-cflags", "llvm.cflags", "build LLVM with these extra compiler flags")
|
||||
v("llvm-cxxflags", "llvm.cxxflags", "build LLVM with these extra compiler flags")
|
||||
v("llvm-ldflags", "llvm.ldflags", "build LLVM with these extra linker flags")
|
||||
|
||||
o("llvm-libunwind", "rust.llvm-libunwind", "use LLVM libunwind")
|
||||
|
||||
@ -392,11 +393,12 @@ for target in configured_targets:
|
||||
|
||||
|
||||
def is_number(value):
|
||||
try:
|
||||
float(value)
|
||||
return True
|
||||
except ValueError:
|
||||
return False
|
||||
try:
|
||||
float(value)
|
||||
return True
|
||||
except ValueError:
|
||||
return False
|
||||
|
||||
|
||||
# Here we walk through the constructed configuration we have from the parsed
|
||||
# command line arguments. We then apply each piece of configuration by
|
||||
|
@ -105,6 +105,7 @@ impl Step for Docs {
|
||||
t!(fs::create_dir_all(&dst));
|
||||
let src = builder.doc_out(host);
|
||||
builder.cp_r(&src, &dst);
|
||||
builder.install(&builder.src.join("src/doc/robots.txt"), &dst, 0o644);
|
||||
|
||||
let mut cmd = rust_installer(builder);
|
||||
cmd.arg("generate")
|
||||
@ -233,7 +234,14 @@ fn make_win_dist(
|
||||
}
|
||||
}
|
||||
|
||||
let target_tools = ["gcc.exe", "ld.exe", "dlltool.exe", "libwinpthread-1.dll"];
|
||||
let compiler = if target_triple == "i686-pc-windows-gnu" {
|
||||
"i686-w64-mingw32-gcc.exe"
|
||||
} else if target_triple == "x86_64-pc-windows-gnu" {
|
||||
"x86_64-w64-mingw32-gcc.exe"
|
||||
} else {
|
||||
"gcc.exe"
|
||||
};
|
||||
let target_tools = [compiler, "ld.exe", "dlltool.exe", "libwinpthread-1.dll"];
|
||||
let mut rustc_dlls = vec!["libwinpthread-1.dll"];
|
||||
if target_triple.starts_with("i686-") {
|
||||
rustc_dlls.push("libgcc_s_dw2-1.dll");
|
||||
@ -827,7 +835,7 @@ impl Step for Analysis {
|
||||
assert!(builder.config.extended);
|
||||
let name = pkgname(builder, "rust-analysis");
|
||||
|
||||
if &compiler.host != builder.config.build {
|
||||
if compiler.host != builder.config.build {
|
||||
return distdir(builder).join(format!("{}-{}.tar.gz", name, target));
|
||||
}
|
||||
|
||||
@ -876,7 +884,7 @@ fn copy_src_dirs(builder: &Builder<'_>, src_dirs: &[&str], exclude_dirs: &[&str]
|
||||
Some(path) => path,
|
||||
None => return false,
|
||||
};
|
||||
if spath.ends_with("~") || spath.ends_with(".pyc") {
|
||||
if spath.ends_with('~') || spath.ends_with(".pyc") {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -994,8 +1002,6 @@ impl Step for Src {
|
||||
"src/tools/rustc-std-workspace-core",
|
||||
"src/tools/rustc-std-workspace-alloc",
|
||||
"src/tools/rustc-std-workspace-std",
|
||||
"src/librustc",
|
||||
"src/libsyntax",
|
||||
];
|
||||
|
||||
copy_src_dirs(builder, &std_src_dirs[..], &[], &dst_src);
|
||||
|
@ -560,7 +560,7 @@ impl Step for Rustdoc {
|
||||
builder.ensure(Rustc { stage, target });
|
||||
|
||||
// Build rustdoc.
|
||||
builder.ensure(tool::Rustdoc { compiler: compiler });
|
||||
builder.ensure(tool::Rustdoc { compiler });
|
||||
|
||||
// Symlink compiler docs to the output directory of rustdoc documentation.
|
||||
let out_dir = builder.stage_out(compiler, Mode::ToolRustc).join(target).join("doc");
|
||||
|
@ -33,7 +33,7 @@ pub struct Flags {
|
||||
pub rustc_error_format: Option<String>,
|
||||
pub dry_run: bool,
|
||||
|
||||
// This overrides the deny-warnings configuation option,
|
||||
// This overrides the deny-warnings configuration option,
|
||||
// which passes -Dwarnings to the compiler invocations.
|
||||
//
|
||||
// true => deny, false => warn
|
||||
@ -571,7 +571,7 @@ fn split(s: &[String]) -> Vec<String> {
|
||||
}
|
||||
|
||||
fn parse_deny_warnings(matches: &getopts::Matches) -> Option<bool> {
|
||||
match matches.opt_str("warnings").as_ref().map(|v| v.as_str()) {
|
||||
match matches.opt_str("warnings").as_deref() {
|
||||
Some("deny") => Some(true),
|
||||
Some("warn") => Some(false),
|
||||
Some(value) => {
|
||||
|
@ -1,7 +1,7 @@
|
||||
//! Runs rustfmt on the repository.
|
||||
|
||||
use crate::Build;
|
||||
use build_helper::t;
|
||||
use build_helper::{output, t};
|
||||
use ignore::WalkBuilder;
|
||||
use std::path::Path;
|
||||
use std::process::Command;
|
||||
@ -53,6 +53,17 @@ pub fn format(build: &Build, check: bool) {
|
||||
for ignore in rustfmt_config.ignore {
|
||||
ignore_fmt.add(&format!("!{}", ignore)).expect(&ignore);
|
||||
}
|
||||
let untracked_paths_output = output(
|
||||
Command::new("git").arg("status").arg("--porcelain").arg("--untracked-files=normal"),
|
||||
);
|
||||
let untracked_paths = untracked_paths_output
|
||||
.lines()
|
||||
.filter(|entry| entry.starts_with("??"))
|
||||
.map(|entry| entry.split(" ").nth(1).expect("every git status entry should list a path"));
|
||||
for untracked_path in untracked_paths {
|
||||
eprintln!("skip untracked path {} during rustfmt invocations", untracked_path);
|
||||
ignore_fmt.add(&format!("!{}", untracked_path)).expect(&untracked_path);
|
||||
}
|
||||
let ignore_fmt = ignore_fmt.build().unwrap();
|
||||
|
||||
let rustfmt_path = build.config.initial_rustfmt.as_ref().unwrap_or_else(|| {
|
||||
|
@ -126,9 +126,8 @@ fn add_destdir(path: &Path, destdir: &Option<PathBuf>) -> PathBuf {
|
||||
None => return path.to_path_buf(),
|
||||
};
|
||||
for part in path.components() {
|
||||
match part {
|
||||
Component::Normal(s) => ret.push(s),
|
||||
_ => {}
|
||||
if let Component::Normal(s) = part {
|
||||
ret.push(s)
|
||||
}
|
||||
}
|
||||
ret
|
||||
|
@ -103,7 +103,6 @@
|
||||
//! More documentation can be found in each respective module below, and you can
|
||||
//! also check out the `src/bootstrap/README.md` file for more information.
|
||||
|
||||
#![feature(core_intrinsics)]
|
||||
#![feature(drain_filter)]
|
||||
|
||||
use std::cell::{Cell, RefCell};
|
||||
@ -239,9 +238,10 @@ pub struct Build {
|
||||
hosts: Vec<Interned<String>>,
|
||||
targets: Vec<Interned<String>>,
|
||||
|
||||
// Stage 0 (downloaded) compiler and cargo or their local rust equivalents
|
||||
// Stage 0 (downloaded) compiler, lld and cargo or their local rust equivalents
|
||||
initial_rustc: PathBuf,
|
||||
initial_cargo: PathBuf,
|
||||
initial_lld: PathBuf,
|
||||
|
||||
// Runtime state filled in later on
|
||||
// C/C++ compilers and archiver for all targets
|
||||
@ -343,9 +343,18 @@ impl Build {
|
||||
// we always try to use git for LLVM builds
|
||||
let in_tree_llvm_info = channel::GitInfo::new(false, &src.join("src/llvm-project"));
|
||||
|
||||
let initial_sysroot = config.initial_rustc.parent().unwrap().parent().unwrap();
|
||||
let initial_lld = initial_sysroot
|
||||
.join("lib")
|
||||
.join("rustlib")
|
||||
.join(config.build)
|
||||
.join("bin")
|
||||
.join("rust-lld");
|
||||
|
||||
let mut build = Build {
|
||||
initial_rustc: config.initial_rustc.clone(),
|
||||
initial_cargo: config.initial_cargo.clone(),
|
||||
initial_lld,
|
||||
local_rebuild: config.local_rebuild,
|
||||
fail_fast: config.cmd.fail_fast(),
|
||||
doc_tests: config.cmd.doc_tests(),
|
||||
@ -444,7 +453,7 @@ impl Build {
|
||||
builder.execute_cli();
|
||||
} else {
|
||||
let builder = builder::Builder::new(&self);
|
||||
let _ = builder.execute_cli();
|
||||
builder.execute_cli();
|
||||
}
|
||||
|
||||
// Check for postponed failures from `test --no-fail-fast`.
|
||||
@ -810,7 +819,7 @@ impl Build {
|
||||
}
|
||||
|
||||
/// Returns the path to the linker for the given target if it needs to be overridden.
|
||||
fn linker(&self, target: Interned<String>) -> Option<&Path> {
|
||||
fn linker(&self, target: Interned<String>, can_use_lld: bool) -> Option<&Path> {
|
||||
if let Some(linker) = self.config.target_config.get(&target).and_then(|c| c.linker.as_ref())
|
||||
{
|
||||
Some(linker)
|
||||
@ -819,6 +828,8 @@ impl Build {
|
||||
&& !target.contains("msvc")
|
||||
{
|
||||
Some(self.cc(target))
|
||||
} else if can_use_lld && self.config.use_lld && self.build == target {
|
||||
Some(&self.initial_lld)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
@ -839,7 +850,7 @@ impl Build {
|
||||
.target_config
|
||||
.get(&target)
|
||||
.and_then(|t| t.musl_root.as_ref())
|
||||
.or(self.config.musl_root.as_ref())
|
||||
.or_else(|| self.config.musl_root.as_ref())
|
||||
.map(|p| &**p)
|
||||
}
|
||||
|
||||
@ -1026,7 +1037,7 @@ impl Build {
|
||||
}
|
||||
|
||||
fn llvm_link_tools_dynamically(&self, target: Interned<String>) -> bool {
|
||||
(target.contains("linux-gnu") || target.contains("apple-darwin"))
|
||||
target.contains("linux-gnu") || target.contains("apple-darwin")
|
||||
}
|
||||
|
||||
/// Returns the `version` string associated with this compiler for Rust
|
||||
|
@ -5,7 +5,6 @@ use std::process::Command;
|
||||
|
||||
use build_helper::output;
|
||||
use serde::Deserialize;
|
||||
use serde_json;
|
||||
|
||||
use crate::cache::INTERNER;
|
||||
use crate::{Build, Crate};
|
||||
|
@ -15,8 +15,6 @@ use std::path::{Path, PathBuf};
|
||||
use std::process::Command;
|
||||
|
||||
use build_helper::{output, t};
|
||||
use cc;
|
||||
use cmake;
|
||||
|
||||
use crate::builder::{Builder, RunConfig, ShouldRun, Step};
|
||||
use crate::cache::Interned;
|
||||
@ -205,7 +203,7 @@ impl Step for Llvm {
|
||||
cfg.define("LLVM_ENABLE_LIBXML2", "OFF");
|
||||
}
|
||||
|
||||
if enabled_llvm_projects.len() > 0 {
|
||||
if !enabled_llvm_projects.is_empty() {
|
||||
enabled_llvm_projects.sort();
|
||||
enabled_llvm_projects.dedup();
|
||||
cfg.define("LLVM_ENABLE_PROJECTS", enabled_llvm_projects.join(";"));
|
||||
@ -243,12 +241,8 @@ impl Step for Llvm {
|
||||
cfg.define("LLVM_VERSION_SUFFIX", suffix);
|
||||
}
|
||||
} else {
|
||||
let mut default_suffix =
|
||||
format!("-rust-{}-{}", channel::CFG_RELEASE_NUM, builder.config.channel,);
|
||||
if let Some(sha) = llvm_info.sha_short() {
|
||||
default_suffix.push_str("-");
|
||||
default_suffix.push_str(sha);
|
||||
}
|
||||
let default_suffix =
|
||||
format!("-rust-{}-{}", channel::CFG_RELEASE_NUM, builder.config.channel);
|
||||
cfg.define("LLVM_VERSION_SUFFIX", default_suffix);
|
||||
}
|
||||
|
||||
@ -580,7 +574,7 @@ impl Step for Sanitizers {
|
||||
}
|
||||
|
||||
let out_dir = builder.native_dir(self.target).join("sanitizers");
|
||||
let runtimes = supported_sanitizers(&out_dir, self.target);
|
||||
let runtimes = supported_sanitizers(&out_dir, self.target, &builder.config.channel);
|
||||
if runtimes.is_empty() {
|
||||
return runtimes;
|
||||
}
|
||||
@ -647,7 +641,11 @@ pub struct SanitizerRuntime {
|
||||
}
|
||||
|
||||
/// Returns sanitizers available on a given target.
|
||||
fn supported_sanitizers(out_dir: &Path, target: Interned<String>) -> Vec<SanitizerRuntime> {
|
||||
fn supported_sanitizers(
|
||||
out_dir: &Path,
|
||||
target: Interned<String>,
|
||||
channel: &str,
|
||||
) -> Vec<SanitizerRuntime> {
|
||||
let mut result = Vec::new();
|
||||
match &*target {
|
||||
"x86_64-apple-darwin" => {
|
||||
@ -656,7 +654,7 @@ fn supported_sanitizers(out_dir: &Path, target: Interned<String>) -> Vec<Sanitiz
|
||||
cmake_target: format!("clang_rt.{}_osx_dynamic", s),
|
||||
path: out_dir
|
||||
.join(&format!("build/lib/darwin/libclang_rt.{}_osx_dynamic.dylib", s)),
|
||||
name: format!("librustc_rt.{}.dylib", s),
|
||||
name: format!("librustc-{}_rt.{}.dylib", channel, s),
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -665,7 +663,7 @@ fn supported_sanitizers(out_dir: &Path, target: Interned<String>) -> Vec<Sanitiz
|
||||
result.push(SanitizerRuntime {
|
||||
cmake_target: format!("clang_rt.{}-x86_64", s),
|
||||
path: out_dir.join(&format!("build/lib/linux/libclang_rt.{}-x86_64.a", s)),
|
||||
name: format!("librustc_rt.{}.a", s),
|
||||
name: format!("librustc-{}_rt.{}.a", channel, s),
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -674,7 +672,7 @@ fn supported_sanitizers(out_dir: &Path, target: Interned<String>) -> Vec<Sanitiz
|
||||
result.push(SanitizerRuntime {
|
||||
cmake_target: format!("clang_rt.{}-x86_64", s),
|
||||
path: out_dir.join(&format!("build/lib/fuchsia/libclang_rt.{}-x86_64.a", s)),
|
||||
name: format!("librustc_rt.{}.a", s),
|
||||
name: format!("librustc-{}_rt.{}.a", channel, s),
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -683,7 +681,7 @@ fn supported_sanitizers(out_dir: &Path, target: Interned<String>) -> Vec<Sanitiz
|
||||
result.push(SanitizerRuntime {
|
||||
cmake_target: format!("clang_rt.{}-aarch64", s),
|
||||
path: out_dir.join(&format!("build/lib/fuchsia/libclang_rt.{}-aarch64.a", s)),
|
||||
name: format!("librustc_rt.{}.a", s),
|
||||
name: format!("librustc-{}_rt.{}.a", channel, s),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ use std::process::Command;
|
||||
|
||||
use build_helper::{output, t};
|
||||
|
||||
use crate::config::Target;
|
||||
use crate::Build;
|
||||
|
||||
struct Finder {
|
||||
@ -192,13 +193,9 @@ pub fn check(build: &mut Build) {
|
||||
panic!("the iOS target is only supported on macOS");
|
||||
}
|
||||
|
||||
build.config.target_config.entry(target.clone()).or_insert(Target::from_triple(target));
|
||||
|
||||
if target.contains("-none-") || target.contains("nvptx") {
|
||||
if build.no_std(*target).is_none() {
|
||||
let target = build.config.target_config.entry(target.clone()).or_default();
|
||||
|
||||
target.no_std = true;
|
||||
}
|
||||
|
||||
if build.no_std(*target) == Some(false) {
|
||||
panic!("All the *-none-* and nvptx* targets are no-std targets")
|
||||
}
|
||||
|
@ -388,8 +388,10 @@ impl Step for Miri {
|
||||
cargo.env("XARGO_RUST_SRC", builder.src.join("src"));
|
||||
// Debug things.
|
||||
cargo.env("RUST_BACKTRACE", "1");
|
||||
// Overwrite bootstrap's `rustc` wrapper overwriting our flags.
|
||||
cargo.env("RUSTC_DEBUG_ASSERTIONS", "true");
|
||||
// Let cargo-miri know where xargo ended up.
|
||||
cargo.env("XARGO", builder.out.join("bin").join("xargo"));
|
||||
cargo.env("XARGO_CHECK", builder.out.join("bin").join("xargo-check"));
|
||||
|
||||
let mut cargo = Command::from(cargo);
|
||||
if !try_run(builder, &mut cargo) {
|
||||
@ -397,7 +399,7 @@ impl Step for Miri {
|
||||
}
|
||||
|
||||
// # Determine where Miri put its sysroot.
|
||||
// To this end, we run `cargo miri setup --env` and capture the output.
|
||||
// To this end, we run `cargo miri setup --print-sysroot` and capture the output.
|
||||
// (We do this separately from the above so that when the setup actually
|
||||
// happens we get some output.)
|
||||
// We re-use the `cargo` from above.
|
||||
@ -596,7 +598,7 @@ impl Step for RustdocTheme {
|
||||
.env("RUSTDOC_REAL", builder.rustdoc(self.compiler))
|
||||
.env("RUSTDOC_CRATE_VERSION", builder.rust_version())
|
||||
.env("RUSTC_BOOTSTRAP", "1");
|
||||
if let Some(linker) = builder.linker(self.compiler.host) {
|
||||
if let Some(linker) = builder.linker(self.compiler.host, true) {
|
||||
cmd.env("RUSTC_TARGET_LINKER", linker);
|
||||
}
|
||||
try_run(builder, &mut cmd);
|
||||
@ -662,7 +664,7 @@ impl Step for RustdocJSNotStd {
|
||||
target: self.target,
|
||||
mode: "js-doc-test",
|
||||
suite: "rustdoc-js",
|
||||
path: None,
|
||||
path: "src/test/rustdoc-js",
|
||||
compare_mode: None,
|
||||
});
|
||||
} else {
|
||||
@ -698,7 +700,7 @@ impl Step for RustdocUi {
|
||||
target: self.target,
|
||||
mode: "ui",
|
||||
suite: "rustdoc-ui",
|
||||
path: Some("src/test/rustdoc-ui"),
|
||||
path: "src/test/rustdoc-ui",
|
||||
compare_mode: None,
|
||||
})
|
||||
}
|
||||
@ -843,7 +845,7 @@ macro_rules! test_definitions {
|
||||
target: self.target,
|
||||
mode: $mode,
|
||||
suite: $suite,
|
||||
path: Some($path),
|
||||
path: $path,
|
||||
compare_mode: $compare_mode,
|
||||
})
|
||||
}
|
||||
@ -926,7 +928,7 @@ struct Compiletest {
|
||||
target: Interned<String>,
|
||||
mode: &'static str,
|
||||
suite: &'static str,
|
||||
path: Option<&'static str>,
|
||||
path: &'static str,
|
||||
compare_mode: Option<&'static str>,
|
||||
}
|
||||
|
||||
@ -949,7 +951,7 @@ impl Step for Compiletest {
|
||||
let suite = self.suite;
|
||||
|
||||
// Path for test suite
|
||||
let suite_path = self.path.unwrap_or("");
|
||||
let suite_path = self.path;
|
||||
|
||||
// Skip codegen tests if they aren't enabled in configuration.
|
||||
if !builder.config.codegen_tests && suite == "codegen" {
|
||||
@ -1035,7 +1037,8 @@ impl Step for Compiletest {
|
||||
flags.push("-Zunstable-options".to_string());
|
||||
flags.push(builder.config.cmd.rustc_args().join(" "));
|
||||
|
||||
if let Some(linker) = builder.linker(target) {
|
||||
// Don't use LLD here since we want to test that rustc finds and uses a linker by itself.
|
||||
if let Some(linker) = builder.linker(target, false) {
|
||||
cmd.arg("--linker").arg(linker);
|
||||
}
|
||||
|
||||
@ -1149,7 +1152,6 @@ impl Step for Compiletest {
|
||||
// requires that a C++ compiler was configured which isn't always the case.
|
||||
if !builder.config.dry_run && suite == "run-make-fulldeps" {
|
||||
let llvm_components = output(Command::new(&llvm_config).arg("--components"));
|
||||
let llvm_cxxflags = output(Command::new(&llvm_config).arg("--cxxflags"));
|
||||
cmd.arg("--cc")
|
||||
.arg(builder.cc(target))
|
||||
.arg("--cxx")
|
||||
@ -1157,9 +1159,7 @@ impl Step for Compiletest {
|
||||
.arg("--cflags")
|
||||
.arg(builder.cflags(target, GitRepo::Rustc).join(" "))
|
||||
.arg("--llvm-components")
|
||||
.arg(llvm_components.trim())
|
||||
.arg("--llvm-cxxflags")
|
||||
.arg(llvm_cxxflags.trim());
|
||||
.arg(llvm_components.trim());
|
||||
if let Some(ar) = builder.ar(target) {
|
||||
cmd.arg("--ar").arg(ar);
|
||||
}
|
||||
@ -1197,8 +1197,6 @@ impl Step for Compiletest {
|
||||
.arg("--cflags")
|
||||
.arg("")
|
||||
.arg("--llvm-components")
|
||||
.arg("")
|
||||
.arg("--llvm-cxxflags")
|
||||
.arg("");
|
||||
}
|
||||
|
||||
@ -1268,15 +1266,15 @@ impl Step for Compiletest {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
|
||||
struct DocTest {
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
struct BookTest {
|
||||
compiler: Compiler,
|
||||
path: &'static str,
|
||||
path: PathBuf,
|
||||
name: &'static str,
|
||||
is_ext_doc: bool,
|
||||
}
|
||||
|
||||
impl Step for DocTest {
|
||||
impl Step for BookTest {
|
||||
type Output = ();
|
||||
const ONLY_HOSTS: bool = true;
|
||||
|
||||
@ -1284,12 +1282,59 @@ impl Step for DocTest {
|
||||
run.never()
|
||||
}
|
||||
|
||||
/// Runs `rustdoc --test` for all documentation in `src/doc`.
|
||||
/// Runs the documentation tests for a book in `src/doc`.
|
||||
///
|
||||
/// This will run all tests in our markdown documentation (e.g., the book)
|
||||
/// located in `src/doc`. The `rustdoc` that's run is the one that sits next to
|
||||
/// `compiler`.
|
||||
/// This uses the `rustdoc` that sits next to `compiler`.
|
||||
fn run(self, builder: &Builder<'_>) {
|
||||
// External docs are different from local because:
|
||||
// - Some books need pre-processing by mdbook before being tested.
|
||||
// - They need to save their state to toolstate.
|
||||
// - They are only tested on the "checktools" builders.
|
||||
//
|
||||
// The local docs are tested by default, and we don't want to pay the
|
||||
// cost of building mdbook, so they use `rustdoc --test` directly.
|
||||
// Also, the unstable book is special because SUMMARY.md is generated,
|
||||
// so it is easier to just run `rustdoc` on its files.
|
||||
if self.is_ext_doc {
|
||||
self.run_ext_doc(builder);
|
||||
} else {
|
||||
self.run_local_doc(builder);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl BookTest {
|
||||
/// This runs the equivalent of `mdbook test` (via the rustbook wrapper)
|
||||
/// which in turn runs `rustdoc --test` on each file in the book.
|
||||
fn run_ext_doc(self, builder: &Builder<'_>) {
|
||||
let compiler = self.compiler;
|
||||
|
||||
builder.ensure(compile::Std { compiler, target: compiler.host });
|
||||
|
||||
// mdbook just executes a binary named "rustdoc", so we need to update
|
||||
// PATH so that it points to our rustdoc.
|
||||
let mut rustdoc_path = builder.rustdoc(compiler);
|
||||
rustdoc_path.pop();
|
||||
let old_path = env::var_os("PATH").unwrap_or_default();
|
||||
let new_path = env::join_paths(iter::once(rustdoc_path).chain(env::split_paths(&old_path)))
|
||||
.expect("could not add rustdoc to PATH");
|
||||
|
||||
let mut rustbook_cmd = builder.tool_cmd(Tool::Rustbook);
|
||||
let path = builder.src.join(&self.path);
|
||||
rustbook_cmd.env("PATH", new_path).arg("test").arg(path);
|
||||
builder.add_rust_test_threads(&mut rustbook_cmd);
|
||||
builder.info(&format!("Testing rustbook {}", self.path.display()));
|
||||
let _time = util::timeit(&builder);
|
||||
let toolstate = if try_run(builder, &mut rustbook_cmd) {
|
||||
ToolState::TestPass
|
||||
} else {
|
||||
ToolState::TestFail
|
||||
};
|
||||
builder.save_toolstate(self.name, toolstate);
|
||||
}
|
||||
|
||||
/// This runs `rustdoc --test` on all `.md` files in the path.
|
||||
fn run_local_doc(self, builder: &Builder<'_>) {
|
||||
let compiler = self.compiler;
|
||||
|
||||
builder.ensure(compile::Std { compiler, target: compiler.host });
|
||||
@ -1298,7 +1343,6 @@ impl Step for DocTest {
|
||||
// tests for all files that end in `*.md`
|
||||
let mut stack = vec![builder.src.join(self.path)];
|
||||
let _time = util::timeit(&builder);
|
||||
|
||||
let mut files = Vec::new();
|
||||
while let Some(p) = stack.pop() {
|
||||
if p.is_dir() {
|
||||
@ -1310,25 +1354,13 @@ impl Step for DocTest {
|
||||
continue;
|
||||
}
|
||||
|
||||
// The nostarch directory in the book is for no starch, and so isn't
|
||||
// guaranteed to builder. We don't care if it doesn't build, so skip it.
|
||||
if p.to_str().map_or(false, |p| p.contains("nostarch")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
files.push(p);
|
||||
}
|
||||
|
||||
files.sort();
|
||||
|
||||
let mut toolstate = ToolState::TestPass;
|
||||
for file in files {
|
||||
if !markdown_test(builder, compiler, &file) {
|
||||
toolstate = ToolState::TestFail;
|
||||
}
|
||||
}
|
||||
if self.is_ext_doc {
|
||||
builder.save_toolstate(self.name, toolstate);
|
||||
markdown_test(builder, compiler, &file);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1357,9 +1389,9 @@ macro_rules! test_book {
|
||||
}
|
||||
|
||||
fn run(self, builder: &Builder<'_>) {
|
||||
builder.ensure(DocTest {
|
||||
builder.ensure(BookTest {
|
||||
compiler: self.compiler,
|
||||
path: $path,
|
||||
path: PathBuf::from($path),
|
||||
name: $book_name,
|
||||
is_ext_doc: !$default,
|
||||
});
|
||||
@ -1429,13 +1461,10 @@ impl Step for ErrorIndex {
|
||||
}
|
||||
|
||||
fn markdown_test(builder: &Builder<'_>, compiler: Compiler, markdown: &Path) -> bool {
|
||||
match fs::read_to_string(markdown) {
|
||||
Ok(contents) => {
|
||||
if !contents.contains("```") {
|
||||
return true;
|
||||
}
|
||||
if let Ok(contents) = fs::read_to_string(markdown) {
|
||||
if !contents.contains("```") {
|
||||
return true;
|
||||
}
|
||||
Err(_) => {}
|
||||
}
|
||||
|
||||
builder.info(&format!("doc tests for: {}", markdown.display()));
|
||||
@ -1464,7 +1493,7 @@ impl Step for RustcGuide {
|
||||
const ONLY_HOSTS: bool = true;
|
||||
|
||||
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
|
||||
run.path("src/doc/rustc-guide")
|
||||
run.path("src/doc/rustc-dev-guide")
|
||||
}
|
||||
|
||||
fn make_run(run: RunConfig<'_>) {
|
||||
@ -1472,14 +1501,14 @@ impl Step for RustcGuide {
|
||||
}
|
||||
|
||||
fn run(self, builder: &Builder<'_>) {
|
||||
let src = builder.src.join("src/doc/rustc-guide");
|
||||
let src = builder.src.join("src/doc/rustc-dev-guide");
|
||||
let mut rustbook_cmd = builder.tool_cmd(Tool::Rustbook);
|
||||
let toolstate = if try_run(builder, rustbook_cmd.arg("linkcheck").arg(&src)) {
|
||||
ToolState::TestPass
|
||||
} else {
|
||||
ToolState::TestFail
|
||||
};
|
||||
builder.save_toolstate("rustc-guide", toolstate);
|
||||
builder.save_toolstate("rustc-dev-guide", toolstate);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -234,7 +234,7 @@ pub fn prepare_tool_cargo(
|
||||
cargo.env("RUSTC_EXTERNAL_TOOL", "1");
|
||||
}
|
||||
|
||||
let mut features = extra_features.iter().cloned().collect::<Vec<_>>();
|
||||
let mut features = extra_features.to_vec();
|
||||
if builder.build.config.cargo_native_static {
|
||||
if path.ends_with("cargo")
|
||||
|| path.ends_with("rls")
|
||||
|
@ -6,7 +6,7 @@ use std::env;
|
||||
use std::fmt;
|
||||
use std::fs;
|
||||
use std::io::{Seek, SeekFrom};
|
||||
use std::path::PathBuf;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::process::Command;
|
||||
use std::time;
|
||||
|
||||
@ -24,7 +24,7 @@ const OS: Option<&str> = None;
|
||||
|
||||
type ToolstateData = HashMap<Box<str>, ToolState>;
|
||||
|
||||
#[derive(Copy, Clone, Debug, Deserialize, Serialize, PartialEq, Eq)]
|
||||
#[derive(Copy, Clone, Debug, Deserialize, Serialize, PartialEq, Eq, PartialOrd)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
/// Whether a tool can be compiled, tested or neither
|
||||
pub enum ToolState {
|
||||
@ -89,7 +89,7 @@ static STABLE_TOOLS: &[(&str, &str)] = &[
|
||||
static NIGHTLY_TOOLS: &[(&str, &str)] = &[
|
||||
("miri", "src/tools/miri"),
|
||||
("embedded-book", "src/doc/embedded-book"),
|
||||
("rustc-guide", "src/doc/rustc-guide"),
|
||||
("rustc-dev-guide", "src/doc/rustc-dev-guide"),
|
||||
];
|
||||
|
||||
fn print_error(tool: &str, submodule: &str) {
|
||||
@ -124,7 +124,7 @@ fn check_changed_files(toolstates: &HashMap<Box<str>, ToolState>) {
|
||||
let output = t!(String::from_utf8(output.stdout));
|
||||
|
||||
for (tool, submodule) in STABLE_TOOLS.iter().chain(NIGHTLY_TOOLS.iter()) {
|
||||
let changed = output.lines().any(|l| l.starts_with("M") && l.ends_with(submodule));
|
||||
let changed = output.lines().any(|l| l.starts_with('M') && l.ends_with(submodule));
|
||||
eprintln!("Verifying status of {}...", tool);
|
||||
if !changed {
|
||||
continue;
|
||||
@ -143,10 +143,31 @@ pub struct ToolStateCheck;
|
||||
impl Step for ToolStateCheck {
|
||||
type Output = ();
|
||||
|
||||
/// Runs the `linkchecker` tool as compiled in `stage` by the `host` compiler.
|
||||
/// Checks tool state status.
|
||||
///
|
||||
/// This tool in `src/tools` will verify the validity of all our links in the
|
||||
/// documentation to ensure we don't have a bunch of dead ones.
|
||||
/// This is intended to be used in the `checktools.sh` script. To use
|
||||
/// this, set `save-toolstates` in `config.toml` so that tool status will
|
||||
/// be saved to a JSON file. Then, run `x.py test --no-fail-fast` for all
|
||||
/// of the tools to populate the JSON file. After that is done, this
|
||||
/// command can be run to check for any status failures, and exits with an
|
||||
/// error if there are any.
|
||||
///
|
||||
/// This also handles publishing the results to the `history` directory of
|
||||
/// the toolstate repo https://github.com/rust-lang-nursery/rust-toolstate
|
||||
/// if the env var `TOOLSTATE_PUBLISH` is set. Note that there is a
|
||||
/// *separate* step of updating the `latest.json` file and creating GitHub
|
||||
/// issues and comments in `src/ci/publish_toolstate.sh`, which is only
|
||||
/// performed on master. (The shell/python code is intended to be migrated
|
||||
/// here eventually.)
|
||||
///
|
||||
/// The rules for failure are:
|
||||
/// * If the PR modifies a tool, the status must be test-pass.
|
||||
/// NOTE: There is intent to change this, see
|
||||
/// https://github.com/rust-lang/rust/issues/65000.
|
||||
/// * All "stable" tools must be test-pass on the stable or beta branches.
|
||||
/// * During beta promotion week, a PR is not allowed to "regress" a
|
||||
/// stable tool. That is, the status is not allowed to get worse
|
||||
/// (test-pass to test-fail or build-fail).
|
||||
fn run(self, builder: &Builder<'_>) {
|
||||
if builder.config.dry_run {
|
||||
return;
|
||||
@ -171,6 +192,8 @@ impl Step for ToolStateCheck {
|
||||
}
|
||||
|
||||
check_changed_files(&toolstates);
|
||||
checkout_toolstate_repo();
|
||||
let old_toolstate = read_old_toolstate();
|
||||
|
||||
for (tool, _) in STABLE_TOOLS.iter() {
|
||||
let state = toolstates[*tool];
|
||||
@ -180,11 +203,24 @@ impl Step for ToolStateCheck {
|
||||
did_error = true;
|
||||
eprintln!("error: Tool `{}` should be test-pass but is {}", tool, state);
|
||||
} else if in_beta_week {
|
||||
did_error = true;
|
||||
eprintln!(
|
||||
"error: Tool `{}` should be test-pass but is {} during beta week.",
|
||||
tool, state
|
||||
);
|
||||
let old_state = old_toolstate
|
||||
.iter()
|
||||
.find(|ts| ts.tool == *tool)
|
||||
.expect("latest.json missing tool")
|
||||
.state();
|
||||
if state < old_state {
|
||||
did_error = true;
|
||||
eprintln!(
|
||||
"error: Tool `{}` has regressed from {} to {} during beta week.",
|
||||
tool, old_state, state
|
||||
);
|
||||
} else {
|
||||
eprintln!(
|
||||
"warning: Tool `{}` is not test-pass (is `{}`), \
|
||||
this should be fixed before beta is branched.",
|
||||
tool, state
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -247,6 +283,70 @@ impl Builder<'_> {
|
||||
}
|
||||
}
|
||||
|
||||
fn toolstate_repo() -> String {
|
||||
env::var("TOOLSTATE_REPO")
|
||||
.unwrap_or_else(|_| "https://github.com/rust-lang-nursery/rust-toolstate.git".to_string())
|
||||
}
|
||||
|
||||
/// Directory where the toolstate repo is checked out.
|
||||
const TOOLSTATE_DIR: &str = "rust-toolstate";
|
||||
|
||||
/// Checks out the toolstate repo into `TOOLSTATE_DIR`.
|
||||
fn checkout_toolstate_repo() {
|
||||
if let Ok(token) = env::var("TOOLSTATE_REPO_ACCESS_TOKEN") {
|
||||
prepare_toolstate_config(&token);
|
||||
}
|
||||
if Path::new(TOOLSTATE_DIR).exists() {
|
||||
eprintln!("Cleaning old toolstate directory...");
|
||||
t!(fs::remove_dir_all(TOOLSTATE_DIR));
|
||||
}
|
||||
|
||||
let status = Command::new("git")
|
||||
.arg("clone")
|
||||
.arg("--depth=1")
|
||||
.arg(toolstate_repo())
|
||||
.arg(TOOLSTATE_DIR)
|
||||
.status();
|
||||
let success = match status {
|
||||
Ok(s) => s.success(),
|
||||
Err(_) => false,
|
||||
};
|
||||
if !success {
|
||||
panic!("git clone unsuccessful (status: {:?})", status);
|
||||
}
|
||||
}
|
||||
|
||||
/// Sets up config and authentication for modifying the toolstate repo.
|
||||
fn prepare_toolstate_config(token: &str) {
|
||||
fn git_config(key: &str, value: &str) {
|
||||
let status = Command::new("git").arg("config").arg("--global").arg(key).arg(value).status();
|
||||
let success = match status {
|
||||
Ok(s) => s.success(),
|
||||
Err(_) => false,
|
||||
};
|
||||
if !success {
|
||||
panic!("git config key={} value={} successful (status: {:?})", key, value, status);
|
||||
}
|
||||
}
|
||||
|
||||
// If changing anything here, then please check that src/ci/publish_toolstate.sh is up to date
|
||||
// as well.
|
||||
git_config("user.email", "7378925+rust-toolstate-update@users.noreply.github.com");
|
||||
git_config("user.name", "Rust Toolstate Update");
|
||||
git_config("credential.helper", "store");
|
||||
|
||||
let credential = format!("https://{}:x-oauth-basic@github.com\n", token,);
|
||||
let git_credential_path = PathBuf::from(t!(env::var("HOME"))).join(".git-credentials");
|
||||
t!(fs::write(&git_credential_path, credential));
|
||||
}
|
||||
|
||||
/// Reads the latest toolstate from the toolstate repo.
|
||||
fn read_old_toolstate() -> Vec<RepoState> {
|
||||
let latest_path = Path::new(TOOLSTATE_DIR).join("_data").join("latest.json");
|
||||
let old_toolstate = t!(fs::read(latest_path));
|
||||
t!(serde_json::from_slice(&old_toolstate))
|
||||
}
|
||||
|
||||
/// This function `commit_toolstate_change` provides functionality for pushing a change
|
||||
/// to the `rust-toolstate` repository.
|
||||
///
|
||||
@ -274,45 +374,7 @@ impl Builder<'_> {
|
||||
/// * See <https://help.github.com/articles/about-commit-email-addresses/>
|
||||
/// if a private email by GitHub is wanted.
|
||||
fn commit_toolstate_change(current_toolstate: &ToolstateData, in_beta_week: bool) {
|
||||
fn git_config(key: &str, value: &str) {
|
||||
let status = Command::new("git").arg("config").arg("--global").arg(key).arg(value).status();
|
||||
let success = match status {
|
||||
Ok(s) => s.success(),
|
||||
Err(_) => false,
|
||||
};
|
||||
if !success {
|
||||
panic!("git config key={} value={} successful (status: {:?})", key, value, status);
|
||||
}
|
||||
}
|
||||
|
||||
// If changing anything here, then please check that src/ci/publish_toolstate.sh is up to date
|
||||
// as well.
|
||||
git_config("user.email", "7378925+rust-toolstate-update@users.noreply.github.com");
|
||||
git_config("user.name", "Rust Toolstate Update");
|
||||
git_config("credential.helper", "store");
|
||||
|
||||
let credential = format!(
|
||||
"https://{}:x-oauth-basic@github.com\n",
|
||||
t!(env::var("TOOLSTATE_REPO_ACCESS_TOKEN")),
|
||||
);
|
||||
let git_credential_path = PathBuf::from(t!(env::var("HOME"))).join(".git-credentials");
|
||||
t!(fs::write(&git_credential_path, credential));
|
||||
|
||||
let status = Command::new("git")
|
||||
.arg("clone")
|
||||
.arg("--depth=1")
|
||||
.arg(t!(env::var("TOOLSTATE_REPO")))
|
||||
.status();
|
||||
let success = match status {
|
||||
Ok(s) => s.success(),
|
||||
Err(_) => false,
|
||||
};
|
||||
if !success {
|
||||
panic!("git clone successful (status: {:?})", status);
|
||||
}
|
||||
|
||||
let old_toolstate = t!(fs::read("rust-toolstate/_data/latest.json"));
|
||||
let old_toolstate: Vec<RepoState> = t!(serde_json::from_slice(&old_toolstate));
|
||||
let old_toolstate = read_old_toolstate();
|
||||
|
||||
let message = format!("({} CI update)", OS.expect("linux/windows only"));
|
||||
let mut success = false;
|
||||
@ -322,7 +384,7 @@ fn commit_toolstate_change(current_toolstate: &ToolstateData, in_beta_week: bool
|
||||
|
||||
// `git commit` failing means nothing to commit.
|
||||
let status = t!(Command::new("git")
|
||||
.current_dir("rust-toolstate")
|
||||
.current_dir(TOOLSTATE_DIR)
|
||||
.arg("commit")
|
||||
.arg("-a")
|
||||
.arg("-m")
|
||||
@ -334,7 +396,7 @@ fn commit_toolstate_change(current_toolstate: &ToolstateData, in_beta_week: bool
|
||||
}
|
||||
|
||||
let status = t!(Command::new("git")
|
||||
.current_dir("rust-toolstate")
|
||||
.current_dir(TOOLSTATE_DIR)
|
||||
.arg("push")
|
||||
.arg("origin")
|
||||
.arg("master")
|
||||
@ -347,14 +409,14 @@ fn commit_toolstate_change(current_toolstate: &ToolstateData, in_beta_week: bool
|
||||
eprintln!("Sleeping for 3 seconds before retrying push");
|
||||
std::thread::sleep(std::time::Duration::from_secs(3));
|
||||
let status = t!(Command::new("git")
|
||||
.current_dir("rust-toolstate")
|
||||
.current_dir(TOOLSTATE_DIR)
|
||||
.arg("fetch")
|
||||
.arg("origin")
|
||||
.arg("master")
|
||||
.status());
|
||||
assert!(status.success());
|
||||
let status = t!(Command::new("git")
|
||||
.current_dir("rust-toolstate")
|
||||
.current_dir(TOOLSTATE_DIR)
|
||||
.arg("reset")
|
||||
.arg("--hard")
|
||||
.arg("origin/master")
|
||||
@ -375,19 +437,13 @@ fn change_toolstate(
|
||||
let mut regressed = false;
|
||||
for repo_state in old_toolstate {
|
||||
let tool = &repo_state.tool;
|
||||
let state = if cfg!(target_os = "linux") {
|
||||
&repo_state.linux
|
||||
} else if cfg!(windows) {
|
||||
&repo_state.windows
|
||||
} else {
|
||||
unimplemented!()
|
||||
};
|
||||
let state = repo_state.state();
|
||||
let new_state = current_toolstate[tool.as_str()];
|
||||
|
||||
if new_state != *state {
|
||||
if new_state != state {
|
||||
eprintln!("The state of `{}` has changed from `{}` to `{}`", tool, state, new_state);
|
||||
if (new_state as u8) < (*state as u8) {
|
||||
if !["rustc-guide", "miri", "embedded-book"].contains(&tool.as_str()) {
|
||||
if new_state < state {
|
||||
if !NIGHTLY_TOOLS.iter().any(|(name, _path)| name == tool) {
|
||||
regressed = true;
|
||||
}
|
||||
}
|
||||
@ -403,7 +459,9 @@ fn change_toolstate(
|
||||
|
||||
let toolstate_serialized = t!(serde_json::to_string(¤t_toolstate));
|
||||
|
||||
let history_path = format!("rust-toolstate/history/{}.tsv", OS.expect("linux/windows only"));
|
||||
let history_path = Path::new(TOOLSTATE_DIR)
|
||||
.join("history")
|
||||
.join(format!("{}.tsv", OS.expect("linux/windows only")));
|
||||
let mut file = t!(fs::read_to_string(&history_path));
|
||||
let end_of_first_line = file.find('\n').unwrap();
|
||||
file.insert_str(end_of_first_line, &format!("\n{}\t{}", commit.trim(), toolstate_serialized));
|
||||
@ -418,3 +476,15 @@ struct RepoState {
|
||||
commit: String,
|
||||
datetime: String,
|
||||
}
|
||||
|
||||
impl RepoState {
|
||||
fn state(&self) -> ToolState {
|
||||
if cfg!(target_os = "linux") {
|
||||
self.linux
|
||||
} else if cfg!(windows) {
|
||||
self.windows
|
||||
} else {
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -98,7 +98,7 @@ impl Drop for TimeIt {
|
||||
fn drop(&mut self) {
|
||||
let time = self.1.elapsed();
|
||||
if !self.0 {
|
||||
println!("\tfinished in {}.{:03}", time.as_secs(), time.subsec_nanos() / 1_000_000);
|
||||
println!("\tfinished in {}.{:03}", time.as_secs(), time.subsec_millis());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ jobs:
|
||||
|
||||
# The macOS and Windows builds here are currently disabled due to them not being
|
||||
# overly necessary on `try` builds. We also don't actually have anything that
|
||||
# consumes the artifacts currently. Perhaps one day we can reenable, but for now
|
||||
# consumes the artifacts currently. Perhaps one day we can re-enable, but for now
|
||||
# it helps free up capacity on Azure.
|
||||
# - job: macOS
|
||||
# timeoutInMinutes: 600
|
||||
|
@ -148,11 +148,11 @@ else:
|
||||
print('unknown platform', sys.platform)
|
||||
sys.exit(1)
|
||||
|
||||
cur_state = State();
|
||||
cur_state = State()
|
||||
print("Time,Idle")
|
||||
while True:
|
||||
time.sleep(1);
|
||||
next_state = State();
|
||||
time.sleep(1)
|
||||
next_state = State()
|
||||
now = datetime.datetime.utcnow().isoformat()
|
||||
idle = next_state.idle_since(cur_state)
|
||||
print("%s,%s" % (now, idle))
|
||||
|
@ -48,7 +48,7 @@ RUN /tmp/build-solaris-toolchain.sh sparcv9 sparcv9 solaris-sparc
|
||||
COPY dist-various-2/build-x86_64-fortanix-unknown-sgx-toolchain.sh /tmp/
|
||||
# We pass the commit id of the port of LLVM's libunwind to the build script.
|
||||
# Any update to the commit id here, should cause the container image to be re-built from this point on.
|
||||
RUN /tmp/build-x86_64-fortanix-unknown-sgx-toolchain.sh "53b586346f2c7870e20b170decdc30729d97c42b"
|
||||
RUN /tmp/build-x86_64-fortanix-unknown-sgx-toolchain.sh "5125c169b30837208a842f85f7ae44a83533bd0e"
|
||||
|
||||
COPY dist-various-2/build-wasi-toolchain.sh /tmp/
|
||||
RUN /tmp/build-wasi-toolchain.sh
|
||||
|
@ -14,7 +14,7 @@ python2.7 "$X_PY" test --no-fail-fast \
|
||||
src/doc/rust-by-example \
|
||||
src/doc/embedded-book \
|
||||
src/doc/edition-guide \
|
||||
src/doc/rustc-guide \
|
||||
src/doc/rustc-dev-guide \
|
||||
src/tools/clippy \
|
||||
src/tools/rls \
|
||||
src/tools/rustfmt \
|
||||
|
@ -13,6 +13,7 @@ if isWindows; then
|
||||
# one way or another. The msys interpreters seem to have weird path conversions
|
||||
# baked in which break LLVM's build system one way or another, so let's use the
|
||||
# native version which keeps everything as native as possible.
|
||||
cp C:/Python27amd64/python.exe C:/Python27amd64/python2.7.exe
|
||||
ciCommandAddPath "C:\\Python27amd64"
|
||||
python_home="C:/hostedtoolcache/windows/Python/2.7.17/x64"
|
||||
cp "${python_home}/python.exe" "${python_home}/python2.7.exe"
|
||||
ciCommandAddPath "C:\\hostedtoolcache\\windows\\Python\\2.7.17\\x64"
|
||||
fi
|
||||
|
3
src/doc/book/.cargo/config
Normal file
3
src/doc/book/.cargo/config
Normal file
@ -0,0 +1,3 @@
|
||||
[cargo-new]
|
||||
name = "Your Name"
|
||||
email = "you@example.com"
|
@ -3,7 +3,7 @@ dist: trusty
|
||||
language: rust
|
||||
cache: cargo
|
||||
rust:
|
||||
- 1.37.0
|
||||
- 1.41.0
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
|
@ -7,4 +7,4 @@ version of the book](../ch18-02-refutability.html) instead.
|
||||
|
||||
If you have an internet connection, you can [find a copy distributed with
|
||||
Rust
|
||||
1.30](https://doc.rust-lang.org/1.30.0/book/2018-edition/ch18-02-refuatbility.html).
|
||||
1.30](https://doc.rust-lang.org/1.30.0/book/2018-edition/ch18-02-refutability.html).
|
109
src/doc/book/ADMIN_TASKS.md
Normal file
109
src/doc/book/ADMIN_TASKS.md
Normal file
@ -0,0 +1,109 @@
|
||||
# Administrative Tasks
|
||||
|
||||
This documentation is for Carol and Steve and anyone else managing the repo to remember how to do
|
||||
occasional maintenance tasks.
|
||||
|
||||
## Update the `rustc` version
|
||||
|
||||
- Change the version number in `.travis.yml`
|
||||
- Change the version number in `rust-toolchain`, which should change the version you're using
|
||||
locally with `rustup`
|
||||
- Change the version number in `src/title-page.md`
|
||||
- Run `./tools/update-rustc.sh` (see its commented code for details on what it does)
|
||||
- Inspect the changes (by looking at the files changed according to git) and their effects (by
|
||||
looking at the files in `tmp/book-before` and `tmp/book-after`) and commit them if they look good
|
||||
- Grep for `manual-regeneration` and follow the instructions in those places to update output that
|
||||
cannot be generated by a script
|
||||
|
||||
## Release a new version of the listings
|
||||
|
||||
We now make `.tar` files of complete projects containing every listing available [as GitHub
|
||||
Releases](https://github.com/rust-lang/book/releases). To create a new release artifact, for
|
||||
example if there have been code changes due to edits or due to updating Rust and `rustfmt`, do the
|
||||
following:
|
||||
|
||||
- Create a git tag for the release and push it to GitHub, or create a new tag by going to the
|
||||
GitHub UI, [drafting a new release](https://github.com/rust-lang/book/releases/new), and entering
|
||||
a new tag instead of selecting an existing tag
|
||||
- Run `cargo run --bin release_listings`, which will generate `tmp/listings.tar.gz`
|
||||
- Upload `tmp/listings.tar.gz` in the GitHub UI for the draft release
|
||||
- Publish the release
|
||||
|
||||
## Add a new listing
|
||||
|
||||
To facilitate the scripts that run `rustfmt` on all the listings, update the output when the
|
||||
compiler is updated, and produce release artifacts containing full projects for the listings, any
|
||||
listing beyond the most trivial should be extracted into a file. To do that:
|
||||
|
||||
- Find where the new listing should go in the `listings` directory.
|
||||
- There is one subdirectory for each chapter
|
||||
- Numbered listings should use `listing-[chapter num]-[listing num]` for their directory names.
|
||||
- Listings without a number should start with `no-listing-` followed by a number that indicates
|
||||
its position in the chapter relative to the other listings without numbers in the chapter, then
|
||||
a short description that someone could read to find the code they're looking for.
|
||||
- Listings used only for displaying the output of the code (for example, when we say "if we had
|
||||
written x instead of y, we would get this compiler error:" but we don't actually show code x)
|
||||
should be named with `output-only-` followed by a number that indicates its position in the
|
||||
chapter relative to the other listings used only for output, then a short description that
|
||||
authors or contributors could read to find the code they're looking for.
|
||||
- **Remember to adjust surrounding listing numbers as appropriate!**
|
||||
- Create a full Cargo project in that directory, either by using `cargo new` or copying another
|
||||
listing as a starting point.
|
||||
- Add the code and any surrounding code needed to create a full working example.
|
||||
- If you only want to show part of the code in the file, use anchor comments (`// ANCHOR: some_tag`
|
||||
and `// ANCHOR_END: some_tag`) to mark the parts of the file you want to show.
|
||||
- For Rust code, use the `{{#rustdoc_include [fileame:some_tag]}}` directive within the code blocks
|
||||
in the text. The `rustdoc_include` directive gives the code that doesn't get displayed to
|
||||
`rustdoc` for `mdbook test` purposes.
|
||||
- For anything else, use the `{{#include [filename:some_tag]}}` directive.
|
||||
- If you want to display the output of a command in the text as well, create an `output.txt` file
|
||||
in the listing's directory as follows:
|
||||
- Run the command, like `cargo run` or `cargo test`, and copy all of the output.
|
||||
- Create a new `output.txt` file with the first line `$ [the command you ran]`.
|
||||
- Paste the output you just copied.
|
||||
- Run `./tools/update-rustc.sh`, which should perform some normalization on the compiler output.
|
||||
- Include the output in the text with the `{{#include [filename]}}` directive.
|
||||
- Add and commit output.txt.
|
||||
- If you want to display output but for some reason it can't be generated by a script (say, because
|
||||
of user input or external events like making a web request), keep the output inline but make a
|
||||
comment that contains `manual-regeneration` and instructions for manually updating the inline
|
||||
output.
|
||||
- If you don't want this example to even be attempted to be formatted by `rustfmt` (for example
|
||||
because the example doesn't parse on purpose), add a `rustfmt-ignore` file in the listing's
|
||||
directory and the reason it's not being formatted as the contents of that file (in case it's a
|
||||
rustfmt bug that might get fixed someday).
|
||||
|
||||
## See the effect of some change on the rendered book
|
||||
|
||||
To check, say, updating `mdbook` or changing the way files get included:
|
||||
|
||||
- Generate a built book before the change you want to test by running `mdbook build -d
|
||||
tmp/book-before`
|
||||
- Apply the changes you want to test and run `mdbook build -d tmp/book-after`
|
||||
- Run `./tools/megadiff.sh`
|
||||
- Files remaining in `tmp/book-before` and `tmp/book-after` have differences you can manually
|
||||
inspect with your favorite diff viewing mechanism
|
||||
|
||||
## Produce new markdown files for No Starch
|
||||
|
||||
- Run `./tools/nostarch.sh`
|
||||
- Spot check the files that script created in the `nostarch` directory
|
||||
- Check them into git if you're starting a round of edits
|
||||
|
||||
## Produce markdown from docx for diffing
|
||||
|
||||
- TODO Carol to document this next time she does it
|
||||
|
||||
## Generate Graphviz dot
|
||||
|
||||
We're using [Graphviz](http://graphviz.org/) for some of the diagrams in the
|
||||
book. The source for those files live in the `dot` directory. To turn a `dot`
|
||||
file, for example, `dot/trpl04-01.dot` into an `svg`, run:
|
||||
|
||||
```bash
|
||||
$ dot dot/trpl04-01.dot -Tsvg > src/img/trpl04-01.svg
|
||||
```
|
||||
|
||||
In the generated SVG, remove the width and the height attributes from the `svg`
|
||||
element and set the `viewBox` attribute to `0.00 0.00 1000.00 1000.00` or other
|
||||
values that don't cut off the image.
|
253
src/doc/book/Cargo.lock
generated
253
src/doc/book/Cargo.lock
generated
@ -1,144 +1,275 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
[[package]]
|
||||
name = "adler32"
|
||||
version = "1.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "aho-corasick"
|
||||
version = "0.5.3"
|
||||
version = "0.7.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"memchr 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"memchr 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "0.1.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "crc32fast"
|
||||
version = "1.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "docopt"
|
||||
version = "0.6.86"
|
||||
version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"lazy_static 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex 0.1.80 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"strsim 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"strsim 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "kernel32-sys"
|
||||
version = "0.2.2"
|
||||
name = "filetime"
|
||||
version = "0.2.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "flate2"
|
||||
version = "1.0.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"miniz_oxide 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lazy_static"
|
||||
version = "0.2.10"
|
||||
version = "1.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.33"
|
||||
version = "0.2.66"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
version = "0.1.11"
|
||||
version = "2.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "miniz_oxide"
|
||||
version = "0.3.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"adler32 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex"
|
||||
version = "0.1.80"
|
||||
name = "proc-macro2"
|
||||
version = "1.0.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"aho-corasick 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"memchr 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex-syntax 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"thread_local 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"utf8-ranges 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redox_syscall"
|
||||
version = "0.1.56"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "regex"
|
||||
version = "1.3.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"aho-corasick 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"memchr 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex-syntax 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"thread_local 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex-syntax"
|
||||
version = "0.3.9"
|
||||
version = "0.6.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "rust-book"
|
||||
version = "0.0.1"
|
||||
dependencies = [
|
||||
"docopt 0.6.86 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lazy_static 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex 0.1.80 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"walkdir 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"docopt 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"flate2 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"tar 0.4.26 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"walkdir 2.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustc-serialize"
|
||||
version = "0.3.24"
|
||||
name = "same-file"
|
||||
version = "1.0.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"winapi-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.104"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"serde_derive 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.104"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"syn 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "strsim"
|
||||
version = "0.5.2"
|
||||
version = "0.9.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "thread-id"
|
||||
version = "2.0.0"
|
||||
name = "syn"
|
||||
version = "1.0.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tar"
|
||||
version = "0.4.26"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"filetime 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"xattr 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thread_local"
|
||||
version = "0.2.7"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"thread-id 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "utf8-ranges"
|
||||
version = "0.1.3"
|
||||
name = "unicode-xid"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "walkdir"
|
||||
version = "0.1.8"
|
||||
version = "2.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"same-file 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi"
|
||||
version = "0.2.8"
|
||||
version = "0.3.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-i686-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "winapi-build"
|
||||
version = "0.1.1"
|
||||
name = "winapi-util"
|
||||
version = "0.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-x86_64-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "xattr"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[metadata]
|
||||
"checksum aho-corasick 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ca972c2ea5f742bfce5687b9aef75506a764f61d37f8f649047846a9686ddb66"
|
||||
"checksum docopt 0.6.86 (registry+https://github.com/rust-lang/crates.io-index)" = "4a7ef30445607f6fc8720f0a0a2c7442284b629cf0d049286860fae23e71c4d9"
|
||||
"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d"
|
||||
"checksum lazy_static 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "236eb37a62591d4a41a89b7763d7de3e06ca02d5ab2815446a8bae5d2f8c2d57"
|
||||
"checksum libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)" = "5ba3df4dcb460b9dfbd070d41c94c19209620c191b0340b929ce748a2bcd42d2"
|
||||
"checksum memchr 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d8b629fb514376c675b98c1421e80b151d3817ac42d7c667717d282761418d20"
|
||||
"checksum regex 0.1.80 (registry+https://github.com/rust-lang/crates.io-index)" = "4fd4ace6a8cf7860714a2c2280d6c1f7e6a413486c13298bbc86fd3da019402f"
|
||||
"checksum regex-syntax 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "f9ec002c35e86791825ed294b50008eea9ddfc8def4420124fbc6b08db834957"
|
||||
"checksum rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)" = "dcf128d1287d2ea9d80910b5f1120d0b8eede3fbf1abe91c40d39ea7d51e6fda"
|
||||
"checksum strsim 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "67f84c44fbb2f91db7fef94554e6b2ac05909c9c0b0bc23bb98d3a1aebfe7f7c"
|
||||
"checksum thread-id 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a9539db560102d1cef46b8b78ce737ff0bb64e7e18d35b2a5688f7d097d0ff03"
|
||||
"checksum thread_local 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "8576dbbfcaef9641452d5cf0df9b0e7eeab7694956dd33bb61515fb8f18cfdd5"
|
||||
"checksum utf8-ranges 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a1ca13c08c41c9c3e04224ed9ff80461d97e121589ff27c753a16cb10830ae0f"
|
||||
"checksum walkdir 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "c66c0b9792f0a765345452775f3adbd28dde9d33f30d13e5dcc5ae17cf6f3780"
|
||||
"checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a"
|
||||
"checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc"
|
||||
"checksum adler32 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "5d2e7343e7fc9de883d1b0341e0b13970f764c14101234857d2ddafa1cb1cac2"
|
||||
"checksum aho-corasick 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)" = "58fb5e95d83b38284460a5fda7d6470aa0b8844d283a0b614b8535e880800d2d"
|
||||
"checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
|
||||
"checksum crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1"
|
||||
"checksum docopt 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7f525a586d310c87df72ebcd98009e57f1cc030c8c268305287a476beb653969"
|
||||
"checksum filetime 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "6bd7380b54ced79dda72ecc35cc4fbbd1da6bba54afaa37e96fd1c2a308cd469"
|
||||
"checksum flate2 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)" = "6bd6d6f4752952feb71363cffc9ebac9411b75b87c6ab6058c40c8900cf43c0f"
|
||||
"checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
||||
"checksum libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)" = "d515b1f41455adea1313a4a2ac8a8a477634fbae63cc6100e3aebb207ce61558"
|
||||
"checksum memchr 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3197e20c7edb283f87c071ddfc7a2cca8f8e0b888c242959846a6fce03c72223"
|
||||
"checksum miniz_oxide 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6f3f74f726ae935c3f514300cc6773a0c9492abc5e972d42ba0c0ebb88757625"
|
||||
"checksum proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)" = "3acb317c6ff86a4e579dfa00fc5e6cca91ecbb4e7eb2df0468805b674eb88548"
|
||||
"checksum quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe"
|
||||
"checksum redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)" = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84"
|
||||
"checksum regex 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b5508c1941e4e7cb19965abef075d35a9a8b5cdf0846f30b4050e9b55dc55e87"
|
||||
"checksum regex-syntax 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)" = "e734e891f5b408a29efbf8309e656876276f49ab6a6ac208600b4419bd893d90"
|
||||
"checksum same-file 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502"
|
||||
"checksum serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)" = "414115f25f818d7dfccec8ee535d76949ae78584fc4f79a6f45a904bf8ab4449"
|
||||
"checksum serde_derive 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)" = "128f9e303a5a29922045a830221b8f78ec74a5f544944f3d5984f8ec3895ef64"
|
||||
"checksum strsim 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6446ced80d6c486436db5c078dde11a9f73d42b57fb273121e160b84f63d894c"
|
||||
"checksum syn 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)" = "af6f3550d8dff9ef7dc34d384ac6f107e5d31c8f57d9f28e0081503f547ac8f5"
|
||||
"checksum tar 0.4.26 (registry+https://github.com/rust-lang/crates.io-index)" = "b3196bfbffbba3e57481b6ea32249fbaf590396a52505a2615adbb79d9d826d3"
|
||||
"checksum thread_local 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14"
|
||||
"checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c"
|
||||
"checksum walkdir 2.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "777182bc735b6424e1a57516d35ed72cb8019d85c8c9bf536dccb3445c1a2f7d"
|
||||
"checksum winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6"
|
||||
"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||
"checksum winapi-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4ccfbf554c6ad11084fb7517daca16cfdcaccbdadba4fc336f032a8b12c2ad80"
|
||||
"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||
"checksum xattr 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "244c3741f4240ef46274860397c7c74e50eb23624996930e484c16679633a54c"
|
||||
|
@ -21,6 +21,14 @@ path = "tools/src/bin/lfp.rs"
|
||||
name = "link2print"
|
||||
path = "tools/src/bin/link2print.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "release_listings"
|
||||
path = "tools/src/bin/release_listings.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "remove_hidden_lines"
|
||||
path = "tools/src/bin/remove_hidden_lines.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "remove_links"
|
||||
path = "tools/src/bin/remove_links.rs"
|
||||
@ -30,8 +38,10 @@ name = "remove_markup"
|
||||
path = "tools/src/bin/remove_markup.rs"
|
||||
|
||||
[dependencies]
|
||||
walkdir = "0.1.5"
|
||||
docopt = "0.6.82"
|
||||
rustc-serialize = "0.3.19"
|
||||
regex = "0.1.73"
|
||||
lazy_static = "0.2.1"
|
||||
walkdir = "2.3.1"
|
||||
docopt = "1.1.0"
|
||||
serde = "1.0"
|
||||
regex = "1.3.3"
|
||||
lazy_static = "1.4.0"
|
||||
flate2 = "1.0.13"
|
||||
tar = "0.4.26"
|
||||
|
@ -83,20 +83,6 @@ before we merge any in, but feel free to start!
|
||||
[Translations]: https://github.com/rust-lang/book/issues?q=is%3Aopen+is%3Aissue+label%3ATranslations
|
||||
[mdbook support]: https://github.com/rust-lang-nursery/mdBook/issues/5
|
||||
|
||||
## Graphviz dot
|
||||
|
||||
We're using [Graphviz](http://graphviz.org/) for some of the diagrams in the
|
||||
book. The source for those files live in the `dot` directory. To turn a `dot`
|
||||
file, for example, `dot/trpl04-01.dot` into an `svg`, run:
|
||||
|
||||
```bash
|
||||
$ dot dot/trpl04-01.dot -Tsvg > src/img/trpl04-01.svg
|
||||
```
|
||||
|
||||
In the generated SVG, remove the width and the height attributes from the `svg`
|
||||
element and set the `viewBox` attribute to `0.00 0.00 1000.00 1000.00` or other
|
||||
values that don't cut off the image.
|
||||
|
||||
## Spellchecking
|
||||
|
||||
To scan source files for spelling errors, you can use the `spellcheck.sh`
|
||||
|
@ -6,6 +6,7 @@ adaptor
|
||||
adaptors
|
||||
AddAssign
|
||||
Addr
|
||||
afdc
|
||||
aggregator
|
||||
AGraph
|
||||
aliasability
|
||||
@ -18,6 +19,7 @@ APIs
|
||||
app's
|
||||
aren
|
||||
args
|
||||
ArgumentV
|
||||
associativity
|
||||
async
|
||||
atomics
|
||||
@ -126,6 +128,7 @@ doccratesio
|
||||
DOCTYPE
|
||||
doesn
|
||||
disambiguating
|
||||
DisplayBacktrace
|
||||
DivAssign
|
||||
DraftPost
|
||||
DSTs
|
||||
@ -247,6 +250,7 @@ libpanic
|
||||
librarys
|
||||
libreoffice
|
||||
libstd
|
||||
libunwind
|
||||
lifecycle
|
||||
LimitTracker
|
||||
linter
|
||||
@ -334,6 +338,7 @@ parameterize
|
||||
ParseIntError
|
||||
PartialEq
|
||||
PartialOrd
|
||||
pbcopy
|
||||
PendingReview
|
||||
PendingReviewPost
|
||||
PlaceholderType
|
||||
|
6
src/doc/book/listings/ch02-guessing-game-tutorial/listing-02-01/Cargo.lock
generated
Normal file
6
src/doc/book/listings/ch02-guessing-game-tutorial/listing-02-01/Cargo.lock
generated
Normal file
@ -0,0 +1,6 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
[[package]]
|
||||
name = "guessing_game"
|
||||
version = "0.1.0"
|
||||
|
@ -0,0 +1,9 @@
|
||||
[package]
|
||||
name = "guessing_game"
|
||||
version = "0.1.0"
|
||||
authors = ["Your Name <you@example.com>"]
|
||||
edition = "2018"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
@ -0,0 +1,31 @@
|
||||
// ANCHOR: all
|
||||
// ANCHOR: io
|
||||
use std::io;
|
||||
// ANCHOR_END: io
|
||||
|
||||
// ANCHOR: main
|
||||
fn main() {
|
||||
// ANCHOR_END: main
|
||||
// ANCHOR: print
|
||||
println!("Guess the number!");
|
||||
|
||||
println!("Please input your guess.");
|
||||
// ANCHOR_END: print
|
||||
|
||||
// ANCHOR: string
|
||||
let mut guess = String::new();
|
||||
// ANCHOR_END: string
|
||||
|
||||
// ANCHOR: read
|
||||
io::stdin()
|
||||
.read_line(&mut guess)
|
||||
// ANCHOR_END: read
|
||||
// ANCHOR: expect
|
||||
.expect("Failed to read line");
|
||||
// ANCHOR_END: expect
|
||||
|
||||
// ANCHOR: print_guess
|
||||
println!("You guessed: {}", guess);
|
||||
// ANCHOR_END: print_guess
|
||||
}
|
||||
// ANCHOR: all
|
87
src/doc/book/listings/ch02-guessing-game-tutorial/listing-02-02/Cargo.lock
generated
Normal file
87
src/doc/book/listings/ch02-guessing-game-tutorial/listing-02-02/Cargo.lock
generated
Normal file
@ -0,0 +1,87 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "1.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "cloudabi"
|
||||
version = "0.0.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fuchsia-cprng"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "guessing_game"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.66"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "rand"
|
||||
version = "0.5.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_core"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_core"
|
||||
version = "0.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "winapi"
|
||||
version = "0.3.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-i686-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "winapi-x86_64-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[metadata]
|
||||
"checksum bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
|
||||
"checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f"
|
||||
"checksum fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba"
|
||||
"checksum libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)" = "d515b1f41455adea1313a4a2ac8a8a477634fbae63cc6100e3aebb207ce61558"
|
||||
"checksum rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c618c47cd3ebd209790115ab837de41425723956ad3ce2e6a7f09890947cacb9"
|
||||
"checksum rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b"
|
||||
"checksum rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc"
|
||||
"checksum winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6"
|
||||
"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||
"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
@ -0,0 +1,10 @@
|
||||
[package]
|
||||
name = "guessing_game"
|
||||
version = "0.1.0"
|
||||
authors = ["Your Name <you@example.com>"]
|
||||
edition = "2018"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
rand = "0.5.5"
|
@ -0,0 +1,15 @@
|
||||
use std::io;
|
||||
|
||||
fn main() {
|
||||
println!("Guess the number!");
|
||||
|
||||
println!("Please input your guess.");
|
||||
|
||||
let mut guess = String::new();
|
||||
|
||||
io::stdin()
|
||||
.read_line(&mut guess)
|
||||
.expect("Failed to read line");
|
||||
|
||||
println!("You guessed: {}", guess);
|
||||
}
|
87
src/doc/book/listings/ch02-guessing-game-tutorial/listing-02-03/Cargo.lock
generated
Normal file
87
src/doc/book/listings/ch02-guessing-game-tutorial/listing-02-03/Cargo.lock
generated
Normal file
@ -0,0 +1,87 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "1.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "cloudabi"
|
||||
version = "0.0.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"bitflags 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fuchsia-cprng"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "guessing_game"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.51"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "rand"
|
||||
version = "0.5.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_core"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_core"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "winapi"
|
||||
version = "0.3.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-i686-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "winapi-x86_64-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[metadata]
|
||||
"checksum bitflags 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8a606a02debe2813760609f57a64a2ffd27d9fdf5b2f133eaca0b248dd92cdd2"
|
||||
"checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f"
|
||||
"checksum fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba"
|
||||
"checksum libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)" = "bedcc7a809076656486ffe045abeeac163da1b558e963a31e29fbfbeba916917"
|
||||
"checksum rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c618c47cd3ebd209790115ab837de41425723956ad3ce2e6a7f09890947cacb9"
|
||||
"checksum rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b"
|
||||
"checksum rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d0e7a549d590831370895ab7ba4ea0c1b6b011d106b5ff2da6eee112615e6dc0"
|
||||
"checksum winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "f10e386af2b13e47c89e7236a7a14a086791a2b88ebad6df9bf42040195cf770"
|
||||
"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||
"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
@ -0,0 +1,10 @@
|
||||
[package]
|
||||
name = "guessing_game"
|
||||
version = "0.1.0"
|
||||
authors = ["Your Name <you@example.com>"]
|
||||
edition = "2018"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
rand = "0.5.5"
|
@ -0,0 +1,28 @@
|
||||
// ANCHOR: all
|
||||
use std::io;
|
||||
// ANCHOR: ch07-04
|
||||
use rand::Rng;
|
||||
|
||||
fn main() {
|
||||
// ANCHOR_END: ch07-04
|
||||
println!("Guess the number!");
|
||||
|
||||
// ANCHOR: ch07-04
|
||||
let secret_number = rand::thread_rng().gen_range(1, 101);
|
||||
// ANCHOR_END: ch07-04
|
||||
|
||||
println!("The secret number is: {}", secret_number);
|
||||
|
||||
println!("Please input your guess.");
|
||||
|
||||
let mut guess = String::new();
|
||||
|
||||
io::stdin()
|
||||
.read_line(&mut guess)
|
||||
.expect("Failed to read line");
|
||||
|
||||
println!("You guessed: {}", guess);
|
||||
// ANCHOR: ch07-04
|
||||
}
|
||||
// ANCHOR_END: ch07-04
|
||||
// ANCHOR_END: all
|
87
src/doc/book/listings/ch02-guessing-game-tutorial/listing-02-04/Cargo.lock
generated
Normal file
87
src/doc/book/listings/ch02-guessing-game-tutorial/listing-02-04/Cargo.lock
generated
Normal file
@ -0,0 +1,87 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "1.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "cloudabi"
|
||||
version = "0.0.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"bitflags 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fuchsia-cprng"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "guessing_game"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.51"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "rand"
|
||||
version = "0.5.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_core"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_core"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "winapi"
|
||||
version = "0.3.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-i686-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "winapi-x86_64-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[metadata]
|
||||
"checksum bitflags 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8a606a02debe2813760609f57a64a2ffd27d9fdf5b2f133eaca0b248dd92cdd2"
|
||||
"checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f"
|
||||
"checksum fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba"
|
||||
"checksum libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)" = "bedcc7a809076656486ffe045abeeac163da1b558e963a31e29fbfbeba916917"
|
||||
"checksum rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c618c47cd3ebd209790115ab837de41425723956ad3ce2e6a7f09890947cacb9"
|
||||
"checksum rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b"
|
||||
"checksum rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d0e7a549d590831370895ab7ba4ea0c1b6b011d106b5ff2da6eee112615e6dc0"
|
||||
"checksum winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "f10e386af2b13e47c89e7236a7a14a086791a2b88ebad6df9bf42040195cf770"
|
||||
"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||
"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
@ -0,0 +1,10 @@
|
||||
[package]
|
||||
name = "guessing_game"
|
||||
version = "0.1.0"
|
||||
authors = ["Your Name <you@example.com>"]
|
||||
edition = "2018"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
rand = "0.5.5"
|
@ -0,0 +1,21 @@
|
||||
$ cargo build
|
||||
Compiling libc v0.2.51
|
||||
Compiling rand_core v0.4.0
|
||||
Compiling rand_core v0.3.1
|
||||
Compiling rand v0.5.6
|
||||
Compiling guessing_game v0.1.0 (file:///projects/guessing_game)
|
||||
error[E0308]: mismatched types
|
||||
--> src/main.rs:22:21
|
||||
|
|
||||
22 | match guess.cmp(&secret_number) {
|
||||
| ^^^^^^^^^^^^^^ expected struct `std::string::String`, found integer
|
||||
|
|
||||
= note: expected reference `&std::string::String`
|
||||
found reference `&{integer}`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0308`.
|
||||
error: could not compile `guessing_game`.
|
||||
|
||||
To learn more, run the command again with --verbose.
|
@ -0,0 +1,32 @@
|
||||
// ANCHOR: here
|
||||
use rand::Rng;
|
||||
use std::cmp::Ordering;
|
||||
use std::io;
|
||||
|
||||
fn main() {
|
||||
// --snip--
|
||||
// ANCHOR_END: here
|
||||
println!("Guess the number!");
|
||||
|
||||
let secret_number = rand::thread_rng().gen_range(1, 101);
|
||||
|
||||
println!("The secret number is: {}", secret_number);
|
||||
|
||||
println!("Please input your guess.");
|
||||
|
||||
let mut guess = String::new();
|
||||
|
||||
io::stdin()
|
||||
.read_line(&mut guess)
|
||||
.expect("Failed to read line");
|
||||
// ANCHOR: here
|
||||
|
||||
println!("You guessed: {}", guess);
|
||||
|
||||
match guess.cmp(&secret_number) {
|
||||
Ordering::Less => println!("Too small!"),
|
||||
Ordering::Greater => println!("Too big!"),
|
||||
Ordering::Equal => println!("You win!"),
|
||||
}
|
||||
}
|
||||
// ANCHOR_END: here
|
87
src/doc/book/listings/ch02-guessing-game-tutorial/listing-02-05/Cargo.lock
generated
Normal file
87
src/doc/book/listings/ch02-guessing-game-tutorial/listing-02-05/Cargo.lock
generated
Normal file
@ -0,0 +1,87 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "1.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "cloudabi"
|
||||
version = "0.0.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"bitflags 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fuchsia-cprng"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "guessing_game"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.51"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "rand"
|
||||
version = "0.5.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_core"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_core"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "winapi"
|
||||
version = "0.3.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-i686-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "winapi-x86_64-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[metadata]
|
||||
"checksum bitflags 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8a606a02debe2813760609f57a64a2ffd27d9fdf5b2f133eaca0b248dd92cdd2"
|
||||
"checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f"
|
||||
"checksum fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba"
|
||||
"checksum libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)" = "bedcc7a809076656486ffe045abeeac163da1b558e963a31e29fbfbeba916917"
|
||||
"checksum rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c618c47cd3ebd209790115ab837de41425723956ad3ce2e6a7f09890947cacb9"
|
||||
"checksum rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b"
|
||||
"checksum rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d0e7a549d590831370895ab7ba4ea0c1b6b011d106b5ff2da6eee112615e6dc0"
|
||||
"checksum winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "f10e386af2b13e47c89e7236a7a14a086791a2b88ebad6df9bf42040195cf770"
|
||||
"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||
"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
@ -0,0 +1,10 @@
|
||||
[package]
|
||||
name = "guessing_game"
|
||||
version = "0.1.0"
|
||||
authors = ["Your Name <you@example.com>"]
|
||||
edition = "2018"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
rand = "0.5.5"
|
@ -0,0 +1,45 @@
|
||||
use rand::Rng;
|
||||
use std::cmp::Ordering;
|
||||
use std::io;
|
||||
|
||||
fn main() {
|
||||
println!("Guess the number!");
|
||||
|
||||
let secret_number = rand::thread_rng().gen_range(1, 101);
|
||||
|
||||
println!("The secret number is: {}", secret_number);
|
||||
|
||||
loop {
|
||||
println!("Please input your guess.");
|
||||
|
||||
let mut guess = String::new();
|
||||
|
||||
// ANCHOR: here
|
||||
// --snip--
|
||||
|
||||
io::stdin()
|
||||
.read_line(&mut guess)
|
||||
.expect("Failed to read line");
|
||||
|
||||
// ANCHOR: ch19
|
||||
let guess: u32 = match guess.trim().parse() {
|
||||
Ok(num) => num,
|
||||
Err(_) => continue,
|
||||
};
|
||||
// ANCHOR_END: ch19
|
||||
|
||||
println!("You guessed: {}", guess);
|
||||
|
||||
// --snip--
|
||||
// ANCHOR_END: here
|
||||
|
||||
match guess.cmp(&secret_number) {
|
||||
Ordering::Less => println!("Too small!"),
|
||||
Ordering::Greater => println!("Too big!"),
|
||||
Ordering::Equal => {
|
||||
println!("You win!");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
87
src/doc/book/listings/ch02-guessing-game-tutorial/listing-02-06/Cargo.lock
generated
Normal file
87
src/doc/book/listings/ch02-guessing-game-tutorial/listing-02-06/Cargo.lock
generated
Normal file
@ -0,0 +1,87 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "1.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "cloudabi"
|
||||
version = "0.0.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"bitflags 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fuchsia-cprng"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "guessing_game"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.53"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "rand"
|
||||
version = "0.5.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.53 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_core"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_core"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "winapi"
|
||||
version = "0.3.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-i686-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "winapi-x86_64-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[metadata]
|
||||
"checksum bitflags 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8a606a02debe2813760609f57a64a2ffd27d9fdf5b2f133eaca0b248dd92cdd2"
|
||||
"checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f"
|
||||
"checksum fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba"
|
||||
"checksum libc 0.2.53 (registry+https://github.com/rust-lang/crates.io-index)" = "ec350a9417dfd244dc9a6c4a71e13895a4db6b92f0b106f07ebbc3f3bc580cee"
|
||||
"checksum rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c618c47cd3ebd209790115ab837de41425723956ad3ce2e6a7f09890947cacb9"
|
||||
"checksum rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b"
|
||||
"checksum rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d0e7a549d590831370895ab7ba4ea0c1b6b011d106b5ff2da6eee112615e6dc0"
|
||||
"checksum winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "f10e386af2b13e47c89e7236a7a14a086791a2b88ebad6df9bf42040195cf770"
|
||||
"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||
"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
@ -0,0 +1,10 @@
|
||||
[package]
|
||||
name = "guessing_game"
|
||||
version = "0.1.0"
|
||||
authors = ["Your Name <you@example.com>"]
|
||||
edition = "2018"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
rand = "0.5.5"
|
@ -0,0 +1,35 @@
|
||||
use rand::Rng;
|
||||
use std::cmp::Ordering;
|
||||
use std::io;
|
||||
|
||||
fn main() {
|
||||
println!("Guess the number!");
|
||||
|
||||
let secret_number = rand::thread_rng().gen_range(1, 101);
|
||||
|
||||
loop {
|
||||
println!("Please input your guess.");
|
||||
|
||||
let mut guess = String::new();
|
||||
|
||||
io::stdin()
|
||||
.read_line(&mut guess)
|
||||
.expect("Failed to read line");
|
||||
|
||||
let guess: u32 = match guess.trim().parse() {
|
||||
Ok(num) => num,
|
||||
Err(_) => continue,
|
||||
};
|
||||
|
||||
println!("You guessed: {}", guess);
|
||||
|
||||
match guess.cmp(&secret_number) {
|
||||
Ordering::Less => println!("Too small!"),
|
||||
Ordering::Greater => println!("Too big!"),
|
||||
Ordering::Equal => {
|
||||
println!("You win!");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
6
src/doc/book/listings/ch02-guessing-game-tutorial/no-listing-01-cargo-new/Cargo.lock
generated
Normal file
6
src/doc/book/listings/ch02-guessing-game-tutorial/no-listing-01-cargo-new/Cargo.lock
generated
Normal file
@ -0,0 +1,6 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
[[package]]
|
||||
name = "guessing_game"
|
||||
version = "0.1.0"
|
||||
|
@ -0,0 +1,9 @@
|
||||
[package]
|
||||
name = "guessing_game"
|
||||
version = "0.1.0"
|
||||
authors = ["Your Name <you@example.com>"]
|
||||
edition = "2018"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
@ -0,0 +1,5 @@
|
||||
$ cargo run
|
||||
Compiling guessing_game v0.1.0 (file:///projects/guessing_game)
|
||||
Finished dev [unoptimized + debuginfo] target(s) in 1.50s
|
||||
Running `target/debug/guessing_game`
|
||||
Hello, world!
|
@ -0,0 +1,3 @@
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
}
|
6
src/doc/book/listings/ch02-guessing-game-tutorial/no-listing-02-without-expect/Cargo.lock
generated
Normal file
6
src/doc/book/listings/ch02-guessing-game-tutorial/no-listing-02-without-expect/Cargo.lock
generated
Normal file
@ -0,0 +1,6 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
[[package]]
|
||||
name = "guessing_game"
|
||||
version = "0.1.0"
|
||||
|
@ -0,0 +1,9 @@
|
||||
[package]
|
||||
name = "guessing_game"
|
||||
version = "0.1.0"
|
||||
authors = ["Your Name <you@example.com>"]
|
||||
edition = "2018"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
@ -0,0 +1,12 @@
|
||||
$ cargo build
|
||||
Compiling guessing_game v0.1.0 (file:///projects/guessing_game)
|
||||
warning: unused `std::result::Result` that must be used
|
||||
--> src/main.rs:10:5
|
||||
|
|
||||
10 | io::stdin().read_line(&mut guess);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: `#[warn(unused_must_use)]` on by default
|
||||
= note: this `Result` may be an `Err` variant, which should be handled
|
||||
|
||||
Finished dev [unoptimized + debuginfo] target(s) in 0.59s
|
@ -0,0 +1,13 @@
|
||||
use std::io;
|
||||
|
||||
fn main() {
|
||||
println!("Guess the number!");
|
||||
|
||||
println!("Please input your guess.");
|
||||
|
||||
let mut guess = String::new();
|
||||
|
||||
io::stdin().read_line(&mut guess);
|
||||
|
||||
println!("You guessed: {}", guess);
|
||||
}
|
87
src/doc/book/listings/ch02-guessing-game-tutorial/no-listing-03-convert-string-to-number/Cargo.lock
generated
Normal file
87
src/doc/book/listings/ch02-guessing-game-tutorial/no-listing-03-convert-string-to-number/Cargo.lock
generated
Normal file
@ -0,0 +1,87 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "1.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "cloudabi"
|
||||
version = "0.0.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"bitflags 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fuchsia-cprng"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "guessing_game"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.51"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "rand"
|
||||
version = "0.5.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_core"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_core"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "winapi"
|
||||
version = "0.3.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-i686-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "winapi-x86_64-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[metadata]
|
||||
"checksum bitflags 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8a606a02debe2813760609f57a64a2ffd27d9fdf5b2f133eaca0b248dd92cdd2"
|
||||
"checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f"
|
||||
"checksum fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba"
|
||||
"checksum libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)" = "bedcc7a809076656486ffe045abeeac163da1b558e963a31e29fbfbeba916917"
|
||||
"checksum rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c618c47cd3ebd209790115ab837de41425723956ad3ce2e6a7f09890947cacb9"
|
||||
"checksum rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b"
|
||||
"checksum rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d0e7a549d590831370895ab7ba4ea0c1b6b011d106b5ff2da6eee112615e6dc0"
|
||||
"checksum winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "f10e386af2b13e47c89e7236a7a14a086791a2b88ebad6df9bf42040195cf770"
|
||||
"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||
"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
@ -0,0 +1,10 @@
|
||||
[package]
|
||||
name = "guessing_game"
|
||||
version = "0.1.0"
|
||||
authors = ["Your Name <you@example.com>"]
|
||||
edition = "2018"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
rand = "0.5.5"
|
@ -0,0 +1,33 @@
|
||||
use rand::Rng;
|
||||
use std::cmp::Ordering;
|
||||
use std::io;
|
||||
|
||||
fn main() {
|
||||
println!("Guess the number!");
|
||||
|
||||
let secret_number = rand::thread_rng().gen_range(1, 101);
|
||||
|
||||
println!("The secret number is: {}", secret_number);
|
||||
|
||||
println!("Please input your guess.");
|
||||
|
||||
// ANCHOR: here
|
||||
// --snip--
|
||||
|
||||
let mut guess = String::new();
|
||||
|
||||
io::stdin()
|
||||
.read_line(&mut guess)
|
||||
.expect("Failed to read line");
|
||||
|
||||
let guess: u32 = guess.trim().parse().expect("Please type a number!");
|
||||
|
||||
println!("You guessed: {}", guess);
|
||||
|
||||
match guess.cmp(&secret_number) {
|
||||
Ordering::Less => println!("Too small!"),
|
||||
Ordering::Greater => println!("Too big!"),
|
||||
Ordering::Equal => println!("You win!"),
|
||||
}
|
||||
}
|
||||
// ANCHOR_END: here
|
87
src/doc/book/listings/ch02-guessing-game-tutorial/no-listing-04-looping/Cargo.lock
generated
Normal file
87
src/doc/book/listings/ch02-guessing-game-tutorial/no-listing-04-looping/Cargo.lock
generated
Normal file
@ -0,0 +1,87 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "1.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "cloudabi"
|
||||
version = "0.0.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"bitflags 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fuchsia-cprng"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "guessing_game"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.51"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "rand"
|
||||
version = "0.5.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_core"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_core"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "winapi"
|
||||
version = "0.3.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-i686-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "winapi-x86_64-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[metadata]
|
||||
"checksum bitflags 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8a606a02debe2813760609f57a64a2ffd27d9fdf5b2f133eaca0b248dd92cdd2"
|
||||
"checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f"
|
||||
"checksum fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba"
|
||||
"checksum libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)" = "bedcc7a809076656486ffe045abeeac163da1b558e963a31e29fbfbeba916917"
|
||||
"checksum rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c618c47cd3ebd209790115ab837de41425723956ad3ce2e6a7f09890947cacb9"
|
||||
"checksum rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b"
|
||||
"checksum rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d0e7a549d590831370895ab7ba4ea0c1b6b011d106b5ff2da6eee112615e6dc0"
|
||||
"checksum winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "f10e386af2b13e47c89e7236a7a14a086791a2b88ebad6df9bf42040195cf770"
|
||||
"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||
"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
@ -0,0 +1,10 @@
|
||||
[package]
|
||||
name = "guessing_game"
|
||||
version = "0.1.0"
|
||||
authors = ["Your Name <you@example.com>"]
|
||||
edition = "2018"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
rand = "0.5.5"
|
@ -0,0 +1,40 @@
|
||||
use rand::Rng;
|
||||
use std::cmp::Ordering;
|
||||
use std::io;
|
||||
|
||||
fn main() {
|
||||
println!("Guess the number!");
|
||||
|
||||
let secret_number = rand::thread_rng().gen_range(1, 101);
|
||||
|
||||
// ANCHOR: here
|
||||
// --snip--
|
||||
|
||||
println!("The secret number is: {}", secret_number);
|
||||
|
||||
loop {
|
||||
println!("Please input your guess.");
|
||||
|
||||
// --snip--
|
||||
|
||||
// ANCHOR_END: here
|
||||
|
||||
let mut guess = String::new();
|
||||
|
||||
io::stdin()
|
||||
.read_line(&mut guess)
|
||||
.expect("Failed to read line");
|
||||
|
||||
let guess: u32 = guess.trim().parse().expect("Please type a number!");
|
||||
|
||||
println!("You guessed: {}", guess);
|
||||
|
||||
// ANCHOR: here
|
||||
match guess.cmp(&secret_number) {
|
||||
Ordering::Less => println!("Too small!"),
|
||||
Ordering::Greater => println!("Too big!"),
|
||||
Ordering::Equal => println!("You win!"),
|
||||
}
|
||||
}
|
||||
}
|
||||
// ANCHOR_END: here
|
87
src/doc/book/listings/ch02-guessing-game-tutorial/no-listing-05-quitting/Cargo.lock
generated
Normal file
87
src/doc/book/listings/ch02-guessing-game-tutorial/no-listing-05-quitting/Cargo.lock
generated
Normal file
@ -0,0 +1,87 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "1.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "cloudabi"
|
||||
version = "0.0.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"bitflags 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fuchsia-cprng"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "guessing_game"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.51"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "rand"
|
||||
version = "0.5.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_core"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_core"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "winapi"
|
||||
version = "0.3.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-i686-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "winapi-x86_64-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[metadata]
|
||||
"checksum bitflags 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8a606a02debe2813760609f57a64a2ffd27d9fdf5b2f133eaca0b248dd92cdd2"
|
||||
"checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f"
|
||||
"checksum fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba"
|
||||
"checksum libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)" = "bedcc7a809076656486ffe045abeeac163da1b558e963a31e29fbfbeba916917"
|
||||
"checksum rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c618c47cd3ebd209790115ab837de41425723956ad3ce2e6a7f09890947cacb9"
|
||||
"checksum rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b"
|
||||
"checksum rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d0e7a549d590831370895ab7ba4ea0c1b6b011d106b5ff2da6eee112615e6dc0"
|
||||
"checksum winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "f10e386af2b13e47c89e7236a7a14a086791a2b88ebad6df9bf42040195cf770"
|
||||
"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||
"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
@ -0,0 +1,10 @@
|
||||
[package]
|
||||
name = "guessing_game"
|
||||
version = "0.1.0"
|
||||
authors = ["Your Name <you@example.com>"]
|
||||
edition = "2018"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
rand = "0.5.5"
|
@ -0,0 +1,38 @@
|
||||
use rand::Rng;
|
||||
use std::cmp::Ordering;
|
||||
use std::io;
|
||||
|
||||
fn main() {
|
||||
println!("Guess the number!");
|
||||
|
||||
let secret_number = rand::thread_rng().gen_range(1, 101);
|
||||
|
||||
println!("The secret number is: {}", secret_number);
|
||||
|
||||
loop {
|
||||
println!("Please input your guess.");
|
||||
|
||||
let mut guess = String::new();
|
||||
|
||||
io::stdin()
|
||||
.read_line(&mut guess)
|
||||
.expect("Failed to read line");
|
||||
|
||||
let guess: u32 = guess.trim().parse().expect("Please type a number!");
|
||||
|
||||
println!("You guessed: {}", guess);
|
||||
|
||||
// ANCHOR: here
|
||||
// --snip--
|
||||
|
||||
match guess.cmp(&secret_number) {
|
||||
Ordering::Less => println!("Too small!"),
|
||||
Ordering::Greater => println!("Too big!"),
|
||||
Ordering::Equal => {
|
||||
println!("You win!");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// ANCHOR_END: here
|
6
src/doc/book/listings/ch03-common-programming-concepts/listing-03-01/Cargo.lock
generated
Normal file
6
src/doc/book/listings/ch03-common-programming-concepts/listing-03-01/Cargo.lock
generated
Normal file
@ -0,0 +1,6 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
[[package]]
|
||||
name = "functions"
|
||||
version = "0.1.0"
|
||||
|
@ -0,0 +1,7 @@
|
||||
[package]
|
||||
name = "functions"
|
||||
version = "0.1.0"
|
||||
authors = ["Your Name <you@example.com>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
@ -0,0 +1,3 @@
|
||||
fn main() {
|
||||
let y = 6;
|
||||
}
|
6
src/doc/book/listings/ch03-common-programming-concepts/listing-03-02/Cargo.lock
generated
Normal file
6
src/doc/book/listings/ch03-common-programming-concepts/listing-03-02/Cargo.lock
generated
Normal file
@ -0,0 +1,6 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
[[package]]
|
||||
name = "branches"
|
||||
version = "0.1.0"
|
||||
|
@ -0,0 +1,7 @@
|
||||
[package]
|
||||
name = "branches"
|
||||
version = "0.1.0"
|
||||
authors = ["Your Name <you@example.com>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
@ -0,0 +1,5 @@
|
||||
$ cargo run
|
||||
Compiling branches v0.1.0 (file:///projects/branches)
|
||||
Finished dev [unoptimized + debuginfo] target(s) in 0.30s
|
||||
Running `target/debug/branches`
|
||||
The value of number is: 5
|
@ -0,0 +1,6 @@
|
||||
fn main() {
|
||||
let condition = true;
|
||||
let number = if condition { 5 } else { 6 };
|
||||
|
||||
println!("The value of number is: {}", number);
|
||||
}
|
6
src/doc/book/listings/ch03-common-programming-concepts/listing-03-03/Cargo.lock
generated
Normal file
6
src/doc/book/listings/ch03-common-programming-concepts/listing-03-03/Cargo.lock
generated
Normal file
@ -0,0 +1,6 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
[[package]]
|
||||
name = "loops"
|
||||
version = "0.1.0"
|
||||
|
@ -0,0 +1,7 @@
|
||||
[package]
|
||||
name = "loops"
|
||||
version = "0.1.0"
|
||||
authors = ["Your Name <you@example.com>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
@ -0,0 +1,11 @@
|
||||
fn main() {
|
||||
let mut number = 3;
|
||||
|
||||
while number != 0 {
|
||||
println!("{}!", number);
|
||||
|
||||
number -= 1;
|
||||
}
|
||||
|
||||
println!("LIFTOFF!!!");
|
||||
}
|
6
src/doc/book/listings/ch03-common-programming-concepts/listing-03-04/Cargo.lock
generated
Normal file
6
src/doc/book/listings/ch03-common-programming-concepts/listing-03-04/Cargo.lock
generated
Normal file
@ -0,0 +1,6 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
[[package]]
|
||||
name = "loops"
|
||||
version = "0.1.0"
|
||||
|
@ -0,0 +1,7 @@
|
||||
[package]
|
||||
name = "loops"
|
||||
version = "0.1.0"
|
||||
authors = ["Your Name <you@example.com>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
@ -0,0 +1,9 @@
|
||||
$ cargo run
|
||||
Compiling loops v0.1.0 (file:///projects/loops)
|
||||
Finished dev [unoptimized + debuginfo] target(s) in 0.32s
|
||||
Running `target/debug/loops`
|
||||
the value is: 10
|
||||
the value is: 20
|
||||
the value is: 30
|
||||
the value is: 40
|
||||
the value is: 50
|
@ -0,0 +1,10 @@
|
||||
fn main() {
|
||||
let a = [10, 20, 30, 40, 50];
|
||||
let mut index = 0;
|
||||
|
||||
while index < 5 {
|
||||
println!("the value is: {}", a[index]);
|
||||
|
||||
index += 1;
|
||||
}
|
||||
}
|
6
src/doc/book/listings/ch03-common-programming-concepts/listing-03-05/Cargo.lock
generated
Normal file
6
src/doc/book/listings/ch03-common-programming-concepts/listing-03-05/Cargo.lock
generated
Normal file
@ -0,0 +1,6 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
[[package]]
|
||||
name = "loops"
|
||||
version = "0.1.0"
|
||||
|
@ -0,0 +1,7 @@
|
||||
[package]
|
||||
name = "loops"
|
||||
version = "0.1.0"
|
||||
authors = ["Your Name <you@example.com>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
@ -0,0 +1,7 @@
|
||||
fn main() {
|
||||
let a = [10, 20, 30, 40, 50];
|
||||
|
||||
for element in a.iter() {
|
||||
println!("the value is: {}", element);
|
||||
}
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
[[package]]
|
||||
name = "variables"
|
||||
version = "0.1.0"
|
||||
|
@ -0,0 +1,7 @@
|
||||
[package]
|
||||
name = "variables"
|
||||
version = "0.1.0"
|
||||
authors = ["Your Name <you@example.com>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
@ -0,0 +1,20 @@
|
||||
$ cargo run
|
||||
Compiling variables v0.1.0 (file:///projects/variables)
|
||||
error[E0384]: cannot assign twice to immutable variable `x`
|
||||
--> src/main.rs:4:5
|
||||
|
|
||||
2 | let x = 5;
|
||||
| -
|
||||
| |
|
||||
| first assignment to `x`
|
||||
| help: make this binding mutable: `mut x`
|
||||
3 | println!("The value of x is: {}", x);
|
||||
4 | x = 6;
|
||||
| ^^^^^ cannot assign twice to immutable variable
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0384`.
|
||||
error: could not compile `variables`.
|
||||
|
||||
To learn more, run the command again with --verbose.
|
@ -0,0 +1,6 @@
|
||||
fn main() {
|
||||
let x = 5;
|
||||
println!("The value of x is: {}", x);
|
||||
x = 6;
|
||||
println!("The value of x is: {}", x);
|
||||
}
|
6
src/doc/book/listings/ch03-common-programming-concepts/no-listing-02-adding-mut/Cargo.lock
generated
Normal file
6
src/doc/book/listings/ch03-common-programming-concepts/no-listing-02-adding-mut/Cargo.lock
generated
Normal file
@ -0,0 +1,6 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
[[package]]
|
||||
name = "variables"
|
||||
version = "0.1.0"
|
||||
|
@ -0,0 +1,7 @@
|
||||
[package]
|
||||
name = "variables"
|
||||
version = "0.1.0"
|
||||
authors = ["Your Name <you@example.com>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user