Skip to content

Rollup of 8 pull requests #78640

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 20 commits into from
Closed
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
3296d5c
Add support for SHA256 source file hashing for LLVM 11+.
arlosi Oct 13, 2020
ad27894
Move compiletest meta tests to a separate directory
tmiasko Oct 30, 2020
affb47f
Add a test for compiletest rustc-env & unset-rustc-env directives
tmiasko Oct 30, 2020
6febaf2
Implement -Z relax-elf-relocations=yes|no
nox Oct 26, 2020
47279b3
Clarify handling of final line ending in str::lines()
autarch Oct 31, 2020
6b63e9b
Do not remove tokens before AST json serialization
petrochenkov Oct 31, 2020
66d68cd
Trivial fixes to bitwise operator documentation
gabhijit Nov 1, 2020
7c88bcc
Fixes incorrect paranthesis.
gabhijit Nov 1, 2020
d422e24
documentation examples fixes in rustfmt convention
gabhijit Nov 1, 2020
b2d7b3a
Remove incorrect statement about line ending content in lines doc change
autarch Nov 1, 2020
a79059d
Point out that total_cmp is no strict superset of partial comparison
est31 Nov 1, 2020
00f32e6
Add fetch_update methods to AtomicBool and AtomicPtr
mystor Nov 1, 2020
3508fa5
Rollup merge of #77950 - arlosi:sha256, r=eddyb
m-ou-se Nov 1, 2020
4a1aec9
Rollup merge of #78575 - tmiasko:compiletest-rustc-env, r=Aaron1011
m-ou-se Nov 1, 2020
92fa615
Rollup merge of #78605 - nox:relax-elf-relocations, r=nagisa
m-ou-se Nov 1, 2020
68ddcad
Rollup merge of #78606 - autarch:patch-1, r=m-ou-se
m-ou-se Nov 1, 2020
b5075b7
Rollup merge of #78610 - petrochenkov:nostriptok, r=Aaron1011
m-ou-se Nov 1, 2020
c43eb4a
Rollup merge of #78620 - gabhijit:bitops_doc_fix, r=m-ou-se
m-ou-se Nov 1, 2020
9a2caba
Rollup merge of #78627 - est31:total_cmp_no_superset, r=m-ou-se
m-ou-se Nov 1, 2020
53eed5a
Rollup merge of #78637 - mystor:atomic_ptr_bool, r=m-ou-se
m-ou-se Nov 1, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 30 additions & 5 deletions Cargo.lock
Original file line number Diff line number Diff line change
@@ -1928,6 +1928,17 @@ dependencies = [
"opaque-debug 0.2.3",
]

[[package]]
name = "md-5"
version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7b5a279bb9607f9f53c22d496eade00d138d1bdcccd07d74650387cf94942a15"
dependencies = [
"block-buffer 0.9.0",
"digest 0.9.0",
"opaque-debug 0.3.0",
]

[[package]]
name = "mdbook"
version = "0.4.3"
@@ -2467,7 +2478,7 @@ checksum = "54be6e404f5317079812fc8f9f5279de376d8856929e21c184ecf6bbd692a11d"
dependencies = [
"maplit",
"pest",
"sha-1",
"sha-1 0.8.2",
]

[[package]]
@@ -3281,14 +3292,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1c267f15c3cfc82a8a441d2bf86bcccf299d1eb625822468e3d8ee6f7c5a1c89"
dependencies = [
"cfg-if 0.1.10",
"md-5",
"md-5 0.8.0",
"rustc-ap-rustc_arena",
"rustc-ap-rustc_data_structures",
"rustc-ap-rustc_index",
"rustc-ap-rustc_macros",
"rustc-ap-rustc_serialize",
"scoped-tls",
"sha-1",
"sha-1 0.8.2",
"tracing",
"unicode-width",
]
@@ -4124,14 +4135,15 @@ name = "rustc_span"
version = "0.0.0"
dependencies = [
"cfg-if 0.1.10",
"md-5",
"md-5 0.9.1",
"rustc_arena",
"rustc_data_structures",
"rustc_index",
"rustc_macros",
"rustc_serialize",
"scoped-tls",
"sha-1",
"sha-1 0.9.1",
"sha2",
"tracing",
"unicode-width",
]
@@ -4496,6 +4508,19 @@ dependencies = [
"opaque-debug 0.2.3",
]

[[package]]
name = "sha-1"
version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "170a36ea86c864a3f16dd2687712dd6646f7019f301e57537c7f4dc9f5916770"
dependencies = [
"block-buffer 0.9.0",
"cfg-if 0.1.10",
"cpuid-bool",
"digest 0.9.0",
"opaque-debug 0.3.0",
]

[[package]]
name = "sha2"
version = "0.9.1"
5 changes: 3 additions & 2 deletions compiler/rustc_ast/src/tokenstream.rs
Original file line number Diff line number Diff line change
@@ -153,8 +153,9 @@ impl fmt::Debug for LazyTokenStream {
}

