Skip to content

Rollup of 8 pull requests #110295

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

Merged
merged 22 commits into from
Apr 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
2c66c8f
Fix diff option conflict in UI test
chenyukang Mar 11, 2023
1178c49
Check for body owner fallibly
compiler-errors Apr 11, 2023
229b0a0
Make rust-intrinsic ABI unwindable
nbdd0121 Apr 12, 2023
5c9b371
Bless tests
nbdd0121 Apr 12, 2023
9e0e4c3
Added diagnostic for pin! macro in addition to Box::pin if Unpin isn'…
ndrewxie Apr 12, 2023
1e2f0d2
automatically update the LLVM submodule
KittyBorgX Apr 13, 2023
03cf0e9
refactor: emit "unused assoc fn" in lexical order
Ezrashaw Apr 12, 2023
731c6dc
Document catch_fn in r#try cannot unwind
nbdd0121 Apr 12, 2023
c41dcac
dead-code-lint: de-dup multiple unused assoc fns
Ezrashaw Apr 13, 2023
b07a470
Add regression test
nbdd0121 Apr 12, 2023
39e23ef
impl reviewer feedback
Ezrashaw Apr 13, 2023
2bafc0f
bless the single test
Ezrashaw Apr 13, 2023
4061eb5
Only emit alignment checks if we have a panic_impl
saethlin Apr 13, 2023
09a8791
Implement `Copy` for `LocationDetail`
WaffleLapkin Apr 13, 2023
d146211
Rollup merge of #109036 - chenyukang:yukang/fix-testcase, r=jyn514
matthiaskrgr Apr 13, 2023
232eb69
Rollup merge of #110193 - compiler-errors:body-owner-issue, r=WaffleL…
matthiaskrgr Apr 13, 2023
e85ecbb
Rollup merge of #110233 - nbdd0121:intrinsic, r=tmiasko
matthiaskrgr Apr 13, 2023
e413c2e
Rollup merge of #110259 - ndrewxie:issue-109964-fix-gitstuff, r=cjgillot
matthiaskrgr Apr 13, 2023
e86de74
Rollup merge of #110265 - KittyBorgX:master, r=ozkanonur
matthiaskrgr Apr 13, 2023
759d4e8
Rollup merge of #110277 - Ezrashaw:combine-assoc-fns-dlint, r=lcnr
matthiaskrgr Apr 13, 2023
c140e25
Rollup merge of #110283 - saethlin:check-panics-before-alignment, r=b…
matthiaskrgr Apr 13, 2023
46c6301
Rollup merge of #110291 - WaffleLapkin:copy_location_detail, r=oli-obk
matthiaskrgr Apr 13, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
line: u32,
col: u32,
) -> MPlaceTy<'tcx, M::Provenance> {
let loc_details = &self.tcx.sess.opts.unstable_opts.location_detail;
let loc_details = self.tcx.sess.opts.unstable_opts.location_detail;
// This can fail if rustc runs out of memory right here. Trying to emit an error would be
// pointless, since that would require allocating more memory than these short strings.
let file = if loc_details.file {
Expand Down
5 changes: 3 additions & 2 deletions compiler/rustc_middle/src/ty/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1226,10 +1226,11 @@ pub fn fn_can_unwind(tcx: TyCtxt<'_>, fn_def_id: Option<DefId>, abi: SpecAbi) ->
| AvrNonBlockingInterrupt
| CCmseNonSecureCall
| Wasm
| RustIntrinsic
| PlatformIntrinsic
| Unadjusted => false,
Rust | RustCall | RustCold => tcx.sess.panic_strategy() == PanicStrategy::Unwind,
Rust | RustCall | RustCold | RustIntrinsic => {
tcx.sess.panic_strategy() == PanicStrategy::Unwind
}
}
}

