Skip to content

Commit

Permalink
Auto merge of #63990 - Centril:rollup-q1nt0b0, r=Centril
Browse files Browse the repository at this point in the history
Rollup of 11 pull requests

Successful merges:

 - #63811 (Correctly suggest adding bounds to `impl Trait` argument)
 - #63933 (Resolve some small issues related to #63580)
 - #63938 (or-pattern: fix typo in error message)
 - #63945 (Recover `mut $pat` and other improvements)
 - #63958 (const_prop: only call error_to_const_error if we are actually showing something)
 - #63961 (Add Option<Span> to `require_lang_item`)
 - #63963 (remove the reference to __cxa_thread_atexit_impl)
 - #63965 (Prevent syntax error in LD linker version script)
 - #63968 (rustc_apfloat: make the crate #![no_std] explicitly.)
 - #63970 (Notify me (flip1995) when Clippy toolstate changes)
 - #63980 (add missing `#[repr(C)]` on the Slices union)

Failed merges:

 - #63989 (Add Yaah to clippy toolstain notification list)

r? @ghost
  • Loading branch information
bors committed Aug 29, 2019
2 parents 3476543 + 7391009 commit 85ed538
Show file tree
Hide file tree
Showing 112 changed files with 741 additions and 296 deletions.
1 change: 1 addition & 0 deletions src/libcore/str/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2170,6 +2170,7 @@ impl str {
#[inline(always)]
#[rustc_const_unstable(feature="const_str_as_bytes")]
pub const fn as_bytes(&self) -> &[u8] {
#[repr(C)]
union Slices<'a> {
str: &'a str,
slice: &'a [u8],
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/infer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1460,7 +1460,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
}
}

let copy_def_id = self.tcx.require_lang_item(lang_items::CopyTraitLangItem);
let copy_def_id = self.tcx.require_lang_item(lang_items::CopyTraitLangItem, None);

