forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
Auto merge of rust-lang#135861 - jieyouxu:rollup-d4naa6s, r=jieyouxu
Rollup of 8 pull requests Successful merges: - rust-lang#135779 (CI: free disk on linux arm runner) - rust-lang#135794 (Detect missing fields with default values and suggest `..`) - rust-lang#135814 (ci: use ghcr buildkit image) - rust-lang#135818 (tests: Port `translation` to rmake.rs) - rust-lang#135823 (make UI tests that use `--test` work on panic=abort targets) - rust-lang#135837 (Remove test panic from File::open) - rust-lang#135852 (Add `AsyncFn*` to `core` prelude) - rust-lang#135856 (Library: Finalize dyn compatibility renaming) r? `@ghost` `@rustbot` modify labels: rollup
Showing
16 changed files
with
407 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
run-make/jobserver-error/Makefile | ||
run-make/split-debuginfo/Makefile | ||
run-make/symbol-mangling-hashed/Makefile | ||
run-make/translation/Makefile |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,179 @@ | ||
//! Smoke test for the rustc diagnostics translation infrastructure. | ||
//! | ||
//! # References | ||
//! | ||
//! - Current tracking issue: <https://github.com/rust-lang/rust/issues/132181>. | ||
//! - Old tracking issue: <https://github.com/rust-lang/rust/issues/100717> | ||
//! - Initial translation infra implementation: <https://github.com/rust-lang/rust/pull/95512>. | ||
// This test uses symbolic links to stub out a fake sysroot to save testing time. | ||
//@ needs-symlink | ||
|
||
#![deny(warnings)] | ||
|
||
use std::path::{Path, PathBuf}; | ||
|
||
use run_make_support::rustc::sysroot; | ||
use run_make_support::{cwd, rfs, run_in_tmpdir, rustc}; | ||
|
||
fn main() { | ||
builtin_fallback_bundle(); | ||
additional_primary_bundle(); | ||
missing_slug_prefers_fallback_bundle(); | ||
broken_primary_bundle_prefers_fallback_bundle(); | ||
locale_sysroot(); | ||
missing_sysroot(); | ||
file_sysroot(); | ||
} | ||
|
||
/// Check that the test works normally, using the built-in fallback bundle. | ||
fn builtin_fallback_bundle() { | ||
rustc().input("test.rs").run_fail().assert_stderr_contains("struct literal body without path"); | ||
} | ||
|
||
/// Check that a primary bundle can be loaded and will be preferentially used where possible. | ||
fn additional_primary_bundle() { | ||
rustc() | ||
.input("test.rs") | ||
.arg("-Ztranslate-additional-ftl=working.ftl") | ||
.run_fail() | ||
.assert_stderr_contains("this is a test message"); | ||
} | ||
|
||
/// Check that a primary bundle without the desired message will use the fallback bundle. | ||
fn missing_slug_prefers_fallback_bundle() { | ||
rustc() | ||
.input("test.rs") | ||
.arg("-Ztranslate-additional-ftl=missing.ftl") | ||
.run_fail() | ||
.assert_stderr_contains("struct literal body without path"); | ||
} | ||
|
||
/// Check that a primary bundle with a broken message (e.g. an interpolated variable is not | ||
/// provided) will use the fallback bundle. | ||
fn broken_primary_bundle_prefers_fallback_bundle() { | ||
// FIXME(#135817): as of the rmake.rs port, the compiler actually ICEs on the additional | ||
// `broken.ftl`, even though the original intention seems to be that it should gracefully | ||
// failover to the fallback bundle. | ||
|
||
rustc() | ||
.env("RUSTC_ICE", "0") // disable ICE dump file, not needed | ||
.input("test.rs") | ||
.arg("-Ztranslate-additional-ftl=broken.ftl") | ||
.run_fail() | ||
.assert_exit_code(101); | ||
} | ||
|
||
#[track_caller] | ||
fn shallow_symlink_dir_entries(src_dir: &Path, dst_dir: &Path) { | ||
for entry in rfs::read_dir(src_dir) { | ||
let entry = entry.unwrap(); | ||
let src_entry_path = entry.path(); | ||
let src_filename = src_entry_path.file_name().unwrap(); | ||
let meta = rfs::symlink_metadata(&src_entry_path); | ||
|
||
if meta.is_symlink() || meta.is_file() { | ||
rfs::symlink_file(&src_entry_path, dst_dir.join(src_filename)); | ||
} else if meta.is_dir() { | ||
rfs::symlink_dir(&src_entry_path, dst_dir.join(src_filename)); | ||
} else { | ||
unreachable!() | ||
} | ||
} | ||
} | ||
|
||
#[track_caller] | ||
fn shallow_symlink_dir_entries_materialize_single_dir( | ||
src_dir: &Path, | ||
dst_dir: &Path, | ||
dir_filename: &str, | ||
) { | ||
shallow_symlink_dir_entries(src_dir, dst_dir); | ||
|
||
// On Windows, this would be a symlink-to-dir, so we have to remove with `remove_dir` instead. | ||
#[cfg(windows)] | ||
rfs::remove_dir(dst_dir.join(dir_filename)); | ||
#[cfg(not(windows))] | ||
rfs::remove_file(dst_dir.join(dir_filename)); | ||
|
||
rfs::create_dir_all(dst_dir.join(dir_filename)); | ||
} | ||
|
||
#[track_caller] | ||
fn setup_fakeroot_parents() -> PathBuf { | ||
let sysroot = sysroot(); | ||
let fakeroot = cwd().join("fakeroot"); | ||
rfs::create_dir_all(&fakeroot); | ||
shallow_symlink_dir_entries_materialize_single_dir(&sysroot, &fakeroot, "lib"); | ||
shallow_symlink_dir_entries_materialize_single_dir( | ||
&sysroot.join("lib"), | ||
&fakeroot.join("lib"), | ||
"rustlib", | ||
); | ||
shallow_symlink_dir_entries_materialize_single_dir( | ||
&sysroot.join("lib").join("rustlib"), | ||
&fakeroot.join("lib").join("rustlib"), | ||
"src", | ||
); | ||
shallow_symlink_dir_entries( | ||
&sysroot.join("lib").join("rustlib").join("src"), | ||
&fakeroot.join("lib").join("rustlib").join("src"), | ||
); | ||
fakeroot | ||
} | ||
|
||
/// Check that a locale can be loaded from the sysroot given a language identifier by making a local | ||
/// copy of the sysroot and adding the custom locale to it. | ||
fn locale_sysroot() { | ||
run_in_tmpdir(|| { | ||
let fakeroot = setup_fakeroot_parents(); | ||
|
||
// When download-rustc is enabled, real sysroot will have a share directory. Delete the link | ||
// to it. | ||
let _ = std::fs::remove_file(fakeroot.join("share")); | ||
|
||
let fake_locale_path = fakeroot.join("share").join("locale").join("zh-CN"); | ||
rfs::create_dir_all(&fake_locale_path); | ||
rfs::symlink_file( | ||
cwd().join("working.ftl"), | ||
fake_locale_path.join("basic-translation.ftl"), | ||
); | ||
|
||
rustc() | ||
.env("RUSTC_ICE", "0") | ||
.input("test.rs") | ||
.sysroot(&fakeroot) | ||
.arg("-Ztranslate-lang=zh-CN") | ||
.run_fail() | ||
.assert_stderr_contains("this is a test message"); | ||
}); | ||
} | ||
|
||
/// Check that the compiler errors out when the sysroot requested cannot be found. This test might | ||
/// start failing if there actually exists a Klingon translation of rustc's error messages. | ||
fn missing_sysroot() { | ||
run_in_tmpdir(|| { | ||
rustc() | ||
.input("test.rs") | ||
.arg("-Ztranslate-lang=tlh") | ||
.run_fail() | ||
.assert_stderr_contains("missing locale directory"); | ||
}); | ||
} | ||
|
||
/// Check that the compiler errors out when the directory for the locale in the sysroot is actually | ||
/// a file. | ||
fn file_sysroot() { | ||
run_in_tmpdir(|| { | ||
let fakeroot = setup_fakeroot_parents(); | ||
rfs::create_dir_all(fakeroot.join("share").join("locale")); | ||
rfs::write(fakeroot.join("share").join("locale").join("zh-CN"), b"not a dir"); | ||
|
||
rustc() | ||
.input("test.rs") | ||
.sysroot(&fakeroot) | ||
.arg("-Ztranslate-lang=zh-CN") | ||
.run_fail() | ||
.assert_stderr_contains("is not a directory"); | ||
}); | ||
} |
4 changes: 3 additions & 1 deletion
4
...-2011-nicer-assert-messages/assert-with-custom-errors-does-not-create-unnecessary-code.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 3 additions & 1 deletion
4
tests/ui/macros/rfc-2011-nicer-assert-messages/feature-gate-generic_assert.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
tests/ui/structs/default-field-values/non-exhaustive-ctor.disabled.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
error[E0658]: default values on fields are experimental | ||
--> $DIR/non-exhaustive-ctor.rs:9:22 | ||
| | ||
LL | pub field: () = (), | ||
| ^^^^^ | ||
| | ||
= note: see issue #132162 <https://github.com/rust-lang/rust/issues/132162> for more information | ||
= help: add `#![feature(default_field_values)]` to the crate attributes to enable | ||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date | ||
|
||
error[E0658]: default values on fields are experimental | ||
--> $DIR/non-exhaustive-ctor.rs:11:25 | ||
| | ||
LL | pub field1: Priv = Priv, | ||
| ^^^^^^^ | ||
| | ||
= note: see issue #132162 <https://github.com/rust-lang/rust/issues/132162> for more information | ||
= help: add `#![feature(default_field_values)]` to the crate attributes to enable | ||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date | ||
|
||
error[E0658]: default values on fields are experimental | ||
--> $DIR/non-exhaustive-ctor.rs:13:25 | ||
| | ||
LL | pub field2: Priv = Priv, | ||
| ^^^^^^^ | ||
| | ||
= note: see issue #132162 <https://github.com/rust-lang/rust/issues/132162> for more information | ||
= help: add `#![feature(default_field_values)]` to the crate attributes to enable | ||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date | ||
|
||
error[E0797]: base expression required after `..` | ||
--> $DIR/non-exhaustive-ctor.rs:20:19 | ||
| | ||
LL | let _ = S { .. }; // ok | ||
| ^ | ||
| | ||
help: add `#![feature(default_field_values)]` to the crate attributes to enable default values on `struct` fields | ||
| | ||
LL + #![feature(default_field_values)] | ||
| | ||
help: add a base expression here | ||
| | ||
LL | let _ = S { ../* expr */ }; // ok | ||
| ++++++++++ | ||
|
||
error[E0797]: base expression required after `..` | ||
--> $DIR/non-exhaustive-ctor.rs:22:30 | ||
| | ||
LL | let _ = S { field: (), .. }; // ok | ||
| ^ | ||
| | ||
help: add `#![feature(default_field_values)]` to the crate attributes to enable default values on `struct` fields | ||
| | ||
LL + #![feature(default_field_values)] | ||
| | ||
help: add a base expression here | ||
| | ||
LL | let _ = S { field: (), ../* expr */ }; // ok | ||
| ++++++++++ | ||
|
||
error[E0063]: missing fields `field`, `field1` and `field2` in initializer of `S` | ||
--> $DIR/non-exhaustive-ctor.rs:24:13 | ||
| | ||
LL | let _ = S { }; | ||
| ^ missing `field`, `field1` and `field2` | ||
| | ||
help: all remaining fields have default values, if you added `#![feature(default_field_values)]` to your crate you could use those values with `..` | ||
| | ||
LL | let _ = S { .. }; | ||
| ~~~~~~ | ||
|
||
error[E0063]: missing fields `field1` and `field2` in initializer of `S` | ||
--> $DIR/non-exhaustive-ctor.rs:26:13 | ||
| | ||
LL | let _ = S { field: () }; | ||
| ^ missing `field1` and `field2` | ||
| | ||
help: all remaining fields have default values, if you added `#![feature(default_field_values)]` to your crate you could use those values with `..` | ||
| | ||
LL | let _ = S { field: (), .. }; | ||
| ++++ | ||
|
||
error: aborting due to 7 previous errors | ||
|
||
Some errors have detailed explanations: E0063, E0658, E0797. | ||
For more information about an error, try `rustc --explain E0063`. |
28 changes: 28 additions & 0 deletions
28
tests/ui/structs/default-field-values/non-exhaustive-ctor.enabled.fixed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
//@ revisions: enabled disabled | ||
//@[enabled] run-rustfix | ||
#![allow(private_interfaces, dead_code)] | ||
#![cfg_attr(enabled, feature(default_field_values))] | ||
use m::S; | ||
|
||
mod m { | ||
pub struct S { | ||
pub field: () = (), | ||
//[disabled]~^ ERROR default values on fields are experimental | ||
pub field1: Priv = Priv, | ||
//[disabled]~^ ERROR default values on fields are experimental | ||
pub field2: Priv = Priv, | ||
//[disabled]~^ ERROR default values on fields are experimental | ||
} | ||
struct Priv; | ||
} | ||
|
||
fn main() { | ||
let _ = S { .. }; // ok | ||
//[disabled]~^ ERROR base expression required after `..` | ||
let _ = S { field: (), .. }; // ok | ||
//[disabled]~^ ERROR base expression required after `..` | ||
let _ = S { .. }; | ||
//~^ ERROR missing fields `field`, `field1` and `field2` | ||
let _ = S { field: (), .. }; | ||
//~^ ERROR missing fields `field1` and `field2` | ||
} |
25 changes: 25 additions & 0 deletions
25
tests/ui/structs/default-field-values/non-exhaustive-ctor.enabled.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
error[E0063]: missing fields `field`, `field1` and `field2` in initializer of `S` | ||
--> $DIR/non-exhaustive-ctor.rs:24:13 | ||
| | ||
LL | let _ = S { }; | ||
| ^ missing `field`, `field1` and `field2` | ||
| | ||
help: all remaining fields have default values, you can use those values with `..` | ||
| | ||
LL | let _ = S { .. }; | ||
| ~~~~~~ | ||
|
||
error[E0063]: missing fields `field1` and `field2` in initializer of `S` | ||
--> $DIR/non-exhaustive-ctor.rs:26:13 | ||
| | ||
LL | let _ = S { field: () }; | ||
| ^ missing `field1` and `field2` | ||
| | ||
help: all remaining fields have default values, you can use those values with `..` | ||
| | ||
LL | let _ = S { field: (), .. }; | ||
| ++++ | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0063`. |
28 changes: 28 additions & 0 deletions
28
tests/ui/structs/default-field-values/non-exhaustive-ctor.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
//@ revisions: enabled disabled | ||
//@[enabled] run-rustfix | ||
#![allow(private_interfaces, dead_code)] | ||
#![cfg_attr(enabled, feature(default_field_values))] | ||
use m::S; | ||
|
||
mod m { | ||
pub struct S { | ||
pub field: () = (), | ||
//[disabled]~^ ERROR default values on fields are experimental | ||
pub field1: Priv = Priv, | ||
//[disabled]~^ ERROR default values on fields are experimental | ||
pub field2: Priv = Priv, | ||
//[disabled]~^ ERROR default values on fields are experimental | ||
} | ||
struct Priv; | ||
} | ||
|
||
fn main() { | ||
let _ = S { .. }; // ok | ||
//[disabled]~^ ERROR base expression required after `..` | ||
let _ = S { field: (), .. }; // ok | ||
//[disabled]~^ ERROR base expression required after `..` | ||
let _ = S { }; | ||
//~^ ERROR missing fields `field`, `field1` and `field2` | ||
let _ = S { field: () }; | ||
//~^ ERROR missing fields `field1` and `field2` | ||
} |