diff --git a/src/doc/rustc/src/codegen-options/index.md b/src/doc/rustc/src/codegen-options/index.md
index 70c7acccd3638..0dc81378e05b2 100644
--- a/src/doc/rustc/src/codegen-options/index.md
+++ b/src/doc/rustc/src/codegen-options/index.md
@@ -197,7 +197,11 @@ in software.
## prefer-dynamic
By default, `rustc` prefers to statically link dependencies. This option will
-make it use dynamic linking instead.
+indicate that dynamic linking should be used if possible if both a static and
+dynamic versions of a library are available. There is an internal algorithm
+for determining whether or not it is possible to statically or dynamically
+link with a dependency. For example, `cdylib` crate types may only use static
+linkage.
## no-integrated-as
diff --git a/src/doc/rustc/src/command-line-arguments.md b/src/doc/rustc/src/command-line-arguments.md
index 79b4f7542f9b0..ee04a769e123e 100644
--- a/src/doc/rustc/src/command-line-arguments.md
+++ b/src/doc/rustc/src/command-line-arguments.md
@@ -20,9 +20,9 @@ to `#[cfg(verbose)]` and `#[cfg(feature = "serde")]` respectively.
## `-L`: add a directory to the library search path
+
-When looking for external crates or libraries, a directory passed to this flag
-will be searched.
+The `-L` flag adds a path to search for external crates and libraries.
The kind of search path can optionally be specified with the form `-L
KIND=PATH` where `KIND` may be one of:
@@ -262,9 +262,30 @@ This flag, when combined with other flags, makes them produce extra output.
## `--extern`: specify where an external library is located
-This flag allows you to pass the name and location of an external crate that
-will be linked into the crate you are building. This flag may be specified
-multiple times. The format of the value should be `CRATENAME=PATH`.
+This flag allows you to pass the name and location for an external crate of a
+direct dependency. Indirect dependencies (dependencies of dependencies) are
+located using the [`-L` flag](#option-l-search-path). The given crate name is
+added to the [extern prelude], which is the same as specifying `extern crate`
+within the root module. The given crate name does not need to match the name
+the library was built with.
+
+This flag may be specified multiple times. This flag takes an argument with
+either of the following formats:
+
+* `CRATENAME=PATH` — Indicates the given crate is found at the given path.
+* `CRATENAME` — Indicates the given crate may be found in the search path,
+ such as within the sysroot or via the `-L` flag.
+
+The same crate name may be specified multiple times for different crate types.
+If both an `rlib` and `dylib` are found, an internal algorithm is used to
+decide which to use for linking. The [`-C prefer-dynamic`
+flag][prefer-dynamic] may be used to influence which is used.
+
+If the same crate name is specified with and without a path, the one with the
+path is used and the pathless flag has no effect.
+
+[extern prelude]: ../reference/items/extern-crates.html#extern-prelude
+[prefer-dynamic]: codegen-options/index.md#prefer-dynamic
## `--sysroot`: Override the system root
diff --git a/src/libcore/mem/maybe_uninit.rs b/src/libcore/mem/maybe_uninit.rs
index 03093139bc2f9..0c0a6d8a121b8 100644
--- a/src/libcore/mem/maybe_uninit.rs
+++ b/src/libcore/mem/maybe_uninit.rs
@@ -258,6 +258,43 @@ impl MaybeUninit {
MaybeUninit { uninit: () }
}
+ /// Create a new array of `MaybeUninit` items, in an uninitialized state.
+ ///
+ /// Note: in a future Rust version this method may become unnecessary
+ /// when array literal syntax allows
+ /// [repeating const expressions](https://github.com/rust-lang/rust/issues/49147).
+ /// The example below could then use `let mut buf = [MaybeUninit::::uninit(); 32];`.
+ ///
+ /// # Examples
+ ///
+ /// ```no_run
+ /// #![feature(maybe_uninit_uninit_array, maybe_uninit_extra, maybe_uninit_slice_assume_init)]
+ ///
+ /// use std::mem::MaybeUninit;
+ ///
+ /// extern "C" {
+ /// fn read_into_buffer(ptr: *mut u8, max_len: usize) -> usize;
+ /// }
+ ///
+ /// /// Returns a (possibly smaller) slice of data that was actually read
+ /// fn read(buf: &mut [MaybeUninit]) -> &[u8] {
+ /// unsafe {
+ /// let len = read_into_buffer(buf.as_mut_ptr() as *mut u8, buf.len());
+ /// MaybeUninit::slice_get_ref(&buf[..len])
+ /// }
+ /// }
+ ///
+ /// let mut buf: [MaybeUninit; 32] = MaybeUninit::uninit_array();
+ /// let data = read(&mut buf);
+ /// ```
+ #[unstable(feature = "maybe_uninit_uninit_array", issue = "0")]
+ #[inline(always)]
+ pub fn uninit_array() -> [Self; LEN] {
+ unsafe {
+ MaybeUninit::<[MaybeUninit; LEN]>::uninit().assume_init()
+ }
+ }
+
/// A promotable constant, equivalent to `uninit()`.
#[unstable(feature = "internal_uninit_const", issue = "0",
reason = "hack to work around promotability")]
@@ -690,6 +727,32 @@ impl MaybeUninit {
&mut *self.value
}
+ /// Assuming all the elements are initialized, get a slice to them.
+ ///
+ /// # Safety
+ ///
+ /// It is up to the caller to guarantee that the `MaybeUninit` elements
+ /// really are in an initialized state.
+ /// Calling this when the content is not yet fully initialized causes undefined behavior.
+ #[unstable(feature = "maybe_uninit_slice_assume_init", issue = "0")]
+ #[inline(always)]
+ pub unsafe fn slice_get_ref(slice: &[Self]) -> &[T] {
+ &*(slice as *const [Self] as *const [T])
+ }
+
+ /// Assuming all the elements are initialized, get a mutable slice to them.
+ ///
+ /// # Safety
+ ///
+ /// It is up to the caller to guarantee that the `MaybeUninit` elements
+ /// really are in an initialized state.
+ /// Calling this when the content is not yet fully initialized causes undefined behavior.
+ #[unstable(feature = "maybe_uninit_slice_assume_init", issue = "0")]
+ #[inline(always)]
+ pub unsafe fn slice_get_mut(slice: &mut [Self]) -> &mut [T] {
+ &mut *(slice as *mut [Self] as *mut [T])
+ }
+
/// Gets a pointer to the first element of the array.
#[unstable(feature = "maybe_uninit_slice", issue = "63569")]
#[inline(always)]
diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs
index 2bcddeaf1962d..eb5654e80a82c 100644
--- a/src/librustc/session/config.rs
+++ b/src/librustc/session/config.rs
@@ -1800,7 +1800,7 @@ pub fn rustc_optgroups() -> Vec {
"",
"extern",
"Specify where an external rust library is located",
- "NAME=PATH",
+ "NAME[=PATH]",
),
opt::multi_s(
"",
@@ -2164,7 +2164,6 @@ fn collect_print_requests(
cg: &mut CodegenOptions,
dopts: &mut DebuggingOptions,
matches: &getopts::Matches,
- is_unstable_enabled: bool,
error_format: ErrorOutputType,
) -> Vec {
let mut prints = Vec::::new();
@@ -2206,7 +2205,7 @@ fn collect_print_requests(
"tls-models" => PrintRequest::TlsModels,
"native-static-libs" => PrintRequest::NativeStaticLibs,
"target-spec-json" => {
- if is_unstable_enabled {
+ if dopts.unstable_options {
PrintRequest::TargetSpec
} else {
early_error(
@@ -2370,7 +2369,6 @@ fn parse_externs(
matches: &getopts::Matches,
debugging_opts: &DebuggingOptions,
error_format: ErrorOutputType,
- is_unstable_enabled: bool,
) -> Externs {
if matches.opt_present("extern-private") && !debugging_opts.unstable_options {
early_error(
@@ -2392,13 +2390,6 @@ fn parse_externs(
let name = parts.next().unwrap_or_else(||
early_error(error_format, "--extern value must not be empty"));
let location = parts.next().map(|s| s.to_string());
- if location.is_none() && !is_unstable_enabled {
- early_error(
- error_format,
- "the `-Z unstable-options` flag must also be passed to \
- enable `--extern crate_name` without `=path`",
- );
- };
let entry = externs
.entry(name.to_owned())
@@ -2483,12 +2474,10 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
);
}
- let is_unstable_enabled = nightly_options::is_unstable_enabled(matches);
let prints = collect_print_requests(
&mut cg,
&mut debugging_opts,
matches,
- is_unstable_enabled,
error_format,
);
@@ -2521,7 +2510,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
);
}
- let externs = parse_externs(matches, &debugging_opts, error_format, is_unstable_enabled);
+ let externs = parse_externs(matches, &debugging_opts, error_format);
let crate_name = matches.opt_str("crate-name");
diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs
index 867f5f76b59bc..c6fd1256a8e64 100644
--- a/src/librustc_lint/builtin.rs
+++ b/src/librustc_lint/builtin.rs
@@ -2052,7 +2052,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for InvalidValue {
);
err.span_label(expr.span,
"this code causes undefined behavior when executed");
- err.span_label(expr.span, "help: use `MaybeUninit` instead");
+ err.span_label(expr.span, "help: use `MaybeUninit` instead, \
+ and only call `assume_init` after initialization is done");
if let Some(span) = span {
err.span_note(span, &msg);
} else {
diff --git a/src/librustdoc/config.rs b/src/librustdoc/config.rs
index 0b8d4d6c302f1..255d5f9f35dbf 100644
--- a/src/librustdoc/config.rs
+++ b/src/librustdoc/config.rs
@@ -615,10 +615,6 @@ fn parse_externs(matches: &getopts::Matches) -> Result {
let mut parts = arg.splitn(2, '=');
let name = parts.next().ok_or("--extern value must not be empty".to_string())?;
let location = parts.next().map(|s| s.to_string());
- if location.is_none() && !nightly_options::is_unstable_enabled(matches) {
- return Err("the `-Z unstable-options` flag must also be passed to \
- enable `--extern crate_name` without `=path`".to_string());
- }
let name = name.to_string();
// For Rustdoc purposes, we can treat all externs as public
externs.entry(name)
diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs
index 29f0b99d8ee69..9a87bcc10db8e 100644
--- a/src/librustdoc/html/render.rs
+++ b/src/librustdoc/html/render.rs
@@ -1230,18 +1230,87 @@ impl AllTypes {
}
}
+#[derive(Debug)]
+enum Setting {
+ Section {
+ description: &'static str,
+ sub_settings: Vec,
+ },
+ Entry {
+ js_data_name: &'static str,
+ description: &'static str,
+ default_value: bool,
+ }
+}
+
+impl Setting {
+ fn display(&self) -> String {
+ match *self {
+ Setting::Section { ref description, ref sub_settings } => {
+ format!(
+ "