diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs index fc30679be03cb..1f5e2b76bf0dc 100644 --- a/compiler/rustc_codegen_ssa/src/back/link.rs +++ b/compiler/rustc_codegen_ssa/src/back/link.rs @@ -1952,7 +1952,7 @@ fn linker_with_args<'a, B: ArchiveBuilder<'a>>( add_local_native_libraries(cmd, sess, codegen_results); } - // Upstream rust libraries and their nobundle static libraries + // Upstream rust libraries and their non-bundled static libraries add_upstream_rust_crates::(cmd, sess, codegen_results, crate_type, tmpdir); // Upstream dynamic native libraries linked with `#[link]` attributes at and `-l` @@ -2237,7 +2237,7 @@ fn add_local_native_libraries( } } -/// # Linking Rust crates and their nobundle static libraries +/// # Linking Rust crates and their non-bundled static libraries /// /// Rust crates are not considered at all when creating an rlib output. All dependencies will be /// linked when producing the final output (instead of the intermediate rlib version). diff --git a/compiler/rustc_error_codes/src/error_codes/E0060.md b/compiler/rustc_error_codes/src/error_codes/E0060.md index e6906d72367d8..54b10c886ccce 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0060.md +++ b/compiler/rustc_error_codes/src/error_codes/E0060.md @@ -16,10 +16,10 @@ Using this declaration, it must be called with at least one argument, so simply calling `printf()` is invalid. But the following uses are allowed: ``` -# #![feature(static_nobundle)] # use std::os::raw::{c_char, c_int}; # #[cfg_attr(all(windows, target_env = "msvc"), -# link(name = "legacy_stdio_definitions", kind = "static-nobundle"))] +# link(name = "legacy_stdio_definitions", +# kind = "static", modifiers = "-bundle"))] # extern "C" { fn printf(_: *const c_char, ...) -> c_int; } # fn main() { unsafe { diff --git a/compiler/rustc_errors/src/lib.rs b/compiler/rustc_errors/src/lib.rs index 3be6dd5af75ac..83fe2a2df892f 100644 --- a/compiler/rustc_errors/src/lib.rs +++ b/compiler/rustc_errors/src/lib.rs @@ -400,6 +400,9 @@ struct HandlerInner { emitter: Box, delayed_span_bugs: Vec, delayed_good_path_bugs: Vec, + /// This flag indicates that an expected diagnostic was emitted and suppressed. + /// This is used for the `delayed_good_path_bugs` check. + suppressed_expected_diag: bool, /// This set contains the `DiagnosticId` of all emitted diagnostics to avoid /// emitting the same diagnostic with extended help (`--teach`) twice, which @@ -495,7 +498,7 @@ impl Drop for HandlerInner { // instead of "require some error happened". Sadly that isn't ideal, as // lints can be `#[allow]`'d, potentially leading to this triggering. // Also, "good path" should be replaced with a better naming. - if !self.has_any_message() { + if !self.has_any_message() && !self.suppressed_expected_diag { let bugs = std::mem::replace(&mut self.delayed_good_path_bugs, Vec::new()); self.flush_delayed( bugs.into_iter().map(DelayedDiagnostic::decorate), @@ -577,6 +580,7 @@ impl Handler { emitter, delayed_span_bugs: Vec::new(), delayed_good_path_bugs: Vec::new(), + suppressed_expected_diag: false, taught_diagnostics: Default::default(), emitted_diagnostic_codes: Default::default(), emitted_diagnostics: Default::default(), @@ -1000,20 +1004,20 @@ impl Handler { let mut inner = self.inner.borrow_mut(); let diags = std::mem::take(&mut inner.unstable_expect_diagnostics); inner.check_unstable_expect_diagnostics = true; - if diags.is_empty() { - return; - } - for mut diag in diags.into_iter() { - diag.update_unstable_expectation_id(unstable_to_stable); + if !diags.is_empty() { + inner.suppressed_expected_diag = true; + for mut diag in diags.into_iter() { + diag.update_unstable_expectation_id(unstable_to_stable); - let stable_id = diag - .level - .get_expectation_id() - .expect("all diagnostics inside `unstable_expect_diagnostics` must have a `LintExpectationId`"); - inner.fulfilled_expectations.insert(stable_id); + let stable_id = diag + .level + .get_expectation_id() + .expect("all diagnostics inside `unstable_expect_diagnostics` must have a `LintExpectationId`"); + inner.fulfilled_expectations.insert(stable_id); - (*TRACK_DIAGNOSTICS)(&diag); + (*TRACK_DIAGNOSTICS)(&diag); + } } inner @@ -1100,6 +1104,7 @@ impl HandlerInner { (*TRACK_DIAGNOSTICS)(diagnostic); if let Level::Expect(expectation_id) = diagnostic.level { + self.suppressed_expected_diag = true; self.fulfilled_expectations.insert(expectation_id); return None; } else if diagnostic.level == Allow { diff --git a/compiler/rustc_feature/src/accepted.rs b/compiler/rustc_feature/src/accepted.rs index 071e88e07fd1e..0abd45c621d24 100644 --- a/compiler/rustc_feature/src/accepted.rs +++ b/compiler/rustc_feature/src/accepted.rs @@ -219,6 +219,8 @@ declare_features! ( (accepted, move_ref_pattern, "1.49.0", Some(68354), None), /// Allows specifying modifiers in the link attribute: `#[link(modifiers = "...")]` (accepted, native_link_modifiers, "1.61.0", Some(81490), None), + /// Allows specifying the bundle link modifier + (accepted, native_link_modifiers_bundle, "1.63.0", Some(81490), None), /// Allows specifying the whole-archive link modifier (accepted, native_link_modifiers_whole_archive, "1.61.0", Some(81490), None), /// Allows using non lexical lifetimes (RFC 2094). diff --git a/compiler/rustc_feature/src/active.rs b/compiler/rustc_feature/src/active.rs index 1803f665013ad..1798bf8d42823 100644 --- a/compiler/rustc_feature/src/active.rs +++ b/compiler/rustc_feature/src/active.rs @@ -451,8 +451,6 @@ declare_features! ( (active, naked_functions, "1.9.0", Some(32408), None), /// Allows specifying the as-needed link modifier (active, native_link_modifiers_as_needed, "1.53.0", Some(81490), None), - /// Allows specifying the bundle link modifier - (active, native_link_modifiers_bundle, "1.53.0", Some(81490), None), /// Allows specifying the verbatim link modifier (active, native_link_modifiers_verbatim, "1.53.0", Some(81490), None), /// Allow negative trait implementations. @@ -502,8 +500,6 @@ declare_features! ( (active, simd_ffi, "1.0.0", Some(27731), None), /// Allows specialization of implementations (RFC 1210). (incomplete, specialization, "1.7.0", Some(31844), None), - /// Allows `#[link(kind="static-nobundle"...)]`. - (active, static_nobundle, "1.16.0", Some(37403), None), /// Allows attributes on expressions and non-item statements. (active, stmt_expr_attributes, "1.6.0", Some(15701), None), /// Allows lints part of the strict provenance effort. diff --git a/compiler/rustc_feature/src/removed.rs b/compiler/rustc_feature/src/removed.rs index b546662dc1496..7194416cd1d60 100644 --- a/compiler/rustc_feature/src/removed.rs +++ b/compiler/rustc_feature/src/removed.rs @@ -169,6 +169,9 @@ declare_features! ( (removed, sanitizer_runtime, "1.17.0", None, None, None), (removed, simd, "1.0.0", Some(27731), None, Some("removed in favor of `#[repr(simd)]`")), + /// Allows `#[link(kind = "static-nobundle", ...)]`. + (removed, static_nobundle, "1.16.0", Some(37403), None, + Some(r#"subsumed by `#[link(kind = "static", modifiers = "-bundle", ...)]`"#)), (removed, struct_inherit, "1.0.0", None, None, None), (removed, test_removed_feature, "1.0.0", None, None, None), /// Allows using items which are missing stability attributes diff --git a/compiler/rustc_metadata/src/native_libs.rs b/compiler/rustc_metadata/src/native_libs.rs index 95892d8341479..c33219e470050 100644 --- a/compiler/rustc_metadata/src/native_libs.rs +++ b/compiler/rustc_metadata/src/native_libs.rs @@ -97,24 +97,6 @@ impl<'tcx> Collector<'tcx> { let span = item.name_value_literal_span().unwrap(); let link_kind = match link_kind.as_str() { "static" => NativeLibKind::Static { bundle: None, whole_archive: None }, - "static-nobundle" => { - sess.struct_span_warn( - span, - "link kind `static-nobundle` has been superseded by specifying \ - modifier `-bundle` with link kind `static`", - ) - .emit(); - if !features.static_nobundle { - feature_err( - &sess.parse_sess, - sym::static_nobundle, - span, - "link kind `static-nobundle` is unstable", - ) - .emit(); - } - NativeLibKind::Static { bundle: Some(false), whole_archive: None } - } "dylib" => NativeLibKind::Dylib { as_needed: None }, "framework" => { if !sess.target.is_like_osx { @@ -264,7 +246,6 @@ impl<'tcx> Collector<'tcx> { }; match (modifier, &mut kind) { ("bundle", Some(NativeLibKind::Static { bundle, .. })) => { - report_unstable_modifier!(native_link_modifiers_bundle); assign_modifier(bundle) } ("bundle", _) => { diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index cabaf321f80c3..c4a67006504fd 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -1920,21 +1920,6 @@ fn parse_native_lib_kind( let kind = match kind { "static" => NativeLibKind::Static { bundle: None, whole_archive: None }, - "static-nobundle" => { - early_warn( - error_format, - "library kind `static-nobundle` has been superseded by specifying \ - modifier `-bundle` with library kind `static`. Try `static:-bundle`", - ); - if !nightly_options::match_is_nightly_build(matches) { - early_error( - error_format, - "library kind `static-nobundle` is unstable \ - and only accepted on the nightly compiler", - ); - } - NativeLibKind::Static { bundle: Some(false), whole_archive: None } - } "dylib" => NativeLibKind::Dylib { as_needed: None }, "framework" => NativeLibKind::Framework { as_needed: None }, _ => early_error( @@ -1987,10 +1972,7 @@ fn parse_native_lib_modifiers( } }; match (modifier, &mut kind) { - ("bundle", NativeLibKind::Static { bundle, .. }) => { - report_unstable_modifier(); - assign_modifier(bundle) - } + ("bundle", NativeLibKind::Static { bundle, .. }) => assign_modifier(bundle), ("bundle", _) => early_error( error_format, "linking modifier `bundle` is only compatible with `static` linking kind", diff --git a/library/core/src/future/into_future.rs b/library/core/src/future/into_future.rs index 8014dacdd98da..d22094130ad9a 100644 --- a/library/core/src/future/into_future.rs +++ b/library/core/src/future/into_future.rs @@ -1,6 +1,109 @@ use crate::future::Future; /// Conversion into a `Future`. +/// +/// By implementing `Intofuture` for a type, you define how it will be +/// converted to a future. +/// +/// # `.await` desugaring +/// +/// The `.await` keyword desugars into a call to `IntoFuture::into_future` +/// first before polling the future to completion. `IntoFuture` is implemented +/// for all `T: Future` which means the `into_future` method will be available +/// on all futures. +/// +/// ```no_run +/// #![feature(into_future)] +/// +/// use std::future::IntoFuture; +/// +/// # async fn foo() { +/// let v = async { "meow" }; +/// let mut fut = v.into_future(); +/// assert_eq!("meow", fut.await); +/// # } +/// ``` +/// +/// # Async builders +/// +/// When implementing futures manually there will often be a choice between +/// implementing `Future` or `IntoFuture` for a type. Implementing `Future` is a +/// good choice in most cases. But implementing `IntoFuture` is most useful when +/// implementing "async builder" types, which allows the type to be modified +/// multiple times before being `.await`ed. +/// +/// ```rust +/// #![feature(into_future)] +/// +/// use std::future::{ready, Ready, IntoFuture}; +/// +/// /// Eventually multiply two numbers +/// pub struct Multiply { +/// num: u16, +/// factor: u16, +/// } +/// +/// impl Multiply { +/// /// Construct a new instance of `Multiply`. +/// pub fn new(num: u16, factor: u16) -> Self { +/// Self { num, factor } +/// } +/// +/// /// Set the number to multiply by the factor. +/// pub fn number(mut self, num: u16) -> Self { +/// self.num = num; +/// self +/// } +/// +/// /// Set the factor to multiply the number with. +/// pub fn factor(mut self, factor: u16) -> Self { +/// self.factor = factor; +/// self +/// } +/// } +/// +/// impl IntoFuture for Multiply { +/// type Output = u16; +/// type IntoFuture = Ready; +/// +/// fn into_future(self) -> Self::IntoFuture { +/// ready(self.num * self.factor) +/// } +/// } +/// +/// // NOTE: Rust does not yet have an `async fn main` function, that functionality +/// // currently only exists in the ecosystem. +/// async fn run() { +/// let num = Multiply::new(0, 0) // initialize the builder to number: 0, factor: 0 +/// .number(2) // change the number to 2 +/// .factor(2) // change the factor to 2 +/// .await; // convert to future and .await +/// +/// assert_eq!(num, 4); +/// } +/// ``` +/// +/// # Usage in trait bounds +/// +/// Using `IntoFuture` in trait bounds allows a function to be generic over both +/// `Future` and `IntoFuture`. This is convenient for users of the function, so +/// when they are using it they don't have to make an extra call to +/// `IntoFuture::into_future` to obtain an instance of `Future`: +/// +/// ```rust +/// #![feature(into_future)] +/// +/// use std::future::IntoFuture; +/// +/// /// Convert the output of a future to a string. +/// async fn fut_to_string(fut: Fut) -> String +/// where +/// Fut: IntoFuture, +/// Fut::Output: std::fmt::Debug, +/// { +/// format!("{:?}", fut.await) +/// } +/// ``` #[unstable(feature = "into_future", issue = "67644")] pub trait IntoFuture { /// The output that the future will produce on completion. @@ -12,6 +115,22 @@ pub trait IntoFuture { type IntoFuture: Future; /// Creates a future from a value. + /// + /// # Examples + /// + /// Basic usage: + /// + /// ```no_run + /// #![feature(into_future)] + /// + /// use std::future::IntoFuture; + /// + /// # async fn foo() { + /// let v = async { "meow" }; + /// let mut fut = v.into_future(); + /// assert_eq!("meow", fut.await); + /// # } + /// ``` #[unstable(feature = "into_future", issue = "67644")] #[lang = "into_future"] fn into_future(self) -> Self::IntoFuture; diff --git a/library/std/src/io/impls.rs b/library/std/src/io/impls.rs index 0ca58efe1fe2f..95072547302eb 100644 --- a/library/std/src/io/impls.rs +++ b/library/std/src/io/impls.rs @@ -441,14 +441,12 @@ impl Read for VecDeque { impl Write for VecDeque { #[inline] fn write(&mut self, buf: &[u8]) -> io::Result { - self.reserve(buf.len()); self.extend(buf); Ok(buf.len()) } #[inline] fn write_all(&mut self, buf: &[u8]) -> io::Result<()> { - self.reserve(buf.len()); self.extend(buf); Ok(()) } diff --git a/library/unwind/src/lib.rs b/library/unwind/src/lib.rs index 15254bc755bea..52d737de7aef8 100644 --- a/library/unwind/src/lib.rs +++ b/library/unwind/src/lib.rs @@ -1,7 +1,7 @@ #![no_std] #![unstable(feature = "panic_unwind", issue = "32837")] #![feature(link_cfg)] -#![feature(native_link_modifiers_bundle)] +#![cfg_attr(bootstrap, feature(native_link_modifiers_bundle))] #![feature(staged_api)] #![feature(c_unwind)] #![feature(cfg_target_abi)] diff --git a/src/doc/rustc/src/command-line-arguments.md b/src/doc/rustc/src/command-line-arguments.md index 73e7764a11d37..bc04dfd4433f6 100644 --- a/src/doc/rustc/src/command-line-arguments.md +++ b/src/doc/rustc/src/command-line-arguments.md @@ -84,6 +84,26 @@ The default for this modifier is `-whole-archive`. \ NOTE: The default may currently be different in some cases for backward compatibility, but it is not guaranteed. If you need whole archive semantics use `+whole-archive` explicitly. +### Linking modifiers: `bundle` + +This modifier is only compatible with the `static` linking kind. +Using any other kind will result in a compiler error. + +When building a rlib or staticlib `+bundle` means that all object files from the native static +library will be added to the rlib or staticlib archive, and then used from it during linking of +the final binary. + +When building a rlib `-bundle` means that the native static library is registered as a dependency +of that rlib "by name", and object files from it are included only during linking of the final +binary, the file search by that name is also performed during final linking. \ +When building a staticlib `-bundle` means that the native static library is simply not included +into the archive and some higher level build system will need to add it later during linking of +the final binary. + +This modifier has no effect when building other targets like executables or dynamic libraries. + +The default for this modifier is `+bundle`. + ## `--crate-type`: a list of types of crates for the compiler to emit diff --git a/src/doc/unstable-book/src/language-features/native-link-modifiers-bundle.md b/src/doc/unstable-book/src/language-features/native-link-modifiers-bundle.md deleted file mode 100644 index ac192cff13a3d..0000000000000 --- a/src/doc/unstable-book/src/language-features/native-link-modifiers-bundle.md +++ /dev/null @@ -1,19 +0,0 @@ -# `native_link_modifiers_bundle` - -The tracking issue for this feature is: [#81490] - -[#81490]: https://github.com/rust-lang/rust/issues/81490 - ------------------------- - -The `native_link_modifiers_bundle` feature allows you to use the `bundle` modifier. - -Only compatible with the `static` linking kind. Using any other kind will result in a compiler error. - -`+bundle` means objects from the static library are bundled into the produced crate (a rlib, for example) and are used from this crate later during linking of the final binary. - -`-bundle` means the static library is included into the produced rlib "by name" and object files from it are included only during linking of the final binary, the file search by that name is also performed during final linking. - -This modifier is supposed to supersede the `static-nobundle` linking kind defined by [RFC 1717](https://github.com/rust-lang/rfcs/pull/1717). - -The default for this modifier is currently `+bundle`, but it could be changed later on some future edition boundary. diff --git a/src/test/run-make-fulldeps/static-nobundle/Makefile b/src/test/run-make-fulldeps/static-nobundle/Makefile deleted file mode 100644 index 001081798a6e4..0000000000000 --- a/src/test/run-make-fulldeps/static-nobundle/Makefile +++ /dev/null @@ -1,23 +0,0 @@ --include ../tools.mk - -# aaa is a native static library -# bbb is a rlib -# ccc is a dylib -# ddd is an executable - -all: $(call NATIVE_STATICLIB,aaa) - $(RUSTC) bbb.rs --crate-type=rlib - - # Check that bbb does NOT contain the definition of `native_func` - # We're using the llvm-nm instead of the system nm to ensure it - # is compatible with the LLVM bitcode generated by rustc. - "$(LLVM_BIN_DIR)/llvm-nm" $(TMPDIR)/libbbb.rlib | $(CGREP) -ve "T _*native_func" - "$(LLVM_BIN_DIR)/llvm-nm" $(TMPDIR)/libbbb.rlib | $(CGREP) -e "U _*native_func" - - # Check that aaa gets linked (either as `-l aaa` or `aaa.lib`) when building ccc. - $(RUSTC) ccc.rs -C prefer-dynamic --crate-type=dylib --print link-args | $(CGREP) -e '-l[" ]*aaa|aaa\.lib' - - # Check that aaa does NOT get linked when building ddd. - $(RUSTC) ddd.rs --print link-args | $(CGREP) -ve '-l[" ]*aaa|aaa\.lib' - - $(call RUN,ddd) diff --git a/src/test/run-make-fulldeps/static-nobundle/bbb.rs b/src/test/run-make-fulldeps/static-nobundle/bbb.rs deleted file mode 100644 index 69d1668d4f643..0000000000000 --- a/src/test/run-make-fulldeps/static-nobundle/bbb.rs +++ /dev/null @@ -1,13 +0,0 @@ -#![crate_type = "rlib"] -#![feature(static_nobundle)] - -#[link(name = "aaa", kind = "static-nobundle")] -extern "C" { - pub fn native_func(); -} - -pub fn wrapped_func() { - unsafe { - native_func(); - } -} diff --git a/src/test/run-make-fulldeps/static-nobundle/ccc.rs b/src/test/run-make-fulldeps/static-nobundle/ccc.rs deleted file mode 100644 index a1f875a52d514..0000000000000 --- a/src/test/run-make-fulldeps/static-nobundle/ccc.rs +++ /dev/null @@ -1,13 +0,0 @@ -#![crate_type = "dylib"] - -extern crate bbb; - -pub fn do_work() { - unsafe { bbb::native_func(); } - bbb::wrapped_func(); -} - -pub fn do_work_generic() { - unsafe { bbb::native_func(); } - bbb::wrapped_func(); -} diff --git a/src/test/run-make-fulldeps/static-nobundle/ddd.rs b/src/test/run-make-fulldeps/static-nobundle/ddd.rs deleted file mode 100644 index 50b41211ff02b..0000000000000 --- a/src/test/run-make-fulldeps/static-nobundle/ddd.rs +++ /dev/null @@ -1,7 +0,0 @@ -extern crate ccc; - -fn main() { - ccc::do_work(); - ccc::do_work_generic::(); - ccc::do_work_generic::(); -} diff --git a/src/test/run-make-fulldeps/tools.mk b/src/test/run-make-fulldeps/tools.mk index 9655d09df0f2a..a14f6e3ab95a5 100644 --- a/src/test/run-make-fulldeps/tools.mk +++ b/src/test/run-make-fulldeps/tools.mk @@ -120,7 +120,7 @@ else # So we end up with the following hack: we link use static:-bundle to only # link the parts of libstdc++ that we actually use, which doesn't include # the dependency on the pthreads DLL. - EXTRARSCXXFLAGS := -l static:-bundle=stdc++ -Z unstable-options + EXTRARSCXXFLAGS := -l static:-bundle=stdc++ endif else ifeq ($(UNAME),Darwin) diff --git a/src/test/run-make/native-link-modifier-bundle/Makefile b/src/test/run-make/native-link-modifier-bundle/Makefile new file mode 100644 index 0000000000000..723bb4689fe40 --- /dev/null +++ b/src/test/run-make/native-link-modifier-bundle/Makefile @@ -0,0 +1,29 @@ +# ignore-cross-compile +# ignore-windows-msvc + +-include ../../run-make-fulldeps/tools.mk + +all: $(call NATIVE_STATICLIB,native-staticlib) + # Build a staticlib and a rlib, the `native_func` symbol will be bundled into them + $(RUSTC) bundled.rs --crate-type=staticlib --crate-type=rlib + nm $(TMPDIR)/libbundled.a | $(CGREP) -e "T _*native_func" + nm $(TMPDIR)/libbundled.a | $(CGREP) -e "U _*native_func" + nm $(TMPDIR)/libbundled.rlib | $(CGREP) -e "T _*native_func" + nm $(TMPDIR)/libbundled.rlib | $(CGREP) -e "U _*native_func" + + # Build a staticlib and a rlib, the `native_func` symbol will not be bundled into it + $(RUSTC) non-bundled.rs --crate-type=staticlib --crate-type=rlib + nm $(TMPDIR)/libnon_bundled.a | $(CGREP) -ve "T _*native_func" + nm $(TMPDIR)/libnon_bundled.a | $(CGREP) -e "U _*native_func" + nm $(TMPDIR)/libnon_bundled.rlib | $(CGREP) -ve "T _*native_func" + nm $(TMPDIR)/libnon_bundled.rlib | $(CGREP) -e "U _*native_func" + + # Build a cdylib, `native-staticlib` will not appear on the linker line because it was bundled previously + # The cdylib will contain the `native_func` symbol in the end + $(RUSTC) cdylib-bundled.rs --crate-type=cdylib --print link-args | $(CGREP) -ve '-l[" ]*native-staticlib' + nm $(call DYLIB,cdylib_bundled) | $(CGREP) -e "[Tt] _*native_func" + + # Build a cdylib, `native-staticlib` will appear on the linker line because it was not bundled previously + # The cdylib will contain the `native_func` symbol in the end + $(RUSTC) cdylib-non-bundled.rs --crate-type=cdylib --print link-args | $(CGREP) -e '-l[" ]*native-staticlib' + nm $(call DYLIB,cdylib_non_bundled) | $(CGREP) -e "[Tt] _*native_func" diff --git a/src/test/run-make/native-link-modifier-bundle/bundled.rs b/src/test/run-make/native-link-modifier-bundle/bundled.rs new file mode 100644 index 0000000000000..0bbae8752d7b3 --- /dev/null +++ b/src/test/run-make/native-link-modifier-bundle/bundled.rs @@ -0,0 +1,11 @@ +#[link(name = "native-staticlib", kind = "static", modifiers = "+bundle")] +extern "C" { + pub fn native_func(); +} + +#[no_mangle] +pub extern "C" fn wrapped_func() { + unsafe { + native_func(); + } +} diff --git a/src/test/run-make/native-link-modifier-bundle/cdylib-bundled.rs b/src/test/run-make/native-link-modifier-bundle/cdylib-bundled.rs new file mode 100644 index 0000000000000..7291309168a48 --- /dev/null +++ b/src/test/run-make/native-link-modifier-bundle/cdylib-bundled.rs @@ -0,0 +1 @@ +extern crate bundled; diff --git a/src/test/run-make/native-link-modifier-bundle/cdylib-non-bundled.rs b/src/test/run-make/native-link-modifier-bundle/cdylib-non-bundled.rs new file mode 100644 index 0000000000000..1df81fd101f75 --- /dev/null +++ b/src/test/run-make/native-link-modifier-bundle/cdylib-non-bundled.rs @@ -0,0 +1 @@ +extern crate non_bundled; diff --git a/src/test/run-make-fulldeps/static-nobundle/aaa.c b/src/test/run-make/native-link-modifier-bundle/native-staticlib.c similarity index 100% rename from src/test/run-make-fulldeps/static-nobundle/aaa.c rename to src/test/run-make/native-link-modifier-bundle/native-staticlib.c diff --git a/src/test/run-make/native-link-modifier-bundle/non-bundled.rs b/src/test/run-make/native-link-modifier-bundle/non-bundled.rs new file mode 100644 index 0000000000000..8181e6387c5c7 --- /dev/null +++ b/src/test/run-make/native-link-modifier-bundle/non-bundled.rs @@ -0,0 +1,11 @@ +#[link(name = "native-staticlib", kind = "static", modifiers = "-bundle")] +extern "C" { + pub fn native_func(); +} + +#[no_mangle] +pub extern "C" fn wrapped_func() { + unsafe { + native_func(); + } +} diff --git a/src/test/run-make/native-link-modifier-whole-archive/Makefile b/src/test/run-make/native-link-modifier-whole-archive/Makefile index 799b5f6f5fc6f..3b49d1188ae6b 100644 --- a/src/test/run-make/native-link-modifier-whole-archive/Makefile +++ b/src/test/run-make/native-link-modifier-whole-archive/Makefile @@ -17,7 +17,7 @@ all: $(TMPDIR)/$(call BIN,directly_linked) $(TMPDIR)/$(call BIN,indirectly_linke # Native lib linked directly into executable $(TMPDIR)/$(call BIN,directly_linked): $(call NATIVE_STATICLIB,c_static_lib_with_constructor) - $(RUSTC) directly_linked.rs -Z unstable-options -l static:+whole-archive=c_static_lib_with_constructor + $(RUSTC) directly_linked.rs -l static:+whole-archive=c_static_lib_with_constructor # Native lib linked into RLIB via `-l static:-bundle,+whole-archive`, RLIB linked into executable $(TMPDIR)/$(call BIN,indirectly_linked): $(TMPDIR)/librlib_with_cmdline_native_lib.rlib @@ -29,7 +29,7 @@ $(TMPDIR)/$(call BIN,indirectly_linked_via_attr): $(TMPDIR)/libnative_lib_in_src # Native lib linked into rlib with via commandline $(TMPDIR)/librlib_with_cmdline_native_lib.rlib: $(call NATIVE_STATICLIB,c_static_lib_with_constructor) - $(RUSTC) rlib_with_cmdline_native_lib.rs -Z unstable-options --crate-type=rlib -l static:-bundle,+whole-archive=c_static_lib_with_constructor + $(RUSTC) rlib_with_cmdline_native_lib.rs --crate-type=rlib -l static:-bundle,+whole-archive=c_static_lib_with_constructor # Native lib linked into rlib via `#[link()]` attribute on extern block. $(TMPDIR)/libnative_lib_in_src.rlib: $(call NATIVE_STATICLIB,c_static_lib_with_constructor) diff --git a/src/test/run-make/native-link-modifier-whole-archive/native_lib_in_src.rs b/src/test/run-make/native-link-modifier-whole-archive/native_lib_in_src.rs index 2436c36e6ebfb..971f3be7a61e9 100644 --- a/src/test/run-make/native-link-modifier-whole-archive/native_lib_in_src.rs +++ b/src/test/run-make/native-link-modifier-whole-archive/native_lib_in_src.rs @@ -1,5 +1,3 @@ -#![feature(native_link_modifiers_bundle)] - use std::io::Write; #[link(name = "c_static_lib_with_constructor", diff --git a/src/test/ui/feature-gates/feature-gate-native_link_modifiers_bundle-2.rs b/src/test/ui/feature-gates/feature-gate-native_link_modifiers_bundle-2.rs deleted file mode 100644 index e229564950fcf..0000000000000 --- a/src/test/ui/feature-gates/feature-gate-native_link_modifiers_bundle-2.rs +++ /dev/null @@ -1,9 +0,0 @@ -// Test native_link_modifiers_bundle don't need static-nobundle -// check-pass - -#![feature(native_link_modifiers_bundle)] - -#[link(name = "foo", kind = "static", modifiers = "-bundle")] -extern "C" {} - -fn main() {} diff --git a/src/test/ui/feature-gates/feature-gate-native_link_modifiers_bundle-3.rs b/src/test/ui/feature-gates/feature-gate-native_link_modifiers_bundle-3.rs deleted file mode 100644 index 3da943ee4a963..0000000000000 --- a/src/test/ui/feature-gates/feature-gate-native_link_modifiers_bundle-3.rs +++ /dev/null @@ -1,3 +0,0 @@ -// compile-flags: -l static:-bundle=nonexistent - -fn main() {} diff --git a/src/test/ui/feature-gates/feature-gate-native_link_modifiers_bundle-3.stderr b/src/test/ui/feature-gates/feature-gate-native_link_modifiers_bundle-3.stderr deleted file mode 100644 index 743bcc9a1b381..0000000000000 --- a/src/test/ui/feature-gates/feature-gate-native_link_modifiers_bundle-3.stderr +++ /dev/null @@ -1,2 +0,0 @@ -error: linking modifier `bundle` is unstable and only accepted on the nightly compiler - diff --git a/src/test/ui/feature-gates/feature-gate-native_link_modifiers_bundle.rs b/src/test/ui/feature-gates/feature-gate-native_link_modifiers_bundle.rs deleted file mode 100644 index c1d5a31aaa4df..0000000000000 --- a/src/test/ui/feature-gates/feature-gate-native_link_modifiers_bundle.rs +++ /dev/null @@ -1,5 +0,0 @@ -#[link(name = "foo", kind = "static", modifiers = "+bundle")] -//~^ ERROR: linking modifier `bundle` is unstable -extern "C" {} - -fn main() {} diff --git a/src/test/ui/feature-gates/feature-gate-native_link_modifiers_bundle.stderr b/src/test/ui/feature-gates/feature-gate-native_link_modifiers_bundle.stderr deleted file mode 100644 index dcaa7fcc64f02..0000000000000 --- a/src/test/ui/feature-gates/feature-gate-native_link_modifiers_bundle.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0658]: linking modifier `bundle` is unstable - --> $DIR/feature-gate-native_link_modifiers_bundle.rs:1:51 - | -LL | #[link(name = "foo", kind = "static", modifiers = "+bundle")] - | ^^^^^^^^^ - | - = note: see issue #81490 for more information - = help: add `#![feature(native_link_modifiers_bundle)]` to the crate attributes to enable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/feature-gates/feature-gate-static-nobundle-2.rs b/src/test/ui/feature-gates/feature-gate-static-nobundle-2.rs deleted file mode 100644 index ad0662b6892d2..0000000000000 --- a/src/test/ui/feature-gates/feature-gate-static-nobundle-2.rs +++ /dev/null @@ -1,4 +0,0 @@ -// check-pass -// compile-flags: -l static-nobundle=nonexistent - -fn main() {} diff --git a/src/test/ui/feature-gates/feature-gate-static-nobundle-2.stderr b/src/test/ui/feature-gates/feature-gate-static-nobundle-2.stderr deleted file mode 100644 index 782d9e3945615..0000000000000 --- a/src/test/ui/feature-gates/feature-gate-static-nobundle-2.stderr +++ /dev/null @@ -1,2 +0,0 @@ -warning: library kind `static-nobundle` has been superseded by specifying modifier `-bundle` with library kind `static`. Try `static:-bundle` - diff --git a/src/test/ui/feature-gates/feature-gate-static-nobundle.rs b/src/test/ui/feature-gates/feature-gate-static-nobundle.rs deleted file mode 100644 index 50f1b7ff3fc48..0000000000000 --- a/src/test/ui/feature-gates/feature-gate-static-nobundle.rs +++ /dev/null @@ -1,6 +0,0 @@ -#[link(name = "foo", kind = "static-nobundle")] -//~^ WARNING: link kind `static-nobundle` has been superseded by specifying modifier `-bundle` with link kind `static` -//~^^ ERROR: link kind `static-nobundle` is unstable -extern "C" {} - -fn main() {} diff --git a/src/test/ui/feature-gates/feature-gate-static-nobundle.stderr b/src/test/ui/feature-gates/feature-gate-static-nobundle.stderr deleted file mode 100644 index 094661aeb57af..0000000000000 --- a/src/test/ui/feature-gates/feature-gate-static-nobundle.stderr +++ /dev/null @@ -1,18 +0,0 @@ -warning: link kind `static-nobundle` has been superseded by specifying modifier `-bundle` with link kind `static` - --> $DIR/feature-gate-static-nobundle.rs:1:29 - | -LL | #[link(name = "foo", kind = "static-nobundle")] - | ^^^^^^^^^^^^^^^^^ - -error[E0658]: link kind `static-nobundle` is unstable - --> $DIR/feature-gate-static-nobundle.rs:1:29 - | -LL | #[link(name = "foo", kind = "static-nobundle")] - | ^^^^^^^^^^^^^^^^^ - | - = note: see issue #37403 for more information - = help: add `#![feature(static_nobundle)]` to the crate attributes to enable - -error: aborting due to previous error; 1 warning emitted - -For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/hrtb/hrtb-just-for-static.rs b/src/test/ui/hrtb/hrtb-just-for-static.rs index ffafdce2a6c83..8fb4218f8a409 100644 --- a/src/test/ui/hrtb/hrtb-just-for-static.rs +++ b/src/test/ui/hrtb/hrtb-just-for-static.rs @@ -24,7 +24,7 @@ fn give_static() { want_hrtb::() //~ ERROR } -// AnyInt implements Foo<&'a isize> for any 'a, so it is a match. +// &'a u32 only implements Foo<&'a isize> for specific 'a, so it is an error. impl<'a> Foo<&'a isize> for &'a u32 { } fn give_some<'a>() { want_hrtb::<&'a u32>() diff --git a/src/test/ui/lint/rfc-2383-lint-reason/avoid_delayed_good_path_ice.rs b/src/test/ui/lint/rfc-2383-lint-reason/avoid_delayed_good_path_ice.rs new file mode 100644 index 0000000000000..912e831d88a7d --- /dev/null +++ b/src/test/ui/lint/rfc-2383-lint-reason/avoid_delayed_good_path_ice.rs @@ -0,0 +1,8 @@ +// check-pass +#![feature(lint_reasons)] + +#[expect(drop_bounds)] +fn trigger_rustc_lints() { +} + +fn main() {} diff --git a/src/test/ui/native-library-link-flags/mix-bundle-and-whole-archive-link-attr.rs b/src/test/ui/native-library-link-flags/mix-bundle-and-whole-archive-link-attr.rs index b153ef94626a3..066048795c8a2 100644 --- a/src/test/ui/native-library-link-flags/mix-bundle-and-whole-archive-link-attr.rs +++ b/src/test/ui/native-library-link-flags/mix-bundle-and-whole-archive-link-attr.rs @@ -2,8 +2,6 @@ // build-fail // error-pattern: the linking modifiers `+bundle` and `+whole-archive` are not compatible with each other when generating rlibs -#![feature(native_link_modifiers_bundle)] - #[link(name = "mylib", kind = "static", modifiers = "+bundle,+whole-archive")] extern "C" { } diff --git a/src/test/ui/native-library-link-flags/modifiers-override.rs b/src/test/ui/native-library-link-flags/modifiers-override.rs index 3912ac9f13d6c..42cdb5004adcb 100644 --- a/src/test/ui/native-library-link-flags/modifiers-override.rs +++ b/src/test/ui/native-library-link-flags/modifiers-override.rs @@ -1,7 +1,5 @@ // compile-flags:-ldylib:+as-needed=foo -lstatic=bar -Zunstable-options -#![feature(native_link_modifiers_bundle)] - #[link(name = "foo")] #[link( name = "bar", diff --git a/src/test/ui/native-library-link-flags/modifiers-override.stderr b/src/test/ui/native-library-link-flags/modifiers-override.stderr index 55362910e71c6..eb3ab55c31044 100644 --- a/src/test/ui/native-library-link-flags/modifiers-override.stderr +++ b/src/test/ui/native-library-link-flags/modifiers-override.stderr @@ -1,23 +1,23 @@ error: multiple `modifiers` arguments in a single `#[link]` attribute - --> $DIR/modifiers-override.rs:11:5 + --> $DIR/modifiers-override.rs:9:5 | LL | modifiers = "+bundle" | ^^^^^^^^^^^^^^^^^^^^^ error: multiple `whole-archive` modifiers in a single `modifiers` argument - --> $DIR/modifiers-override.rs:9:17 + --> $DIR/modifiers-override.rs:7:17 | LL | modifiers = "+whole-archive,-whole-archive", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: overriding linking modifiers from command line is not supported - --> $DIR/modifiers-override.rs:14:1 + --> $DIR/modifiers-override.rs:12:1 | LL | extern "C" {} | ^^^^^^^^^^^^^ error: overriding linking modifiers from command line is not supported - --> $DIR/modifiers-override.rs:14:1 + --> $DIR/modifiers-override.rs:12:1 | LL | extern "C" {} | ^^^^^^^^^^^^^