diff --git a/src/tools/tidy/src/allowed_run_make_makefiles.txt b/src/tools/tidy/src/allowed_run_make_makefiles.txt index be9df226d64e8..ec184c2c2146f 100644 --- a/src/tools/tidy/src/allowed_run_make_makefiles.txt +++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt @@ -43,7 +43,6 @@ run-make/error-writing-dependencies/Makefile run-make/export-executable-symbols/Makefile run-make/extern-diff-internal-name/Makefile run-make/extern-flag-disambiguates/Makefile -run-make/extern-flag-fun/Makefile run-make/extern-flag-pathless/Makefile run-make/extern-flag-rename-transitive/Makefile run-make/extern-fn-explicit-align/Makefile diff --git a/tests/run-make/extern-flag-fun/Makefile b/tests/run-make/extern-flag-fun/Makefile deleted file mode 100644 index 687cdfd76755b..0000000000000 --- a/tests/run-make/extern-flag-fun/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -# ignore-cross-compile -include ../tools.mk - -all: - $(RUSTC) bar.rs --crate-type=rlib - $(RUSTC) bar.rs --crate-type=rlib -C extra-filename=-a - $(RUSTC) bar-alt.rs --crate-type=rlib - $(RUSTC) foo.rs --extern bar=no-exist && exit 1 || exit 0 - $(RUSTC) foo.rs --extern bar=foo.rs && exit 1 || exit 0 - $(RUSTC) foo.rs \ - --extern bar=$(TMPDIR)/libbar.rlib \ - --extern bar=$(TMPDIR)/libbar-alt.rlib \ - && exit 1 || exit 0 - $(RUSTC) foo.rs \ - --extern bar=$(TMPDIR)/libbar.rlib \ - --extern bar=$(TMPDIR)/libbar-a.rlib - $(RUSTC) foo.rs --extern bar=$(TMPDIR)/libbar.rlib - # Try to be sneaky and load a private crate from with a non-private name. - $(RUSTC) rustc.rs -Zforce-unstable-if-unmarked --crate-type=rlib - $(RUSTC) gated_unstable.rs --extern alloc=$(TMPDIR)/librustc.rlib 2>&1 | $(CGREP) 'rustc_private' diff --git a/tests/run-make/extern-flag-fun/rmake.rs b/tests/run-make/extern-flag-fun/rmake.rs new file mode 100644 index 0000000000000..10fec6e30b423 --- /dev/null +++ b/tests/run-make/extern-flag-fun/rmake.rs @@ -0,0 +1,36 @@ +// The --extern flag can override the default crate search of +// the compiler and directly fetch a given path. There are a few rules +// to follow: for example, there can't be more than one rlib, the crates must +// be valid ("no-exist" in this test), and private crates can't be loaded +// as non-private. This test checks that these rules are enforced. +// See https://github.com/rust-lang/rust/pull/15319 + +//@ ignore-cross-compile + +use run_make_support::{rust_lib_name, rustc}; + +fn main() { + rustc().input("bar.rs").crate_type("rlib").run(); + rustc().input("bar.rs").crate_type("rlib").extra_filename("-a").run(); + rustc().input("bar-alt.rs").crate_type("rlib").run(); + rustc().input("foo.rs").extern_("bar", "no-exist").run_fail(); + rustc().input("foo.rs").extern_("bar", "foo.rs").run_fail(); + rustc() + .input("foo.rs") + .extern_("bar", rust_lib_name("bar")) + .extern_("bar", rust_lib_name("bar-alt")) + .run_fail(); + rustc() + .input("foo.rs") + .extern_("bar", rust_lib_name("bar")) + .extern_("bar", rust_lib_name("bar-a")) + .run(); + rustc().input("foo.rs").extern_("bar", rust_lib_name("bar")).run(); + // Try to be sneaky and load a private crate from with a non-private name. + rustc().input("rustc.rs").arg("-Zforce-unstable-if-unmarked").crate_type("rlib").run(); + rustc() + .input("gated_unstable.rs") + .extern_("alloc", rust_lib_name("rustc")) + .run_fail() + .assert_stderr_contains("rustc_private"); +}