Skip to content

Commit 85ed538

Browse files
committed
Auto merge of #63990 - Centril:rollup-q1nt0b0, r=Centril
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
2 parents 3476543 + 7391009 commit 85ed538

File tree

112 files changed

+741
-296
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

112 files changed

+741
-296
lines changed

src/libcore/str/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -2170,6 +2170,7 @@ impl str {
21702170
#[inline(always)]
21712171
#[rustc_const_unstable(feature="const_str_as_bytes")]
21722172
pub const fn as_bytes(&self) -> &[u8] {
2173+
#[repr(C)]
21732174
union Slices<'a> {
21742175
str: &'a str,
21752176
slice: &'a [u8],

src/librustc/infer/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1460,7 +1460,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
14601460
}
14611461
}
14621462

1463-
let copy_def_id = self.tcx.require_lang_item(lang_items::CopyTraitLangItem);
1463+
let copy_def_id = self.tcx.require_lang_item(lang_items::CopyTraitLangItem, None);
14641464

14651465
// this can get called from typeck (by euv), and moves_by_default
14661466
// rightly refuses to work with inference variables, but

src/librustc/middle/lang_items.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -381,9 +381,13 @@ language_item_table! {
381381
impl<'tcx> TyCtxt<'tcx> {
382382
/// Returns the `DefId` for a given `LangItem`.
383383
/// If not found, fatally abort compilation.
384-
pub fn require_lang_item(&self, lang_item: LangItem) -> DefId {
384+
pub fn require_lang_item(&self, lang_item: LangItem, span: Option<Span>) -> DefId {
385385
self.lang_items().require(lang_item).unwrap_or_else(|msg| {
386-
self.sess.fatal(&msg)
386+
if let Some(span) = span {
387+
self.sess.span_fatal(span, &msg)
388+
} else {
389+
self.sess.fatal(&msg)
390+
}
387391
})
388392
}
389393
}

src/librustc/mir/mod.rs

+7
Original file line numberDiff line numberDiff line change
@@ -1733,13 +1733,20 @@ pub enum PlaceBase<'tcx> {
17331733
pub struct Static<'tcx> {
17341734
pub ty: Ty<'tcx>,
17351735
pub kind: StaticKind<'tcx>,
1736+
/// The `DefId` of the item this static was declared in. For promoted values, usually, this is
1737+
/// the same as the `DefId` of the `mir::Body` containing the `Place` this promoted appears in.
1738+
/// However, after inlining, that might no longer be the case as inlined `Place`s are copied
1739+
/// into the calling frame.
17361740
pub def_id: DefId,
17371741
}
17381742

17391743
#[derive(
17401744
Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, HashStable, RustcEncodable, RustcDecodable,
17411745
)]
17421746
pub enum StaticKind<'tcx> {
1747+
/// Promoted references consist of an id (`Promoted`) and the substs necessary to monomorphize
1748+
/// it. Usually, these substs are just the identity substs for the item. However, the inliner
1749+
/// will adjust these substs when it inlines a function based on the substs at the callsite.
17431750
Promoted(Promoted, SubstsRef<'tcx>),
17441751
Static,
17451752
}

src/librustc/traits/select.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3513,7 +3513,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
35133513

35143514
// We can only make objects from sized types.
35153515
let tr = ty::TraitRef {
3516-
def_id: tcx.require_lang_item(lang_items::SizedTraitLangItem),
3516+
def_id: tcx.require_lang_item(lang_items::SizedTraitLangItem, None),
35173517
substs: tcx.mk_substs_trait(source, &[]),
35183518
};
35193519
nested.push(predicate_to_obligation(tr.to_predicate()));