impl<S: Encoder> Encodable<S> for LazyTokenStream {
fn encode(&self, _s: &mut S) -> Result<(), S::Error> {
panic!("Attempted to encode LazyTokenStream");
fn encode(&self, s: &mut S) -> Result<(), S::Error> {
// Used by AST json printing.
Encodable::encode(&self.create_token_stream(), s)
}
}

6 changes: 5 additions & 1 deletion compiler/rustc_codegen_llvm/src/back/write.rs
Original file line number Diff line number Diff line change
@@ -156,7 +156,11 @@ pub fn target_machine_factory(
let emit_stack_size_section = sess.opts.debugging_opts.emit_stack_sizes;

let asm_comments = sess.asm_comments();
let relax_elf_relocations = sess.target.options.relax_elf_relocations;
let relax_elf_relocations = sess
.opts
.debugging_opts
.relax_elf_relocations
.unwrap_or(sess.target.options.relax_elf_relocations);

let use_init_array = !sess
.opts
1 change: 1 addition & 0 deletions compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs
Original file line number Diff line number Diff line change
@@ -801,6 +801,7 @@ fn file_metadata_raw(
let kind = match hash.kind {
rustc_span::SourceFileHashAlgorithm::Md5 => llvm::ChecksumKind::MD5,
rustc_span::SourceFileHashAlgorithm::Sha1 => llvm::ChecksumKind::SHA1,
rustc_span::SourceFileHashAlgorithm::Sha256 => llvm::ChecksumKind::SHA256,
};
(kind, hex_encode(hash.hash_bytes()))
}
1 change: 1 addition & 0 deletions compiler/rustc_codegen_llvm/src/llvm/ffi.rs
Original file line number Diff line number Diff line change
@@ -558,6 +558,7 @@ pub enum ChecksumKind {
None,
MD5,
SHA1,
SHA256,
}

extern "C" {
90 changes: 2 additions & 88 deletions compiler/rustc_interface/src/passes.rs
Original file line number Diff line number Diff line change
@@ -2,9 +2,8 @@ use crate::interface::{Compiler, Result};
use crate::proc_macro_decls;
use crate::util;

use rustc_ast::mut_visit::{self, MutVisitor};
use rustc_ast::ptr::P;
use rustc_ast::{self as ast, token, visit};
use rustc_ast::mut_visit::MutVisitor;
use rustc_ast::{self as ast, visit};
use rustc_codegen_ssa::back::link::emit_metadata;
use rustc_codegen_ssa::traits::CodegenBackend;
use rustc_data_structures::sync::{par_iter, Lrc, OnceCell, ParallelIterator, WorkerLocal};
@@ -37,7 +36,6 @@ use rustc_span::symbol::Symbol;
use rustc_span::{FileName, RealFileName};
use rustc_trait_selection::traits;
use rustc_typeck as typeck;
use smallvec::SmallVec;
use tracing::{info, warn};

use rustc_serialize::json;
@@ -52,82 +50,6 @@ use std::path::PathBuf;
use std::rc::Rc;
use std::{env, fs, iter, mem};

/// Remove alls `LazyTokenStreams` from an AST struct
/// Normally, this is done during AST lowering. However,
/// printing the AST JSON requires us to serialize
/// the entire AST, and we don't want to serialize
/// a `LazyTokenStream`.
struct TokenStripper;
impl mut_visit::MutVisitor for TokenStripper {
fn flat_map_item(&mut self, mut i: P<ast::Item>) -> SmallVec<[P<ast::Item>; 1]> {
i.tokens = None;
mut_visit::noop_flat_map_item(i, self)
}
fn flat_map_foreign_item(
&mut self,
mut i: P<ast::ForeignItem>,
) -> SmallVec<[P<ast::ForeignItem>; 1]> {
i.tokens = None;
mut_visit::noop_flat_map_foreign_item(i, self)
}
fn flat_map_trait_item(
&mut self,
mut i: P<ast::AssocItem>,
) -> SmallVec<[P<ast::AssocItem>; 1]> {
i.tokens = None;
mut_visit::noop_flat_map_assoc_item(i, self)
}
fn flat_map_impl_item(&mut self, mut i: P<ast::AssocItem>) -> SmallVec<[P<ast::AssocItem>; 1]> {
i.tokens = None;
mut_visit::noop_flat_map_assoc_item(i, self)
}
fn visit_block(&mut self, b: &mut P<ast::Block>) {
b.tokens = None;
mut_visit::noop_visit_block(b, self);
}
fn flat_map_stmt(&mut self, mut stmt: ast::Stmt) -> SmallVec<[ast::Stmt; 1]> {
stmt.tokens = None;
mut_visit::noop_flat_map_stmt(stmt, self)
}
fn visit_pat(&mut self, p: &mut P<ast::Pat>) {
p.tokens = None;
mut_visit::noop_visit_pat(p, self);
}
fn visit_ty(&mut self, ty: &mut P<ast::Ty>) {
ty.tokens = None;
mut_visit::noop_visit_ty(ty, self);
}
fn visit_attribute(&mut self, attr: &mut ast::Attribute) {
attr.tokens = None;
if let ast::AttrKind::Normal(ast::AttrItem { tokens, .. }) = &mut attr.kind {
*tokens = None;
}
mut_visit::noop_visit_attribute(attr, self);
}

fn visit_interpolated(&mut self, nt: &mut token::Nonterminal) {
if let token::Nonterminal::NtMeta(meta) = nt {
meta.tokens = None;
}
// Handles all of the other cases
mut_visit::noop_visit_interpolated(nt, self);
}

fn visit_path(&mut self, p: &mut ast::Path) {
p.tokens = None;
mut_visit::noop_visit_path(p, self);
}
fn visit_vis(&mut self, vis: &mut ast::Visibility) {
vis.tokens = None;
mut_visit::noop_visit_vis(vis, self);
}
fn visit_expr(&mut self, e: &mut P<ast::Expr>) {
e.tokens = None;
mut_visit::noop_visit_expr(e, self);
}
fn visit_mac(&mut self, _mac: &mut ast::MacCall) {}
}

pub fn parse<'a>(sess: &'a Session, input: &Input) -> PResult<'a, ast::Crate> {
let krate = sess.time("parse_crate", || match input {
Input::File(file) => parse_crate_from_file(file, &sess.parse_sess),
@@ -137,10 +59,6 @@ pub fn parse<'a>(sess: &'a Session, input: &Input) -> PResult<'a, ast::Crate> {
})?;

if sess.opts.debugging_opts.ast_json_noexpand {
// Set any `token` fields to `None` before
// we display the AST.
let mut krate = krate.clone();
TokenStripper.visit_crate(&mut krate);
println!("{}", json::as_json(&krate));
}

@@ -461,10 +379,6 @@ fn configure_and_expand_inner<'a>(
}

