diff --git a/.mailmap b/.mailmap index a2e3c581eabba..aae034dd938b5 100644 --- a/.mailmap +++ b/.mailmap @@ -54,9 +54,10 @@ Chris C Cerami Chris C Cerami Chris Thorn Chris Thorn Chris Vittal Christopher Vittal -Christian Poveda -Christian Poveda -Christian Poveda +Christian Poveda +Christian Poveda +Christian Poveda +Christian Poveda Clark Gaebel Clinton Ryan Corey Richardson Elaine "See More" Nemo diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8fbbd7c4a2e49..fc8ca5d07b212 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -367,7 +367,7 @@ labels to triage issues: to fix the issue. * The dark blue **final-comment-period** label marks bugs that are using the - RFC signoff functionality of [rfcbot][rfcbot] and are currently in the final + RFC signoff functionality of [rfcbot] and are currently in the final comment period. * Red, **I**-prefixed labels indicate the **importance** of the issue. The @@ -385,7 +385,7 @@ labels to triage issues: label. * The gray **proposed-final-comment-period** label marks bugs that are using - the RFC signoff functionality of [rfcbot][rfcbot] and are currently awaiting + the RFC signoff functionality of [rfcbot] and are currently awaiting signoff of all team members in order to enter the final comment period. * Pink, **regression**-prefixed labels track regressions from stable to the diff --git a/RELEASES.md b/RELEASES.md index 5afc6f9bdc0cb..e3597473f62fd 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -4951,10 +4951,10 @@ Stabilized APIs --------------- * [`std::panic`] -* [`std::panic::catch_unwind`][] (renamed from `recover`) -* [`std::panic::resume_unwind`][] (renamed from `propagate`) -* [`std::panic::AssertUnwindSafe`][] (renamed from `AssertRecoverSafe`) -* [`std::panic::UnwindSafe`][] (renamed from `RecoverSafe`) +* [`std::panic::catch_unwind`] (renamed from `recover`) +* [`std::panic::resume_unwind`] (renamed from `propagate`) +* [`std::panic::AssertUnwindSafe`] (renamed from `AssertRecoverSafe`) +* [`std::panic::UnwindSafe`] (renamed from `RecoverSafe`) * [`str::is_char_boundary`] * [`<*const T>::as_ref`] * [`<*mut T>::as_ref`] @@ -5234,18 +5234,18 @@ Libraries --------- * Stabilized APIs: - * [`str::encode_utf16`][] (renamed from `utf16_units`) - * [`str::EncodeUtf16`][] (renamed from `Utf16Units`) + * [`str::encode_utf16`] (renamed from `utf16_units`) + * [`str::EncodeUtf16`] (renamed from `Utf16Units`) * [`Ref::map`] * [`RefMut::map`] * [`ptr::drop_in_place`] * [`time::Instant`] * [`time::SystemTime`] * [`Instant::now`] - * [`Instant::duration_since`][] (renamed from `duration_from_earlier`) + * [`Instant::duration_since`] (renamed from `duration_from_earlier`) * [`Instant::elapsed`] * [`SystemTime::now`] - * [`SystemTime::duration_since`][] (renamed from `duration_from_earlier`) + * [`SystemTime::duration_since`] (renamed from `duration_from_earlier`) * [`SystemTime::elapsed`] * Various `Add`/`Sub` impls for `Time` and `SystemTime` * [`SystemTimeError`] @@ -5432,8 +5432,8 @@ Libraries * Stabilized APIs * `Path` - * [`Path::strip_prefix`][] (renamed from relative_from) - * [`path::StripPrefixError`][] (new error type returned from strip_prefix) + * [`Path::strip_prefix`] (renamed from relative_from) + * [`path::StripPrefixError`] (new error type returned from strip_prefix) * `Ipv4Addr` * [`Ipv4Addr::is_loopback`] * [`Ipv4Addr::is_private`] @@ -5646,7 +5646,7 @@ Libraries * Stabilized APIs: [`Read::read_exact`], - [`ErrorKind::UnexpectedEof`][] (renamed from `UnexpectedEOF`), + [`ErrorKind::UnexpectedEof`] (renamed from `UnexpectedEOF`), [`fs::DirBuilder`], [`fs::DirBuilder::new`], [`fs::DirBuilder::recursive`], [`fs::DirBuilder::create`], [`os::unix::fs::DirBuilderExt`], @@ -5659,11 +5659,11 @@ Libraries [`collections::hash_set::HashSet::drain`], [`collections::binary_heap::Drain`], [`collections::binary_heap::BinaryHeap::drain`], - [`Vec::extend_from_slice`][] (renamed from `push_all`), + [`Vec::extend_from_slice`] (renamed from `push_all`), [`Mutex::get_mut`], [`Mutex::into_inner`], [`RwLock::get_mut`], [`RwLock::into_inner`], - [`Iterator::min_by_key`][] (renamed from `min_by`), - [`Iterator::max_by_key`][] (renamed from `max_by`). + [`Iterator::min_by_key`] (renamed from `min_by`), + [`Iterator::max_by_key`] (renamed from `max_by`). * The [core library][1.6co] is stable, as are most of its APIs. * [The `assert_eq!` macro supports arguments that don't implement `Sized`][1.6ae], such as arrays. In this way it behaves more like diff --git a/src/doc/unstable-book/src/language-features/lang-items.md b/src/doc/unstable-book/src/language-features/lang-items.md index d4ad65e84b7b4..6f096e582f575 100644 --- a/src/doc/unstable-book/src/language-features/lang-items.md +++ b/src/doc/unstable-book/src/language-features/lang-items.md @@ -188,11 +188,7 @@ pub extern fn rust_begin_panic(info: &PanicInfo) -> ! { In many cases, you may need to manually link to the `compiler_builtins` crate when building a `no_std` binary. You may observe this via linker error messages -such as "```undefined reference to `__rust_probestack'```". Using this crate -also requires enabling the library feature `compiler_builtins_lib`. You can read -more about this [here][compiler-builtins-lib]. - -[compiler-builtins-lib]: ../library-features/compiler-builtins-lib.md +such as "```undefined reference to `__rust_probestack'```". ## More about the language items diff --git a/src/doc/unstable-book/src/library-features/compiler-builtins-lib.md b/src/doc/unstable-book/src/library-features/compiler-builtins-lib.md deleted file mode 100644 index 6c71c3f2ce191..0000000000000 --- a/src/doc/unstable-book/src/library-features/compiler-builtins-lib.md +++ /dev/null @@ -1,35 +0,0 @@ -# `compiler_builtins_lib` - -The tracking issue for this feature is: None. - ------------------------- - -This feature is required to link to the `compiler_builtins` crate which contains -"compiler intrinsics". Compiler intrinsics are software implementations of basic -operations like multiplication of `u64`s. These intrinsics are only required on -platforms where these operations don't directly map to a hardware instruction. - -You should never need to explicitly link to the `compiler_builtins` crate when -building "std" programs as `compiler_builtins` is already in the dependency -graph of `std`. But you may need it when building `no_std` **binary** crates. If -you get a *linker* error like: - -``` text -$PWD/src/main.rs:11: undefined reference to `__aeabi_lmul' -$PWD/src/main.rs:11: undefined reference to `__aeabi_uldivmod' -``` - -That means that you need to link to this crate. - -When you link to this crate, make sure it only appears once in your crate -dependency graph. Also, it doesn't matter where in the dependency graph you -place the `compiler_builtins` crate. - - - -``` rust,ignore -#![feature(compiler_builtins_lib)] -#![no_std] - -extern crate compiler_builtins; -``` diff --git a/src/etc/installer/msi/rust.wxs b/src/etc/installer/msi/rust.wxs index a2e378f7b1db4..a182bc4067a9f 100644 --- a/src/etc/installer/msi/rust.wxs +++ b/src/etc/installer/msi/rust.wxs @@ -85,7 +85,7 @@ - + diff --git a/src/liballoc/collections/binary_heap.rs b/src/liballoc/collections/binary_heap.rs index 0148711bb8625..c527b378f7465 100644 --- a/src/liballoc/collections/binary_heap.rs +++ b/src/liballoc/collections/binary_heap.rs @@ -1094,7 +1094,7 @@ impl FusedIterator for Iter<'_, T> {} /// An owning iterator over the elements of a `BinaryHeap`. /// -/// This `struct` is created by the [`into_iter`] method on [`BinaryHeap`][`BinaryHeap`] +/// This `struct` is created by the [`into_iter`] method on [`BinaryHeap`] /// (provided by the `IntoIterator` trait). See its documentation for more. /// /// [`into_iter`]: struct.BinaryHeap.html#method.into_iter diff --git a/src/liballoc/collections/btree/map.rs b/src/liballoc/collections/btree/map.rs index 7d0a862d79e48..fa8aae04011ed 100644 --- a/src/liballoc/collections/btree/map.rs +++ b/src/liballoc/collections/btree/map.rs @@ -283,7 +283,7 @@ pub struct IterMut<'a, K: 'a, V: 'a> { /// An owning iterator over the entries of a `BTreeMap`. /// -/// This `struct` is created by the [`into_iter`] method on [`BTreeMap`][`BTreeMap`] +/// This `struct` is created by the [`into_iter`] method on [`BTreeMap`] /// (provided by the `IntoIterator` trait). See its documentation for more. /// /// [`into_iter`]: struct.BTreeMap.html#method.into_iter diff --git a/src/liballoc/collections/btree/set.rs b/src/liballoc/collections/btree/set.rs index 282d163141bc8..f5487426814a5 100644 --- a/src/liballoc/collections/btree/set.rs +++ b/src/liballoc/collections/btree/set.rs @@ -83,7 +83,7 @@ impl fmt::Debug for Iter<'_, T> { /// An owning iterator over the items of a `BTreeSet`. /// -/// This `struct` is created by the [`into_iter`] method on [`BTreeSet`][`BTreeSet`] +/// This `struct` is created by the [`into_iter`] method on [`BTreeSet`] /// (provided by the `IntoIterator` trait). See its documentation for more. /// /// [`BTreeSet`]: struct.BTreeSet.html diff --git a/src/liballoc/collections/linked_list.rs b/src/liballoc/collections/linked_list.rs index 4931093c55c99..29bf2fdb30cf7 100644 --- a/src/liballoc/collections/linked_list.rs +++ b/src/liballoc/collections/linked_list.rs @@ -105,7 +105,7 @@ impl fmt::Debug for IterMut<'_, T> { /// An owning iterator over the elements of a `LinkedList`. /// -/// This `struct` is created by the [`into_iter`] method on [`LinkedList`][`LinkedList`] +/// This `struct` is created by the [`into_iter`] method on [`LinkedList`] /// (provided by the `IntoIterator` trait). See its documentation for more. /// /// [`into_iter`]: struct.LinkedList.html#method.into_iter diff --git a/src/liballoc/collections/vec_deque.rs b/src/liballoc/collections/vec_deque.rs index 9d2eec94a0c02..2cc450bb68a20 100644 --- a/src/liballoc/collections/vec_deque.rs +++ b/src/liballoc/collections/vec_deque.rs @@ -2474,7 +2474,7 @@ impl FusedIterator for IterMut<'_, T> {} /// An owning iterator over the elements of a `VecDeque`. /// -/// This `struct` is created by the [`into_iter`] method on [`VecDeque`][`VecDeque`] +/// This `struct` is created by the [`into_iter`] method on [`VecDeque`] /// (provided by the `IntoIterator` trait). See its documentation for more. /// /// [`into_iter`]: struct.VecDeque.html#method.into_iter diff --git a/src/liballoc/fmt.rs b/src/liballoc/fmt.rs index 01d4913665c07..e6162e0f571e2 100644 --- a/src/liballoc/fmt.rs +++ b/src/liballoc/fmt.rs @@ -330,7 +330,7 @@ //! //! Additionally, the return value of this function is [`fmt::Result`] which is a //! type alias of [`Result`]`<(), `[`std::fmt::Error`]`>`. Formatting implementations -//! should ensure that they propagate errors from the [`Formatter`][`Formatter`] (e.g., when +//! should ensure that they propagate errors from the [`Formatter`] (e.g., when //! calling [`write!`]). However, they should never return errors spuriously. That //! is, a formatting implementation must and may only return an error if the //! passed-in [`Formatter`] returns an error. This is because, contrary to what diff --git a/src/liballoc/slice.rs b/src/liballoc/slice.rs index 2f6d10c027be3..7b83658fca60d 100644 --- a/src/liballoc/slice.rs +++ b/src/liballoc/slice.rs @@ -450,7 +450,8 @@ impl [T] { // and `rem` is the remaining part of `n`. // Using `Vec` to access `set_len()`. - let mut buf = Vec::with_capacity(self.len().checked_mul(n).expect("capacity overflow")); + let capacity = self.len().checked_mul(n).expect("capacity overflow"); + let mut buf = Vec::with_capacity(capacity); // `2^expn` repetition is done by doubling `buf` `expn`-times. buf.extend(self); @@ -476,7 +477,7 @@ impl [T] { // `rem` (`= n - 2^expn`) repetition is done by copying // first `rem` repetitions from `buf` itself. - let rem_len = self.len() * n - buf.len(); // `self.len() * rem` + let rem_len = capacity - buf.len(); // `self.len() * rem` if rem_len > 0 { // `buf.extend(buf[0 .. rem_len])`: unsafe { @@ -487,8 +488,7 @@ impl [T] { rem_len, ); // `buf.len() + rem_len` equals to `buf.capacity()` (`= self.len() * n`). - let buf_cap = buf.capacity(); - buf.set_len(buf_cap); + buf.set_len(capacity); } } buf diff --git a/src/liballoc/vec.rs b/src/liballoc/vec.rs index dcd7dc49526b6..93a51ccb20737 100644 --- a/src/liballoc/vec.rs +++ b/src/liballoc/vec.rs @@ -242,7 +242,7 @@ use crate::raw_vec::RawVec; /// ensures no unnecessary allocations or deallocations occur. Emptying a `Vec` /// and then filling it back up to the same [`len`] should incur no calls to /// the allocator. If you wish to free up unused memory, use -/// [`shrink_to_fit`][`shrink_to_fit`]. +/// [`shrink_to_fit`]. /// /// [`push`] and [`insert`] will never (re)allocate if the reported capacity is /// sufficient. [`push`] and [`insert`] *will* (re)allocate if @@ -2461,7 +2461,7 @@ where /// An iterator that moves out of a vector. /// -/// This `struct` is created by the `into_iter` method on [`Vec`][`Vec`] (provided +/// This `struct` is created by the `into_iter` method on [`Vec`] (provided /// by the [`IntoIterator`] trait). /// /// [`Vec`]: struct.Vec.html diff --git a/src/libcore/intrinsics.rs b/src/libcore/intrinsics.rs index 502090731f4a1..416c73f50bd89 100644 --- a/src/libcore/intrinsics.rs +++ b/src/libcore/intrinsics.rs @@ -697,7 +697,7 @@ extern "rust-intrinsic" { #[rustc_const_stable(feature = "const_min_align_of", since = "1.40.0")] pub fn min_align_of() -> usize; - #[rustc_const_unstable(feature = "const_pref_align_of", issue = "0")] + #[rustc_const_unstable(feature = "const_pref_align_of", issue = "none")] pub fn pref_align_of() -> usize; /// The size of the referenced value in bytes. @@ -708,13 +708,13 @@ extern "rust-intrinsic" { pub fn min_align_of_val(_: &T) -> usize; /// Gets a static string slice containing the name of a type. - #[rustc_const_unstable(feature = "const_type_name", issue = "0")] + #[rustc_const_unstable(feature = "const_type_name", issue = "none")] pub fn type_name() -> &'static str; /// Gets an identifier which is globally unique to the specified type. This /// function will return the same value for a type regardless of whichever /// crate it is invoked in. - #[rustc_const_unstable(feature = "const_type_id", issue = "0")] + #[rustc_const_unstable(feature = "const_type_id", issue = "none")] pub fn type_id() -> u64; /// A guard for unsafe functions that cannot ever be executed if `T` is uninhabited: @@ -1222,7 +1222,7 @@ extern "rust-intrinsic" { /// let num_leading = unsafe { ctlz_nonzero(x) }; /// assert_eq!(num_leading, 3); /// ``` - #[rustc_const_unstable(feature = "constctlz", issue = "0")] + #[rustc_const_unstable(feature = "constctlz", issue = "none")] pub fn ctlz_nonzero(x: T) -> T; /// Returns the number of trailing unset bits (zeroes) in an integer type `T`. @@ -1267,7 +1267,7 @@ extern "rust-intrinsic" { /// let num_trailing = unsafe { cttz_nonzero(x) }; /// assert_eq!(num_trailing, 3); /// ``` - #[rustc_const_unstable(feature = "const_cttz", issue = "0")] + #[rustc_const_unstable(feature = "const_cttz", issue = "none")] pub fn cttz_nonzero(x: T) -> T; /// Reverses the bytes in an integer type `T`. @@ -1396,7 +1396,7 @@ extern "rust-intrinsic" { pub fn nontemporal_store(ptr: *mut T, val: T); /// See documentation of `<*const T>::offset_from` for details. - #[rustc_const_unstable(feature = "const_ptr_offset_from", issue = "0")] + #[rustc_const_unstable(feature = "const_ptr_offset_from", issue = "none")] pub fn ptr_offset_from(ptr: *const T, base: *const T) -> isize; /// Internal hook used by Miri to implement unwinding. diff --git a/src/libcore/marker.rs b/src/libcore/marker.rs index 978d622156413..3b98bc1c272f0 100644 --- a/src/libcore/marker.rs +++ b/src/libcore/marker.rs @@ -142,7 +142,7 @@ pub trait Unsize { /// In either of the two scenarios above, we reject usage of such a constant in /// a pattern match. /// -/// See also the [structural match RFC][RFC1445], and [issue 63438][] which +/// See also the [structural match RFC][RFC1445], and [issue 63438] which /// motivated migrating from attribute-based design to this trait. /// /// [RFC1445]: https://github.com/rust-lang/rfcs/blob/master/text/1445-restrict-constants-in-patterns.md diff --git a/src/libcore/num/f32.rs b/src/libcore/num/f32.rs index fd7b7cf0b3490..f1f1bb13f0f24 100644 --- a/src/libcore/num/f32.rs +++ b/src/libcore/num/f32.rs @@ -226,7 +226,7 @@ impl f32 { } /// Returns `true` if the number is neither zero, infinite, - /// [subnormal][subnormal], or `NaN`. + /// [subnormal], or `NaN`. /// /// ``` /// use std::f32; diff --git a/src/libcore/num/f64.rs b/src/libcore/num/f64.rs index 540c6a529d7c8..5f9dc541b7d91 100644 --- a/src/libcore/num/f64.rs +++ b/src/libcore/num/f64.rs @@ -226,7 +226,7 @@ impl f64 { } /// Returns `true` if the number is neither zero, infinite, - /// [subnormal][subnormal], or `NaN`. + /// [subnormal], or `NaN`. /// /// ``` /// use std::f64; diff --git a/src/libcore/ops/function.rs b/src/libcore/ops/function.rs index 505a65cee3de0..04c7789fa4ff4 100644 --- a/src/libcore/ops/function.rs +++ b/src/libcore/ops/function.rs @@ -2,12 +2,12 @@ /// /// Instances of `Fn` can be called repeatedly without mutating state. /// -/// *This trait (`Fn`) is not to be confused with [function pointers][] +/// *This trait (`Fn`) is not to be confused with [function pointers] /// (`fn`).* /// /// `Fn` is implemented automatically by closures which only take immutable /// references to captured variables or don't capture anything at all, as well -/// as (safe) [function pointers][] (with some caveats, see their documentation +/// as (safe) [function pointers] (with some caveats, see their documentation /// for more details). Additionally, for any type `F` that implements `Fn`, `&F` /// implements `Fn`, too. /// @@ -78,7 +78,7 @@ pub trait Fn: FnMut { /// /// `FnMut` is implemented automatically by closures which take mutable /// references to captured variables, as well as all types that implement -/// [`Fn`], e.g., (safe) [function pointers][] (since `FnMut` is a supertrait of +/// [`Fn`], e.g., (safe) [function pointers] (since `FnMut` is a supertrait of /// [`Fn`]). Additionally, for any type `F` that implements `FnMut`, `&mut F` /// implements `FnMut`, too. /// @@ -162,7 +162,7 @@ pub trait FnMut: FnOnce { /// /// `FnOnce` is implemented automatically by closure that might consume captured /// variables, as well as all types that implement [`FnMut`], e.g., (safe) -/// [function pointers][] (since `FnOnce` is a supertrait of [`FnMut`]). +/// [function pointers] (since `FnOnce` is a supertrait of [`FnMut`]). /// /// Since both [`Fn`] and [`FnMut`] are subtraits of `FnOnce`, any instance of /// [`Fn`] or [`FnMut`] can be used where a `FnOnce` is expected. diff --git a/src/libcore/result.rs b/src/libcore/result.rs index ce4c8995a3c48..5628658c5bdf5 100644 --- a/src/libcore/result.rs +++ b/src/libcore/result.rs @@ -1370,7 +1370,7 @@ unsafe impl TrustedLen for IterMut<'_, A> {} /// The iterator yields one value if the result is [`Ok`], otherwise none. /// /// This struct is created by the [`into_iter`] method on -/// [`Result`][`Result`] (provided by the [`IntoIterator`] trait). +/// [`Result`] (provided by the [`IntoIterator`] trait). /// /// [`Ok`]: enum.Result.html#variant.Ok /// [`Result`]: enum.Result.html diff --git a/src/libpanic_unwind/seh.rs b/src/libpanic_unwind/seh.rs index 9a28c47ba9458..e1907ec4e5f32 100644 --- a/src/libpanic_unwind/seh.rs +++ b/src/libpanic_unwind/seh.rs @@ -41,7 +41,7 @@ //! are then recovered in the filter function to be written to the stack frame //! of the `try` intrinsic. //! -//! [win64]: http://msdn.microsoft.com/en-us/library/1eyas8tf.aspx +//! [win64]: https://docs.microsoft.com/en-us/cpp/build/exception-handling-x64 //! [llvm]: http://llvm.org/docs/ExceptionHandling.html#background-on-windows-exceptions #![allow(nonstandard_style)] diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index 2659caf030b0c..0fb294bb9da60 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -1610,13 +1610,11 @@ pub mod tls { use crate::dep_graph::TaskDeps; use crate::ty::query; - use errors::{Diagnostic, TRACK_DIAGNOSTICS}; + use errors::Diagnostic; use rustc_data_structures::sync::{self, Lock, Lrc}; use rustc_data_structures::thin_vec::ThinVec; use rustc_data_structures::OnDrop; - use std::fmt; use std::mem; - use syntax_pos; #[cfg(not(parallel_compiler))] use std::cell::Cell; @@ -1692,58 +1690,6 @@ pub mod tls { TLV.with(|tlv| tlv.get()) } - /// This is a callback from libsyntax as it cannot access the implicit state - /// in librustc otherwise. - fn span_debug(span: syntax_pos::Span, f: &mut fmt::Formatter<'_>) -> fmt::Result { - with_opt(|tcx| { - if let Some(tcx) = tcx { - write!(f, "{}", tcx.sess.source_map().span_to_string(span)) - } else { - syntax_pos::default_span_debug(span, f) - } - }) - } - - /// This is a callback from libsyntax as it cannot access the implicit state - /// in librustc otherwise. It is used to when diagnostic messages are - /// emitted and stores them in the current query, if there is one. - fn track_diagnostic(diagnostic: &Diagnostic) { - with_context_opt(|icx| { - if let Some(icx) = icx { - if let Some(ref diagnostics) = icx.diagnostics { - let mut diagnostics = diagnostics.lock(); - diagnostics.extend(Some(diagnostic.clone())); - } - } - }) - } - - /// Sets up the callbacks from libsyntax on the current thread. - pub fn with_thread_locals(f: F) -> R - where - F: FnOnce() -> R, - { - syntax_pos::SPAN_DEBUG.with(|span_dbg| { - let original_span_debug = span_dbg.get(); - span_dbg.set(span_debug); - - let _on_drop = OnDrop(move || { - span_dbg.set(original_span_debug); - }); - - TRACK_DIAGNOSTICS.with(|current| { - let original = current.get(); - current.set(track_diagnostic); - - let _on_drop = OnDrop(move || { - current.set(original); - }); - - f() - }) - }) - } - /// Sets `context` as the new current `ImplicitCtxt` for the duration of the function `f`. #[inline] pub fn enter_context<'a, 'tcx, F, R>(context: &ImplicitCtxt<'a, 'tcx>, f: F) -> R diff --git a/src/librustc/ty/query/job.rs b/src/librustc/ty/query/job.rs index 7361485c55d9f..fbcbfae9f8f4f 100644 --- a/src/librustc/ty/query/job.rs +++ b/src/librustc/ty/query/job.rs @@ -435,13 +435,14 @@ pub unsafe fn handle_deadlock() { let syntax_pos_globals = syntax_pos::GLOBALS.with(|syntax_pos_globals| syntax_pos_globals as *const _); let syntax_pos_globals = &*syntax_pos_globals; + let syntax_globals = syntax::GLOBALS.with(|syntax_globals| syntax_globals as *const _); + let syntax_globals = &*syntax_globals; thread::spawn(move || { tls::GCX_PTR.set(gcx_ptr, || { - syntax_pos::GLOBALS.set(syntax_pos_globals, || { - syntax_pos::GLOBALS.set(syntax_pos_globals, || { - tls::with_thread_locals(|| tls::with_global(|tcx| deadlock(tcx, ®istry))) - }) - }) + syntax::GLOBALS.set(syntax_globals, || { + syntax_pos::GLOBALS + .set(syntax_pos_globals, || tls::with_global(|tcx| deadlock(tcx, ®istry))) + }); }) }); } diff --git a/src/librustc_codegen_llvm/metadata.rs b/src/librustc_codegen_llvm/metadata.rs index d328144a15e12..abe34bb148ce5 100644 --- a/src/librustc_codegen_llvm/metadata.rs +++ b/src/librustc_codegen_llvm/metadata.rs @@ -97,7 +97,7 @@ pub fn metadata_section_name(target: &Target) -> &'static str { // > Executable images do not use a string table and do not support // > section names longer than 8 characters // - // https://msdn.microsoft.com/en-us/library/windows/hardware/gg463119.aspx + // https://docs.microsoft.com/en-us/windows/win32/debug/pe-format // // As a result, we choose a slightly shorter name! As to why // `.note.rustc` works on MinGW, that's another good question... diff --git a/src/librustc_codegen_ssa/back/command.rs b/src/librustc_codegen_ssa/back/command.rs index 5595386be2431..dcc16416e5e87 100644 --- a/src/librustc_codegen_ssa/back/command.rs +++ b/src/librustc_codegen_ssa/back/command.rs @@ -168,8 +168,8 @@ impl Command { // error code if we fail to spawn and automatically re-spawning the // linker with smaller arguments. // - // [1]: https://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx - // [2]: https://blogs.msdn.microsoft.com/oldnewthing/20031210-00/?p=41553 + // [1]: https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-createprocessa + // [2]: https://devblogs.microsoft.com/oldnewthing/?p=41553 let estimated_command_line_len = self.args.iter().map(|a| a.len()).sum::(); estimated_command_line_len > 1024 * 6 diff --git a/src/librustc_codegen_ssa/back/link.rs b/src/librustc_codegen_ssa/back/link.rs index f3420f9a9f9fd..c7a599a5749b7 100644 --- a/src/librustc_codegen_ssa/back/link.rs +++ b/src/librustc_codegen_ssa/back/link.rs @@ -1044,7 +1044,7 @@ pub fn exec_linker( fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { if self.is_like_msvc { // This is "documented" at - // https://msdn.microsoft.com/en-us/library/4xdcbak7.aspx + // https://docs.microsoft.com/en-us/cpp/build/reference/at-specify-a-linker-response-file // // Unfortunately there's not a great specification of the // syntax I could find online (at least) but some local diff --git a/src/librustc_data_structures/atomic_ref.rs b/src/librustc_data_structures/atomic_ref.rs new file mode 100644 index 0000000000000..eeb1b309257d4 --- /dev/null +++ b/src/librustc_data_structures/atomic_ref.rs @@ -0,0 +1,26 @@ +use std::marker::PhantomData; +use std::sync::atomic::{AtomicPtr, Ordering}; + +/// This is essentially an `AtomicPtr` but is guaranteed to always be valid +pub struct AtomicRef(AtomicPtr, PhantomData<&'static T>); + +impl AtomicRef { + pub const fn new(initial: &'static T) -> AtomicRef { + AtomicRef(AtomicPtr::new(initial as *const T as *mut T), PhantomData) + } + + pub fn swap(&self, new: &'static T) -> &'static T { + // We never allow storing anything but a `'static` reference so it's safe to + // return it for the same. + unsafe { &*self.0.swap(new as *const T as *mut T, Ordering::SeqCst) } + } +} + +impl std::ops::Deref for AtomicRef { + type Target = T; + fn deref(&self) -> &Self::Target { + // We never allow storing anything but a `'static` reference so it's safe to lend + // it out for any amount of time. + unsafe { &*self.0.load(Ordering::SeqCst) } + } +} diff --git a/src/librustc_data_structures/graph/iterate/mod.rs b/src/librustc_data_structures/graph/iterate/mod.rs index 53475cdf4ba42..d9d4c7e321fb5 100644 --- a/src/librustc_data_structures/graph/iterate/mod.rs +++ b/src/librustc_data_structures/graph/iterate/mod.rs @@ -101,14 +101,14 @@ pub enum ControlFlow { pub enum NodeStatus { /// This node has been examined by the depth-first search but is not yet `Settled`. /// - /// Also referred to as "gray" or "discovered" nodes in [CLR][]. + /// Also referred to as "gray" or "discovered" nodes in [CLR]. /// /// [CLR]: https://en.wikipedia.org/wiki/Introduction_to_Algorithms Visited, /// This node and all nodes reachable from it have been examined by the depth-first search. /// - /// Also referred to as "black" or "finished" nodes in [CLR][]. + /// Also referred to as "black" or "finished" nodes in [CLR]. /// /// [CLR]: https://en.wikipedia.org/wiki/Introduction_to_Algorithms Settled, @@ -122,13 +122,13 @@ struct Event { /// A depth-first search that also tracks when all successors of a node have been examined. /// /// This is based on the DFS described in [Introduction to Algorithms (1st ed.)][CLR], hereby -/// referred to as **CLR**. However, we use the terminology in [`NodeStatus`][] above instead of +/// referred to as **CLR**. However, we use the terminology in [`NodeStatus`] above instead of /// "discovered"/"finished" or "white"/"grey"/"black". Each node begins the search with no status, /// becomes `Visited` when it is first examined by the DFS and is `Settled` when all nodes /// reachable from it have been examined. This allows us to differentiate between "tree", "back" /// and "forward" edges (see [`TriColorVisitor::node_examined`]). /// -/// Unlike the pseudocode in [CLR][], this implementation is iterative and does not use timestamps. +/// Unlike the pseudocode in [CLR], this implementation is iterative and does not use timestamps. /// We accomplish this by storing `Event`s on the stack that result in a (possible) state change /// for each node. A `Visited` event signifies that we should examine this node if it has not yet /// been `Visited` or `Settled`. When a node is examined for the first time, we mark it as @@ -246,7 +246,7 @@ where /// By checking the value of `prior_status`, this visitor can determine whether the edge /// leading to this node was a tree edge (`None`), forward edge (`Some(Settled)`) or back edge /// (`Some(Visited)`). For a full explanation of each edge type, see the "Depth-first Search" - /// chapter in [CLR][] or [wikipedia][]. + /// chapter in [CLR] or [wikipedia]. /// /// If you want to know *both* nodes linked by each edge, you'll need to modify /// `TriColorDepthFirstSearch` to store a `source` node for each `Visited` event. diff --git a/src/librustc_data_structures/lib.rs b/src/librustc_data_structures/lib.rs index e035f39e34fd7..25bb8f6afae62 100644 --- a/src/librustc_data_structures/lib.rs +++ b/src/librustc_data_structures/lib.rs @@ -89,10 +89,12 @@ pub mod thin_vec; pub mod tiny_list; pub mod transitive_relation; pub use ena::unify; +mod atomic_ref; pub mod fingerprint; pub mod profiling; pub mod vec_linked_list; pub mod work_queue; +pub use atomic_ref::AtomicRef; pub struct OnDrop(pub F); diff --git a/src/librustc_errors/lib.rs b/src/librustc_errors/lib.rs index e93106b7adff1..53a673714a90a 100644 --- a/src/librustc_errors/lib.rs +++ b/src/librustc_errors/lib.rs @@ -17,11 +17,11 @@ use registry::Registry; use rustc_data_structures::fx::{FxHashSet, FxIndexMap}; use rustc_data_structures::stable_hasher::StableHasher; use rustc_data_structures::sync::{self, Lock, Lrc}; +use rustc_data_structures::AtomicRef; use syntax_pos::source_map::SourceMap; use syntax_pos::{Loc, MultiSpan, Span}; use std::borrow::Cow; -use std::cell::Cell; use std::panic; use std::path::Path; use std::{error, fmt}; @@ -309,8 +309,8 @@ pub enum StashKey { fn default_track_diagnostic(_: &Diagnostic) {} -thread_local!(pub static TRACK_DIAGNOSTICS: Cell = - Cell::new(default_track_diagnostic)); +pub static TRACK_DIAGNOSTICS: AtomicRef = + AtomicRef::new(&(default_track_diagnostic as fn(&_))); #[derive(Copy, Clone, Default)] pub struct HandlerFlags { @@ -730,9 +730,7 @@ impl HandlerInner { return; } - TRACK_DIAGNOSTICS.with(|track_diagnostics| { - track_diagnostics.get()(diagnostic); - }); + (*TRACK_DIAGNOSTICS)(diagnostic); if let Some(ref code) = diagnostic.code { self.emitted_diagnostic_codes.insert(code.clone()); diff --git a/src/librustc_interface/callbacks.rs b/src/librustc_interface/callbacks.rs new file mode 100644 index 0000000000000..28e687a378646 --- /dev/null +++ b/src/librustc_interface/callbacks.rs @@ -0,0 +1,48 @@ +//! Throughout the compiler tree, there are several places which want to have +//! access to state or queries while being inside crates that are dependencies +//! of librustc. To facilitate this, we have the +//! `rustc_data_structures::AtomicRef` type, which allows us to setup a global +//! static which can then be set in this file at program startup. +//! +//! See `SPAN_DEBUG` for an example of how to set things up. +//! +//! The functions in this file should fall back to the default set in their +//! origin crate when the `TyCtxt` is not present in TLS. + +use rustc::ty::tls; +use rustc_errors::{Diagnostic, TRACK_DIAGNOSTICS}; +use std::fmt; +use syntax_pos; + +/// This is a callback from libsyntax as it cannot access the implicit state +/// in librustc otherwise. +fn span_debug(span: syntax_pos::Span, f: &mut fmt::Formatter<'_>) -> fmt::Result { + tls::with_opt(|tcx| { + if let Some(tcx) = tcx { + write!(f, "{}", tcx.sess.source_map().span_to_string(span)) + } else { + syntax_pos::default_span_debug(span, f) + } + }) +} + +/// This is a callback from libsyntax as it cannot access the implicit state +/// in librustc otherwise. It is used to when diagnostic messages are +/// emitted and stores them in the current query, if there is one. +fn track_diagnostic(diagnostic: &Diagnostic) { + tls::with_context_opt(|icx| { + if let Some(icx) = icx { + if let Some(ref diagnostics) = icx.diagnostics { + let mut diagnostics = diagnostics.lock(); + diagnostics.extend(Some(diagnostic.clone())); + } + } + }) +} + +/// Sets up the callbacks in prior crates which we want to refer to the +/// TyCtxt in. +pub fn setup_callbacks() { + syntax_pos::SPAN_DEBUG.swap(&(span_debug as fn(_, &mut fmt::Formatter<'_>) -> _)); + TRACK_DIAGNOSTICS.swap(&(track_diagnostic as fn(&_))); +} diff --git a/src/librustc_interface/lib.rs b/src/librustc_interface/lib.rs index 3d79661978811..e4e6849ab8e59 100644 --- a/src/librustc_interface/lib.rs +++ b/src/librustc_interface/lib.rs @@ -11,6 +11,7 @@ #[cfg(unix)] extern crate libc; +mod callbacks; pub mod interface; mod passes; mod proc_macro_decls; diff --git a/src/librustc_interface/util.rs b/src/librustc_interface/util.rs index 1a2958a0a92c9..ccc2dcabec2c5 100644 --- a/src/librustc_interface/util.rs +++ b/src/librustc_interface/util.rs @@ -145,13 +145,15 @@ pub fn spawn_thread_pool R + Send, R: Send>( cfg = cfg.stack_size(size); } + crate::callbacks::setup_callbacks(); + scoped_thread(cfg, || { syntax::with_globals(edition, || { ty::tls::GCX_PTR.set(&Lock::new(0), || { if let Some(stderr) = stderr { io::set_panic(Some(box Sink(stderr.clone()))); } - ty::tls::with_thread_locals(|| f()) + f() }) }) }) @@ -167,6 +169,7 @@ pub fn spawn_thread_pool R + Send, R: Send>( use rayon::{ThreadBuilder, ThreadPool, ThreadPoolBuilder}; let gcx_ptr = &Lock::new(0); + crate::callbacks::setup_callbacks(); let mut config = ThreadPoolBuilder::new() .thread_name(|_| "rustc".to_string()) @@ -194,9 +197,7 @@ pub fn spawn_thread_pool R + Send, R: Send>( if let Some(stderr) = stderr { io::set_panic(Some(box Sink(stderr.clone()))); } - ty::tls::with_thread_locals(|| { - ty::tls::GCX_PTR.set(gcx_ptr, || thread.run()) - }) + ty::tls::GCX_PTR.set(gcx_ptr, || thread.run()) }) }) }; diff --git a/src/librustc_mir/dataflow/generic.rs b/src/librustc_mir/dataflow/generic.rs index 659ebeab65022..7eb6f5cc073df 100644 --- a/src/librustc_mir/dataflow/generic.rs +++ b/src/librustc_mir/dataflow/generic.rs @@ -10,7 +10,7 @@ //! interface, but make `Engine` and `ResultsCursor` the canonical way to perform and inspect a //! dataflow analysis. This requires porting the graphviz debugging logic to this module, deciding //! on a way to handle the `before` methods in `BitDenotation` and creating an adapter so that -//! gen-kill problems can still be evaluated efficiently. See the discussion in [#64566][] for more +//! gen-kill problems can still be evaluated efficiently. See the discussion in [#64566] for more //! information. //! //! [gk]: https://en.wikipedia.org/wiki/Data-flow_analysis#Bit_vector_problems diff --git a/src/librustc_mir/transform/const_prop.rs b/src/librustc_mir/transform/const_prop.rs index a6b30ab5e68cf..ab43249692cf4 100644 --- a/src/librustc_mir/transform/const_prop.rs +++ b/src/librustc_mir/transform/const_prop.rs @@ -20,7 +20,7 @@ use rustc::ty::layout::{ HasDataLayout, HasTyCtxt, LayoutError, LayoutOf, Size, TargetDataLayout, TyLayout, }; use rustc::ty::subst::InternalSubsts; -use rustc::ty::{self, Instance, ParamEnv, Ty, TyCtxt}; +use rustc::ty::{self, Instance, ParamEnv, Ty, TyCtxt, TypeFoldable}; use rustc_data_structures::fx::FxHashMap; use rustc_index::vec::IndexVec; use syntax::ast::Mutability; @@ -410,6 +410,12 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> { } fn eval_constant(&mut self, c: &Constant<'tcx>) -> Option> { + // `eval_const_to_op` uses `Instance::resolve` which still has a bug (#66901) in the + // presence of trait items with a default body. So we just bail out if we aren't 100% + // monomorphic. + if c.literal.needs_subst() { + return None; + } self.ecx.tcx.span = c.span; match self.ecx.eval_const_to_op(c.literal, None) { Ok(op) => Some(op), @@ -556,6 +562,13 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> { _ => {} } + // `eval_rvalue_into_place` uses `Instance::resolve` for constants which still has a bug + // (#66901) in the presence of trait items with a default body. So we just bail out if we + // aren't 100% monomorphic. + if rvalue.needs_subst() { + return None; + } + self.use_ecx(source_info, |this| { trace!("calling eval_rvalue_into_place(rvalue = {:?}, place = {:?})", rvalue, place); this.ecx.eval_rvalue_into_place(rvalue, place)?; diff --git a/src/librustc_target/abi/call/x86_win64.rs b/src/librustc_target/abi/call/x86_win64.rs index f08a7c5063e03..2aad641b1ecf0 100644 --- a/src/librustc_target/abi/call/x86_win64.rs +++ b/src/librustc_target/abi/call/x86_win64.rs @@ -1,7 +1,7 @@ use crate::abi::call::{ArgAbi, FnAbi, Reg}; use crate::abi::Abi; -// Win64 ABI: http://msdn.microsoft.com/en-us/library/zthk2dkh.aspx +// Win64 ABI: https://docs.microsoft.com/en-us/cpp/build/parameter-passing pub fn compute_abi_info(fn_abi: &mut FnAbi<'_, Ty>) { let fixup = |a: &mut ArgAbi<'_, Ty>| { diff --git a/src/librustc_target/spec/i686_pc_windows_msvc.rs b/src/librustc_target/spec/i686_pc_windows_msvc.rs index 195c00d684f7d..b160007e0621a 100644 --- a/src/librustc_target/spec/i686_pc_windows_msvc.rs +++ b/src/librustc_target/spec/i686_pc_windows_msvc.rs @@ -11,7 +11,7 @@ pub fn target() -> TargetResult { // Ensure the linker will only produce an image if it can also produce a table of // the image's safe exception handlers. - // https://msdn.microsoft.com/en-us/library/9a89h429.aspx + // https://docs.microsoft.com/en-us/cpp/build/reference/safeseh-image-has-safe-exception-handlers base.pre_link_args.get_mut(&LinkerFlavor::Msvc).unwrap().push("/SAFESEH".to_string()); Ok(Target { diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs index a928867d9de93..fdc587ba5dacf 100644 --- a/src/libstd/collections/hash/map.rs +++ b/src/libstd/collections/hash/map.rs @@ -1076,7 +1076,7 @@ impl<'a, K, V> IterMut<'a, K, V> { /// An owning iterator over the entries of a `HashMap`. /// -/// This `struct` is created by the [`into_iter`] method on [`HashMap`][`HashMap`] +/// This `struct` is created by the [`into_iter`] method on [`HashMap`] /// (provided by the `IntoIterator` trait). See its documentation for more. /// /// [`into_iter`]: struct.HashMap.html#method.into_iter diff --git a/src/libstd/collections/hash/set.rs b/src/libstd/collections/hash/set.rs index fff64e9fc9008..566e5146cf857 100644 --- a/src/libstd/collections/hash/set.rs +++ b/src/libstd/collections/hash/set.rs @@ -1101,7 +1101,7 @@ pub struct Iter<'a, K: 'a> { /// An owning iterator over the items of a `HashSet`. /// -/// This `struct` is created by the [`into_iter`] method on [`HashSet`][`HashSet`] +/// This `struct` is created by the [`into_iter`] method on [`HashSet`] /// (provided by the `IntoIterator` trait). See its documentation for more. /// /// [`HashSet`]: struct.HashSet.html diff --git a/src/libstd/env.rs b/src/libstd/env.rs index 52eebcfcb94c0..60facd9f8d468 100644 --- a/src/libstd/env.rs +++ b/src/libstd/env.rs @@ -552,7 +552,7 @@ impl Error for JoinPathsError { /// (including to an empty string). /// - If both do not exist, [`GetUserProfileDirectory`][msdn] is used to return the path. /// -/// [msdn]: https://msdn.microsoft.com/en-us/library/windows/desktop/bb762280(v=vs.85).aspx +/// [msdn]: https://docs.microsoft.com/en-us/windows/win32/api/userenv/nf-userenv-getuserprofiledirectorya /// /// # Examples /// @@ -591,7 +591,7 @@ pub fn home_dir() -> Option { /// This behavior is identical to that of [`GetTempPath`][msdn], which this /// function uses internally. /// -/// [msdn]: https://msdn.microsoft.com/en-us/library/windows/desktop/aa364992(v=vs.85).aspx +/// [msdn]: https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-gettemppatha /// /// ```no_run /// use std::env; diff --git a/src/libstd/fs.rs b/src/libstd/fs.rs index 01e57ec0ab941..cff7bbe5ef183 100644 --- a/src/libstd/fs.rs +++ b/src/libstd/fs.rs @@ -1841,7 +1841,7 @@ pub fn read_link>(path: P) -> io::Result { /// or written to a file another application may read). /// /// [changes]: ../io/index.html#platform-specific-behavior -/// [path]: https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx#maxpath +/// [path]: https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file /// /// # Errors /// diff --git a/src/libstd/path.rs b/src/libstd/path.rs index 580ff1610ac83..f308d511cf850 100644 --- a/src/libstd/path.rs +++ b/src/libstd/path.rs @@ -2,7 +2,7 @@ //! Cross-platform path manipulation. //! -//! This module provides two types, [`PathBuf`] and [`Path`][`Path`] (akin to [`String`] +//! This module provides two types, [`PathBuf`] and [`Path`] (akin to [`String`] //! and [`str`]), for working with paths abstractly. These types are thin wrappers //! around [`OsString`] and [`OsStr`] respectively, meaning that they work directly //! on strings according to the local platform's path syntax. @@ -296,6 +296,13 @@ where } // See note at the top of this module to understand why these are used: +// +// These casts are safe as OsStr is internally a wrapper around [u8] on all +// platforms. +// +// Note that currently this relies on the special knowledge that libstd has; +// these types are single-element structs but are not marked repr(transparent) +// or repr(C) which would make these casts allowable outside std. fn os_str_as_u8_slice(s: &OsStr) -> &[u8] { unsafe { &*(s as *const OsStr as *const [u8]) } } diff --git a/src/libstd/sync/mpsc/mod.rs b/src/libstd/sync/mpsc/mod.rs index 0e334c191e7b9..e70204d6839fc 100644 --- a/src/libstd/sync/mpsc/mod.rs +++ b/src/libstd/sync/mpsc/mod.rs @@ -286,7 +286,7 @@ mod sync; mod cache_aligned; -/// The receiving half of Rust's [`channel`][] (or [`sync_channel`]) type. +/// The receiving half of Rust's [`channel`] (or [`sync_channel`]) type. /// This half can only be owned by one thread. /// /// Messages sent to the channel can be retrieved using [`recv`]. @@ -558,7 +558,7 @@ pub struct SendError(#[stable(feature = "rust1", since = "1.0.0")] pub T); /// An error returned from the [`recv`] function on a [`Receiver`]. /// /// The [`recv`] operation can only fail if the sending half of a -/// [`channel`][`channel`] (or [`sync_channel`]) is disconnected, implying that no further +/// [`channel`] (or [`sync_channel`]) is disconnected, implying that no further /// messages will ever be received. /// /// [`recv`]: struct.Receiver.html#method.recv @@ -1108,7 +1108,7 @@ impl Receiver { /// /// This function will always block the current thread if there is no data /// available and it's possible for more data to be sent. Once a message is - /// sent to the corresponding [`Sender`][] (or [`SyncSender`]), then this + /// sent to the corresponding [`Sender`] (or [`SyncSender`]), then this /// receiver will wake up and return that message. /// /// If the corresponding [`Sender`] has disconnected, or it disconnects while @@ -1194,7 +1194,7 @@ impl Receiver { /// /// This function will always block the current thread if there is no data /// available and it's possible for more data to be sent. Once a message is - /// sent to the corresponding [`Sender`][] (or [`SyncSender`]), then this + /// sent to the corresponding [`Sender`] (or [`SyncSender`]), then this /// receiver will wake up and return that message. /// /// If the corresponding [`Sender`] has disconnected, or it disconnects while @@ -1295,7 +1295,7 @@ impl Receiver { /// /// This function will always block the current thread if there is no data /// available and it's possible for more data to be sent. Once a message is - /// sent to the corresponding [`Sender`][] (or [`SyncSender`]), then this + /// sent to the corresponding [`Sender`] (or [`SyncSender`]), then this /// receiver will wake up and return that message. /// /// If the corresponding [`Sender`] has disconnected, or it disconnects while diff --git a/src/libstd/sync/rwlock.rs b/src/libstd/sync/rwlock.rs index 2ff36133a7cef..fdd29af858185 100644 --- a/src/libstd/sync/rwlock.rs +++ b/src/libstd/sync/rwlock.rs @@ -25,7 +25,7 @@ use crate::sys_common::rwlock as sys; /// The type parameter `T` represents the data that this lock protects. It is /// required that `T` satisfies [`Send`] to be shared across threads and /// [`Sync`] to allow concurrent access through readers. The RAII guards -/// returned from the locking methods implement [`Deref`][] (and [`DerefMut`] +/// returned from the locking methods implement [`Deref`] (and [`DerefMut`] /// for the `write` methods) to allow access to the content of the lock. /// /// # Poisoning diff --git a/src/libstd/sys/windows/ext/fs.rs b/src/libstd/sys/windows/ext/fs.rs index 0462f889a8e54..d508a333484ae 100644 --- a/src/libstd/sys/windows/ext/fs.rs +++ b/src/libstd/sys/windows/ext/fs.rs @@ -117,7 +117,7 @@ pub trait OpenOptionsExt { /// let file = OpenOptions::new().access_mode(0).open("foo.txt"); /// ``` /// - /// [`CreateFile`]: https://msdn.microsoft.com/en-us/library/windows/desktop/aa363858.aspx + /// [`CreateFile`]: https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfilea #[stable(feature = "open_options_ext", since = "1.10.0")] fn access_mode(&mut self, access: u32) -> &mut Self; @@ -145,7 +145,7 @@ pub trait OpenOptionsExt { /// .open("foo.txt"); /// ``` /// - /// [`CreateFile`]: https://msdn.microsoft.com/en-us/library/windows/desktop/aa363858.aspx + /// [`CreateFile`]: https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfilea #[stable(feature = "open_options_ext", since = "1.10.0")] fn share_mode(&mut self, val: u32) -> &mut Self; @@ -174,8 +174,8 @@ pub trait OpenOptionsExt { /// .open("foo.txt"); /// ``` /// - /// [`CreateFile`]: https://msdn.microsoft.com/en-us/library/windows/desktop/aa363858.aspx - /// [`CreateFile2`]: https://msdn.microsoft.com/en-us/library/windows/desktop/hh449422.aspx + /// [`CreateFile`]: https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfilea + /// [`CreateFile2`]: https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfile2 #[stable(feature = "open_options_ext", since = "1.10.0")] fn custom_flags(&mut self, flags: u32) -> &mut Self; @@ -211,8 +211,8 @@ pub trait OpenOptionsExt { /// .open("foo.txt"); /// ``` /// - /// [`CreateFile`]: https://msdn.microsoft.com/en-us/library/windows/desktop/aa363858.aspx - /// [`CreateFile2`]: https://msdn.microsoft.com/en-us/library/windows/desktop/hh449422.aspx + /// [`CreateFile`]: https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfilea + /// [`CreateFile2`]: https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfile2 #[stable(feature = "open_options_ext", since = "1.10.0")] fn attributes(&mut self, val: u32) -> &mut Self; @@ -254,10 +254,10 @@ pub trait OpenOptionsExt { /// .open(r"\\.\pipe\MyPipe"); /// ``` /// - /// [`CreateFile`]: https://msdn.microsoft.com/en-us/library/windows/desktop/aa363858.aspx - /// [`CreateFile2`]: https://msdn.microsoft.com/en-us/library/windows/desktop/hh449422.aspx + /// [`CreateFile`]: https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfilea + /// [`CreateFile2`]: https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfile2 /// [Impersonation Levels]: - /// https://msdn.microsoft.com/en-us/library/windows/desktop/aa379572.aspx + /// https://docs.microsoft.com/en-us/windows/win32/api/winnt/ne-winnt-security_impersonation_level #[stable(feature = "open_options_ext", since = "1.10.0")] fn security_qos_flags(&mut self, flags: u32) -> &mut OpenOptions; } @@ -297,7 +297,7 @@ impl OpenOptionsExt for OpenOptions { /// /// [`fs::Metadata`]: ../../../../std/fs/struct.Metadata.html /// [`BY_HANDLE_FILE_INFORMATION`]: -/// https://msdn.microsoft.com/en-us/library/windows/desktop/aa363788.aspx +/// https://docs.microsoft.com/en-us/windows/win32/api/fileapi/ns-fileapi-by_handle_file_information #[stable(feature = "metadata_ext", since = "1.1.0")] pub trait MetadataExt { /// Returns the value of the `dwFileAttributes` field of this metadata. @@ -321,7 +321,7 @@ pub trait MetadataExt { /// ``` /// /// [File Attribute Constants]: - /// https://msdn.microsoft.com/en-us/library/windows/desktop/gg258117.aspx + /// https://docs.microsoft.com/en-us/windows/win32/fileio/file-attribute-constants #[stable(feature = "metadata_ext", since = "1.1.0")] fn file_attributes(&self) -> u32; @@ -350,7 +350,7 @@ pub trait MetadataExt { /// } /// ``` /// - /// [`FILETIME`]: https://msdn.microsoft.com/en-us/library/windows/desktop/ms724284.aspx + /// [`FILETIME`]: https://docs.microsoft.com/en-us/windows/win32/api/minwinbase/ns-minwinbase-filetime #[stable(feature = "metadata_ext", since = "1.1.0")] fn creation_time(&self) -> u64; @@ -385,7 +385,7 @@ pub trait MetadataExt { /// } /// ``` /// - /// [`FILETIME`]: https://msdn.microsoft.com/en-us/library/windows/desktop/ms724284.aspx + /// [`FILETIME`]: https://docs.microsoft.com/en-us/windows/win32/api/minwinbase/ns-minwinbase-filetime #[stable(feature = "metadata_ext", since = "1.1.0")] fn last_access_time(&self) -> u64; @@ -418,7 +418,7 @@ pub trait MetadataExt { /// } /// ``` /// - /// [`FILETIME`]: https://msdn.microsoft.com/en-us/library/windows/desktop/ms724284.aspx + /// [`FILETIME`]: https://docs.microsoft.com/en-us/windows/win32/api/minwinbase/ns-minwinbase-filetime #[stable(feature = "metadata_ext", since = "1.1.0")] fn last_write_time(&self) -> u64; diff --git a/src/libstd/sys/windows/ext/process.rs b/src/libstd/sys/windows/ext/process.rs index ed35c5ff19446..8c34a9faf1d4a 100644 --- a/src/libstd/sys/windows/ext/process.rs +++ b/src/libstd/sys/windows/ext/process.rs @@ -99,7 +99,7 @@ pub trait CommandExt { /// /// These will always be ORed with `CREATE_UNICODE_ENVIRONMENT`. /// - /// [1]: https://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx + /// [1]: https://docs.microsoft.com/en-us/windows/win32/procthread/process-creation-flags #[stable(feature = "windows_process_extensions", since = "1.16.0")] fn creation_flags(&mut self, flags: u32) -> &mut process::Command; } diff --git a/src/libstd/sys/windows/mod.rs b/src/libstd/sys/windows/mod.rs index a515b382ab02a..b004cd19020f8 100644 --- a/src/libstd/sys/windows/mod.rs +++ b/src/libstd/sys/windows/mod.rs @@ -262,7 +262,7 @@ pub fn dur2timeout(dur: Duration) -> c::DWORD { // terminating the process but without necessarily bypassing all exception // handlers. // -// https://msdn.microsoft.com/en-us/library/dn774154.aspx +// https://docs.microsoft.com/en-us/cpp/intrinsics/fastfail #[allow(unreachable_code)] pub unsafe fn abort_internal() -> ! { #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] diff --git a/src/libstd/sys/windows/os.rs b/src/libstd/sys/windows/os.rs index e0a1d2f4c0e20..e7fa61dd0f6b9 100644 --- a/src/libstd/sys/windows/os.rs +++ b/src/libstd/sys/windows/os.rs @@ -34,7 +34,7 @@ pub fn error_string(mut errnum: i32) -> String { // NTSTATUS errors may be encoded as HRESULT, which may returned from // GetLastError. For more information about Windows error codes, see - // `[MS-ERREF]`: https://msdn.microsoft.com/en-us/library/cc231198.aspx + // `[MS-ERREF]`: https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-erref/0642cb2f-2075-4469-918c-4441e69c548a if (errnum & c::FACILITY_NT_BIT as i32) != 0 { // format according to https://support.microsoft.com/en-us/help/259693 const NTDLL_DLL: &[u16] = &[ diff --git a/src/libsyntax_pos/lib.rs b/src/libsyntax_pos/lib.rs index 4af552c65617e..a58c12f23508a 100644 --- a/src/libsyntax_pos/lib.rs +++ b/src/libsyntax_pos/lib.rs @@ -13,6 +13,7 @@ #![feature(specialization)] #![feature(step_trait)] +use rustc_data_structures::AtomicRef; use rustc_macros::HashStable_Generic; use rustc_serialize::{Decodable, Decoder, Encodable, Encoder}; @@ -41,7 +42,7 @@ use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; use rustc_data_structures::sync::{Lock, Lrc}; use std::borrow::Cow; -use std::cell::{Cell, RefCell}; +use std::cell::RefCell; use std::cmp::{self, Ordering}; use std::fmt; use std::hash::{Hash, Hasher}; @@ -665,13 +666,13 @@ pub fn default_span_debug(span: Span, f: &mut fmt::Formatter<'_>) -> fmt::Result impl fmt::Debug for Span { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - SPAN_DEBUG.with(|span_debug| span_debug.get()(*self, f)) + (*SPAN_DEBUG)(*self, f) } } impl fmt::Debug for SpanData { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - SPAN_DEBUG.with(|span_debug| span_debug.get()(Span::new(self.lo, self.hi, self.ctxt), f)) + (*SPAN_DEBUG)(Span::new(self.lo, self.hi, self.ctxt), f) } } @@ -1503,8 +1504,8 @@ pub struct FileLines { pub lines: Vec, } -thread_local!(pub static SPAN_DEBUG: Cell) -> fmt::Result> = - Cell::new(default_span_debug)); +pub static SPAN_DEBUG: AtomicRef) -> fmt::Result> = + AtomicRef::new(&(default_span_debug as fn(_, &mut fmt::Formatter<'_>) -> _)); #[derive(Debug)] pub struct MacroBacktrace { diff --git a/src/libterm/lib.rs b/src/libterm/lib.rs index 7318ced676a4c..d2e3b07ab855d 100644 --- a/src/libterm/lib.rs +++ b/src/libterm/lib.rs @@ -27,7 +27,7 @@ //! ``` //! //! [ansi]: https://en.wikipedia.org/wiki/ANSI_escape_code -//! [win]: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682010%28v=vs.85%29.aspx +//! [win]: https://docs.microsoft.com/en-us/windows/console/character-mode-applications //! [ti]: https://en.wikipedia.org/wiki/Terminfo #![doc( diff --git a/src/libterm/win.rs b/src/libterm/win.rs index a789d739ab174..b6c607a30816c 100644 --- a/src/libterm/win.rs +++ b/src/libterm/win.rs @@ -101,7 +101,7 @@ impl WinConsole { unsafe { // Magic -11 means stdout, from - // http://msdn.microsoft.com/en-us/library/windows/desktop/ms683231%28v=vs.85%29.aspx + // https://docs.microsoft.com/en-us/windows/console/getstdhandle // // You may be wondering, "but what about stderr?", and the answer // to that is that setting terminal attributes on the stdout