Skip to content

Commit 2ee151f

Browse files
committed
Auto merge of #6216 - ehuss:destabilize-edition, r=Mark-Simulacrum
[BETA] Partially destabilize edition. Removes edition from `cargo new`, and documentation. Also includes (parts of) #6176 and #6027 to get the beta branch to pass tests on CI.
2 parents 05e9b01 + 12704b6 commit 2ee151f

File tree

7 files changed

+18
-84
lines changed

7 files changed

+18
-84
lines changed

src/bin/cargo/command_prelude.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,6 @@ pub trait AppExt: Sized {
150150
)
151151
._arg(opt("bin", "Use a binary (application) template [default]"))
152152
._arg(opt("lib", "Use a library template"))
153-
._arg(
154-
opt("edition", "Edition to set for the crate generated")
155-
.possible_values(&["2015", "2018"])
156-
.value_name("YEAR")
157-
)
158153
._arg(
159154
opt(
160155
"name",
@@ -346,7 +341,6 @@ pub trait ArgMatchesExt {
346341
self._is_present("lib"),
347342
self.value_of_path("path", config).unwrap(),
348343
self._value_of("name").map(|s| s.to_string()),
349-
self._value_of("edition").map(|s| s.to_string()),
350344
)
351345
}
352346

src/cargo/ops/cargo_new.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ pub struct NewOptions {
3030
/// Absolute path to the directory for the new project
3131
pub path: PathBuf,
3232
pub name: Option<String>,
33-
pub edition: Option<String>,
3433
}
3534

3635
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
@@ -66,7 +65,6 @@ struct MkOptions<'a> {
6665
name: &'a str,
6766
source_files: Vec<SourceFileInformation>,
6867
bin: bool,
69-
edition: Option<&'a str>,
7068
}
7169

