Skip to content

Commit c7cbe14

Browse files
committed
Auto merge of #48955 - kennytm:rollup, r=kennytm
Rollup of 13 pull requests - Successful merges: #48201, #48705, #48725, #48824, #48877, #48880, #48887, #48928, #48934, #48480, #48631, #48898, #48954 - Failed merges:
2 parents 883e746 + 99d0ac0 commit c7cbe14

33 files changed

+222
-267
lines changed

CODE_OF_CONDUCT.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ A version of this document [can be found online](https://www.rust-lang.org/condu
1111
* Please be kind and courteous. There's no need to be mean or rude.
1212
* Respect that people have differences of opinion and that every design or implementation choice carries a trade-off and numerous costs. There is seldom a right answer.
1313
* Please keep unstructured critique to a minimum. If you have solid ideas you want to experiment with, make a fork and see how it works.
14-
* We will exclude you from interaction if you insult, demean or harass anyone. That is not welcome behaviour. We interpret the term "harassment" as including the definition in the <a href="http://citizencodeofconduct.org/">Citizen Code of Conduct</a>; if you have any lack of clarity about what might be included in that concept, please read their definition. In particular, we don't tolerate behavior that excludes people in socially marginalized groups.
14+
* We will exclude you from interaction if you insult, demean or harass anyone. That is not welcome behavior. We interpret the term "harassment" as including the definition in the <a href="http://citizencodeofconduct.org/">Citizen Code of Conduct</a>; if you have any lack of clarity about what might be included in that concept, please read their definition. In particular, we don't tolerate behavior that excludes people in socially marginalized groups.
1515
* Private harassment is also unacceptable. No matter who you are, if you feel you have been or are being harassed or made uncomfortable by a community member, please contact one of the channel ops or any of the [Rust moderation team][mod_team] immediately. Whether you're a regular contributor or a newcomer, we care about making this community a safe place for you and we've got your back.
16-
* Likewise any spamming, trolling, flaming, baiting or other attention-stealing behaviour is not welcome.
16+
* Likewise any spamming, trolling, flaming, baiting or other attention-stealing behavior is not welcome.
1717

1818
## Moderation
1919

CONTRIBUTING.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ As a reminder, all contributors are expected to follow our [Code of Conduct][coc
2626
## Feature Requests
2727
[feature-requests]: #feature-requests
2828

29-
To request a change to the way that the Rust language works, please open an
30-
issue in the [RFCs repository](https://github.com/rust-lang/rfcs/issues/new)
31-
rather than this one. New features and other significant language changes
32-
must go through the RFC process.
29+
To request a change to the way the Rust language works, please head over
30+
to the [RFCs repository](https://github.com/rust-lang/rfcs) and view the
31+
[README](https://github.com/rust-lang/rfcs/blob/master/README.md)
32+
for instructions.
3333

3434
## Bug Reports
3535
[bug-reports]: #bug-reports

src/liballoc/vec.rs

+14-7
Original file line numberDiff line numberDiff line change
@@ -1212,8 +1212,9 @@ impl<T: Clone> Vec<T> {
12121212
/// difference, with each additional slot filled with `value`.
12131213
/// If `new_len` is less than `len`, the `Vec` is simply truncated.
12141214
///
1215-
/// This method requires `Clone` to clone the passed value. If you'd
1216-
/// rather create a value with `Default` instead, see [`resize_default`].
1215+
/// This method requires [`Clone`] to be able clone the passed value. If
1216+
/// you'd rather create a value with [`Default`] instead, see
1217+
/// [`resize_default`].
12171218
///
12181219
/// # Examples
12191220
///
@@ -1227,6 +1228,8 @@ impl<T: Clone> Vec<T> {
12271228
/// assert_eq!(vec, [1, 2]);
12281229
/// ```
12291230
///
1231+
/// [`Clone`]: ../../std/clone/trait.Clone.html
1232+
/// [`Default`]: ../../std/default/trait.Default.html
12301233
/// [`resize_default`]: #method.resize_default
12311234
#[stable(feature = "vec_resize", since = "1.5.0")]
12321235
pub fn resize(&mut self, new_len: usize, value: T) {
@@ -1244,7 +1247,7 @@ impl<T: Clone> Vec<T> {
12441247
/// Iterates over the slice `other`, clones each element, and then appends
12451248
/// it to this `Vec`. The `other` vector is traversed in-order.
12461249
///
1247-
/// Note that this function is same as `extend` except that it is
1250+
/// Note that this function is same as [`extend`] except that it is
12481251
/// specialized to work with slices instead. If and when Rust gets
12491252
/// specialization this function will likely be deprecated (but still
12501253
/// available).
@@ -1256,6 +1259,8 @@ impl<T: Clone> Vec<T> {
12561259
/// vec.extend_from_slice(&[2, 3, 4]);
12571260
/// assert_eq!(vec, [1, 2, 3, 4]);
12581261
/// ```
1262+
///
1263+
/// [`extend`]: #method.extend
12591264
#[stable(feature = "vec_extend_from_slice", since = "1.6.0")]
12601265
pub fn extend_from_slice(&mut self, other: &[T]) {
12611266
self.spec_extend(other.iter())
@@ -1266,12 +1271,11 @@ impl<T: Default> Vec<T> {
12661271
/// Resizes the `Vec` in-place so that `len` is equal to `new_len`.
12671272
///
12681273
/// If `new_len` is greater than `len`, the `Vec` is extended by the
1269-
/// difference, with each additional slot filled with `Default::default()`.
1274+
/// difference, with each additional slot filled with [`Default::default()`].
12701275
/// If `new_len` is less than `len`, the `Vec` is simply truncated.
12711276
///
1272-
/// This method uses `Default` to create new values on every push. If
1273-
/// you'd rather `Clone` a given value, use [`resize`].
1274-
///
1277+
/// This method uses [`Default`] to create new values on every push. If
1278+
/// you'd rather [`Clone`] a given value, use [`resize`].
12751279
///
12761280
/// # Examples
12771281
///
@@ -1288,6 +1292,9 @@ impl<T: Default> Vec<T> {
12881292
/// ```
12891293
///
12901294
/// [`resize`]: #method.resize
1295+
/// [`Default::default()`]: ../../std/default/trait.Default.html#tymethod.default
1296+
/// [`Default`]: ../../std/default/trait.Default.html
1297+
/// [`Clone`]: ../../std/clone/trait.Clone.html
12911298
#[unstable(feature = "vec_resize_default", issue = "41758")]
12921299
pub fn resize_default(&mut self, new_len: usize) {
12931300
let len = self.len();

src/libcore/cell.rs

+36-15
Original file line numberDiff line numberDiff line change
@@ -1203,21 +1203,42 @@ impl<'a, T: ?Sized + fmt::Display> fmt::Display for RefMut<'a, T> {
12031203
/// The `UnsafeCell<T>` type is the only legal way to obtain aliasable data that is considered
12041204
/// mutable. In general, transmuting an `&T` type into an `&mut T` is considered undefined behavior.
12051205
///
1206-
/// The compiler makes optimizations based on the knowledge that `&T` is not mutably aliased or
1207-
/// mutated, and that `&mut T` is unique. When building abstractions like `Cell`, `RefCell`,
1208-
/// `Mutex`, etc, you need to turn these optimizations off. `UnsafeCell` is the only legal way
1209-
/// to do this. When `UnsafeCell<T>` is immutably aliased, it is still safe to obtain a mutable
1210-
/// reference to its interior and/or to mutate it. However, it is up to the abstraction designer
1211-
/// to ensure that no two mutable references obtained this way are active at the same time, and
1212-
/// that there are no active mutable references or mutations when an immutable reference is obtained
1213-
/// from the cell. This is often done via runtime checks.
1206+
/// If you have a reference `&SomeStruct`, then normally in Rust all fields of `SomeStruct` are
1207+
/// immutable. The compiler makes optimizations based on the knowledge that `&T` is not mutably
1208+
/// aliased or mutated, and that `&mut T` is unique. `UnsafeCel<T>` is the only core language
1209+
/// feature to work around this restriction. All other types that allow internal mutability, such as
1210+
/// `Cell<T>` and `RefCell<T>` use `UnsafeCell` to wrap their internal data.
12141211
///
1215-
/// Note that while mutating or mutably aliasing the contents of an `& UnsafeCell<T>` is
1216-
/// okay (provided you enforce the invariants some other way); it is still undefined behavior
1217-
/// to have multiple `&mut UnsafeCell<T>` aliases.
1212+
/// The `UnsafeCell` API itself is technically very simple: it gives you a raw pointer `*mut T` to
1213+
/// its contents. It is up to _you_ as the abstraction designer to use that raw pointer correctly.
1214+
///
1215+
/// The precise Rust aliasing rules are somewhat in flux, but the main points are not contentious:
1216+
///
1217+
/// - If you create a safe reference with lifetime `'a` (either a `&T` or `&mut T` reference) that
1218+
/// is accessible by safe code (for example, because you returned it), then you must not access
1219+
/// the data in any way that contradicts that reference for the remainder of `'a`. For example, that
1220+
/// means that if you take the `*mut T` from an `UnsafeCell<T>` and case it to an `&T`, then until
1221+
/// that reference's lifetime expires, the data in `T` must remain immutable (modulo any
1222+
/// `UnsafeCell` data found within `T`, of course). Similarly, if you create an `&mut T` reference
1223+
/// that is released to safe code, then you must not access the data within the `UnsafeCell` until
1224+
/// that reference expires.
1225+
///
1226+
/// - At all times, you must avoid data races, meaning that if multiple threads have access to
1227+
/// the same `UnsafeCell`, then any writes must have a proper happens-before relation to all other
1228+
/// accesses (or use atomics).
12181229
///
1230+
/// To assist with proper design, the following scenarios are explicitly declared legal
1231+
/// for single-threaded code:
12191232
///
1220-
/// Types like `Cell<T>` and `RefCell<T>` use this type to wrap their internal data.
1233+
/// 1. A `&T` reference can be released to safe code and there it can co-exit with other `&T`
1234+
/// references, but not with a `&mut T`
1235+
///
1236+
/// 2. A `&mut T` reference may be released to safe code, provided neither other `&mut T` nor `&T`
1237+
/// co-exist with it. A `&mut T` must always be unique.
1238+
///
1239+
/// Note that while mutating or mutably aliasing the contents of an `& UnsafeCell<T>` is
1240+
/// okay (provided you enforce the invariants some other way), it is still undefined behavior
1241+
/// to have multiple `&mut UnsafeCell<T>` aliases.
12211242
///
12221243
/// # Examples
12231244
///
@@ -1282,9 +1303,9 @@ impl<T: ?Sized> UnsafeCell<T> {
12821303
/// Gets a mutable pointer to the wrapped value.
12831304
///
12841305
/// This can be cast to a pointer of any kind.
1285-
/// Ensure that the access is unique when casting to
1286-
/// `&mut T`, and ensure that there are no mutations or mutable
1287-
/// aliases going on when casting to `&T`
1306+
/// Ensure that the access is unique (no active references, mutable or not)
1307+
/// when casting to `&mut T`, and ensure that there are no mutations
1308+
/// or mutable aliases going on when casting to `&T`
12881309
///
12891310
/// # Examples
12901311
///

src/libcore/fmt/mod.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -684,18 +684,16 @@ pub trait Octal {
684684
///
685685
/// The `Binary` trait should format its output as a number in binary.
686686
///
687-
/// For primitive signed integers (`i8` to `i128`, and `isize`),
687+
/// For primitive signed integers ([`i8`] to [`i128`], and [`isize`]),
688688
/// negative values are formatted as the two’s complement representation.
689689
///
690690
/// The alternate flag, `#`, adds a `0b` in front of the output.
691691
///
692692
/// For more information on formatters, see [the module-level documentation][module].
693693
///
694-
/// [module]: ../../std/fmt/index.html
695-
///
696694
/// # Examples
697695
///
698-
/// Basic usage with `i32`:
696+
/// Basic usage with [`i32`]:
699697
///
700698
/// ```
701699
/// let x = 42; // 42 is '101010' in binary
@@ -725,6 +723,12 @@ pub trait Octal {
725723
///
726724
/// println!("l as binary is: {:b}", l);
727725
/// ```
726+
///
727+
/// [module]: ../../std/fmt/index.html
728+
/// [`i8`]: ../../std/primitive.i8.html
729+
/// [`i128`]: ../../std/primitive.i128.html
730+
/// [`isize`]: ../../std/primitive.isize.html
731+
/// [`i32`]: ../../std/primitive.i32.html
728732
#[stable(feature = "rust1", since = "1.0.0")]
729733
pub trait Binary {
730734
/// Formats the value using the given formatter.

src/libcore/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,9 @@
7474
#![feature(concat_idents)]
7575
#![feature(const_fn)]
7676
#![feature(custom_attribute)]
77+
#![feature(doc_cfg)]
7778
#![feature(doc_spotlight)]
79+
#![feature(fn_must_use)]
7880
#![feature(fundamental)]
7981
#![feature(i128_type)]
8082
#![feature(inclusive_range_syntax)]

src/librustc_back/target/l4re_base.rs

+16-55
Original file line numberDiff line numberDiff line change
@@ -8,74 +8,35 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use PanicStrategy;
1211
use LinkerFlavor;
12+
use PanicStrategy;
1313
use target::{LinkArgs, TargetOptions};
1414
use std::default::Default;
15-
use std::env;
16-
use std::process::Command;
15+
//use std::process::Command;
1716

1817
// Use GCC to locate code for crt* libraries from the host, not from L4Re. Note
1918
// that a few files also come from L4Re, for these, the function shouldn't be
2019
// used. This uses GCC for the location of the file, but GCC is required for L4Re anyway.
21-
fn get_path_or(filename: &str) -> String {
22-
let child = Command::new("gcc")
23-
.arg(format!("-print-file-name={}", filename)).output()
24-
.expect("Failed to execute GCC");
25-
String::from_utf8(child.stdout)
26-
.expect("Couldn't read path from GCC").trim().into()
27-
}
20+
//fn get_path_or(filename: &str) -> String {
21+
// let child = Command::new("gcc")
22+
// .arg(format!("-print-file-name={}", filename)).output()
23+
// .expect("Failed to execute GCC");
24+
// String::from_utf8(child.stdout)
25+
// .expect("Couldn't read path from GCC").trim().into()
26+
//}
2827

29-
pub fn opts() -> Result<TargetOptions, String> {
30-
let l4re_lib_path = env::var_os("L4RE_LIBDIR").ok_or("Unable to find L4Re \
31-
library directory: L4RE_LIBDIR not set.")?.into_string().unwrap();
32-
let mut pre_link_args = LinkArgs::new();
33-
pre_link_args.insert(LinkerFlavor::Ld, vec![
34-
format!("-T{}/main_stat.ld", l4re_lib_path),
35-
"--defsym=__executable_start=0x01000000".to_string(),
36-
"--defsym=__L4_KIP_ADDR__=0x6ffff000".to_string(),
37-
format!("{}/crt1.o", l4re_lib_path),
38-
format!("{}/crti.o", l4re_lib_path),
39-
get_path_or("crtbeginT.o"),
40-
]);
41-
let mut post_link_args = LinkArgs::new();
42-
post_link_args.insert(LinkerFlavor::Ld, vec![
43-
format!("{}/l4f/libpthread.a", l4re_lib_path),
44-
format!("{}/l4f/libc_be_sig.a", l4re_lib_path),
45-
format!("{}/l4f/libc_be_sig_noop.a", l4re_lib_path),
46-
format!("{}/l4f/libc_be_socket_noop.a", l4re_lib_path),
47-
format!("{}/l4f/libc_be_fs_noop.a", l4re_lib_path),
48-
format!("{}/l4f/libc_be_sem_noop.a", l4re_lib_path),
49-
format!("{}/l4f/libl4re-vfs.o.a", l4re_lib_path),
50-
format!("{}/l4f/lib4re.a", l4re_lib_path),
51-
format!("{}/l4f/lib4re-util.a", l4re_lib_path),
52-
format!("{}/l4f/libc_support_misc.a", l4re_lib_path),
53-
format!("{}/l4f/libsupc++.a", l4re_lib_path),
54-
format!("{}/l4f/lib4shmc.a", l4re_lib_path),
55-
format!("{}/l4f/lib4re-c.a", l4re_lib_path),
56-
format!("{}/l4f/lib4re-c-util.a", l4re_lib_path),
57-
get_path_or("libgcc_eh.a"),
58-
format!("{}/l4f/libdl.a", l4re_lib_path),
59-
"--start-group".to_string(),
60-
format!("{}/l4f/libl4util.a", l4re_lib_path),
61-
format!("{}/l4f/libc_be_l4re.a", l4re_lib_path),
62-
format!("{}/l4f/libuc_c.a", l4re_lib_path),
63-
format!("{}/l4f/libc_be_l4refile.a", l4re_lib_path),
64-
"--end-group".to_string(),
65-
format!("{}/l4f/libl4sys.a", l4re_lib_path),
66-
"-gc-sections".to_string(),
67-
get_path_or("crtend.o"),
68-
format!("{}/crtn.o", l4re_lib_path),
69-
]);
28+
pub fn opts() -> TargetOptions {
29+
let mut args = LinkArgs::new();
30+
args.insert(LinkerFlavor::Gcc, vec![]);
7031

71-
Ok(TargetOptions {
32+
TargetOptions {
7233
executables: true,
7334
has_elf_tls: false,
7435
exe_allocation_crate: None,
7536
panic_strategy: PanicStrategy::Abort,
76-
pre_link_args,
77-
post_link_args,
37+
linker: Some("ld".to_string()),
38+
pre_link_args: args,
7839
target_family: Some("unix".to_string()),
7940
.. Default::default()
80-
})
41+
}
8142
}

src/librustc_back/target/x86_64_unknown_l4re_uclibc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use LinkerFlavor;
1212
use target::{Target, TargetResult};
1313

1414
pub fn target() -> TargetResult {
15-
let mut base = super::l4re_base::opts()?;
15+
let mut base = super::l4re_base::opts();
1616
base.cpu = "x86-64".to_string();
1717
base.max_atomic_width = Some(64);
1818

src/librustc_typeck/check/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -3096,10 +3096,10 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
30963096
};
30973097
}
30983098
ty::TyRawPtr(..) => {
3099-
err.note(&format!("`{0}` is a native pointer; perhaps you need to deref \
3100-
with `(*{0}).{1}`",
3101-
self.tcx.hir.node_to_pretty_string(base.id),
3102-
field.node));
3099+
let base = self.tcx.hir.node_to_pretty_string(base.id);
3100+
let msg = format!("`{}` is a native pointer; try dereferencing it", base);
3101+
let suggestion = format!("(*{}).{}", base, field.node);
3102+
err.span_suggestion(field.span, &msg, suggestion);
31033103
}
31043104
_ => {}
31053105
}

src/librustdoc/html/render.rs

+10-8
Original file line numberDiff line numberDiff line change
@@ -3181,14 +3181,16 @@ fn render_assoc_items(w: &mut fmt::Formatter,
31813181
render_impls(cx, w, concrete, containing_item)?;
31823182
write!(w, "</div>")?;
31833183

3184-
write!(w, "
3185-
<h2 id='synthetic-implementations' class='small-section-header'>
3186-
Auto Trait Implementations<a href='#synthetic-implementations' class='anchor'></a>
3187-
</h2>
3188-
<div id='synthetic-implementations-list'>
3189-
")?;
3190-
render_impls(cx, w, synthetic, containing_item)?;
3191-
write!(w, "</div>")?;
3184+
if !synthetic.is_empty() {
3185+
write!(w, "
3186+
<h2 id='synthetic-implementations' class='small-section-header'>
3187+
Auto Trait Implementations<a href='#synthetic-implementations' class='anchor'></a>
3188+
</h2>
3189+
<div id='synthetic-implementations-list'>
3190+
")?;
3191+
render_impls(cx, w, synthetic, containing_item)?;
3192+
write!(w, "</div>")?;
3193+
}
31923194
}
31933195
Ok(())
31943196
}

src/librustdoc/html/static/main.js

+6
Original file line numberDiff line numberDiff line change
@@ -1628,6 +1628,7 @@
16281628
function toggleAllDocs() {
16291629
var toggle = document.getElementById("toggle-all-docs");
16301630
if (hasClass(toggle, "will-expand")) {
1631+
updateLocalStorage("rustdoc-collapse", "false");
16311632
removeClass(toggle, "will-expand");
16321633
onEveryMatchingChild(toggle, "inner", function(e) {
16331634
e.innerHTML = labelForToggleButton(false);
@@ -1637,6 +1638,7 @@
16371638
collapseDocs(e, "show");
16381639
});
16391640
} else {
1641+
updateLocalStorage("rustdoc-collapse", "true");
16401642
addClass(toggle, "will-expand");
16411643
onEveryMatchingChild(toggle, "inner", function(e) {
16421644
e.innerHTML = labelForToggleButton(true);
@@ -1988,6 +1990,10 @@
19881990
window.onresize = function() {
19891991
hideSidebar();
19901992
};
1993+
1994+
if (getCurrentValue("rustdoc-collapse") === "true") {
1995+
toggleAllDocs();
1996+
}
19911997
}());
19921998

19931999
// Sets the focus on the search bar at the top of the page

src/libstd/fs.rs

+4
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,10 @@ impl File {
453453
/// will be extended to `size` and have all of the intermediate data filled
454454
/// in with 0s.
455455
///
456+
/// The file's cursor isn't changed. In particular, if the cursor was at the
457+
/// end and the file is shrunk using this operation, the cursor will now be
458+
/// past the end.
459+
///
456460
/// # Errors
457461
///
458462
/// This function will return an error if the file is not opened for writing.

0 commit comments

Comments
 (0)