src/librustc/ty/context.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2385,13 +2385,13 @@ impl<'tcx> TyCtxt<'tcx> {
23852385

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

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

src/librustc/ty/instance.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ impl<'tcx> Instance<'tcx> {
327327
}
328328

329329
pub fn resolve_drop_in_place(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> ty::Instance<'tcx> {
330-
let def_id = tcx.require_lang_item(DropInPlaceFnLangItem);
330+
let def_id = tcx.require_lang_item(DropInPlaceFnLangItem, None);
331331
let substs = tcx.intern_substs(&[ty.into()]);
332332
Instance::resolve(tcx, ty::ParamEnv::reveal_all(), def_id, substs).unwrap()
333333
}

src/librustc/ty/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -2588,12 +2588,12 @@ impl<'tcx> ClosureKind {
25882588

25892589
pub fn trait_did(&self, tcx: TyCtxt<'tcx>) -> DefId {
25902590
match *self {
2591-
ClosureKind::Fn => tcx.require_lang_item(FnTraitLangItem),
2591+
ClosureKind::Fn => tcx.require_lang_item(FnTraitLangItem, None),
25922592
ClosureKind::FnMut => {
2593-
tcx.require_lang_item(FnMutTraitLangItem)
2593+
tcx.require_lang_item(FnMutTraitLangItem, None)
25942594
}
25952595
ClosureKind::FnOnce => {
2596-
tcx.require_lang_item(FnOnceTraitLangItem)
2596+
tcx.require_lang_item(FnOnceTraitLangItem, None)
25972597
}
25982598
}
25992599
}

src/librustc/ty/util.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -998,7 +998,7 @@ impl<'tcx> ty::TyS<'tcx> {
998998

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

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

10251025
fn is_freeze_raw<'tcx>(tcx: TyCtxt<'tcx>, query: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool {
10261026
let (param_env, ty) = query.into_parts();
1027-
let trait_def_id = tcx.require_lang_item(lang_items::FreezeTraitLangItem);
1027+
let trait_def_id = tcx.require_lang_item(lang_items::FreezeTraitLangItem, None);
10281028
tcx.infer_ctxt()
10291029
.enter(|infcx| traits::type_known_to_meet_bound_modulo_regions(
10301030
&infcx,

src/librustc/ty/wf.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
221221
if !subty.has_escaping_bound_vars() {
222222
let cause = self.cause(cause);
223223
let trait_ref = ty::TraitRef {
224-
def_id: self.infcx.tcx.require_lang_item(lang_items::SizedTraitLangItem),
224+
def_id: self.infcx.tcx.require_lang_item(lang_items::SizedTraitLangItem, None),
225225
substs: self.infcx.tcx.mk_substs_trait(subty, &[]),
226226
};
227227
self.out.push(traits::Obligation::new(cause, self.param_env, trait_ref.to_predicate()));

src/librustc_apfloat/ieee.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
use crate::{Category, ExpInt, IEK_INF, IEK_NAN, IEK_ZERO};
22
use crate::{Float, FloatConvert, ParseError, Round, Status, StatusAnd};
33

4+
use core::cmp::{self, Ordering};
5+
use core::convert::TryFrom;
6+
use core::fmt::{self, Write};
7+
use core::marker::PhantomData;
8+
use core::mem;
9+
use core::ops::Neg;
410
use smallvec::{SmallVec, smallvec};
5-
use std::cmp::{self, Ordering};
6-
use std::convert::TryFrom;
7-
use std::fmt::{self, Write};
8-
use std::marker::PhantomData;
9-
use std::mem;
10-
use std::ops::Neg;
1111

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

22942294
pub(super) fn is_all_zeros(limbs: &[Limb]) -> bool {

src/librustc_apfloat/lib.rs

+20-16
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,19 @@
3131
//! This API is completely unstable and subject to change.
3232
3333
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/")]
34+
#![no_std]
3435
#![forbid(unsafe_code)]
3536

3637
#![feature(nll)]
3738

38-
use std::cmp::Ordering;
39-
use std::fmt;
40-
use std::ops::{Neg, Add, Sub, Mul, Div, Rem};
41-
use std::ops::{AddAssign, SubAssign, MulAssign, DivAssign, RemAssign};
42-
use std::str::FromStr;
39+
#[macro_use]
40+
extern crate alloc;
41+
42+
use core::cmp::Ordering;
43+
use core::fmt;
44+
use core::ops::{Neg, Add, Sub, Mul, Div, Rem};
45+
use core::ops::{AddAssign, SubAssign, MulAssign, DivAssign, RemAssign};
46+
use core::str::FromStr;
4347

4448
bitflags::bitflags! {
4549
/// IEEE-754R 7: Default exception handling.
@@ -587,7 +591,7 @@ macro_rules! float_common_impls {
587591
}
588592
}
589593

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

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

599-
impl<$t> ::std::ops::Add for $ty<$t> where Self: Float {
603+
impl<$t> ::core::ops::Add for $ty<$t> where Self: Float {
600604
type Output = StatusAnd<Self>;
601605
fn add(self, rhs: Self) -> StatusAnd<Self> {
602606
self.add_r(rhs, Round::NearestTiesToEven)
603607
}
604608
}
605609

606-
impl<$t> ::std::ops::Sub for $ty<$t> where Self: Float {
610+
impl<$t> ::core::ops::Sub for $ty<$t> where Self: Float {
607611
type Output = StatusAnd<Self>;
608612
fn sub(self, rhs: Self) -> StatusAnd<Self> {
609613
self.sub_r(rhs, Round::NearestTiesToEven)
610614
}
611615
}
612616

613-
impl<$t> ::std::ops::Mul for $ty<$t> where Self: Float {
617+
impl<$t> ::core::ops::Mul for $ty<$t> where Self: Float {
614618
type Output = StatusAnd<Self>;
615619
fn mul(self, rhs: Self) -> StatusAnd<Self> {
616620
self.mul_r(rhs, Round::NearestTiesToEven)
617621
}
618622
}
619623

620-
impl<$t> ::std::ops::Div for $ty<$t> where Self: Float {
624+
impl<$t> ::core::ops::Div for $ty<$t> where Self: Float {
621625
type Output = StatusAnd<Self>;
622626
fn div(self, rhs: Self) -> StatusAnd<Self> {
623627
self.div_r(rhs, Round::NearestTiesToEven)
624628
}
625629
}
626630

627-
impl<$t> ::std::ops::Rem for $ty<$t> where Self: Float {
631+
impl<$t> ::core::ops::Rem for $ty<$t> where Self: Float {
628632
type Output = StatusAnd<Self>;
629633
fn rem(self, rhs: Self) -> StatusAnd<Self> {
630634
self.c_fmod(rhs)
631635
}
632636
}
633637

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

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

646-
impl<$t> ::std::ops::MulAssign for $ty<$t> where Self: Float {
650+
impl<$t> ::core::ops::MulAssign for $ty<$t> where Self: Float {
647651
fn mul_assign(&mut self, rhs: Self) {
648652
*self = (*self * rhs).value;
649653
}
650654
}
651655

652-
impl<$t> ::std::ops::DivAssign for $ty<$t> where Self: Float {
656+
impl<$t> ::core::ops::DivAssign for $ty<$t> where Self: Float {
653657
fn div_assign(&mut self, rhs: Self) {
654658
*self = (*self / rhs).value;
655659
}
656660
}
657661

658-
impl<$t> ::std::ops::RemAssign for $ty<$t> where Self: Float {
662+
impl<$t> ::core::ops::RemAssign for $ty<$t> where Self: Float {
659663
fn rem_assign(&mut self, rhs: Self) {
660664
*self = (*self % rhs).value;
661665
}

src/librustc_apfloat/ppc.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
use crate::{Category, ExpInt, Float, FloatConvert, Round, ParseError, Status, StatusAnd};
22
use crate::ieee;
33

4-
use std::cmp::Ordering;
5-
use std::fmt;
6-
use std::ops::Neg;
4+
use core::cmp::Ordering;
5+
use core::fmt;
6+
use core::ops::Neg;
77

88
#[must_use]
99
#[derive(Copy, Clone, PartialEq, PartialOrd, Debug)]

src/librustc_codegen_ssa/back/linker.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -430,10 +430,13 @@ impl<'a> Linker for GccLinker<'a> {
430430
// Write an LD version script
431431
let res: io::Result<()> = try {
432432
let mut f = BufWriter::new(File::create(&path)?);
433-
writeln!(f, "{{\n global:")?;
434-
for sym in self.info.exports[&crate_type].iter() {
435-
debug!(" {};", sym);
436-
writeln!(f, " {};", sym)?;
433+
writeln!(f, "{{")?;
434+
if !self.info.exports[&crate_type].is_empty() {
435+
writeln!(f, " global:")?;
436+
for sym in self.info.exports[&crate_type].iter() {
437+
debug!(" {};", sym);
438+
writeln!(f, " {};", sym)?;
439+
}
437440
}
438441
writeln!(f, "\n local:\n *;\n}};")?;
439442
};

src/librustc_codegen_ssa/base.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ pub fn maybe_create_entry_wrapper<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(cx: &'
456456
let arg_argv = param_argv;
457457

458458
let (start_fn, args) = if use_start_lang_item {
459-
let start_def_id = cx.tcx().require_lang_item(StartFnLangItem);
459+
let start_def_id = cx.tcx().require_lang_item(StartFnLangItem, None);
460460
let start_fn = callee::resolve_and_get_fn(
461461
cx,
462462
start_def_id,

src/librustc_metadata/cstore_impl.rs

+2-18
Original file line numberDiff line numberDiff line change
@@ -125,24 +125,8 @@ provide! { <'tcx> tcx, def_id, other, cdata,
125125
bug!("coerce_unsized_info: `{:?}` is missing its info", def_id);
126126
})
127127
}
128-
optimized_mir => {
129-
let mir = cdata.maybe_get_optimized_mir(tcx, def_id.index).unwrap_or_else(|| {
130-
bug!("get_optimized_mir: missing MIR for `{:?}`", def_id)
131-
});
132-
133-
let mir = tcx.arena.alloc(mir);
134-
135-
mir
136-
}
137-
promoted_mir => {
138-
let promoted = cdata.maybe_get_promoted_mir(tcx, def_id.index).unwrap_or_else(|| {
139-
bug!("get_promoted_mir: missing promoted MIR for `{:?}`", def_id)
140-
});
141-
142-
let promoted = tcx.arena.alloc(promoted);
143-
144-
promoted
145-
}
128+
optimized_mir => { tcx.arena.alloc(cdata.get_optimized_mir(tcx, def_id.index)) }
129+
promoted_mir => { tcx.arena.alloc(cdata.get_promoted_mir(tcx, def_id.index)) }
146130
mir_const_qualif => {
147131
(cdata.mir_const_qualif(def_id.index), tcx.arena.alloc(BitSet::new_empty(0)))
148132
}

0 commit comments

Comments
 (0)