Skip to content

Commit c351775

Browse files
committed
Auto merge of rust-lang#77102 - Dylan-DPC:rollup-2jfrg3u, r=Dylan-DPC
Rollup of 9 pull requests Successful merges: - rust-lang#76898 (Record `tcx.def_span` instead of `item.span` in crate metadata) - rust-lang#76939 (emit errors during AbstractConst building) - rust-lang#76965 (Add cfg(target_has_atomic_equal_alignment) and use it for Atomic::from_mut.) - rust-lang#76993 (Changing the alloc() to accept &self instead of &mut self) - rust-lang#76994 (fix small typo in docs and comments) - rust-lang#77017 (Add missing examples on Vec iter types) - rust-lang#77042 (Improve documentation for ToSocketAddrs) - rust-lang#77047 (Miri: more informative deallocation error messages) - rust-lang#77055 (Add #[track_caller] to more panicking Cell functions) Failed merges: r? `@ghost`
2 parents 8b40853 + c3c03f2 commit c351775

File tree

42 files changed

+552
-199
lines changed

Some content is hidden

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

42 files changed

+552
-199
lines changed

compiler/rustc_feature/src/builtin_attrs.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ const GATED_CFGS: &[GatedCfg] = &[
2626
(sym::target_thread_local, sym::cfg_target_thread_local, cfg_fn!(cfg_target_thread_local)),
2727
(sym::target_has_atomic, sym::cfg_target_has_atomic, cfg_fn!(cfg_target_has_atomic)),
2828
(sym::target_has_atomic_load_store, sym::cfg_target_has_atomic, cfg_fn!(cfg_target_has_atomic)),
29+
(
30+
sym::target_has_atomic_equal_alignment,
31+
sym::cfg_target_has_atomic,
32+
cfg_fn!(cfg_target_has_atomic),
33+
),
2934
(sym::sanitize, sym::cfg_sanitize, cfg_fn!(cfg_sanitize)),
3035
(sym::version, sym::cfg_version, cfg_fn!(cfg_version)),
3136
];

compiler/rustc_lint/src/types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,7 @@ fn get_nullable_type<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> Option<Ty<'t
733733
}
734734

735735
/// Check if this enum can be safely exported based on the "nullable pointer optimization". If it
736-
/// can, return the the type that `ty` can be safely converted to, otherwise return `None`.
736+
/// can, return the type that `ty` can be safely converted to, otherwise return `None`.
737737
/// Currently restricted to function pointers, boxes, references, `core::num::NonZero*`,
738738
/// `core::ptr::NonNull`, and `#[repr(transparent)]` newtypes.
739739
/// FIXME: This duplicates code in codegen.

compiler/rustc_metadata/src/rmeta/decoder.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use rustc_data_structures::fingerprint::{Fingerprint, FingerprintDecoder};
1111
use rustc_data_structures::fx::FxHashMap;
1212
use rustc_data_structures::svh::Svh;
1313
use rustc_data_structures::sync::{AtomicCell, Lock, LockGuard, Lrc, OnceCell};
14+
use rustc_errors::ErrorReported;
1415
use rustc_expand::base::{SyntaxExtension, SyntaxExtensionKind};
1516
use rustc_expand::proc_macro::{AttrProcMacro, BangProcMacro, ProcMacroDerive};
1617
use rustc_hir as hir;
@@ -1201,13 +1202,13 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
12011202
&self,
12021203
tcx: TyCtxt<'tcx>,
12031204
id: DefIndex,
1204-
) -> Option<&'tcx [mir::abstract_const::Node<'tcx>]> {
1205+
) -> Result<Option<&'tcx [mir::abstract_const::Node<'tcx>]>, ErrorReported> {
12051206
self.root
12061207
.tables
12071208
.mir_abstract_consts
12081209
.get(self, id)
12091210
.filter(|_| !self.is_proc_macro(id))
1210-
.map_or(None, |v| Some(v.decode((self, tcx))))
1211+
.map_or(Ok(None), |v| Ok(Some(v.decode((self, tcx)))))
12111212
}
12121213