// this can get called from typeck (by euv), and moves_by_default
// rightly refuses to work with inference variables, but
Expand Down
8 changes: 6 additions & 2 deletions src/librustc/middle/lang_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -381,9 +381,13 @@ language_item_table! {
impl<'tcx> TyCtxt<'tcx> {
/// Returns the `DefId` for a given `LangItem`.
/// If not found, fatally abort compilation.
pub fn require_lang_item(&self, lang_item: LangItem) -> DefId {
pub fn require_lang_item(&self, lang_item: LangItem, span: Option<Span>) -> DefId {
self.lang_items().require(lang_item).unwrap_or_else(|msg| {
self.sess.fatal(&msg)
if let Some(span) = span {
self.sess.span_fatal(span, &msg)
} else {
self.sess.fatal(&msg)
}
})
}
}
7 changes: 7 additions & 0 deletions src/librustc/mir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1733,13 +1733,20 @@ pub enum PlaceBase<'tcx> {
pub struct Static<'tcx> {
pub ty: Ty<'tcx>,
pub kind: StaticKind<'tcx>,
/// The `DefId` of the item this static was declared in. For promoted values, usually, this is
/// the same as the `DefId` of the `mir::Body` containing the `Place` this promoted appears in.
/// However, after inlining, that might no longer be the case as inlined `Place`s are copied
/// into the calling frame.
pub def_id: DefId,
}

#[derive(
Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, HashStable, RustcEncodable, RustcDecodable,
)]
pub enum StaticKind<'tcx> {
/// Promoted references consist of an id (`Promoted`) and the substs necessary to monomorphize
/// it. Usually, these substs are just the identity substs for the item. However, the inliner
/// will adjust these substs when it inlines a function based on the substs at the callsite.
Promoted(Promoted, SubstsRef<'tcx>),
Static,
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/traits/select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3513,7 +3513,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {

// We can only make objects from sized types.
let tr = ty::TraitRef {
def_id: tcx.require_lang_item(lang_items::SizedTraitLangItem),
def_id: tcx.require_lang_item(lang_items::SizedTraitLangItem, None),
substs: tcx.mk_substs_trait(source, &[]),
};
nested.push(predicate_to_obligation(tr.to_predicate()));
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/ty/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2385,13 +2385,13 @@ impl<'tcx> TyCtxt<'tcx> {

#[inline]
pub fn mk_box(self, ty: Ty<'tcx>) -> Ty<'tcx> {
let def_id = self.require_lang_item(lang_items::OwnedBoxLangItem);
let def_id = self.require_lang_item(lang_items::OwnedBoxLangItem, None);
self.mk_generic_adt(def_id, ty)
}

#[inline]
pub fn mk_maybe_uninit(self, ty: Ty<'tcx>) -> Ty<'tcx> {
let def_id = self.require_lang_item(lang_items::MaybeUninitLangItem);
let def_id = self.require_lang_item(lang_items::MaybeUninitLangItem, None);
self.mk_generic_adt(def_id, ty)
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustc/ty/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ impl<'tcx> Instance<'tcx> {
}

pub fn resolve_drop_in_place(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> ty::Instance<'tcx> {
let def_id = tcx.require_lang_item(DropInPlaceFnLangItem);
let def_id = tcx.require_lang_item(DropInPlaceFnLangItem, None);
let substs = tcx.intern_substs(&[ty.into()]);
Instance::resolve(tcx, ty::ParamEnv::reveal_all(), def_id, substs).unwrap()
}
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/ty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2588,12 +2588,12 @@ impl<'tcx> ClosureKind {

pub fn trait_did(&self, tcx: TyCtxt<'tcx>) -> DefId {
match *self {
ClosureKind::Fn => tcx.require_lang_item(FnTraitLangItem),
ClosureKind::Fn => tcx.require_lang_item(FnTraitLangItem, None),
ClosureKind::FnMut => {
tcx.require_lang_item(FnMutTraitLangItem)
tcx.require_lang_item(FnMutTraitLangItem, None)
}
ClosureKind::FnOnce => {
tcx.require_lang_item(FnOnceTraitLangItem)
tcx.require_lang_item(FnOnceTraitLangItem, None)
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/ty/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -998,7 +998,7 @@ impl<'tcx> ty::TyS<'tcx> {

fn is_copy_raw<'tcx>(tcx: TyCtxt<'tcx>, query: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool {
let (param_env, ty) = query.into_parts();
let trait_def_id = tcx.require_lang_item(lang_items::CopyTraitLangItem);
let trait_def_id = tcx.require_lang_item(lang_items::CopyTraitLangItem, None);
tcx.infer_ctxt()
.enter(|infcx| traits::type_known_to_meet_bound_modulo_regions(
&infcx,
Expand All @@ -1011,7 +1011,7 @@ fn is_copy_raw<'tcx>(tcx: TyCtxt<'tcx>, query: ty::ParamEnvAnd<'tcx, Ty<'tcx>>)

fn is_sized_raw<'tcx>(tcx: TyCtxt<'tcx>, query: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool {
let (param_env, ty) = query.into_parts();
let trait_def_id = tcx.require_lang_item(lang_items::SizedTraitLangItem);
let trait_def_id = tcx.require_lang_item(lang_items::SizedTraitLangItem, None);
tcx.infer_ctxt()
.enter(|infcx| traits::type_known_to_meet_bound_modulo_regions(
&infcx,
Expand All @@ -1024,7 +1024,7 @@ fn is_sized_raw<'tcx>(tcx: TyCtxt<'tcx>, query: ty::ParamEnvAnd<'tcx, Ty<'tcx>>)

fn is_freeze_raw<'tcx>(tcx: TyCtxt<'tcx>, query: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool {
let (param_env, ty) = query.into_parts();
let trait_def_id = tcx.require_lang_item(lang_items::FreezeTraitLangItem);
let trait_def_id = tcx.require_lang_item(lang_items::FreezeTraitLangItem, None);
tcx.infer_ctxt()
.enter(|infcx| traits::type_known_to_meet_bound_modulo_regions(
&infcx,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/ty/wf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
if !subty.has_escaping_bound_vars() {
let cause = self.cause(cause);
let trait_ref = ty::TraitRef {
def_id: self.infcx.tcx.require_lang_item(lang_items::SizedTraitLangItem),
def_id: self.infcx.tcx.require_lang_item(lang_items::SizedTraitLangItem, None),
substs: self.infcx.tcx.mk_substs_trait(subty, &[]),
};
self.out.push(traits::Obligation::new(cause, self.param_env, trait_ref.to_predicate()));
Expand Down
16 changes: 8 additions & 8 deletions src/librustc_apfloat/ieee.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use crate::{Category, ExpInt, IEK_INF, IEK_NAN, IEK_ZERO};
use crate::{Float, FloatConvert, ParseError, Round, Status, StatusAnd};

use core::cmp::{self, Ordering};
use core::convert::TryFrom;
use core::fmt::{self, Write};
use core::marker::PhantomData;
use core::mem;
use core::ops::Neg;
use smallvec::{SmallVec, smallvec};
use std::cmp::{self, Ordering};
use std::convert::TryFrom;
use std::fmt::{self, Write};
use std::marker::PhantomData;
use std::mem;
use std::ops::Neg;

#[must_use]
pub struct IeeeFloat<S> {
Expand Down Expand Up @@ -2287,8 +2287,8 @@ impl Loss {
/// Implementation details of IeeeFloat significands, such as big integer arithmetic.
/// As a rule of thumb, no functions in this module should dynamically allocate.
mod sig {
use std::cmp::Ordering;
use std::mem;
use core::cmp::Ordering;
use core::mem;
use super::{ExpInt, Limb, LIMB_BITS, limbs_for_bits, Loss};

pub(super) fn is_all_zeros(limbs: &[Limb]) -> bool {
Expand Down
36 changes: 20 additions & 16 deletions src/librustc_apfloat/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,19 @@
//! This API is completely unstable and subject to change.

#![doc(html_root_url = "https://doc.rust-lang.org/nightly/")]
#![no_std]
#![forbid(unsafe_code)]

#![feature(nll)]

use std::cmp::Ordering;
use std::fmt;
use std::ops::{Neg, Add, Sub, Mul, Div, Rem};
use std::ops::{AddAssign, SubAssign, MulAssign, DivAssign, RemAssign};
use std::str::FromStr;
#[macro_use]
extern crate alloc;

use core::cmp::Ordering;
use core::fmt;
use core::ops::{Neg, Add, Sub, Mul, Div, Rem};
use core::ops::{AddAssign, SubAssign, MulAssign, DivAssign, RemAssign};
use core::str::FromStr;

bitflags::bitflags! {
/// IEEE-754R 7: Default exception handling.
Expand Down Expand Up @@ -587,7 +591,7 @@ macro_rules! float_common_impls {
}
}

impl<$t> ::std::str::FromStr for $ty<$t> where Self: Float {
impl<$t> ::core::str::FromStr for $ty<$t> where Self: Float {
type Err = ParseError;
fn from_str(s: &str) -> Result<Self, ParseError> {
Self::from_str_r(s, Round::NearestTiesToEven).map(|x| x.value)
Expand All @@ -596,66 +600,66 @@ macro_rules! float_common_impls {

// Rounding ties to the nearest even, by default.

impl<$t> ::std::ops::Add for $ty<$t> where Self: Float {
impl<$t> ::core::ops::Add for $ty<$t> where Self: Float {
type Output = StatusAnd<Self>;
fn add(self, rhs: Self) -> StatusAnd<Self> {
self.add_r(rhs, Round::NearestTiesToEven)
}
}

impl<$t> ::std::ops::Sub for $ty<$t> where Self: Float {
impl<$t> ::core::ops::Sub for $ty<$t> where Self: Float {
type Output = StatusAnd<Self>;
fn sub(self, rhs: Self) -> StatusAnd<Self> {
self.sub_r(rhs, Round::NearestTiesToEven)
}
}

impl<$t> ::std::ops::Mul for $ty<$t> where Self: Float {
impl<$t> ::core::ops::Mul for $ty<$t> where Self: Float {
type Output = StatusAnd<Self>;
fn mul(self, rhs: Self) -> StatusAnd<Self> {
self.mul_r(rhs, Round::NearestTiesToEven)
}
}

impl<$t> ::std::ops::Div for $ty<$t> where Self: Float {
impl<$t> ::core::ops::Div for $ty<$t> where Self: Float {
type Output = StatusAnd<Self>;
fn div(self, rhs: Self) -> StatusAnd<Self> {
self.div_r(rhs, Round::NearestTiesToEven)
}
}

impl<$t> ::std::ops::Rem for $ty<$t> where Self: Float {
impl<$t> ::core::ops::Rem for $ty<$t> where Self: Float {
type Output = StatusAnd<Self>;
fn rem(self, rhs: Self) -> StatusAnd<Self> {
self.c_fmod(rhs)
}
}

impl<$t> ::std::ops::AddAssign for $ty<$t> where Self: Float {
impl<$t> ::core::ops::AddAssign for $ty<$t> where Self: Float {
fn add_assign(&mut self, rhs: Self) {
*self = (*self + rhs).value;
}
}

impl<$t> ::std::ops::SubAssign for $ty<$t> where Self: Float {
impl<$t> ::core::ops::SubAssign for $ty<$t> where Self: Float {
fn sub_assign(&mut self, rhs: Self) {
*self = (*self - rhs).value;
}
}

impl<$t> ::std::ops::MulAssign for $ty<$t> where Self: Float {
impl<$t> ::core::ops::MulAssign for $ty<$t> where Self: Float {
fn mul_assign(&mut self, rhs: Self) {
*self = (*self * rhs).value;
}
}

impl<$t> ::std::ops::DivAssign for $ty<$t> where Self: Float {
impl<$t> ::core::ops::DivAssign for $ty<$t> where Self: Float {
fn div_assign(&mut self, rhs: Self) {
*self = (*self / rhs).value;
}
}

impl<$t> ::std::ops::RemAssign for $ty<$t> where Self: Float {
impl<$t> ::core::ops::RemAssign for $ty<$t> where Self: Float {
fn rem_assign(&mut self, rhs: Self) {
*self = (*self % rhs).value;
}
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_apfloat/ppc.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use crate::{Category, ExpInt, Float, FloatConvert, Round, ParseError, Status, StatusAnd};
use crate::ieee;

use std::cmp::Ordering;
use std::fmt;
use std::ops::Neg;
use core::cmp::Ordering;
use core::fmt;
use core::ops::Neg;

#[must_use]
#[derive(Copy, Clone, PartialEq, PartialOrd, Debug)]
Expand Down
11 changes: 7 additions & 4 deletions src/librustc_codegen_ssa/back/linker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -430,10 +430,13 @@ impl<'a> Linker for GccLinker<'a> {
// Write an LD version script
let res: io::Result<()> = try {
let mut f = BufWriter::new(File::create(&path)?);
writeln!(f, "{{\n global:")?;
for sym in self.info.exports[&crate_type].iter() {
debug!(" {};", sym);
writeln!(f, " {};", sym)?;
writeln!(f, "{{")?;
if !self.info.exports[&crate_type].is_empty() {
writeln!(f, " global:")?;
for sym in self.info.exports[&crate_type].iter() {
debug!(" {};", sym);
writeln!(f, " {};", sym)?;
}
}
writeln!(f, "\n local:\n *;\n}};")?;
};
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_codegen_ssa/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ pub fn maybe_create_entry_wrapper<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(cx: &'
let arg_argv = param_argv;

let (start_fn, args) = if use_start_lang_item {
let start_def_id = cx.tcx().require_lang_item(StartFnLangItem);
let start_def_id = cx.tcx().require_lang_item(StartFnLangItem, None);
let start_fn = callee::resolve_and_get_fn(
cx,
start_def_id,
Expand Down
20 changes: 2 additions & 18 deletions src/librustc_metadata/cstore_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,24 +125,8 @@ provide! { <'tcx> tcx, def_id, other, cdata,
bug!("coerce_unsized_info: `{:?}` is missing its info", def_id);
})
}
optimized_mir => {
let mir = cdata.maybe_get_optimized_mir(tcx, def_id.index).unwrap_or_else(|| {
bug!("get_optimized_mir: missing MIR for `{:?}`", def_id)
});

let mir = tcx.arena.alloc(mir);

mir
}
promoted_mir => {
let promoted = cdata.maybe_get_promoted_mir(tcx, def_id.index).unwrap_or_else(|| {
bug!("get_promoted_mir: missing promoted MIR for `{:?}`", def_id)
});

let promoted = tcx.arena.alloc(promoted);

promoted
}
optimized_mir => { tcx.arena.alloc(cdata.get_optimized_mir(tcx, def_id.index)) }
promoted_mir => { tcx.arena.alloc(cdata.get_promoted_mir(tcx, def_id.index)) }
mir_const_qualif => {
(cdata.mir_const_qualif(def_id.index), tcx.arena.alloc(BitSet::new_empty(0)))
}
Expand Down
Loading

0 comments on commit 85ed538

Please sign in to comment.