Skip to content

Commit 3d845e1

Browse files
committed
Auto merge of #58361 - GuillaumeGomez:rollup, r=GuillaumeGomez
Rollup of 16 pull requests Successful merges: - #57259 (Update reference of rlibc crate to compiler-builtins crate) - #57740 (Use `to_ne_bytes` for converting IPv4Addr to octets) - #57926 (Tiny expansion to docs for `core::convert`.) - #58157 (Add Cargo.lock automatically adding message) - #58203 (rustdoc: display sugared return types for async functions) - #58243 (Add trait alias support in rustdoc) - #58262 (Add #[must_use] message to Fn* traits) - #58295 (std::sys::unix::stdio: explain why we do into_raw) - #58297 (Cleanup JS a bit) - #58317 (Some writing improvement, conciseness of intro) - #58324 (miri: give non-generic functions a stable address) - #58332 (operand-to-place copies should never be overlapping) - #58345 (When there are multiple filenames, print what got interpreted as filenames) - #58346 (rpath computation: explain why we pop()) - #58350 (Fix failing tidy (line endings on Windows)) - #58352 (miri value visitor: use `?` in macro) Failed merges: r? @ghost
2 parents 0b7af26 + d792cef commit 3d845e1

File tree

25 files changed

+306
-102
lines changed

25 files changed

+306
-102
lines changed

Cargo.lock

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# This file is automatically @generated by Cargo.
2+
# It is not intended for manual editing.
13
[[package]]
24
name = "adler32"
35
version = "1.0.3"

src/doc/rustdoc/src/unstable-features.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
# Unstable features
22

33
Rustdoc is under active development, and like the Rust compiler, some features are only available
4-
on the nightly releases. Some of these are new and need some more testing before they're able to get
5-
released to the world at large, and some of them are tied to features in the Rust compiler that are
6-
themselves unstable. Several features here require a matching `#![feature(...)]` attribute to
4+
on nightly releases. Some of these features are new and need some more testing before they're able to be
5+
released to the world at large, and some of them are tied to features in the Rust compiler that are unstable. Several features here require a matching `#![feature(...)]` attribute to
76
enable, and thus are more fully documented in the [Unstable Book]. Those sections will link over
87
there as necessary.
98

@@ -428,4 +427,4 @@ $ rustdoc src/lib.rs --test -Z unstable-options --persist-doctests target/rustdo
428427

429428
This flag allows you to keep doctest executables around after they're compiled or run.
430429
Usually, rustdoc will immediately discard a compiled doctest after it's been tested, but
431-
with this option, you can keep those binaries around for farther testing.
430+
with this option, you can keep those binaries around for farther testing.

src/libcore/convert.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@
1717
//! [`TryFrom<T>`][`TryFrom`] rather than [`Into<U>`][`Into`] or [`TryInto<U>`][`TryInto`],
1818
//! as [`From`] and [`TryFrom`] provide greater flexibility and offer
1919
//! equivalent [`Into`] or [`TryInto`] implementations for free, thanks to a
20-
//! blanket implementation in the standard library.
20+
//! blanket implementation in the standard library. However, there are some cases
21+
//! where this is not possible, such as creating conversions into a type defined
22+
//! outside your library, so implementing [`Into`] instead of [`From`] is
23+
//! sometimes necessary.
2124
//!
2225
//! # Generic Implementations
2326
//!

src/libcore/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
//! often generated by LLVM. Additionally, this library can make explicit
2525
//! calls to these functions. Their signatures are the same as found in C.
2626
//! These functions are often provided by the system libc, but can also be
27-
//! provided by the [rlibc crate](https://crates.io/crates/rlibc).
27+
//! provided by the [compiler-builtins crate](https://crates.io/crates/compiler_builtins).
2828
//!
2929
//! * `rust_begin_panic` - This function takes four arguments, a
3030
//! `fmt::Arguments`, a `&'static str`, and two `u32`'s. These four arguments