if sess.opts.debugging_opts.ast_json {
// Set any `token` fields to `None` before
// we display the AST.
let mut krate = krate.clone();
TokenStripper.visit_crate(&mut krate);
println!("{}", json::as_json(&krate));
}

1 change: 1 addition & 0 deletions compiler/rustc_interface/src/tests.rs
Original file line number Diff line number Diff line change
@@ -573,6 +573,7 @@ fn test_debugging_options_tracking_hash() {
tracked!(print_fuel, Some("abc".to_string()));
tracked!(profile, true);
tracked!(profile_emit, Some(PathBuf::from("abc")));
tracked!(relax_elf_relocations, Some(true));
tracked!(relro_level, Some(RelroLevel::Full));
tracked!(report_delayed_bugs, true);
tracked!(run_dsymutil, false);
5 changes: 5 additions & 0 deletions compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
Original file line number Diff line number Diff line change
@@ -648,6 +648,7 @@ enum class LLVMRustChecksumKind {
None,
MD5,
SHA1,
SHA256,
};

static Optional<DIFile::ChecksumKind> fromRust(LLVMRustChecksumKind Kind) {
@@ -658,6 +659,10 @@ static Optional<DIFile::ChecksumKind> fromRust(LLVMRustChecksumKind Kind) {
return DIFile::ChecksumKind::CSK_MD5;
case LLVMRustChecksumKind::SHA1:
return DIFile::ChecksumKind::CSK_SHA1;
#if (LLVM_VERSION_MAJOR >= 11)
case LLVMRustChecksumKind::SHA256:
return DIFile::ChecksumKind::CSK_SHA256;
#endif
default:
report_fatal_error("bad ChecksumKind.");
}
4 changes: 3 additions & 1 deletion compiler/rustc_session/src/options.rs
Original file line number Diff line number Diff line change
@@ -1030,6 +1030,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
"enable queries of the dependency graph for regression testing (default: no)"),
query_stats: bool = (false, parse_bool, [UNTRACKED],
"print some statistics about the query system (default: no)"),
relax_elf_relocations: Option<bool> = (None, parse_opt_bool, [TRACKED],
"whether ELF relocations can be relaxed"),
relro_level: Option<RelroLevel> = (None, parse_relro_level, [TRACKED],
"choose which RELRO level to use"),
report_delayed_bugs: bool = (false, parse_bool, [TRACKED],
@@ -1070,7 +1072,7 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
span_free_formats: bool = (false, parse_bool, [UNTRACKED],
"exclude spans when debug-printing compiler state (default: no)"),
src_hash_algorithm: Option<SourceFileHashAlgorithm> = (None, parse_src_file_hash, [TRACKED],
"hash algorithm of source files in debug info (`md5`, or `sha1`)"),
"hash algorithm of source files in debug info (`md5`, `sha1`, or `sha256`)"),
strip: Strip = (Strip::None, parse_strip, [UNTRACKED],
"tell the linker which information to strip (`none` (default), `debuginfo` or `symbols`)"),
symbol_mangling_version: SymbolManglingVersion = (SymbolManglingVersion::Legacy,
5 changes: 3 additions & 2 deletions compiler/rustc_span/Cargo.toml
Original file line number Diff line number Diff line change
@@ -17,5 +17,6 @@ scoped-tls = "1.0"
unicode-width = "0.1.4"
cfg-if = "0.1.2"
tracing = "0.1"
sha-1 = "0.8"
md-5 = "0.8"
sha-1 = "0.9"
sha2 = "0.9"
md-5 = "0.9"
9 changes: 8 additions & 1 deletion compiler/rustc_span/src/lib.rs
Original file line number Diff line number Diff line change
@@ -59,6 +59,7 @@ use std::str::FromStr;
use md5::Md5;
use sha1::Digest;
use sha1::Sha1;
use sha2::Sha256;

use tracing::debug;

@@ -1034,6 +1035,7 @@ pub struct OffsetOverflowError;
pub enum SourceFileHashAlgorithm {
Md5,
Sha1,
Sha256,
}

impl FromStr for SourceFileHashAlgorithm {
@@ -1043,6 +1045,7 @@ impl FromStr for SourceFileHashAlgorithm {
match s {
"md5" => Ok(SourceFileHashAlgorithm::Md5),
"sha1" => Ok(SourceFileHashAlgorithm::Sha1),
"sha256" => Ok(SourceFileHashAlgorithm::Sha256),
_ => Err(()),
}
}
@@ -1055,7 +1058,7 @@ rustc_data_structures::impl_stable_hash_via_hash!(SourceFileHashAlgorithm);
#[derive(HashStable_Generic, Encodable, Decodable)]
pub struct SourceFileHash {
pub kind: SourceFileHashAlgorithm,
value: [u8; 20],
value: [u8; 32],
}

impl SourceFileHash {
@@ -1071,6 +1074,9 @@ impl SourceFileHash {
SourceFileHashAlgorithm::Sha1 => {
value.copy_from_slice(&Sha1::digest(data));
}
SourceFileHashAlgorithm::Sha256 => {
value.copy_from_slice(&Sha256::digest(data));
}
}
hash
}
@@ -1090,6 +1096,7 @@ impl SourceFileHash {
match self.kind {
SourceFileHashAlgorithm::Md5 => 16,
SourceFileHashAlgorithm::Sha1 => 20,
SourceFileHashAlgorithm::Sha256 => 32,
}
}
}
4 changes: 4 additions & 0 deletions library/core/src/num/f32.rs
Original file line number Diff line number Diff line change
@@ -876,6 +876,10 @@ impl f32 {
/// - Positive signaling NaN
/// - Positive quiet NaN
///
/// Note that this function does not always agree with the [`PartialOrd`]
/// and [`PartialEq`] implementations of `f32`. In particular, they regard
/// negative and positive zero as equal, while `total_cmp` doesn't.
///
/// # Example
/// ```
/// #![feature(total_cmp)]
4 changes: 4 additions & 0 deletions library/core/src/num/f64.rs
Original file line number Diff line number Diff line change
@@ -890,6 +890,10 @@ impl f64 {
/// - Positive signaling NaN
/// - Positive quiet NaN
///
/// Note that this function does not always agree with the [`PartialOrd`]
/// and [`PartialEq`] implementations of `f64`. In particular, they regard
/// negative and positive zero as equal, while `total_cmp` doesn't.
///
/// # Example
/// ```
/// #![feature(total_cmp)]
35 changes: 23 additions & 12 deletions library/core/src/ops/bit.rs
Original file line number Diff line number Diff line change
@@ -109,10 +109,12 @@ not_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 }
/// fn bitand(self, Self(rhs): Self) -> Self::Output {
/// let Self(lhs) = self;
/// assert_eq!(lhs.len(), rhs.len());
/// Self(lhs.iter()
/// Self(
/// lhs.iter()
/// .zip(rhs.iter())
/// .map(|(x, y)| *x && *y)
/// .collect())
/// .map(|(x, y)| *x & *y)
/// .collect()
/// )
/// }
/// }
///
@@ -207,7 +209,12 @@ bitand_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 }
/// fn bitor(self, Self(rhs): Self) -> Self::Output {
/// let Self(lhs) = self;
/// assert_eq!(lhs.len(), rhs.len());
/// Self(lhs.iter().zip(rhs.iter()).map(|(x, y)| *x || *y).collect())
/// Self(
/// lhs.iter()
/// .zip(rhs.iter())
/// .map(|(x, y)| *x | *y)
/// .collect()
/// )
/// }
/// }
///
@@ -302,10 +309,12 @@ bitor_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 }
/// fn bitxor(self, Self(rhs): Self) -> Self::Output {
/// let Self(lhs) = self;
/// assert_eq!(lhs.len(), rhs.len());
/// Self(lhs.iter()
/// Self(
/// lhs.iter()
/// .zip(rhs.iter())
/// .map(|(x, y)| (*x || *y) && !(*x && *y))
/// .collect())
/// .map(|(x, y)| *x ^ *y)
/// .collect()
/// )
/// }
/// }
///
@@ -643,11 +652,13 @@ shr_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize }
/// // `rhs` is the "right-hand side" of the expression `a &= b`.
/// fn bitand_assign(&mut self, rhs: Self) {
/// assert_eq!(self.0.len(), rhs.0.len());
/// *self = Self(self.0
/// .iter()
/// .zip(rhs.0.iter())
/// .map(|(x, y)| *x && *y)
/// .collect());
/// *self = Self(
/// self.0
/// .iter()
/// .zip(rhs.0.iter())
/// .map(|(x, y)| *x & *y)
/// .collect()
/// );
/// }
/// }
///
4 changes: 3 additions & 1 deletion library/core/src/str/mod.rs
Original file line number Diff line number Diff line change
@@ -842,7 +842,9 @@ impl str {
/// Lines are ended with either a newline (`\n`) or a carriage return with
/// a line feed (`\r\n`).
///
/// The final line ending is optional.
/// The final line ending is optional. A string that ends with a final line
/// ending will return the same lines as an otherwise identical string
/// without a final line ending.
///
/// # Examples
///
125 changes: 125 additions & 0 deletions library/core/src/sync/atomic.rs
Original file line number Diff line number Diff line change
@@ -801,6 +801,64 @@ impl AtomicBool {
pub fn as_mut_ptr(&self) -> *mut bool {
self.v.get() as *mut bool
}

/// Fetches the value, and applies a function to it that returns an optional
/// new value. Returns a `Result` of `Ok(previous_value)` if the function
/// returned `Some(_)`, else `Err(previous_value)`.
///
/// Note: This may call the function multiple times if the value has been
/// changed from other threads in the meantime, as long as the function
/// returns `Some(_)`, but the function will have been applied only once to
/// the stored value.
///
/// `fetch_update` takes two [`Ordering`] arguments to describe the memory
/// ordering of this operation. The first describes the required ordering for
/// when the operation finally succeeds while the second describes the
/// required ordering for loads. These correspond to the success and failure
/// orderings of [`AtomicBool::compare_exchange`] respectively.
///
/// Using [`Acquire`] as success ordering makes the store part of this
/// operation [`Relaxed`], and using [`Release`] makes the final successful
/// load [`Relaxed`]. The (failed) load ordering can only be [`SeqCst`],
/// [`Acquire`] or [`Relaxed`] and must be equivalent to or weaker than the
/// success ordering.
///
/// **Note:** This method is only available on platforms that support atomic
/// operations on `u8`.
///
/// # Examples
///
/// ```rust
/// #![feature(atomic_fetch_update)]
/// use std::sync::atomic::{AtomicBool, Ordering};
///
/// let x = AtomicBool::new(false);
/// assert_eq!(x.fetch_update(Ordering::SeqCst, Ordering::SeqCst, |_| None), Err(false));
/// assert_eq!(x.fetch_update(Ordering::SeqCst, Ordering::SeqCst, |x| Some(!x)), Ok(false));
/// assert_eq!(x.fetch_update(Ordering::SeqCst, Ordering::SeqCst, |x| Some(!x)), Ok(true));
/// assert_eq!(x.load(Ordering::SeqCst), false);
/// ```
#[inline]
#[unstable(feature = "atomic_fetch_update", reason = "recently added", issue = "78639")]
#[cfg(target_has_atomic = "8")]
pub fn fetch_update<F>(
&self,
set_order: Ordering,
fetch_order: Ordering,
mut f: F,
) -> Result<bool, bool>
where
F: FnMut(bool) -> Option<bool>,
{
let mut prev = self.load(fetch_order);
while let Some(next) = f(prev) {
match self.compare_exchange_weak(prev, next, set_order, fetch_order) {
x @ Ok(_) => return x,
Err(next_prev) => prev = next_prev,
}
}
Err(prev)
}
}

#[cfg(target_has_atomic_load_store = "ptr")]
@@ -1123,6 +1181,73 @@ impl<T> AtomicPtr<T> {
}
}
}

