Skip to content

Rollup of 13 pull requests #85483

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 39 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
3f5f54c
Update list of allowed aarch64 features
adamgemmell Apr 28, 2021
5353c5c
Move `std::memchr` to `sys_common`
CDirkx May 14, 2021
67e8f12
Expose `Concurrent` (private type in public i'face)
eggyal May 14, 2021
f054ce3
:arrow_up: rust-analyzer
lnicola May 17, 2021
445658b
PassWrapper: update for LLVM change D102093
durin42 May 17, 2021
d730cc6
Add diagnostic item to `CStr`
mgacek8 May 18, 2021
24480de
Add method-toggle to <details> for methods.
jsha May 10, 2021
f9752b4
Fix UB in documented example for `ptr::swap`
steffahn May 19, 2021
5b09085
Introduce `sys_common::rt::rterr!`
CDirkx Apr 29, 2021
b987f74
Remove `sys_common::util::abort`
CDirkx Apr 29, 2021
236705f
Replace `sys_common::util::report_overflow` with `rterr!`
CDirkx Apr 29, 2021
6145051
Replace `sys_common::util::dumb_print` with `rterr!`
CDirkx Apr 29, 2021
ec32bcf
Fix invalid CSS rules for a:hover
GuillaumeGomez May 19, 2021
4ff5ab5
Rename `rterr` to `rtprintpanic`
CDirkx May 6, 2021
50a9f00
CTFE Machine: do not expose Allocation
RalfJung May 19, 2021
523b4d1
Remove LSE2
adamgemmell May 19, 2021
c71e58d
Rename fptoint to frintts
adamgemmell May 19, 2021
904467a
Ensure all crypto components (AES, PMULL, SHA1/2) are available on ar…
adamgemmell May 19, 2021
d3737a6
Remove test for crypto feature ahead of its removal
adamgemmell May 19, 2021
f061265
Move the implementation of `Path::exists` to `sys_common::fs` so plat…
ChrisDenton Mar 17, 2021
5d7c75a
Windows implementation of `fs::try_exists`
ChrisDenton May 18, 2021
39441bb
Make a ui test to take the role of libproc_macro #[test] tests
dtolnay Apr 29, 2021
3c16c0e
Move proc_macro tests to ui test
dtolnay Apr 29, 2021
faad7e2
Make a more meaningful test for Punct eq
dtolnay Apr 29, 2021
965bce4
Add proc macro Literal parse test
dtolnay Apr 29, 2021
34585cb
impl FromStr for proc_macro::Literal
dtolnay Apr 29, 2021
c9a2c81
Rollup merge of #84665 - adamgemmell:aarch64-features, r=Amanieu
Dylan-DPC May 19, 2021
ec9b360
Rollup merge of #84697 - CDirkx:util, r=m-ou-se
Dylan-DPC May 19, 2021
f5d308e
Rollup merge of #84717 - dtolnay:literalfromstr, r=petrochenkov
Dylan-DPC May 19, 2021
d7c0dd5
Rollup merge of #85060 - ChrisDenton:win-file-exists, r=yaahc
Dylan-DPC May 19, 2021
7a67602
Rollup merge of #85169 - jsha:hoist-classes, r=GuillaumeGomez
Dylan-DPC May 19, 2021
a7e725f
Rollup merge of #85275 - CDirkx:memchr, r=m-ou-se
Dylan-DPC May 19, 2021
1dd7694
Rollup merge of #85287 - eggyal:expose-test-concurrent, r=m-ou-se
Dylan-DPC May 19, 2021
e9dff04
Rollup merge of #85400 - lnicola:rust-analyzer-2021-05-17, r=jonas-sc…
Dylan-DPC May 19, 2021
2af1b8c
Rollup merge of #85416 - durin42:llvm-catchup-may-2021, r=nagisa
Dylan-DPC May 19, 2021
4e4094e
Rollup merge of #85439 - mgacek8:add_diagnostic_item_to_CStr_type, r=…
Dylan-DPC May 19, 2021
9d2aa4e
Rollup merge of #85464 - steffahn:fix_ub_in_ptr_swap_docs, r=dtolnay
Dylan-DPC May 19, 2021
deaaa1d
Rollup merge of #85470 - GuillaumeGomez:fix-css-rules, r=jsha
Dylan-DPC May 19, 2021
21007ee
Rollup merge of #85472 - RalfJung:allocation, r=oli-obk
Dylan-DPC May 19, 2021
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
6 changes: 6 additions & 0 deletions compiler/rustc_codegen_llvm/src/llvm_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,12 @@ pub fn to_llvm_feature<'a>(sess: &Session, s: &'a str) -> &'a str {
("x86", "avx512vpclmulqdq") => "vpclmulqdq",
("aarch64", "fp") => "fp-armv8",
("aarch64", "fp16") => "fullfp16",
("aarch64", "fhm") => "fp16fml",
("aarch64", "rcpc2") => "rcpc-immo",
("aarch64", "dpb") => "ccpp",
("aarch64", "dpb2") => "ccdp",
("aarch64", "frintts") => "fptoint",
("aarch64", "fcma") => "complxnum",
(_, s) => s,
}
}
Expand Down
79 changes: 77 additions & 2 deletions compiler/rustc_codegen_ssa/src/target_features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ const ARM_ALLOWED_FEATURES: &[(&str, Option<Symbol>)] = &[
("neon", Some(sym::arm_target_feature)),
("crc", Some(sym::arm_target_feature)),
("crypto", Some(sym::arm_target_feature)),
("aes", Some(sym::arm_target_feature)),
("sha2", Some(sym::arm_target_feature)),
("v5te", Some(sym::arm_target_feature)),
("v6", Some(sym::arm_target_feature)),
("v6k", Some(sym::arm_target_feature)),
Expand All @@ -33,22 +35,95 @@ const ARM_ALLOWED_FEATURES: &[(&str, Option<Symbol>)] = &[
("thumb-mode", Some(sym::arm_target_feature)),
];

// Commented features are not available in LLVM 10.0, or have since been renamed
const AARCH64_ALLOWED_FEATURES: &[(&str, Option<Symbol>)] = &[
("fp", Some(sym::aarch64_target_feature)),
// FEAT_AdvSimd
("neon", Some(sym::aarch64_target_feature)),
// FEAT_FP
("fp", Some(sym::aarch64_target_feature)),
// FEAT_FP16
("fp16", Some(sym::aarch64_target_feature)),
// FEAT_SVE
("sve", Some(sym::aarch64_target_feature)),
// FEAT_CRC
("crc", Some(sym::aarch64_target_feature)),
// Cryptographic extension
("crypto", Some(sym::aarch64_target_feature)),
// FEAT_RAS
("ras", Some(sym::aarch64_target_feature)),
// FEAT_LSE
("lse", Some(sym::aarch64_target_feature)),
// FEAT_RDM
("rdm", Some(sym::aarch64_target_feature)),
("fp16", Some(sym::aarch64_target_feature)),
// FEAT_RCPC
("rcpc", Some(sym::aarch64_target_feature)),
// FEAT_RCPC2
("rcpc2", Some(sym::aarch64_target_feature)),
// FEAT_DotProd
("dotprod", Some(sym::aarch64_target_feature)),
// FEAT_TME
("tme", Some(sym::aarch64_target_feature)),
// FEAT_FHM
("fhm", Some(sym::aarch64_target_feature)),
// FEAT_DIT
("dit", Some(sym::aarch64_target_feature)),
// FEAT_FLAGM
// ("flagm", Some(sym::aarch64_target_feature)),
// FEAT_SSBS
("ssbs", Some(sym::aarch64_target_feature)),
// FEAT_SB
("sb", Some(sym::aarch64_target_feature)),
// FEAT_PAUTH
// ("pauth", Some(sym::aarch64_target_feature)),
// FEAT_DPB
("dpb", Some(sym::aarch64_target_feature)),
// FEAT_DPB2
("dpb2", Some(sym::aarch64_target_feature)),
// FEAT_SVE2
("sve2", Some(sym::aarch64_target_feature)),
// FEAT_SVE2_AES
("sve2-aes", Some(sym::aarch64_target_feature)),
// FEAT_SVE2_SM4
("sve2-sm4", Some(sym::aarch64_target_feature)),
// FEAT_SVE2_SHA3
("sve2-sha3", Some(sym::aarch64_target_feature)),
// FEAT_SVE2_BitPerm
("sve2-bitperm", Some(sym::aarch64_target_feature)),
// FEAT_FRINTTS
("frintts", Some(sym::aarch64_target_feature)),
// FEAT_I8MM
// ("i8mm", Some(sym::aarch64_target_feature)),
// FEAT_F32MM
// ("f32mm", Some(sym::aarch64_target_feature)),
// FEAT_F64MM
// ("f64mm", Some(sym::aarch64_target_feature)),
// FEAT_BF16
// ("bf16", Some(sym::aarch64_target_feature)),
// FEAT_RAND
("rand", Some(sym::aarch64_target_feature)),
// FEAT_BTI
("bti", Some(sym::aarch64_target_feature)),
// FEAT_MTE
("mte", Some(sym::aarch64_target_feature)),
// FEAT_JSCVT
("jsconv", Some(sym::aarch64_target_feature)),
// FEAT_FCMA
("fcma", Some(sym::aarch64_target_feature)),
// FEAT_AES
("aes", Some(sym::aarch64_target_feature)),
// FEAT_SHA1 & FEAT_SHA256
("sha2", Some(sym::aarch64_target_feature)),
// FEAT_SHA512 & FEAT_SHA3
("sha3", Some(sym::aarch64_target_feature)),
// FEAT_SM3 & FEAT_SM4
("sm4", Some(sym::aarch64_target_feature)),
("v8.1a", Some(sym::aarch64_target_feature)),
("v8.2a", Some(sym::aarch64_target_feature)),
("v8.3a", Some(sym::aarch64_target_feature)),
("v8.4a", Some(sym::aarch64_target_feature)),
("v8.5a", Some(sym::aarch64_target_feature)),
// ("v8.6a", Some(sym::aarch64_target_feature)),
// ("v8.7a", Some(sym::aarch64_target_feature)),
];

const X86_ALLOWED_FEATURES: &[(&str, Option<Symbol>)] = &[
Expand Down
31 changes: 28 additions & 3 deletions compiler/rustc_expand/src/proc_macro_server.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
use crate::base::{ExtCtxt, ResolverExpand};

use rustc_ast as ast;
use rustc_ast::token;
use rustc_ast::token::Nonterminal;
use rustc_ast::token::NtIdent;
use rustc_ast::token::{self, Nonterminal, NtIdent, TokenKind};
use rustc_ast::tokenstream::{self, CanSynthesizeMissingTokens};
use rustc_ast::tokenstream::{DelimSpan, Spacing::*, TokenStream, TreeAndSpacing};
use rustc_ast_pretty::pprust;
Expand Down Expand Up @@ -541,6 +539,33 @@ impl server::Ident for Rustc<'_> {
}

impl server::Literal for Rustc<'_> {
fn from_str(&mut self, s: &str) -> Result<Self::Literal, ()> {
let override_span = None;
let stream = parse_stream_from_source_str(
FileName::proc_macro_source_code(s),
s.to_owned(),
self.sess,
override_span,
);
if stream.len() != 1 {
return Err(());
}
let tree = stream.into_trees().next().unwrap();
let token = match tree {
tokenstream::TokenTree::Token(token) => token,
tokenstream::TokenTree::Delimited { .. } => return Err(()),
};
let span_data = token.span.data();
if (span_data.hi.0 - span_data.lo.0) as usize != s.len() {
// There is a comment or whitespace adjacent to the literal.
return Err(());
}
let lit = match token.kind {
TokenKind::Literal(lit) => lit,
_ => return Err(()),
};
Ok(Literal { lit, span: self.call_site })
}
fn debug_kind(&mut self, literal: &Self::Literal) -> String {
format!("{:?}", literal.lit.kind)
}
Expand Down
13 changes: 12 additions & 1 deletion compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -793,16 +793,23 @@ LLVMRustOptimizeWithNewPassManager(
PGOOpt = PGOOptions(PGOUsePath, "", "", PGOOptions::IRUse);
}

#if LLVM_VERSION_GE(12, 0)
#if LLVM_VERSION_GE(12, 0) && !LLVM_VERSION_GE(13,0)
PassBuilder PB(DebugPassManager, TM, PTO, PGOOpt, &PIC);
#else
PassBuilder PB(TM, PTO, PGOOpt, &PIC);
#endif

#if LLVM_VERSION_GE(13, 0)
LoopAnalysisManager LAM;
FunctionAnalysisManager FAM;
CGSCCAnalysisManager CGAM;
ModuleAnalysisManager MAM;
#else
LoopAnalysisManager LAM(DebugPassManager);
FunctionAnalysisManager FAM(DebugPassManager);
CGSCCAnalysisManager CGAM(DebugPassManager);
ModuleAnalysisManager MAM(DebugPassManager);
#endif

FAM.registerPass([&] { return PB.buildDefaultAAPipeline(); });

Expand Down Expand Up @@ -956,7 +963,11 @@ LLVMRustOptimizeWithNewPassManager(
}
}