12131214
fn get_unused_generic_params(&self, id: DefIndex) -> FiniteBitSet<u32> {

compiler/rustc_metadata/src/rmeta/encoder.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,7 +1117,7 @@ impl EncodeContext<'a, 'tcx> {
11171117
}
11181118

11191119
let abstract_const = self.tcx.mir_abstract_const(def_id);
1120-
if let Some(abstract_const) = abstract_const {
1120+
if let Ok(Some(abstract_const)) = abstract_const {
11211121
record!(self.tables.mir_abstract_consts[def_id.to_def_id()] <- abstract_const);
11221122
}
11231123
}
@@ -1300,7 +1300,7 @@ impl EncodeContext<'a, 'tcx> {
13001300
});
13011301
record!(self.tables.visibility[def_id] <-
13021302
ty::Visibility::from_hir(&item.vis, item.hir_id, tcx));
1303-
record!(self.tables.span[def_id] <- item.span);
1303+
record!(self.tables.span[def_id] <- self.tcx.def_span(def_id));
13041304
record!(self.tables.attributes[def_id] <- item.attrs);
13051305
// FIXME(eddyb) there should be a nicer way to do this.
13061306
match item.kind {

compiler/rustc_middle/src/mir/interpret/error.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ pub enum ErrorHandled {
2323
TooGeneric,
2424
}
2525

26+
impl From<ErrorReported> for ErrorHandled {
27+
fn from(err: ErrorReported) -> ErrorHandled {
28+
ErrorHandled::Reported(err)
29+
}
30+
}
31+
2632
CloneTypeFoldableAndLiftImpls! {
2733
ErrorHandled,
2834
}

compiler/rustc_middle/src/mir/predecessors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ impl PredecessorCache {
3333
self.cache = OnceCell::new();
3434
}
3535

36-
/// Returns the the predecessor graph for this MIR.
36+
/// Returns the predecessor graph for this MIR.
3737
#[inline]
3838
pub(super) fn compute(
3939
&self,

compiler/rustc_middle/src/query/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,15 +247,15 @@ rustc_queries! {
247247
/// Try to build an abstract representation of the given constant.
248248
query mir_abstract_const(
249249
key: DefId
250-
) -> Option<&'tcx [mir::abstract_const::Node<'tcx>]> {
250+
) -> Result<Option<&'tcx [mir::abstract_const::Node<'tcx>]>, ErrorReported> {
251251
desc {
252252
|tcx| "building an abstract representation for {}", tcx.def_path_str(key),
253253
}
254254
}
255255
/// Try to build an abstract representation of the given constant.
256256
query mir_abstract_const_of_const_arg(
257257
key: (LocalDefId, DefId)
258-
) -> Option<&'tcx [mir::abstract_const::Node<'tcx>]> {
258+
) -> Result<Option<&'tcx [mir::abstract_const::Node<'tcx>]>, ErrorReported> {
259259
desc {
260260
|tcx|
261261
"building an abstract representation for the const argument {}",

compiler/rustc_mir/src/borrow_check/member_constraints.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ impl<'tcx> MemberConstraintSet<'tcx, ty::RegionVid> {
7171
/// Pushes a member constraint into the set.
7272
///
7373
/// The input member constraint `m_c` is in the form produced by
74-
/// the the `rustc_middle::infer` code.
74+
/// the `rustc_middle::infer` code.
7575
///
7676
/// The `to_region_vid` callback fn is used to convert the regions
7777
/// within into `RegionVid` format -- it typically consults the

compiler/rustc_mir/src/interpret/memory.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -285,9 +285,11 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
285285
None => {
286286
// Deallocating global memory -- always an error
287287
return Err(match self.tcx.get_global_alloc(ptr.alloc_id) {
288-
Some(GlobalAlloc::Function(..)) => err_ub_format!("deallocating a function"),
288+
Some(GlobalAlloc::Function(..)) => {
289+
err_ub_format!("deallocating {}, which is a function", ptr.alloc_id)
290+
}
289291
Some(GlobalAlloc::Static(..) | GlobalAlloc::Memory(..)) => {
290-
err_ub_format!("deallocating static memory")
292+
err_ub_format!("deallocating {}, which is static memory", ptr.alloc_id)
291293
}
292294
None => err_ub!(PointerUseAfterFree(ptr.alloc_id)),
293295
}
@@ -297,15 +299,17 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
297299

298300
if alloc_kind != kind {
299301
throw_ub_format!(
300-
"deallocating {} memory using {} deallocation operation",
302+
"deallocating {}, which is {} memory, using {} deallocation operation",
303+
ptr.alloc_id,
301304
alloc_kind,
302305
kind
303306
);
304307
}
305308
if let Some((size, align)) = old_size_and_align {
306309
if size != alloc.size || align != alloc.align {
307310
throw_ub_format!(
308-
"incorrect layout on deallocation: allocation has size {} and alignment {}, but gave size {} and alignment {}",
311+
"incorrect layout on deallocation: {} has size {} and alignment {}, but gave size {} and alignment {}",
312+
ptr.alloc_id,
309313
alloc.size.bytes(),
310314
alloc.align.bytes(),
311315
size.bytes(),

compiler/rustc_mir_build/src/build/matches/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
321321
let target_block = self.cfg.start_new_block();
322322
let mut schedule_drops = true;
323323
// We keep a stack of all of the bindings and type asciptions
324-
// from the the parent candidates that we visit, that also need to
324+
// from the parent candidates that we visit, that also need to
325325
// be bound for each candidate.
326326
traverse_candidate(
327327
candidate,

0 commit comments

Comments
 (0)