/// Fetches the value, and applies a function to it that returns an optional
/// new value. Returns a `Result` of `Ok(previous_value)` if the function
/// returned `Some(_)`, else `Err(previous_value)`.
///
/// Note: This may call the function multiple times if the value has been
/// changed from other threads in the meantime, as long as the function
/// returns `Some(_)`, but the function will have been applied only once to
/// the stored value.
///
/// `fetch_update` takes two [`Ordering`] arguments to describe the memory
/// ordering of this operation. The first describes the required ordering for
/// when the operation finally succeeds while the second describes the
/// required ordering for loads. These correspond to the success and failure
/// orderings of [`AtomicPtr::compare_exchange`] respectively.
///
/// Using [`Acquire`] as success ordering makes the store part of this
/// operation [`Relaxed`], and using [`Release`] makes the final successful
/// load [`Relaxed`]. The (failed) load ordering can only be [`SeqCst`],
/// [`Acquire`] or [`Relaxed`] and must be equivalent to or weaker than the
/// success ordering.
///
/// **Note:** This method is only available on platforms that support atomic
/// operations on pointers.
///
/// # Examples
///
/// ```rust
/// #![feature(atomic_fetch_update)]
/// use std::sync::atomic::{AtomicPtr, Ordering};
///
/// let ptr: *mut _ = &mut 5;
/// let some_ptr = AtomicPtr::new(ptr);
///
/// let new: *mut _ = &mut 10;
/// assert_eq!(some_ptr.fetch_update(Ordering::SeqCst, Ordering::SeqCst, |_| None), Err(ptr));
/// let result = some_ptr.fetch_update(Ordering::SeqCst, Ordering::SeqCst, |x| {
/// if x == ptr {
/// Some(new)
/// } else {
/// None
/// }
/// });
/// assert_eq!(result, Ok(ptr));
/// assert_eq!(some_ptr.load(Ordering::SeqCst), new);
/// ```
#[inline]
#[unstable(feature = "atomic_fetch_update", reason = "recently added", issue = "78639")]
#[cfg(target_has_atomic = "ptr")]
pub fn fetch_update<F>(
&self,
set_order: Ordering,
fetch_order: Ordering,
mut f: F,
) -> Result<*mut T, *mut T>
where
F: FnMut(*mut T) -> Option<*mut T>,
{
let mut prev = self.load(fetch_order);
while let Some(next) = f(prev) {
match self.compare_exchange_weak(prev, next, set_order, fetch_order) {
x @ Ok(_) => return x,
Err(next_prev) => prev = next_prev,
}
}
Err(prev)
}
}