7270
impl NewOptions {
@@ -76,7 +74,6 @@ impl NewOptions {
7674
lib: bool,
7775
path: PathBuf,
7876
name: Option<String>,
79-
edition: Option<String>,
8077
) -> CargoResult<NewOptions> {
8178
let kind = match (bin, lib) {
8279
(true, true) => bail!("can't specify both lib and binary outputs"),
@@ -90,7 +87,6 @@ impl NewOptions {
9087
kind,
9188
path,
9289
name,
93-
edition,
9490
};
9591
Ok(opts)
9692
}
@@ -325,7 +321,6 @@ pub fn new(opts: &NewOptions, config: &Config) -> CargoResult<()> {
325321
name,
326322
source_files: vec![plan_new_source_file(opts.kind.is_bin(), name.to_string())],
327323
bin: opts.kind.is_bin(),
328-
edition: opts.edition.as_ref().map(|s| &**s),
329324
};
330325

331326
mk(config, &mkopts).chain_err(|| {
@@ -402,7 +397,6 @@ pub fn init(opts: &NewOptions, config: &Config) -> CargoResult<()> {
402397
name,
403398
bin: src_paths_types.iter().any(|x| x.bin),
404399
source_files: src_paths_types,
405-
edition: opts.edition.as_ref().map(|s| &**s),
406400
};
407401

408402
mk(config, &mkopts).chain_err(|| {
@@ -536,16 +530,11 @@ path = {}
536530
name = "{}"
537531
version = "0.1.0"
538532
authors = [{}]
539-
edition = {}
540533
541534
[dependencies]
542535
{}"#,
543536
name,
544537
toml::Value::String(author),
545-
match opts.edition {
546-
Some(edition) => toml::Value::String(edition.to_string()),
547-
None => toml::Value::String("2018".to_string()),
548-
},
549538
cargotoml_path_specifier
550539
).as_bytes(),
551540
)?;

src/doc/src/reference/manifest.md

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -31,24 +31,6 @@ Versioning](http://semver.org/), so make sure you follow some basic rules:
3131
traits, fields, types, functions, methods or anything else.
3232
* Use version numbers with three numeric parts such as 1.0.0 rather than 1.0.
3333

34-
#### The `edition` field (optional)
35-
36-
You can opt in to a specific Rust Edition for your package with the
37-
`edition` key in `Cargo.toml`. If you don't specify the edition, it will
38-
default to 2015.
39-
40-
```toml
41-
[package]
42-
# ...
43-
edition = '2018'
44-
```
45-
46-
The `edition` key affects which edition your package is compiled with. Cargo
47-
will always generate projects via `cargo new` with the `edition` key set to the
48-
latest edition. Setting the `edition` key in `[package]` will affect all
49-
targets/crates in the package, including test suites, benchmarks, binaries,
50-
examples, etc.
51-
5234
#### The `build` field (optional)
5335

5436
This field specifies a file in the project root which is a [build script][1] for
@@ -732,12 +714,6 @@ proc-macro = false
732714
# stops it from generating a test harness. This is useful when the binary being
733715
# built manages the test runner itself.
734716
harness = true
735-
736-
# If set then a target can be configured to use a different edition than the
737-
# `[package]` is configured to use, perhaps only compiling a library with the
738-
# 2018 edition or only compiling one unit test with the 2015 edition. By default
739-
# all targets are compiled with the edition specified in `[package]`.
740-
edition = '2015'
741717
```
742718

743719
The `[package]` also includes the optional `autobins`, `autoexamples`,

tests/testsuite/doc.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -568,9 +568,12 @@ fn doc_target() {
568568
.file(
569569
"src/lib.rs",
570570
r#"
571-
#![feature(no_core)]
571+
#![feature(no_core, lang_items)]
572572
#![no_core]
573573
574+
#[lang = "sized"]
575+
trait Sized {}
576+
574577
extern {
575578
pub static A: u32;
576579
}
@@ -635,7 +638,7 @@ fn output_not_captured() {
635638
).build();
636639

637640
p.cargo("doc")
638-
.with_status(101)
641+
.without_status()
639642
.with_stderr_contains("1 | ☃")
640643
.with_stderr_contains(r"error: unknown start of token: \u{2603}")
641644
.run();

tests/testsuite/init.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ fn cargo_process(s: &str) -> Execs {
1313

1414
#[test]
1515
fn simple_lib() {
16-
cargo_process("init --lib --vcs none --edition 2015")
16+
cargo_process("init --lib --vcs none")
1717
.env("USER", "foo")
1818
.with_stderr("[CREATED] library project")
1919
.run();
@@ -29,7 +29,7 @@ fn simple_lib() {
2929
fn simple_bin() {
3030
let path = paths::root().join("foo");
3131
fs::create_dir(&path).unwrap();
32-
cargo_process("init --bin --vcs none --edition 2015")
32+
cargo_process("init --bin --vcs none")
3333
.env("USER", "foo")
3434
.cwd(&path)
3535
.with_stderr("[CREATED] binary (application) project")

tests/testsuite/new.rs

Lines changed: 3 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ fn create_empty_gitconfig() {
1414

1515
#[test]
1616
fn simple_lib() {
17-
cargo_process("new --lib foo --vcs none --edition 2015")
17+
cargo_process("new --lib foo --vcs none")
1818
.env("USER", "foo")
1919
.with_stderr("[CREATED] library `foo` project")
2020
.run();
@@ -47,7 +47,7 @@ mod tests {
4747

4848
#[test]
4949
fn simple_bin() {
50-
cargo_process("new --bin foo --edition 2015")
50+
cargo_process("new --bin foo")
5151
.env("USER", "foo")
5252
.with_stderr("[CREATED] binary (application) `foo` project")
5353
.run();
@@ -75,7 +75,7 @@ fn both_lib_and_bin() {
7575

7676
#[test]
7777
fn simple_git() {
78-
cargo_process("new --lib foo --edition 2015").env("USER", "foo").run();
78+
cargo_process("new --lib foo").env("USER", "foo").run();
7979

8080
assert!(paths::root().is_dir());
8181
assert!(paths::root().join("foo/Cargo.toml").is_file());
@@ -455,39 +455,3 @@ fn explicit_project_name() {
455455
.with_stderr("[CREATED] library `bar` project")
456456
.run();
457457
}
458-
459-
#[test]
460-
fn new_with_edition_2015() {
461-
cargo_process("new --edition 2015 foo")
462-
.env("USER", "foo")
463-
.run();
464-
let manifest = fs::read_to_string(paths::root().join("foo/Cargo.toml")).unwrap();
465-
assert!(manifest.contains("edition = \"2015\""));
466-
}
467-
468-
#[test]
469-
fn new_with_edition_2018() {
470-
cargo_process("new --edition 2018 foo")
471-
.env("USER", "foo")
472-
.run();
473-
let manifest = fs::read_to_string(paths::root().join("foo/Cargo.toml")).unwrap();
474-
assert!(manifest.contains("edition = \"2018\""));
475-
}
476-
477-
#[test]
478-
fn new_default_edition() {
479-
cargo_process("new foo")
480-
.env("USER", "foo")
481-
.run();
482-
let manifest = fs::read_to_string(paths::root().join("foo/Cargo.toml")).unwrap();
483-
assert!(manifest.contains("edition = \"2018\""));
484-
}
485-
486-
#[test]
487-
fn new_with_bad_edition() {
488-
cargo_process("new --edition something_else foo")
489-
.env("USER", "foo")
490-
.with_stderr_contains("error: 'something_else' isn't a valid value[..]")
491-
.with_status(1)
492-
.run();
493-
}

tests/testsuite/support/mod.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,14 @@ impl Execs {
566566
self
567567
}
568568

569+
/// Remove exit code check for the process.
570+
///
571+
/// By default, the expected exit code is `0`.
572+
pub fn without_status(&mut self) -> &mut Self {
573+
self.expect_exit_code = None;
574+
self
575+
}
576+
569577
/// Verify that stdout contains the given contiguous lines somewhere in
570578
/// its output.
571579
/// See `lines_match` for supported patterns.

0 commit comments

Comments
 (0)