#if LLVM_VERSION_GE(13, 0)
ModulePassManager MPM;
#else
ModulePassManager MPM(DebugPassManager);
#endif
bool NeedThinLTOBufferPasses = UseThinLTOBuffers;
if (!NoPrepopulatePasses) {
if (OptLevel == PassBuilder::OptimizationLevel::O0) {
Expand Down
7 changes: 4 additions & 3 deletions compiler/rustc_mir/src/interpret/machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ pub trait Machine<'mir, 'tcx>: Sized {
#[inline(always)]
fn memory_read(
_memory_extra: &Self::MemoryExtra,
_alloc: &Allocation<Self::PointerTag, Self::AllocExtra>,
_alloc_extra: &Self::AllocExtra,
_ptr: Pointer<Self::PointerTag>,
_size: Size,
) -> InterpResult<'tcx> {
Expand All @@ -324,7 +324,7 @@ pub trait Machine<'mir, 'tcx>: Sized {
#[inline(always)]
fn memory_written(
_memory_extra: &mut Self::MemoryExtra,
_alloc: &mut Allocation<Self::PointerTag, Self::AllocExtra>,
_alloc_extra: &mut Self::AllocExtra,
_ptr: Pointer<Self::PointerTag>,
_size: Size,
) -> InterpResult<'tcx> {
Expand All @@ -335,8 +335,9 @@ pub trait Machine<'mir, 'tcx>: Sized {
#[inline(always)]
fn memory_deallocated(
_memory_extra: &mut Self::MemoryExtra,
_alloc: &mut Allocation<Self::PointerTag, Self::AllocExtra>,
_alloc_extra: &mut Self::AllocExtra,
_ptr: Pointer<Self::PointerTag>,
_size: Size,
) -> InterpResult<'tcx> {
Ok(())
}
Expand Down
13 changes: 7 additions & 6 deletions compiler/rustc_mir/src/interpret/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -343,10 +343,11 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
}

// Let the machine take some extra action
M::memory_deallocated(&mut self.extra, &mut alloc, ptr)?;
let size = alloc.size();
M::memory_deallocated(&mut self.extra, &mut alloc.extra, ptr, size)?;

// Don't forget to remember size and align of this now-dead allocation
let old = self.dead_alloc_map.insert(ptr.alloc_id, (alloc.size(), alloc.align));
let old = self.dead_alloc_map.insert(ptr.alloc_id, (size, alloc.align));
if old.is_some() {
bug!("Nothing can be deallocated twice");
}
Expand Down Expand Up @@ -591,7 +592,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
},
)?;
if let Some((ptr, alloc)) = ptr_and_alloc {
M::memory_read(&self.extra, alloc, ptr, size)?;
M::memory_read(&self.extra, &alloc.extra, ptr, size)?;
let range = alloc_range(ptr.offset, size);
Ok(Some(AllocRef { alloc, range, tcx: self.tcx, alloc_id: ptr.alloc_id }))
} else {
Expand Down Expand Up @@ -660,7 +661,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
// FIXME: can we somehow avoid looking up the allocation twice here?
// We cannot call `get_raw_mut` inside `check_and_deref_ptr` as that would duplicate `&mut self`.
let (alloc, extra) = self.get_raw_mut(ptr.alloc_id)?;
M::memory_written(extra, alloc, ptr, size)?;
M::memory_written(extra, &mut alloc.extra, ptr, size)?;
let range = alloc_range(ptr.offset, size);
Ok(Some(AllocRefMut { alloc, range, tcx, alloc_id: ptr.alloc_id }))
} else {
Expand Down Expand Up @@ -1029,7 +1030,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
Some(src_ptr) => src_ptr,
};
let src_alloc = self.get_raw(src.alloc_id)?;
M::memory_read(&self.extra, src_alloc, src, size)?;
M::memory_read(&self.extra, &src_alloc.extra, src, size)?;
// We need the `dest` ptr for the next operation, so we get it now.
// We already did the source checks and called the hooks so we are good to return early.
let dest = match dest {
Expand Down Expand Up @@ -1058,7 +1059,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {

// Destination alloc preparations and access hooks.
let (dest_alloc, extra) = self.get_raw_mut(dest.alloc_id)?;
M::memory_written(extra, dest_alloc, dest, size * num_copies)?;
M::memory_written(extra, &mut dest_alloc.extra, dest, size * num_copies)?;
let dest_bytes = dest_alloc
.get_bytes_mut_ptr(&tcx, alloc_range(dest.offset, size * num_copies))
.as_mut_ptr();
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_span/src/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ symbols! {
Borrow,
Break,
C,
CStr,
CString,
Center,
Clone,
Expand Down
8 changes: 5 additions & 3 deletions library/core/src/ptr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,10 +342,12 @@ pub const fn slice_from_raw_parts_mut<T>(data: *mut T, len: usize) -> *mut [T] {
/// ```
/// use std::ptr;
///
/// let mut array = [0, 1, 2, 3];
/// let mut array: [i32; 4] = [0, 1, 2, 3];
///
/// let array_ptr: *mut i32 = array.as_mut_ptr();
///
/// let x = array[0..].as_mut_ptr() as *mut [u32; 3]; // this is `array[0..3]`
/// let y = array[1..].as_mut_ptr() as *mut [u32; 3]; // this is `array[1..4]`
/// let x = array_ptr as *mut [i32; 3]; // this is `array[0..3]`
/// let y = unsafe { array_ptr.add(1) } as *mut [i32; 3]; // this is `array[1..4]`
///
/// unsafe {
/// ptr::swap(x, y);
Expand Down
14 changes: 14 additions & 0 deletions library/proc_macro/src/bridge/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ macro_rules! with_api {
Literal {
fn drop($self: $S::Literal);
fn clone($self: &$S::Literal) -> $S::Literal;
fn from_str(s: &str) -> Result<$S::Literal, ()>;
fn debug_kind($self: &$S::Literal) -> String;
fn symbol($self: &$S::Literal) -> String;
fn suffix($self: &$S::Literal) -> Option<String>;
Expand Down Expand Up @@ -315,6 +316,19 @@ impl<T: Unmark> Unmark for Option<T> {
}
}

impl<T: Mark, E: Mark> Mark for Result<T, E> {
type Unmarked = Result<T::Unmarked, E::Unmarked>;
fn mark(unmarked: Self::Unmarked) -> Self {
unmarked.map(T::mark).map_err(E::mark)
}
}
impl<T: Unmark, E: Unmark> Unmark for Result<T, E> {
type Unmarked = Result<T::Unmarked, E::Unmarked>;
fn unmark(self) -> Self::Unmarked {
self.map(T::unmark).map_err(E::unmark)
}
}

macro_rules! mark_noop {
($($ty:ty),* $(,)?) => {
$(
Expand Down
28 changes: 28 additions & 0 deletions library/proc_macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@ pub struct LexError {
_inner: (),
}

impl LexError {
fn new() -> Self {
LexError { _inner: () }
}
}

#[stable(feature = "proc_macro_lexerror_impls", since = "1.44.0")]
impl fmt::Display for LexError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
Expand Down Expand Up @@ -1171,6 +1177,28 @@ impl Literal {
}
}

/// Parse a single literal from its stringified representation.
///
/// In order to parse successfully, the input string must not contain anything
/// but the literal token. Specifically, it must not contain whitespace or
/// comments in addition to the literal.
///
/// The resulting literal token will have a `Span::call_site()` span.
///
/// NOTE: some errors may cause panics instead of returning `LexError`. We
/// reserve the right to change these errors into `LexError`s later.
#[stable(feature = "proc_macro_literal_parse", since = "1.54.0")]
impl FromStr for Literal {
type Err = LexError;

fn from_str(src: &str) -> Result<Self, LexError> {
match bridge::client::Literal::from_str(src) {
Ok(literal) => Ok(Literal(literal)),
Err(()) => Err(LexError::new()),
}
}
}

// N.B., the bridge only provides `to_string`, implement `fmt::Display`
// based on it (the reverse of the usual relationship between the two).
#[stable(feature = "proc_macro_lib", since = "1.15.0")]
Expand Down
4 changes: 1 addition & 3 deletions library/std/src/alloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ use core::ptr::NonNull;
use core::sync::atomic::{AtomicPtr, Ordering};
use core::{mem, ptr};

use crate::sys_common::util::dumb_print;

#[stable(feature = "alloc_module", since = "1.28.0")]
#[doc(inline)]
pub use alloc_crate::alloc::*;
Expand Down Expand Up @@ -317,7 +315,7 @@ pub fn take_alloc_error_hook() -> fn(Layout) {
}

fn default_alloc_error_hook(layout: Layout) {
dumb_print(format_args!("memory allocation of {} bytes failed\n", layout.size()));
rtprintpanic!("memory allocation of {} bytes failed\n", layout.size());
}

#[cfg(not(test))]
Expand Down
Loading