#[cfg(target_has_atomic_load_store = "8")]
Original file line number Diff line number Diff line change
@@ -6,6 +6,6 @@ The tracking issue for this feature is: [#70401](https://github.com/rust-lang/ru

The `-Z src-hash-algorithm` compiler flag controls which algorithm is used when hashing each source file. The hash is stored in the debug info and can be used by a debugger to verify the source code matches the executable.

Supported hash algorithms are: `md5`, and `sha1`. Note that not all hash algorithms are supported by all debug info formats.
Supported hash algorithms are: `md5`, `sha1`, and `sha256`. Note that not all hash algorithms are supported by all debug info formats.

By default, the compiler chooses the hash algorithm based on the target specification.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// compile-flags: -g -Z src-hash-algorithm=sha256
// min-llvm-version: 11.0

#![crate_type = "lib"]

pub fn test() {}
// CHECK: checksumkind: CSK_SHA256
23 changes: 23 additions & 0 deletions src/test/ui/ast-json/ast-json-ice.rs
Original file line number Diff line number Diff line change
@@ -39,3 +39,26 @@ fn main() {

struct A;
}

// Regressions tests for issues #78398 and #78510 (captured tokens in associated and foreign items)

struct S;

macro_rules! mac_extern {
($i:item) => {
extern "C" { $i }
}
}
macro_rules! mac_assoc {
($i:item) => {
impl S { $i }
trait Bar { $i }
}
}

mac_extern! {
fn foo();
}
mac_assoc! {
fn foo() {}
}
2 changes: 1 addition & 1 deletion src/test/ui/ast-json/ast-json-noexpand-output.stdout
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"module":{"inner":{"lo":0,"hi":0},"unsafety":"No","items":[{"attrs":[],"id":0,"span":{"lo":0,"hi":0},"vis":{"kind":"Inherited","span":{"lo":0,"hi":0},"tokens":null},"ident":{"name":"core","span":{"lo":0,"hi":0}},"kind":{"variant":"ExternCrate","fields":[null]},"tokens":null}],"inline":true},"attrs":[{"kind":{"variant":"Normal","fields":[{"path":{"span":{"lo":0,"hi":0},"segments":[{"ident":{"name":"crate_type","span":{"lo":0,"hi":0}},"id":0,"args":null}],"tokens":null},"args":{"variant":"Eq","fields":[{"lo":0,"hi":0},{"0":[[{"variant":"Token","fields":[{"kind":{"variant":"Literal","fields":[{"kind":"Str","symbol":"lib","suffix":null}]},"span":{"lo":0,"hi":0}}]},"Alone"]]}]},"tokens":null}]},"id":null,"style":"Inner","span":{"lo":0,"hi":0},"tokens":null}],"span":{"lo":0,"hi":0},"proc_macros":[]}
{"module":{"inner":{"lo":0,"hi":0},"unsafety":"No","items":[{"attrs":[],"id":0,"span":{"lo":0,"hi":0},"vis":{"kind":"Inherited","span":{"lo":0,"hi":0},"tokens":null},"ident":{"name":"core","span":{"lo":0,"hi":0}},"kind":{"variant":"ExternCrate","fields":[null]},"tokens":null}],"inline":true},"attrs":[{"kind":{"variant":"Normal","fields":[{"path":{"span":{"lo":0,"hi":0},"segments":[{"ident":{"name":"crate_type","span":{"lo":0,"hi":0}},"id":0,"args":null}],"tokens":null},"args":{"variant":"Eq","fields":[{"lo":0,"hi":0},{"0":[[{"variant":"Token","fields":[{"kind":{"variant":"Literal","fields":[{"kind":"Str","symbol":"lib","suffix":null}]},"span":{"lo":0,"hi":0}}]},"Alone"]]}]},"tokens":null}]},"id":null,"style":"Inner","span":{"lo":0,"hi":0},"tokens":{"0":[[{"variant":"Token","fields":[{"kind":"Pound","span":{"lo":0,"hi":0}}]},"Joint"],[{"variant":"Token","fields":[{"kind":"Not","span":{"lo":0,"hi":0}}]},"Alone"],[{"variant":"Delimited","fields":[{"open":{"lo":0,"hi":0},"close":{"lo":0,"hi":0}},"Bracket",{"0":[[{"variant":"Token","fields":[{"kind":{"variant":"Ident","fields":["crate_type",false]},"span":{"lo":0,"hi":0}}]},"Alone"],[{"variant":"Token","fields":[{"kind":"Eq","span":{"lo":0,"hi":0}}]},"Alone"],[{"variant":"Token","fields":[{"kind":{"variant":"Literal","fields":[{"kind":"Str","symbol":"lib","suffix":null}]},"span":{"lo":0,"hi":0}}]},"Alone"]]}]},"Alone"]]}}],"span":{"lo":0,"hi":0},"proc_macros":[]}
2 changes: 1 addition & 1 deletion src/test/ui/ast-json/ast-json-output.stdout
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"module":{"inner":{"lo":0,"hi":0},"unsafety":"No","items":[{"attrs":[{"kind":{"variant":"Normal","fields":[{"path":{"span":{"lo":0,"hi":0},"segments":[{"ident":{"name":"prelude_import","span":{"lo":0,"hi":0}},"id":0,"args":null}],"tokens":null},"args":"Empty","tokens":null}]},"id":null,"style":"Outer","span":{"lo":0,"hi":0},"tokens":null}],"id":0,"span":{"lo":0,"hi":0},"vis":{"kind":"Inherited","span":{"lo":0,"hi":0},"tokens":null},"ident":{"name":"","span":{"lo":0,"hi":0}},"kind":{"variant":"Use","fields":[{"prefix":{"span":{"lo":0,"hi":0},"segments":[{"ident":{"name":"{{root}}","span":{"lo":0,"hi":0}},"id":0,"args":null},{"ident":{"name":"std","span":{"lo":0,"hi":0}},"id":0,"args":null},{"ident":{"name":"prelude","span":{"lo":0,"hi":0}},"id":0,"args":null},{"ident":{"name":"v1","span":{"lo":0,"hi":0}},"id":0,"args":null}],"tokens":null},"kind":"Glob","span":{"lo":0,"hi":0}}]},"tokens":null},{"attrs":[{"kind":{"variant":"Normal","fields":[{"path":{"span":{"lo":0,"hi":0},"segments":[{"ident":{"name":"macro_use","span":{"lo":0,"hi":0}},"id":0,"args":null}],"tokens":null},"args":"Empty","tokens":null}]},"id":null,"style":"Outer","span":{"lo":0,"hi":0},"tokens":null}],"id":0,"span":{"lo":0,"hi":0},"vis":{"kind":"Inherited","span":{"lo":0,"hi":0},"tokens":null},"ident":{"name":"std","span":{"lo":0,"hi":0}},"kind":{"variant":"ExternCrate","fields":[null]},"tokens":null},{"attrs":[],"id":0,"span":{"lo":0,"hi":0},"vis":{"kind":"Inherited","span":{"lo":0,"hi":0},"tokens":null},"ident":{"name":"core","span":{"lo":0,"hi":0}},"kind":{"variant":"ExternCrate","fields":[null]},"tokens":null}],"inline":true},"attrs":[{"kind":{"variant":"Normal","fields":[{"path":{"span":{"lo":0,"hi":0},"segments":[{"ident":{"name":"crate_type","span":{"lo":0,"hi":0}},"id":0,"args":null}],"tokens":null},"args":{"variant":"Eq","fields":[{"lo":0,"hi":0},{"0":[[{"variant":"Token","fields":[{"kind":{"variant":"Literal","fields":[{"kind":"Str","symbol":"lib","suffix":null}]},"span":{"lo":0,"hi":0}}]},"Alone"]]}]},"tokens":null}]},"id":null,"style":"Inner","span":{"lo":0,"hi":0},"tokens":null}],"span":{"lo":0,"hi":0},"proc_macros":[]}
{"module":{"inner":{"lo":0,"hi":0},"unsafety":"No","items":[{"attrs":[{"kind":{"variant":"Normal","fields":[{"path":{"span":{"lo":0,"hi":0},"segments":[{"ident":{"name":"prelude_import","span":{"lo":0,"hi":0}},"id":0,"args":null}],"tokens":null},"args":"Empty","tokens":null}]},"id":null,"style":"Outer","span":{"lo":0,"hi":0},"tokens":null}],"id":0,"span":{"lo":0,"hi":0},"vis":{"kind":"Inherited","span":{"lo":0,"hi":0},"tokens":null},"ident":{"name":"","span":{"lo":0,"hi":0}},"kind":{"variant":"Use","fields":[{"prefix":{"span":{"lo":0,"hi":0},"segments":[{"ident":{"name":"{{root}}","span":{"lo":0,"hi":0}},"id":0,"args":null},{"ident":{"name":"std","span":{"lo":0,"hi":0}},"id":0,"args":null},{"ident":{"name":"prelude","span":{"lo":0,"hi":0}},"id":0,"args":null},{"ident":{"name":"v1","span":{"lo":0,"hi":0}},"id":0,"args":null}],"tokens":null},"kind":"Glob","span":{"lo":0,"hi":0}}]},"tokens":null},{"attrs":[{"kind":{"variant":"Normal","fields":[{"path":{"span":{"lo":0,"hi":0},"segments":[{"ident":{"name":"macro_use","span":{"lo":0,"hi":0}},"id":0,"args":null}],"tokens":null},"args":"Empty","tokens":null}]},"id":null,"style":"Outer","span":{"lo":0,"hi":0},"tokens":null}],"id":0,"span":{"lo":0,"hi":0},"vis":{"kind":"Inherited","span":{"lo":0,"hi":0},"tokens":null},"ident":{"name":"std","span":{"lo":0,"hi":0}},"kind":{"variant":"ExternCrate","fields":[null]},"tokens":null},{"attrs":[],"id":0,"span":{"lo":0,"hi":0},"vis":{"kind":"Inherited","span":{"lo":0,"hi":0},"tokens":null},"ident":{"name":"core","span":{"lo":0,"hi":0}},"kind":{"variant":"ExternCrate","fields":[null]},"tokens":null}],"inline":true},"attrs":[{"kind":{"variant":"Normal","fields":[{"path":{"span":{"lo":0,"hi":0},"segments":[{"ident":{"name":"crate_type","span":{"lo":0,"hi":0}},"id":0,"args":null}],"tokens":null},"args":{"variant":"Eq","fields":[{"lo":0,"hi":0},{"0":[[{"variant":"Token","fields":[{"kind":{"variant":"Literal","fields":[{"kind":"Str","symbol":"lib","suffix":null}]},"span":{"lo":0,"hi":0}}]},"Alone"]]}]},"tokens":null}]},"id":null,"style":"Inner","span":{"lo":0,"hi":0},"tokens":{"0":[[{"variant":"Token","fields":[{"kind":"Pound","span":{"lo":0,"hi":0}}]},"Joint"],[{"variant":"Token","fields":[{"kind":"Not","span":{"lo":0,"hi":0}}]},"Alone"],[{"variant":"Delimited","fields":[{"open":{"lo":0,"hi":0},"close":{"lo":0,"hi":0}},"Bracket",{"0":[[{"variant":"Token","fields":[{"kind":{"variant":"Ident","fields":["crate_type",false]},"span":{"lo":0,"hi":0}}]},"Alone"],[{"variant":"Token","fields":[{"kind":"Eq","span":{"lo":0,"hi":0}}]},"Alone"],[{"variant":"Token","fields":[{"kind":{"variant":"Literal","fields":[{"kind":"Str","symbol":"lib","suffix":null}]},"span":{"lo":0,"hi":0}}]},"Alone"]]}]},"Alone"]]}}],"span":{"lo":0,"hi":0},"proc_macros":[]}
18 changes: 0 additions & 18 deletions src/test/ui/ast-json/issue-78398-foreign-ice.rs