Expand Down
7 changes: 7 additions & 0 deletions compiler/rustc_mir_transform/src/check_alignment.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::MirPass;
use rustc_hir::def_id::DefId;
use rustc_hir::lang_items::LangItem;
use rustc_index::vec::IndexVec;
use rustc_middle::mir::*;
use rustc_middle::mir::{
Expand All @@ -17,6 +18,12 @@ impl<'tcx> MirPass<'tcx> for CheckAlignment {
}

fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
// This pass emits new panics. If for whatever reason we do not have a panic
// implementation, running this pass may cause otherwise-valid code to not compile.
if tcx.lang_items().get(LangItem::PanicImpl).is_none() {
return;
}

let basic_blocks = body.basic_blocks.as_mut();
let local_decls = &mut body.local_decls;

Expand Down
62 changes: 42 additions & 20 deletions compiler/rustc_passes/src/dead.rs
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,13 @@ impl<'tcx> DeadVisitor<'tcx> {
.collect();

let descr = tcx.def_descr(first_id.to_def_id());
// `impl` blocks are "batched" and (unlike other batching) might
// contain different kinds of associated items.
let descr = if dead_codes.iter().any(|did| tcx.def_descr(did.to_def_id()) != descr) {
"associated item"
} else {
descr
};
let num = dead_codes.len();
let multiple = num > 6;
let name_list = names.into();
Expand All @@ -712,12 +719,12 @@ impl<'tcx> DeadVisitor<'tcx> {

let parent_info = if let Some(parent_item) = parent_item {
let parent_descr = tcx.def_descr(parent_item.to_def_id());
Some(ParentInfo {
num,
descr,
parent_descr,
span: tcx.def_ident_span(parent_item).unwrap(),
})
let span = if let DefKind::Impl { .. } = tcx.def_kind(parent_item) {
tcx.def_span(parent_item)
} else {
tcx.def_ident_span(parent_item).unwrap()
};
Some(ParentInfo { num, descr, parent_descr, span })
} else {
None
};
Expand Down Expand Up @@ -800,16 +807,7 @@ impl<'tcx> DeadVisitor<'tcx> {
}

fn check_definition(&mut self, def_id: LocalDefId) {
if self.live_symbols.contains(&def_id) {
return;
}
if has_allow_dead_code_or_lang_attr(self.tcx, def_id) {
return;
}
let Some(name) = self.tcx.opt_item_name(def_id.to_def_id()) else {
return
};
if name.as_str().starts_with('_') {
if self.is_live_code(def_id) {
return;
}
match self.tcx.def_kind(def_id) {
Expand All @@ -827,6 +825,18 @@ impl<'tcx> DeadVisitor<'tcx> {
_ => {}
}
}

fn is_live_code(&self, def_id: LocalDefId) -> bool {
// if we cannot get a name for the item, then we just assume that it is
// live. I mean, we can't really emit a lint.
let Some(name) = self.tcx.opt_item_name(def_id.to_def_id()) else {
return true;
};

self.live_symbols.contains(&def_id)
|| has_allow_dead_code_or_lang_attr(self.tcx, def_id)
|| name.as_str().starts_with('_')
}
}

fn check_mod_deathness(tcx: TyCtxt<'_>, module: LocalDefId) {
Expand All @@ -836,6 +846,22 @@ fn check_mod_deathness(tcx: TyCtxt<'_>, module: LocalDefId) {
let module_items = tcx.hir_module_items(module);

for item in module_items.items() {
if let hir::ItemKind::Impl(impl_item) = tcx.hir().item(item).kind {
let mut dead_items = Vec::new();
for item in impl_item.items {
let did = item.id.owner_id.def_id;
if !visitor.is_live_code(did) {
dead_items.push(did)
}
}
visitor.warn_multiple_dead_codes(
&dead_items,
"used",
Some(item.owner_id.def_id),
false,
);
}

if !live_symbols.contains(&item.owner_id.def_id) {
let parent = tcx.local_parent(item.owner_id.def_id);
if parent != module && !live_symbols.contains(&parent) {
Expand Down Expand Up @@ -900,10 +926,6 @@ fn check_mod_deathness(tcx: TyCtxt<'_>, module: LocalDefId) {
}
}

for impl_item in module_items.impl_items() {
visitor.check_definition(impl_item.owner_id.def_id);
}

for foreign_item in module_items.foreign_items() {
visitor.check_definition(foreign_item.owner_id.def_id);
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_session/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ impl LinkerPluginLto {
}

/// The different settings that can be enabled via the `-Z location-detail` flag.
#[derive(Clone, PartialEq, Hash, Debug)]
#[derive(Copy, Clone, PartialEq, Hash, Debug)]
pub struct LocationDetail {
pub file: bool,
pub line: bool,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2396,8 +2396,8 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
}

if let Some(ty::subst::GenericArgKind::Type(_)) = subst.map(|subst| subst.unpack())
&& let Some(body_id) = self.tcx.hir().maybe_body_owned_by(obligation.cause.body_id)
{
let body_id = self.tcx.hir().body_owned_by(obligation.cause.body_id);
let mut expr_finder = FindExprBySpan::new(span);
expr_finder.visit_expr(&self.tcx.hir().body(body_id).value);

Expand Down
3 changes: 3 additions & 0 deletions library/core/src/ffi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -615,12 +615,15 @@ impl<'f> Drop for VaListImpl<'f> {
extern "rust-intrinsic" {
/// Destroy the arglist `ap` after initialization with `va_start` or
/// `va_copy`.
#[rustc_nounwind]
fn va_end(ap: &mut VaListImpl<'_>);

/// Copies the current location of arglist `src` to the arglist `dst`.
#[rustc_nounwind]
fn va_copy<'f>(dest: *mut VaListImpl<'f>, src: &VaListImpl<'f>);

/// Loads an argument of type `T` from the `va_list` `ap` and increment the
/// argument `ap` points to.
#[rustc_nounwind]
fn va_arg<T: sealed_trait::VaArgSafe>(ap: &mut VaListImpl<'_>) -> T;
}
Loading