Skip to content
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

Rollup of 10 pull requests #78212

Merged
merged 32 commits into from
Oct 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
77e6c56
Unify `&mut` and `&raw mut` const-checking errors
ecstatic-morse Oct 1, 2020
c1494d6
Bless tests
ecstatic-morse Oct 1, 2020
7b652d3
Haiku: explicitly set CMAKE_SYSTEM_NAME when cross-compiling
nielx Sep 19, 2020
cc0b718
Mark inout asm! operands as used in liveness pass
oliviacrain Oct 15, 2020
fd193f2
Treat InOut variables like other input variables
oliviacrain Oct 17, 2020
4e2c59a
Greatly improve display for small mobile devices screens
GuillaumeGomez Oct 18, 2020
17c6c59
Mark InOut operands as used in RWU table with write_place
oliviacrain Oct 19, 2020
8f0bced
Refactor liveness-issue-77915 to liveness-asm and improve tests
oliviacrain Oct 19, 2020
c647735
rustc_lint: remove unused to_string
est31 Oct 20, 2020
00d23cf
Make {u,}int_range functions a bit nicer
est31 Oct 20, 2020
fa09404
Fix build failure of rustfmt
bishtpawan Oct 20, 2020
3adac03
Add test case for #77062
wesleywiser Oct 21, 2020
2720b2d
Limit liveness-asm tests to x86_64
oliviacrain Oct 21, 2020
dc29c7a
Bless liveness-asm output
oliviacrain Oct 21, 2020
7f58477
Fix formatting
bishtpawan Oct 21, 2020
51de590
Add tracking issue number for pin_static_ref.
m-ou-se Oct 21, 2020
d25c97a
Add `ControlFlow::is_{break,continue}` methods
LeSeulArtichaut Oct 21, 2020
6b52603
Support signed integers and `char` in v0 mangling
varkor Oct 4, 2020
37c00c4
Do not print type for placeholder values
varkor Oct 7, 2020
2b9d22d
Update rustc-demangle
varkor Oct 7, 2020
a797801
Add test for const generics demangling
varkor Oct 7, 2020
878c97e
Update to rustc-demangle 0.1.18
varkor Oct 21, 2020
6245b95
Rollup merge of #77420 - ecstatic-morse:const-checking-raw-mut-ref, r…
JohnTitor Oct 22, 2020
813066c
Rollup merge of #77554 - varkor:mangle-int-char, r=eddyb
JohnTitor Oct 22, 2020
ae95005
Rollup merge of #77976 - oliviacrain:issue-77915-fix, r=matthewjasper
JohnTitor Oct 22, 2020
004a3aa
Rollup merge of #78009 - nielx:fix/CMAKE_SYSTEM_NAME, r=Mark-Simulacrum
JohnTitor Oct 22, 2020
d9cf1f2
Rollup merge of #78084 - GuillaumeGomez:improve-mobile-display, r=jyn…
JohnTitor Oct 22, 2020
59ae795
Rollup merge of #78155 - est31:rustc_lint_types_refactor, r=davidtwco
JohnTitor Oct 22, 2020
513550c
Rollup merge of #78156 - bishtpawan:bugfix/rustfmt-no-longer-builds, …
JohnTitor Oct 22, 2020
f5127de
Rollup merge of #78172 - wesleywiser:close_77062, r=oli-obk
JohnTitor Oct 22, 2020
6bfbc24
Rollup merge of #78188 - fusion-engineering-forks:static-ref-tracking…
JohnTitor Oct 22, 2020
69e0658
Rollup merge of #78200 - LeSeulArtichaut:controlflow-is-meth, r=scottmcm
JohnTitor Oct 22, 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
4 changes: 2 additions & 2 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3276,9 +3276,9 @@ dependencies = [

[[package]]
name = "rustc-demangle"
version = "0.1.16"
version = "0.1.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783"
checksum = "6e3bad0ee36814ca07d7968269dd4b7ec89ec2da10c4bb613928d3077083c232"
dependencies = [
"compiler_builtins",
"rustc-std-workspace-core",
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_llvm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ measureme = "0.7.1"
snap = "1"
tracing = "0.1"
rustc_middle = { path = "../rustc_middle" }
rustc-demangle = "0.1"
rustc-demangle = "0.1.18"
rustc_attr = { path = "../rustc_attr" }
rustc_codegen_ssa = { path = "../rustc_codegen_ssa" }
rustc_data_structures = { path = "../rustc_data_structures" }
Expand Down
35 changes: 18 additions & 17 deletions compiler/rustc_lint/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,9 @@ fn lint_overflowing_range_endpoint<'tcx>(
// We need to preserve the literal's suffix,
// as it may determine typing information.
let suffix = match lit.node {
LitKind::Int(_, LitIntType::Signed(s)) => s.name_str().to_string(),
LitKind::Int(_, LitIntType::Unsigned(s)) => s.name_str().to_string(),
LitKind::Int(_, LitIntType::Unsuffixed) => "".to_string(),
LitKind::Int(_, LitIntType::Signed(s)) => s.name_str(),
LitKind::Int(_, LitIntType::Unsigned(s)) => s.name_str(),
LitKind::Int(_, LitIntType::Unsuffixed) => "",
_ => bug!(),
};
let suggestion = format!("{}..={}{}", start, lit_val - 1, suffix);
Expand All @@ -170,24 +170,25 @@ fn lint_overflowing_range_endpoint<'tcx>(
// warnings are consistent between 32- and 64-bit platforms.
fn int_ty_range(int_ty: ast::IntTy) -> (i128, i128) {
match int_ty {
ast::IntTy::Isize => (i64::MIN as i128, i64::MAX as i128),
ast::IntTy::I8 => (i8::MIN as i64 as i128, i8::MAX as i128),
ast::IntTy::I16 => (i16::MIN as i64 as i128, i16::MAX as i128),
ast::IntTy::I32 => (i32::MIN as i64 as i128, i32::MAX as i128),
ast::IntTy::I64 => (i64::MIN as i128, i64::MAX as i128),
ast::IntTy::I128 => (i128::MIN as i128, i128::MAX),
ast::IntTy::Isize => (i64::MIN.into(), i64::MAX.into()),
ast::IntTy::I8 => (i8::MIN.into(), i8::MAX.into()),
ast::IntTy::I16 => (i16::MIN.into(), i16::MAX.into()),
ast::IntTy::I32 => (i32::MIN.into(), i32::MAX.into()),
ast::IntTy::I64 => (i64::MIN.into(), i64::MAX.into()),
ast::IntTy::I128 => (i128::MIN, i128::MAX),
}
}

fn uint_ty_range(uint_ty: ast::UintTy) -> (u128, u128) {
match uint_ty {
ast::UintTy::Usize => (u64::MIN as u128, u64::MAX as u128),
ast::UintTy::U8 => (u8::MIN as u128, u8::MAX as u128),
ast::UintTy::U16 => (u16::MIN as u128, u16::MAX as u128),
ast::UintTy::U32 => (u32::MIN as u128, u32::MAX as u128),
ast::UintTy::U64 => (u64::MIN as u128, u64::MAX as u128),
ast::UintTy::U128 => (u128::MIN, u128::MAX),
}
let max = match uint_ty {
ast::UintTy::Usize => u64::MAX.into(),
ast::UintTy::U8 => u8::MAX.into(),
ast::UintTy::U16 => u16::MAX.into(),
ast::UintTy::U32 => u32::MAX.into(),
ast::UintTy::U64 => u64::MAX.into(),
ast::UintTy::U128 => u128::MAX,
};
(0, max)
}

fn get_bin_hex_repr(cx: &LateContext<'_>, lit: &hir::Lit) -> Option<String> {
Expand Down
38 changes: 11 additions & 27 deletions compiler/rustc_mir/src/transform/check_consts/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,8 @@ impl NonConstOp for CellBorrow {
}

#[derive(Debug)]
pub struct MutBorrow;
pub struct MutBorrow(pub hir::BorrowKind);

impl NonConstOp for MutBorrow {
fn status_in_item(&self, ccx: &ConstCx<'_, '_>) -> Status {
// Forbid everywhere except in const fn with a feature gate
Expand All @@ -236,22 +237,28 @@ impl NonConstOp for MutBorrow {
}

fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
let raw = match self.0 {
hir::BorrowKind::Raw => "raw ",
hir::BorrowKind::Ref => "",
};

let mut err = if ccx.const_kind() == hir::ConstContext::ConstFn {
feature_err(
&ccx.tcx.sess.parse_sess,
sym::const_mut_refs,
span,
&format!("mutable references are not allowed in {}s", ccx.const_kind()),
&format!("{}mutable references are not allowed in {}s", raw, ccx.const_kind()),
)
} else {
let mut err = struct_span_err!(
ccx.tcx.sess,
span,
E0764,
"mutable references are not allowed in {}s",
"{}mutable references are not allowed in {}s",
raw,
ccx.const_kind(),
);
err.span_label(span, format!("`&mut` is only allowed in `const fn`"));
err.span_label(span, format!("`&{}mut` is only allowed in `const fn`", raw));
err
};
if ccx.tcx.sess.teach(&err.get_code().unwrap()) {
Expand All @@ -270,29 +277,6 @@ impl NonConstOp for MutBorrow {
}
}

// FIXME(ecstaticmorse): Unify this with `MutBorrow`. It has basically the same issues.
#[derive(Debug)]
pub struct MutAddressOf;
impl NonConstOp for MutAddressOf {
fn status_in_item(&self, ccx: &ConstCx<'_, '_>) -> Status {
// Forbid everywhere except in const fn with a feature gate
if ccx.const_kind() == hir::ConstContext::ConstFn {
Status::Unstable(sym::const_mut_refs)
} else {
Status::Forbidden
}
}

fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
feature_err(
&ccx.tcx.sess.parse_sess,
sym::const_mut_refs,
span,
&format!("`&raw mut` is not allowed in {}s", ccx.const_kind()),
)
}
}

#[derive(Debug)]
pub struct MutDeref;
impl NonConstOp for MutDeref {
Expand Down
6 changes: 4 additions & 2 deletions compiler/rustc_mir/src/transform/check_consts/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -525,14 +525,16 @@ impl Visitor<'tcx> for Validator<'mir, 'tcx> {

if !is_allowed {
if let BorrowKind::Mut { .. } = kind {
self.check_op(ops::MutBorrow);
self.check_op(ops::MutBorrow(hir::BorrowKind::Ref));
} else {
self.check_op(ops::CellBorrow);
}
}
}

Rvalue::AddressOf(Mutability::Mut, _) => self.check_op(ops::MutAddressOf),
Rvalue::AddressOf(Mutability::Mut, _) => {
self.check_op(ops::MutBorrow(hir::BorrowKind::Raw))
}

Rvalue::Ref(_, BorrowKind::Shared | BorrowKind::Shallow, ref place)
| Rvalue::AddressOf(Mutability::Not, ref place) => {
Expand Down
14 changes: 8 additions & 6 deletions compiler/rustc_mir_build/src/lints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,14 @@ impl<'mir, 'tcx> Search<'mir, 'tcx> {

let func_ty = func.ty(body, tcx);
if let ty::FnDef(callee, substs) = *func_ty.kind() {
let (callee, call_substs) =
if let Ok(Some(instance)) = Instance::resolve(tcx, param_env, callee, substs) {
(instance.def_id(), instance.substs)
} else {
(callee, substs)
};
let normalized_substs = tcx.normalize_erasing_regions(param_env, substs);
let (callee, call_substs) = if let Ok(Some(instance)) =
Instance::resolve(tcx, param_env, callee, normalized_substs)
{
(instance.def_id(), instance.substs)
} else {
(callee, normalized_substs)
};

// FIXME(#57965): Make this work across function boundaries

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_passes/src/liveness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1174,7 +1174,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
}
}
hir::InlineAsmOperand::InOut { expr, .. } => {
succ = self.write_place(expr, succ, ACC_READ | ACC_WRITE);
succ = self.write_place(expr, succ, ACC_READ | ACC_WRITE | ACC_USE);
}
hir::InlineAsmOperand::SplitInOut { out_expr, .. } => {
if let Some(expr) = out_expr {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_symbol_mangling/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ doctest = false
[dependencies]
tracing = "0.1"
punycode = "0.4.0"
rustc-demangle = "0.1.16"
rustc-demangle = "0.1.18"

rustc_ast = { path = "../rustc_ast" }
rustc_span = { path = "../rustc_span" }
Expand Down
29 changes: 22 additions & 7 deletions compiler/rustc_symbol_mangling/src/v0.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_hir as hir;
use rustc_hir::def_id::{CrateNum, DefId};
use rustc_hir::definitions::{DefPathData, DisambiguatedDefPathData};
use rustc_middle::mir::interpret::sign_extend;
use rustc_middle::ty::print::{Print, Printer};
use rustc_middle::ty::subst::{GenericArg, GenericArgKind, Subst};
use rustc_middle::ty::{self, Instance, Ty, TyCtxt, TypeFoldable};
Expand Down Expand Up @@ -527,17 +528,31 @@ impl Printer<'tcx> for SymbolMangler<'tcx> {
}
let start = self.out.len();

match ct.ty.kind() {
ty::Uint(_) => {}
ty::Bool => {}
let mut neg = false;
let val = match ct.ty.kind() {
ty::Uint(_) | ty::Bool | ty::Char => {
ct.try_eval_bits(self.tcx, ty::ParamEnv::reveal_all(), ct.ty)
}
ty::Int(_) => {
let param_env = ty::ParamEnv::reveal_all();
ct.try_eval_bits(self.tcx, param_env, ct.ty).and_then(|b| {
let sz = self.tcx.layout_of(param_env.and(ct.ty)).ok()?.size;
let val = sign_extend(b, sz) as i128;
if val < 0 {
neg = true;
}
Some(val.wrapping_abs() as u128)
})
}
_ => {
bug!("symbol_names: unsupported constant of type `{}` ({:?})", ct.ty, ct);
}
}
self = ct.ty.print(self)?;
};

if let Some(bits) = ct.try_eval_bits(self.tcx, ty::ParamEnv::reveal_all(), ct.ty) {
let _ = write!(self.out, "{:x}_", bits);
if let Some(bits) = val {
// We only print the type if the const can be evaluated.
self = ct.ty.print(self)?;
let _ = write!(self.out, "{}{:x}_", if neg { "n" } else { "" }, bits);
} else {
// NOTE(eddyb) despite having the path, we need to
// encode a placeholder, as the path could refer
Expand Down
14 changes: 14 additions & 0 deletions library/core/src/ops/control_flow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,20 @@ impl<C, B> Try for ControlFlow<C, B> {
}

impl<C, B> ControlFlow<C, B> {
/// Returns `true` if this is a `Break` variant.
#[inline]
#[unstable(feature = "control_flow_enum", reason = "new API", issue = "75744")]
pub fn is_break(&self) -> bool {
matches!(*self, ControlFlow::Break(_))
}

/// Returns `true` if this is a `Continue` variant.
#[inline]
#[unstable(feature = "control_flow_enum", reason = "new API", issue = "75744")]
pub fn is_continue(&self) -> bool {
matches!(*self, ControlFlow::Continue(_))
}

/// Converts the `ControlFlow` into an `Option` which is `Some` if the
/// `ControlFlow` was `Break` and `None` otherwise.
#[inline]
Expand Down
4 changes: 2 additions & 2 deletions library/core/src/pin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,7 @@ impl<T: ?Sized> Pin<&'static T> {
///
/// This is safe, because `T` is borrowed for the `'static` lifetime, which
/// never ends.
#[unstable(feature = "pin_static_ref", issue = "none")]
#[unstable(feature = "pin_static_ref", issue = "78186")]
#[rustc_const_unstable(feature = "const_pin", issue = "76654")]
pub const fn static_ref(r: &'static T) -> Pin<&'static T> {
// SAFETY: The 'static borrow guarantees the data will not be
Expand All @@ -800,7 +800,7 @@ impl<T: ?Sized> Pin<&'static mut T> {
///
/// This is safe, because `T` is borrowed for the `'static` lifetime, which
/// never ends.
#[unstable(feature = "pin_static_ref", issue = "none")]
#[unstable(feature = "pin_static_ref", issue = "78186")]
#[rustc_const_unstable(feature = "const_pin", issue = "76654")]
pub const fn static_mut(r: &'static mut T) -> Pin<&'static mut T> {
// SAFETY: The 'static borrow guarantees the data will not be
Expand Down
2 changes: 1 addition & 1 deletion library/std/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ hashbrown = { version = "0.9.0", default-features = false, features = ['rustc-de

# Dependencies of the `backtrace` crate
addr2line = { version = "0.13.0", optional = true, default-features = false }
rustc-demangle = { version = "0.1.4", features = ['rustc-dep-of-std'] }
rustc-demangle = { version = "0.1.18", features = ['rustc-dep-of-std'] }
miniz_oxide = { version = "0.4.0", optional = true, default-features = false }
[dependencies.object]
version = "0.20"
Expand Down
2 changes: 2 additions & 0 deletions src/bootstrap/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,8 @@ fn configure_cmake(
cfg.define("CMAKE_SYSTEM_NAME", "FreeBSD");
} else if target.contains("windows") {
cfg.define("CMAKE_SYSTEM_NAME", "Windows");
} else if target.contains("haiku") {
cfg.define("CMAKE_SYSTEM_NAME", "Haiku");
}
// When cross-compiling we should also set CMAKE_SYSTEM_VERSION, but in
// that case like CMake we cannot easily determine system version either.
Expand Down
35 changes: 35 additions & 0 deletions src/librustdoc/html/static/rustdoc.css
Original file line number Diff line number Diff line change
Expand Up @@ -1568,6 +1568,41 @@ h4 > .notable-traits {
#titles, #titles > div {
height: 73px;
}

#main > table:not(.table-display) td {
word-break: break-word;
min-width: 10%;
}

.search-container > div {
display: block;
width: calc(100% - 37px);
}

#crate-search {
width: 100%;
border-radius: 4px;
border: 0;
}

#crate-search + .search-input {
width: calc(100% + 71px);
margin-left: -36px;
}

#theme-picker, #settings-menu {
padding: 5px;
width: 31px;
height: 31px;
}

#theme-picker {
margin-top: -2px;
}

#settings-menu {
top: 7px;
}
}

h3.notable {
Expand Down
8 changes: 4 additions & 4 deletions src/test/ui/consts/const-address-of-mut.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#![feature(raw_ref_op)]

const A: () = { let mut x = 2; &raw mut x; }; //~ ERROR `&raw mut` is not allowed
const A: () = { let mut x = 2; &raw mut x; }; //~ mutable reference

static B: () = { let mut x = 2; &raw mut x; }; //~ ERROR `&raw mut` is not allowed
static B: () = { let mut x = 2; &raw mut x; }; //~ mutable reference

static mut C: () = { let mut x = 2; &raw mut x; }; //~ ERROR `&raw mut` is not allowed
static mut C: () = { let mut x = 2; &raw mut x; }; //~ mutable reference

const fn foo() {
let mut x = 0;
let y = &raw mut x; //~ ERROR `&raw mut` is not allowed
let y = &raw mut x; //~ mutable reference
}

fn main() {}
Loading