This file was deleted.

1 change: 0 additions & 1 deletion src/test/ui/ast-json/issue-78398-foreign-ice.stdout

This file was deleted.

18 changes: 0 additions & 18 deletions src/test/ui/ast-json/issue-78510-assoc-ice.rs

This file was deleted.

15 changes: 0 additions & 15 deletions src/test/ui/ast-json/issue-78510-assoc-ice.stderr

This file was deleted.

1 change: 0 additions & 1 deletion src/test/ui/ast-json/issue-78510-assoc-ice.stdout

This file was deleted.

9 changes: 9 additions & 0 deletions src/test/ui/meta/auxiliary/env.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Check that aux builds can also use rustc-env, but environment is configured
// separately from the main test case.
//
// rustc-env:COMPILETEST_BAR=bar

pub fn test() {
assert_eq!(option_env!("COMPILETEST_FOO"), None);
assert_eq!(env!("COMPILETEST_BAR"), "bar");
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0308]: mismatched types
--> $DIR/meta-expected-error-correct-rev.rs:7:18
--> $DIR/expected-error-correct-rev.rs:7:18
|
LL | let x: u32 = 22_usize;
| --- ^^^^^^^^ expected `u32`, found `usize`
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// revisions: a

// Counterpart to `meta-expected-error-wrong-rev.rs`
// Counterpart to `expected-error-wrong-rev.rs`

