diff options
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_arena/src/lib.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_attr/src/builtin.rs | 10 | ||||
| -rw-r--r-- | compiler/rustc_interface/src/tests.rs | 1 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/mir/interpret/mod.rs | 9 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/mir/interpret/pointer.rs | 4 | ||||
| -rw-r--r-- | compiler/rustc_mir/src/interpret/intrinsics.rs | 4 | ||||
| -rw-r--r-- | compiler/rustc_mir_build/src/build/expr/as_place.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_mir_build/src/build/expr/into.rs | 13 | ||||
| -rw-r--r-- | compiler/rustc_parse/src/parser/pat.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_passes/src/dead.rs | 15 | ||||
| -rw-r--r-- | compiler/rustc_resolve/src/diagnostics.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_session/src/options.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_session/src/parse.rs | 3 | ||||
| -rw-r--r-- | compiler/rustc_session/src/session.rs | 3 | ||||
| -rw-r--r-- | compiler/rustc_symbol_mangling/src/v0.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_target/src/abi/call/mod.rs | 7 | ||||
| -rw-r--r-- | compiler/rustc_target/src/abi/mod.rs | 2 |
17 files changed, 54 insertions, 29 deletions
diff --git a/compiler/rustc_arena/src/lib.rs b/compiler/rustc_arena/src/lib.rs index a0493056b81..54552b499be 100644 --- a/compiler/rustc_arena/src/lib.rs +++ b/compiler/rustc_arena/src/lib.rs @@ -32,7 +32,7 @@ use std::slice; #[inline(never)] #[cold] -pub fn cold_path<F: FnOnce() -> R, R>(f: F) -> R { +fn cold_path<F: FnOnce() -> R, R>(f: F) -> R { f() } diff --git a/compiler/rustc_attr/src/builtin.rs b/compiler/rustc_attr/src/builtin.rs index 49488070184..696d5fdd6cd 100644 --- a/compiler/rustc_attr/src/builtin.rs +++ b/compiler/rustc_attr/src/builtin.rs @@ -586,12 +586,14 @@ pub fn eval_condition( return false; } }; - let channel = env!("CFG_RELEASE_CHANNEL"); - let nightly = channel == "nightly" || channel == "dev"; let rustc_version = parse_version(env!("CFG_RELEASE"), true).unwrap(); - // See https://github.com/rust-lang/rust/issues/64796#issuecomment-625474439 for details - if nightly { rustc_version > min_version } else { rustc_version >= min_version } + // See https://github.com/rust-lang/rust/issues/64796#issuecomment-640851454 for details + if sess.assume_incomplete_release { + rustc_version > min_version + } else { + rustc_version >= min_version + } } ast::MetaItemKind::List(ref mis) => { for mi in mis.iter() { diff --git a/compiler/rustc_interface/src/tests.rs b/compiler/rustc_interface/src/tests.rs index 31e29351856..f9c3406d3b3 100644 --- a/compiler/rustc_interface/src/tests.rs +++ b/compiler/rustc_interface/src/tests.rs @@ -540,6 +540,7 @@ fn test_debugging_options_tracking_hash() { // This list is in alphabetical order. tracked!(allow_features, Some(vec![String::from("lang_items")])); tracked!(always_encode_mir, true); + tracked!(assume_incomplete_release, true); tracked!(asm_comments, true); tracked!(binary_dep_depinfo, true); tracked!(chalk, true); diff --git a/compiler/rustc_middle/src/mir/interpret/mod.rs b/compiler/rustc_middle/src/mir/interpret/mod.rs index 80b58642136..55fe5f971e7 100644 --- a/compiler/rustc_middle/src/mir/interpret/mod.rs +++ b/compiler/rustc_middle/src/mir/interpret/mod.rs @@ -588,12 +588,3 @@ pub fn read_target_uint(endianness: Endian, mut source: &[u8]) -> Result<u128, i debug_assert!(source.len() == 0); // We should have consumed the source buffer. uint } - -/// Computes the unsigned absolute value without wrapping or panicking. -#[inline] -pub fn uabs(value: i64) -> u64 { - // The only tricky part here is if value == i64::MIN. In that case, - // wrapping_abs() returns i64::MIN == -2^63. Casting this value to a u64 - // gives 2^63, the correct value. - value.wrapping_abs() as u64 -} diff --git a/compiler/rustc_middle/src/mir/interpret/pointer.rs b/compiler/rustc_middle/src/mir/interpret/pointer.rs index e3d5a085613..8774b48fb3e 100644 --- a/compiler/rustc_middle/src/mir/interpret/pointer.rs +++ b/compiler/rustc_middle/src/mir/interpret/pointer.rs @@ -1,4 +1,4 @@ -use super::{uabs, AllocId, InterpResult}; +use super::{AllocId, InterpResult}; use rustc_macros::HashStable; use rustc_target::abi::{HasDataLayout, Size}; @@ -57,7 +57,7 @@ pub trait PointerArithmetic: HasDataLayout { #[inline] fn overflowing_signed_offset(&self, val: u64, i: i64) -> (u64, bool) { // We need to make sure that i fits in a machine isize. - let n = uabs(i); + let n = i.unsigned_abs(); if i >= 0 { let (val, over) = self.overflowing_offset(val, n); (val, over || i > self.machine_isize_max()) diff --git a/compiler/rustc_mir/src/interpret/intrinsics.rs b/compiler/rustc_mir/src/interpret/intrinsics.rs index 58858c09f44..f4309c9cd95 100644 --- a/compiler/rustc_mir/src/interpret/intrinsics.rs +++ b/compiler/rustc_mir/src/interpret/intrinsics.rs @@ -7,7 +7,7 @@ use std::convert::TryFrom; use rustc_hir::def_id::DefId; use rustc_middle::mir::{ self, - interpret::{uabs, ConstValue, GlobalId, InterpResult, Scalar}, + interpret::{ConstValue, GlobalId, InterpResult, Scalar}, BinOp, }; use rustc_middle::ty; @@ -542,7 +542,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { // memory between these pointers must be accessible. Note that we do not require the // pointers to be properly aligned (unlike a read/write operation). let min_ptr = if offset_bytes >= 0 { ptr } else { offset_ptr }; - let size: u64 = uabs(offset_bytes); + let size = offset_bytes.unsigned_abs(); // This call handles checking for integer/NULL pointers. self.memory.check_ptr_access_align( min_ptr, diff --git a/compiler/rustc_mir_build/src/build/expr/as_place.rs b/compiler/rustc_mir_build/src/build/expr/as_place.rs index c11b8f74593..2503360b1e4 100644 --- a/compiler/rustc_mir_build/src/build/expr/as_place.rs +++ b/compiler/rustc_mir_build/src/build/expr/as_place.rs @@ -303,7 +303,7 @@ impl<'tcx> PlaceBuilder<'tcx> { self.base } - fn field(self, f: Field, ty: Ty<'tcx>) -> Self { + crate fn field(self, f: Field, ty: Ty<'tcx>) -> Self { self.project(PlaceElem::Field(f, ty)) } diff --git a/compiler/rustc_mir_build/src/build/expr/into.rs b/compiler/rustc_mir_build/src/build/expr/into.rs index 639f2bbc6e0..32c01f2c733 100644 --- a/compiler/rustc_mir_build/src/build/expr/into.rs +++ b/compiler/rustc_mir_build/src/build/expr/into.rs @@ -296,7 +296,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { let field_names = this.hir.all_fields(adt_def, variant_index); let fields: Vec<_> = if let Some(FruInfo { base, field_types }) = base { - let base = unpack!(block = this.as_place(block, base)); + let place_builder = unpack!(block = this.as_place_builder(block, base)); // MIR does not natively support FRU, so for each // base-supplied field, generate an operand that @@ -306,9 +306,14 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { .zip(field_types.into_iter()) .map(|(n, ty)| match fields_map.get(&n) { Some(v) => v.clone(), - None => this.consume_by_copy_or_move( - this.hir.tcx().mk_place_field(base, n, ty), - ), + None => { + let place_builder = place_builder.clone(); + this.consume_by_copy_or_move( + place_builder + .field(n, ty) + .into_place(this.hir.tcx(), this.hir.typeck_results()), + ) + }, }) .collect() } else { diff --git a/compiler/rustc_parse/src/parser/pat.rs b/compiler/rustc_parse/src/parser/pat.rs index 456e32680fe..d888514cf56 100644 --- a/compiler/rustc_parse/src/parser/pat.rs +++ b/compiler/rustc_parse/src/parser/pat.rs @@ -240,7 +240,7 @@ impl<'a> Parser<'a> { Err(err) } - /// Parse and throw away a parentesized comma separated + /// Parse and throw away a parenthesized comma separated /// sequence of patterns until `)` is reached. fn skip_pat_list(&mut self) -> PResult<'a, ()> { while !self.check(&token::CloseDelim(token::Paren)) { diff --git a/compiler/rustc_passes/src/dead.rs b/compiler/rustc_passes/src/dead.rs index 3b1b53553d5..0d096a0556b 100644 --- a/compiler/rustc_passes/src/dead.rs +++ b/compiler/rustc_passes/src/dead.rs @@ -37,6 +37,15 @@ fn should_explore(tcx: TyCtxt<'_>, hir_id: hir::HirId) -> bool { ) } +fn base_expr<'a>(mut expr: &'a hir::Expr<'a>) -> &'a hir::Expr<'a> { + loop { + match expr.kind { + hir::ExprKind::Field(base, ..) => expr = base, + _ => return expr, + } + } +} + struct MarkSymbolVisitor<'tcx> { worklist: Vec<hir::HirId>, tcx: TyCtxt<'tcx>, @@ -263,6 +272,12 @@ impl<'tcx> Visitor<'tcx> for MarkSymbolVisitor<'tcx> { hir::ExprKind::MethodCall(..) => { self.lookup_and_handle_method(expr.hir_id); } + hir::ExprKind::Assign(ref left, ref right, ..) => { + // Ignore write to field + self.visit_expr(base_expr(left)); + self.visit_expr(right); + return; + } hir::ExprKind::Field(ref lhs, ..) => { self.handle_field_access(&lhs, expr.hir_id); } diff --git a/compiler/rustc_resolve/src/diagnostics.rs b/compiler/rustc_resolve/src/diagnostics.rs index 69fb6870d2c..9d55bafd286 100644 --- a/compiler/rustc_resolve/src/diagnostics.rs +++ b/compiler/rustc_resolve/src/diagnostics.rs @@ -977,7 +977,7 @@ impl<'a> Resolver<'a> { }); if let Some(def_span) = def_span { if span.overlaps(def_span) { - // Don't suggest typo suggestion for itself like in the followoing: + // Don't suggest typo suggestion for itself like in the following: // error[E0423]: expected function, tuple struct or tuple variant, found struct `X` // --> $DIR/issue-64792-bad-unicode-ctor.rs:3:14 // | diff --git a/compiler/rustc_session/src/options.rs b/compiler/rustc_session/src/options.rs index 2aaab84585d..779e0421636 100644 --- a/compiler/rustc_session/src/options.rs +++ b/compiler/rustc_session/src/options.rs @@ -854,6 +854,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options, "only allow the listed language features to be enabled in code (space separated)"), always_encode_mir: bool = (false, parse_bool, [TRACKED], "encode MIR of all functions into the crate metadata (default: no)"), + assume_incomplete_release: bool = (false, parse_bool, [TRACKED], + "make cfg(version) treat the current version as incomplete (default: no)"), asm_comments: bool = (false, parse_bool, [TRACKED], "generate comments into the assembly (may change behavior) (default: no)"), ast_json: bool = (false, parse_bool, [UNTRACKED], diff --git a/compiler/rustc_session/src/parse.rs b/compiler/rustc_session/src/parse.rs index b1a48342417..81b38347414 100644 --- a/compiler/rustc_session/src/parse.rs +++ b/compiler/rustc_session/src/parse.rs @@ -138,6 +138,8 @@ pub struct ParseSess { pub env_depinfo: Lock<FxHashSet<(Symbol, Option<Symbol>)>>, /// All the type ascriptions expressions that have had a suggestion for likely path typo. pub type_ascription_path_suggestions: Lock<FxHashSet<Span>>, + /// Whether cfg(version) should treat the current release as incomplete + pub assume_incomplete_release: bool, } impl ParseSess { @@ -164,6 +166,7 @@ impl ParseSess { reached_eof: Lock::new(false), env_depinfo: Default::default(), type_ascription_path_suggestions: Default::default(), + assume_incomplete_release: false, } } diff --git a/compiler/rustc_session/src/session.rs b/compiler/rustc_session/src/session.rs index dad21e59502..69aa72d899f 100644 --- a/compiler/rustc_session/src/session.rs +++ b/compiler/rustc_session/src/session.rs @@ -1344,7 +1344,8 @@ pub fn build_session( None }; - let parse_sess = ParseSess::with_span_handler(span_diagnostic, source_map); + let mut parse_sess = ParseSess::with_span_handler(span_diagnostic, source_map); + parse_sess.assume_incomplete_release = sopts.debugging_opts.assume_incomplete_release; let sysroot = match &sopts.maybe_sysroot { Some(sysroot) => sysroot.clone(), None => filesearch::get_or_default_sysroot(), diff --git a/compiler/rustc_symbol_mangling/src/v0.rs b/compiler/rustc_symbol_mangling/src/v0.rs index c84e2cb45a6..bbf7ecc39cf 100644 --- a/compiler/rustc_symbol_mangling/src/v0.rs +++ b/compiler/rustc_symbol_mangling/src/v0.rs @@ -530,7 +530,7 @@ impl Printer<'tcx> for SymbolMangler<'tcx> { if val < 0 { neg = true; } - Some(val.wrapping_abs() as u128) + Some(val.unsigned_abs()) }) } _ => { diff --git a/compiler/rustc_target/src/abi/call/mod.rs b/compiler/rustc_target/src/abi/call/mod.rs index aa1c31bda54..ce8e56b1949 100644 --- a/compiler/rustc_target/src/abi/call/mod.rs +++ b/compiler/rustc_target/src/abi/call/mod.rs @@ -103,7 +103,12 @@ impl ArgAttributes { } pub fn ext(&mut self, ext: ArgExtension) -> &mut Self { - assert!(self.arg_ext == ArgExtension::None || self.arg_ext == ext); + assert!( + self.arg_ext == ArgExtension::None || self.arg_ext == ext, + "cannot set {:?} when {:?} is already set", + ext, + self.arg_ext + ); self.arg_ext = ext; self } diff --git a/compiler/rustc_target/src/abi/mod.rs b/compiler/rustc_target/src/abi/mod.rs index 88b2923f6c4..b14b1ef00db 100644 --- a/compiler/rustc_target/src/abi/mod.rs +++ b/compiler/rustc_target/src/abi/mod.rs @@ -682,7 +682,7 @@ pub struct Scalar { impl Scalar { pub fn is_bool(&self) -> bool { - if let Int(I8, _) = self.value { self.valid_range == (0..=1) } else { false } + matches!(self.value, Int(I8, false)) && self.valid_range == (0..=1) } /// Returns the valid range as a `x..y` range. |