src/libcore/ops/function.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
label="expected an `Fn<{Args}>` closure, found `{Self}`",
6363
)]
6464
#[fundamental] // so that regex can rely that `&str: !FnMut`
65-
#[must_use]
65+
#[must_use = "closures are lazy and do nothing unless called"]
6666
pub trait Fn<Args> : FnMut<Args> {
6767
/// Performs the call operation.
6868
#[unstable(feature = "fn_traits", issue = "29625")]
@@ -141,7 +141,7 @@ pub trait Fn<Args> : FnMut<Args> {
141141
label="expected an `FnMut<{Args}>` closure, found `{Self}`",
142142
)]
143143
#[fundamental] // so that regex can rely that `&str: !FnMut`
144-
#[must_use]
144+
#[must_use = "closures are lazy and do nothing unless called"]
145145
pub trait FnMut<Args> : FnOnce<Args> {
146146
/// Performs the call operation.
147147
#[unstable(feature = "fn_traits", issue = "29625")]
@@ -220,7 +220,7 @@ pub trait FnMut<Args> : FnOnce<Args> {
220220
label="expected an `FnOnce<{Args}>` closure, found `{Self}`",
221221
)]
222222
#[fundamental] // so that regex can rely that `&str: !FnMut`
223-
#[must_use]
223+
#[must_use = "closures are lazy and do nothing unless called"]
224224
pub trait FnOnce<Args> {
225225
/// The returned type after the call operator is used.
226226
#[stable(feature = "fn_once_output", since = "1.12.0")]

src/librustc/mir/interpret/mod.rs

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pub use self::pointer::{Pointer, PointerArithmetic};
2727
use std::fmt;
2828
use crate::mir;
2929
use crate::hir::def_id::DefId;
30-
use crate::ty::{self, TyCtxt, Instance};
30+
use crate::ty::{self, TyCtxt, Instance, subst::UnpackedKind};
3131
use crate::ty::layout::{self, Size};
3232
use std::io;
3333
use crate::rustc_serialize::{Encoder, Decodable, Encodable};
@@ -318,14 +318,29 @@ impl<'tcx> AllocMap<'tcx> {
318318
id
319319
}
320320

321-
/// Functions cannot be identified by pointers, as asm-equal functions can get deduplicated
322-
/// by the linker and functions can be duplicated across crates.
323-
/// We thus generate a new `AllocId` for every mention of a function. This means that
324-
/// `main as fn() == main as fn()` is false, while `let x = main as fn(); x == x` is true.
325321
pub fn create_fn_alloc(&mut self, instance: Instance<'tcx>) -> AllocId {
326-
let id = self.reserve();
327-
self.id_to_kind.insert(id, AllocKind::Function(instance));
328-
id
322+
// Functions cannot be identified by pointers, as asm-equal functions can get deduplicated
323+
// by the linker (we set the "unnamed_addr" attribute for LLVM) and functions can be
324+
// duplicated across crates.
325+
// We thus generate a new `AllocId` for every mention of a function. This means that
326+
// `main as fn() == main as fn()` is false, while `let x = main as fn(); x == x` is true.
327+
// However, formatting code relies on function identity (see #58320), so we only do
328+
// this for generic functions. Lifetime parameters are ignored.
329+
let is_generic = instance.substs.into_iter().any(|kind| {
330+
match kind.unpack() {
331+
UnpackedKind::Lifetime(_) => false,
332+
_ => true,
333+
}
334+
});
335+
if is_generic {
336+
// Get a fresh ID
337+
let id = self.reserve();
338+
self.id_to_kind.insert(id, AllocKind::Function(instance));
339+
id
340+
} else {
341+
// Deduplicate
342+
self.intern(AllocKind::Function(instance))
343+
}
329344
}
330345

331346
/// Returns `None` in case the `AllocId` is dangling. An `EvalContext` can still have a

src/librustc_codegen_llvm/back/rpath.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,9 @@ fn get_rpath_relative_to_output(config: &mut RPathConfig, lib: &Path) -> String
101101

102102
let cwd = env::current_dir().unwrap();
103103
let mut lib = fs::canonicalize(&cwd.join(lib)).unwrap_or_else(|_| cwd.join(lib));
104-
lib.pop();
104+
lib.pop(); // strip filename
105105
let mut output = cwd.join(&config.out_filename);
106-
output.pop();
106+
output.pop(); // strip filename
107107
let output = fs::canonicalize(&output).unwrap_or(output);
108108
let relative = path_relative_from(&lib, &output).unwrap_or_else(||
109109
panic!("couldn't create relative path from {:?} to {:?}", output, lib));

src/librustc_driver/lib.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -838,7 +838,15 @@ impl<'a> CompilerCalls<'a> for RustcDefaultCalls {
838838
early_error(sopts.error_format, "no input filename given");
839839
}
840840
1 => panic!("make_input should have provided valid inputs"),
841-
_ => early_error(sopts.error_format, "multiple input filenames provided"),
841+
_ =>
842+
early_error(
843+
sopts.error_format,
844+
&format!(
845+
"multiple input filenames provided (first two filenames are `{}` and `{}`)",
846+
matches.free[0],
847+
matches.free[1],
848+
),
849+
)
842850
}
843851
}
844852

src/librustc_mir/interpret/place.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -823,6 +823,8 @@ where
823823
let src = match self.try_read_immediate(src)? {
824824
Ok(src_val) => {
825825
// Yay, we got a value that we can write directly.
826+
// FIXME: Add a check to make sure that if `src` is indirect,
827+
// it does not overlap with `dest`.
826828
return self.write_immediate_no_validate(src_val, dest);
827829
}
828830
Err(mplace) => mplace,
@@ -836,7 +838,8 @@ where
836838
self.memory.copy(
837839
src_ptr, src_align,
838840
dest_ptr, dest_align,
839-
dest.layout.size, false
841+
dest.layout.size,
842+
/*nonoverlapping*/ true,
840843
)?;
841844

842845
Ok(())

0 commit comments

Comments
 (0)