#[cfg(a)]
fn foo() {
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Meta test for compiletest: check that when we give the right error
// patterns, the test passes. See all `meta-revision-bad.rs`.
// patterns, the test passes. See all `revision-bad.rs`.

// run-fail
// revisions: foo bar
18 changes: 18 additions & 0 deletions src/test/ui/meta/rustc-env.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Compiletest meta test checking that rustc-env and unset-rustc-env directives
// can be used to configure environment for rustc.
//
// run-pass
// aux-build:env.rs
// rustc-env:COMPILETEST_FOO=foo
//
// An environment variable that is likely to be set, but should be safe to unset.
// unset-rustc-env:PWD

extern crate env;

fn main() {
assert_eq!(env!("COMPILETEST_FOO"), "foo");
assert_eq!(option_env!("COMPILETEST_BAR"), None);
assert_eq!(option_env!("PWD"), None);
env::test();
}
2 changes: 2 additions & 0 deletions src/tools/tidy/src/deps.rs
Original file line number Diff line number Diff line change
@@ -80,6 +80,7 @@ const PERMITTED_DEPENDENCIES: &[&str] = &[
"cloudabi",
"cmake",
"compiler_builtins",
"cpuid-bool",
"crc32fast",
"crossbeam-deque",
"crossbeam-epoch",
@@ -160,6 +161,7 @@ const PERMITTED_DEPENDENCIES: &[&str] = &[
"serde",
"serde_derive",
"sha-1",
"sha2",
"smallvec",
"snap",
"stable_deref_trait",