Skip to content
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

Rollup of 7 pull requests #92027

Closed
wants to merge 21 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
e5796c4
Apply path remapping to DW_AT_GNU_dwo_name
cbeuw Dec 5, 2021
4abed50
Provide .dwo paths to llvm-dwp explicitly
cbeuw Dec 6, 2021
3281022
Produce .dwo file for Packed as well
cbeuw Dec 6, 2021
95fd357
Correct test which wasn't failing correctly
cbeuw Dec 6, 2021
42190bb
Remove redundant path join
cbeuw Dec 6, 2021
3d16a20
Remap path in MCOptions
cbeuw Dec 11, 2021
f53e489
Show the unused type for `unused_results` lint
camelid Dec 12, 2021
707f72c
Revert "Produce .dwo file for Packed as well"
cbeuw Dec 13, 2021
5e481d0
Provide object files to llvm-dwp instead of .dwo
cbeuw Dec 13, 2021
8ae5780
pass -Wl,-z,origin to set DF_ORIGIN when using rpath
semarie Dec 13, 2021
77a0c65
Remove `in_band_lifetimes` from `rustc_query_impl`
LegionMammal978 Dec 14, 2021
fd47d24
miri: lift restriction on extern types being the only field in a struct
tmiasko Dec 14, 2021
c4bafaf
Remove `in_band_lifetimes` for `rustc_passes`
pitaj Dec 14, 2021
8150a2f
Update cargo
ehuss Dec 17, 2021
84fbd22
Rollup merge of #91566 - cbeuw:remap-dwo-name, r=davidtwco
matthiaskrgr Dec 17, 2021
6e90e8b
Rollup merge of #91818 - camelid:unused-result-type, r=jackh726
matthiaskrgr Dec 17, 2021
9b356de
Rollup merge of #91858 - semarie:runpath, r=petrochenkov
matthiaskrgr Dec 17, 2021
3379500
Rollup merge of #91896 - pitaj:91867-passes, r=michaelwoerister
matthiaskrgr Dec 17, 2021
e939ff9
Rollup merge of #91910 - tmiasko:miri-extern-type, r=RalfJung
matthiaskrgr Dec 17, 2021
3908da8
Rollup merge of #91923 - LegionMammal978:less-inband-query_impl, r=mi…
matthiaskrgr Dec 17, 2021
3a256f4
Rollup merge of #92023 - ehuss:update-cargo, r=ehuss
matthiaskrgr Dec 17, 2021
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
5 changes: 4 additions & 1 deletion compiler/rustc_codegen_llvm/src/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,11 @@ pub fn target_machine_factory(
let use_init_array =
!sess.opts.debugging_opts.use_ctors_section.unwrap_or(sess.target.use_ctors_section);

let path_mapping = sess.source_map().path_mapping().clone();

Arc::new(move |config: TargetMachineFactoryConfig| {
let split_dwarf_file = config.split_dwarf_file.unwrap_or_default();
let split_dwarf_file =
path_mapping.map_prefix(config.split_dwarf_file.unwrap_or_default()).0;
let split_dwarf_file = CString::new(split_dwarf_file.to_str().unwrap()).unwrap();

let tm = unsafe {
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1055,11 +1055,11 @@ pub fn compile_unit_metadata(
let work_dir = tcx.sess.opts.working_dir.to_string_lossy(FileNameDisplayPreference::Remapped);
let flags = "\0";
let output_filenames = tcx.output_filenames(());
let out_dir = &output_filenames.out_directory;
let split_name = if tcx.sess.target_can_use_split_dwarf() {
output_filenames
.split_dwarf_path(tcx.sess.split_debuginfo(), Some(codegen_unit_name))
.map(|f| out_dir.join(f))
// We get a path relative to the working directory from split_dwarf_path
.map(|f| tcx.sess.source_map().path_mapping().map_prefix(f).0)
} else {
None
}
Expand Down
21 changes: 15 additions & 6 deletions compiler/rustc_codegen_ssa/src/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use cc::windows_registry;
use regex::Regex;
use tempfile::Builder as TempFileBuilder;

use std::ffi::OsString;
use std::ffi::{OsStr, OsString};
use std::lazy::OnceCell;
use std::path::{Path, PathBuf};
use std::process::{ExitStatus, Output, Stdio};
Expand Down Expand Up @@ -504,17 +504,19 @@ fn escape_stdout_stderr_string(s: &[u8]) -> String {

const LLVM_DWP_EXECUTABLE: &'static str = "rust-llvm-dwp";

/// Invoke `llvm-dwp` (shipped alongside rustc) to link `dwo` files from Split DWARF into a `dwp`
/// Invoke `llvm-dwp` (shipped alongside rustc) to link debuginfo in object files into a `dwp`
/// file.
fn link_dwarf_object<'a>(sess: &'a Session, executable_out_filename: &Path) {
fn link_dwarf_object<'a, I>(sess: &'a Session, executable_out_filename: &Path, object_files: I)
where
I: IntoIterator<Item: AsRef<OsStr>>,
{
info!("preparing dwp to {}.dwp", executable_out_filename.to_str().unwrap());

let dwp_out_filename = executable_out_filename.with_extension("dwp");
let mut cmd = Command::new(LLVM_DWP_EXECUTABLE);
cmd.arg("-e");
cmd.arg(executable_out_filename);
cmd.arg("-o");
cmd.arg(&dwp_out_filename);
cmd.args(object_files);

let mut new_path = sess.get_tools_search_paths(false);
if let Some(path) = env::var_os("PATH") {
Expand Down Expand Up @@ -898,7 +900,14 @@ fn link_natively<'a, B: ArchiveBuilder<'a>>(
SplitDebuginfo::Packed if sess.target.is_like_msvc => {}

// ... and otherwise we're processing a `*.dwp` packed dwarf file.
SplitDebuginfo::Packed => link_dwarf_object(sess, &out_filename),
// We cannot rely on the .o paths in the exectuable because they may have been
// remapped by --remap-path-prefix and therefore invalid. So we need to provide
// the .o paths explicitly
SplitDebuginfo::Packed => link_dwarf_object(
sess,
&out_filename,
codegen_results.modules.iter().filter_map(|m| m.object.as_ref()),
),
}

let strip = strip_value(sess);
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_codegen_ssa/src/back/rpath.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ pub fn get_rpath_flags(config: &mut RPathConfig<'_>) -> Vec<String> {
fn rpaths_to_flags(rpaths: &[String]) -> Vec<String> {
let mut ret = Vec::with_capacity(rpaths.len()); // the minimum needed capacity

ret.push(String::from("-Wl,-z,origin"));
for rpath in rpaths {
if rpath.contains(',') {
ret.push("-Wl,-rpath".into());
Expand Down
16 changes: 3 additions & 13 deletions compiler/rustc_const_eval/src/interpret/eval_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -616,19 +616,9 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
match self.size_and_align_of(metadata, &field)? {
Some(size_and_align) => size_and_align,
None => {
// A field with extern type. If this field is at offset 0, we behave
// like the underlying extern type.
// FIXME: Once we have made decisions for how to handle size and alignment
// of `extern type`, this should be adapted. It is just a temporary hack
// to get some code to work that probably ought to work.
if sized_size == Size::ZERO {
return Ok(None);
} else {
span_bug!(
self.cur_span(),
"Fields cannot be extern types, unless they are at offset 0"
)
}
// A field with an extern type. We don't know the actual dynamic size
// or the alignment.
return Ok(None);
}
};

Expand Down
22 changes: 8 additions & 14 deletions compiler/rustc_const_eval/src/interpret/place.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,21 +362,15 @@ where
// Re-use parent metadata to determine dynamic field layout.
// With custom DSTS, this *will* execute user-defined code, but the same
// happens at run-time so that's okay.
let align = match self.size_and_align_of(&base.meta, &field_layout)? {
Some((_, align)) => align,
None if offset == Size::ZERO => {
// An extern type at offset 0, we fall back to its static alignment.
// FIXME: Once we have made decisions for how to handle size and alignment
// of `extern type`, this should be adapted. It is just a temporary hack
// to get some code to work that probably ought to work.
field_layout.align.abi
match self.size_and_align_of(&base.meta, &field_layout)? {
Some((_, align)) => (base.meta, offset.align_to(align)),
None => {
// For unsized types with an extern type tail we perform no adjustments.
// NOTE: keep this in sync with `PlaceRef::project_field` in the codegen backend.
assert!(matches!(base.meta, MemPlaceMeta::None));
(base.meta, offset)
}
None => span_bug!(
self.cur_span(),
"cannot compute offset for extern type field at non-0 offset"
),
};
(base.meta, offset.align_to(align))
}
} else {
// base.meta could be present; we might be accessing a sized field of an unsized
// struct.
Expand Down
4 changes: 3 additions & 1 deletion compiler/rustc_lint/src/unused.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,9 @@ impl<'tcx> LateLintPass<'tcx> for UnusedResults {
}

if !(type_permits_lack_of_use || fn_warned || op_warned) {
cx.struct_span_lint(UNUSED_RESULTS, s.span, |lint| lint.build("unused result").emit());
cx.struct_span_lint(UNUSED_RESULTS, s.span, |lint| {
lint.build(&format!("unused result of type `{}`", ty)).emit()
});
}

// Returns whether an error has been emitted (and thus another does not need to be later).
Expand Down
10 changes: 5 additions & 5 deletions compiler/rustc_passes/src/check_attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ struct CheckAttrVisitor<'tcx> {
tcx: TyCtxt<'tcx>,
}

impl CheckAttrVisitor<'tcx> {
impl CheckAttrVisitor<'_> {
/// Checks any attribute.
fn check_attributes(
&self,
Expand Down Expand Up @@ -382,7 +382,7 @@ impl CheckAttrVisitor<'tcx> {
&self,
hir_id: HirId,
attr_span: &Span,
attrs: &'hir [Attribute],
attrs: &[Attribute],
span: &Span,
target: Target,
) -> bool {
Expand Down Expand Up @@ -1481,7 +1481,7 @@ impl CheckAttrVisitor<'tcx> {
/// Checks if the `#[repr]` attributes on `item` are valid.
fn check_repr(
&self,
attrs: &'hir [Attribute],
attrs: &[Attribute],
span: &Span,
target: Target,
item: Option<ItemLike<'_>>,
Expand Down Expand Up @@ -1663,7 +1663,7 @@ impl CheckAttrVisitor<'tcx> {
}
}

fn check_used(&self, attrs: &'hir [Attribute], target: Target) {
fn check_used(&self, attrs: &[Attribute], target: Target) {
for attr in attrs {
if attr.has_name(sym::used) && target != Target::Static {
self.tcx
Expand Down Expand Up @@ -1842,7 +1842,7 @@ impl CheckAttrVisitor<'tcx> {
}
}

impl Visitor<'tcx> for CheckAttrVisitor<'tcx> {
impl<'tcx> Visitor<'tcx> for CheckAttrVisitor<'tcx> {
type Map = Map<'tcx>;

fn nested_visit_map(&mut self) -> NestedVisitorMap<Self::Map> {
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_passes/src/check_const.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ impl<'tcx> CheckConstTraitVisitor<'tcx> {
impl<'tcx> hir::itemlikevisit::ItemLikeVisitor<'tcx> for CheckConstTraitVisitor<'tcx> {
/// check for const trait impls, and errors if the impl uses provided/default functions
/// of the trait being implemented; as those provided functions can be non-const.
fn visit_item(&mut self, item: &'hir hir::Item<'hir>) {
fn visit_item<'hir>(&mut self, item: &'hir hir::Item<'hir>) {
let _: Option<_> = try {
if let hir::ItemKind::Impl(ref imp) = item.kind {
if let hir::Constness::Const = imp.constness {
Expand Down Expand Up @@ -134,11 +134,11 @@ impl<'tcx> hir::itemlikevisit::ItemLikeVisitor<'tcx> for CheckConstTraitVisitor<
};
}

fn visit_trait_item(&mut self, _: &'hir hir::TraitItem<'hir>) {}
fn visit_trait_item<'hir>(&mut self, _: &'hir hir::TraitItem<'hir>) {}

fn visit_impl_item(&mut self, _: &'hir hir::ImplItem<'hir>) {}
fn visit_impl_item<'hir>(&mut self, _: &'hir hir::ImplItem<'hir>) {}

fn visit_foreign_item(&mut self, _: &'hir hir::ForeignItem<'hir>) {}
fn visit_foreign_item<'hir>(&mut self, _: &'hir hir::ForeignItem<'hir>) {}
}

#[derive(Copy, Clone)]
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_passes/src/dead.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ impl<'tcx> MarkSymbolVisitor<'tcx> {

#[allow(dead_code)] // FIXME(81658): should be used + lint reinstated after #83171 relands.
fn check_for_self_assign(&mut self, assign: &'tcx hir::Expr<'tcx>) {
fn check_for_self_assign_helper(
fn check_for_self_assign_helper<'tcx>(
tcx: TyCtxt<'tcx>,
typeck_results: &'tcx ty::TypeckResults<'tcx>,
lhs: &'tcx hir::Expr<'tcx>,
Expand Down Expand Up @@ -600,7 +600,7 @@ struct DeadVisitor<'tcx> {
live_symbols: FxHashSet<LocalDefId>,
}

impl DeadVisitor<'tcx> {
impl<'tcx> DeadVisitor<'tcx> {
fn should_warn_about_item(&mut self, item: &hir::Item<'_>) -> bool {
let should_warn = matches!(
item.kind,
Expand Down Expand Up @@ -672,7 +672,7 @@ impl DeadVisitor<'tcx> {
}
}

impl Visitor<'tcx> for DeadVisitor<'tcx> {
impl<'tcx> Visitor<'tcx> for DeadVisitor<'tcx> {
type Map = Map<'tcx>;

/// Walk nested items in place so that we don't report dead-code
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_passes/src/intrinsicck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ fn unpack_option_like<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Ty<'tcx> {
ty
}

impl ExprVisitor<'tcx> {
impl<'tcx> ExprVisitor<'tcx> {
fn def_id_is_transmute(&self, def_id: DefId) -> bool {
self.tcx.fn_sig(def_id).abi() == RustIntrinsic
&& self.tcx.item_name(def_id) == sym::transmute
Expand Down Expand Up @@ -487,7 +487,7 @@ impl ExprVisitor<'tcx> {
}
}

impl Visitor<'tcx> for ItemVisitor<'tcx> {
impl<'tcx> Visitor<'tcx> for ItemVisitor<'tcx> {
type Map = intravisit::ErasedMap<'tcx>;

fn nested_visit_map(&mut self) -> NestedVisitorMap<Self::Map> {
Expand All @@ -504,7 +504,7 @@ impl Visitor<'tcx> for ItemVisitor<'tcx> {
}
}

impl Visitor<'tcx> for ExprVisitor<'tcx> {
impl<'tcx> Visitor<'tcx> for ExprVisitor<'tcx> {
type Map = intravisit::ErasedMap<'tcx>;

fn nested_visit_map(&mut self) -> NestedVisitorMap<Self::Map> {
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_passes/src/lang_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ struct LanguageItemCollector<'tcx> {
tcx: TyCtxt<'tcx>,
}

impl ItemLikeVisitor<'v> for LanguageItemCollector<'tcx> {
impl<'v, 'tcx> ItemLikeVisitor<'v> for LanguageItemCollector<'tcx> {
fn visit_item(&mut self, item: &hir::Item<'_>) {
self.check_for_lang(Target::from_item(item), item.hir_id());

Expand All @@ -50,7 +50,7 @@ impl ItemLikeVisitor<'v> for LanguageItemCollector<'tcx> {
fn visit_foreign_item(&mut self, _: &hir::ForeignItem<'_>) {}
}

impl LanguageItemCollector<'tcx> {
impl<'tcx> LanguageItemCollector<'tcx> {
fn new(tcx: TyCtxt<'tcx>) -> LanguageItemCollector<'tcx> {
LanguageItemCollector { tcx, items: LanguageItems::new() }
}
Expand Down
12 changes: 6 additions & 6 deletions compiler/rustc_passes/src/layout_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ struct LayoutTest<'tcx> {
tcx: TyCtxt<'tcx>,
}

impl ItemLikeVisitor<'tcx> for LayoutTest<'tcx> {
impl<'tcx> ItemLikeVisitor<'tcx> for LayoutTest<'tcx> {
fn visit_item(&mut self, item: &'tcx hir::Item<'tcx>) {
match item.kind {
ItemKind::TyAlias(..)
Expand All @@ -42,7 +42,7 @@ impl ItemLikeVisitor<'tcx> for LayoutTest<'tcx> {
fn visit_foreign_item(&mut self, _: &'tcx hir::ForeignItem<'tcx>) {}
}

impl LayoutTest<'tcx> {
impl<'tcx> LayoutTest<'tcx> {
fn dump_layout_of(&self, item_def_id: LocalDefId, item: &hir::Item<'tcx>, attr: &Attribute) {
let tcx = self.tcx;
let param_env = self.tcx.param_env(item_def_id);
Expand Down Expand Up @@ -114,7 +114,7 @@ struct UnwrapLayoutCx<'tcx> {
param_env: ParamEnv<'tcx>,
}

impl LayoutOfHelpers<'tcx> for UnwrapLayoutCx<'tcx> {
impl<'tcx> LayoutOfHelpers<'tcx> for UnwrapLayoutCx<'tcx> {
type LayoutOfResult = TyAndLayout<'tcx>;

fn handle_layout_err(&self, err: LayoutError<'tcx>, span: Span, ty: Ty<'tcx>) -> ! {
Expand All @@ -127,19 +127,19 @@ impl LayoutOfHelpers<'tcx> for UnwrapLayoutCx<'tcx> {
}
}

impl HasTyCtxt<'tcx> for UnwrapLayoutCx<'tcx> {
impl<'tcx> HasTyCtxt<'tcx> for UnwrapLayoutCx<'tcx> {
fn tcx(&self) -> TyCtxt<'tcx> {
self.tcx
}
}

impl HasParamEnv<'tcx> for UnwrapLayoutCx<'tcx> {
impl<'tcx> HasParamEnv<'tcx> for UnwrapLayoutCx<'tcx> {
fn param_env(&self) -> ParamEnv<'tcx> {
self.param_env
}
}

impl HasDataLayout for UnwrapLayoutCx<'tcx> {
impl<'tcx> HasDataLayout for UnwrapLayoutCx<'tcx> {
fn data_layout(&self) -> &TargetDataLayout {
self.tcx.data_layout()
}
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_passes/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
#![feature(crate_visibility_modifier)]
#![feature(in_band_lifetimes)]
#![feature(map_try_insert)]
#![feature(min_specialization)]
#![feature(nll)]
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_passes/src/lib_features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub struct LibFeatureCollector<'tcx> {
lib_features: LibFeatures,
}

impl LibFeatureCollector<'tcx> {
impl<'tcx> LibFeatureCollector<'tcx> {
fn new(tcx: TyCtxt<'tcx>) -> LibFeatureCollector<'tcx> {
LibFeatureCollector { tcx, lib_features: new_lib_features() }
}
Expand Down Expand Up @@ -110,7 +110,7 @@ impl LibFeatureCollector<'tcx> {
}
}

impl Visitor<'tcx> for LibFeatureCollector<'tcx> {
impl<'tcx> Visitor<'tcx> for LibFeatureCollector<'tcx> {
type Map = Map<'tcx>;

fn nested_visit_map(&mut self) -> NestedVisitorMap<Self::Map> {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_passes/src/liveness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ struct IrMaps<'tcx> {
lnks: IndexVec<LiveNode, LiveNodeKind>,
}

impl IrMaps<'tcx> {
impl<'tcx> IrMaps<'tcx> {
fn new(tcx: TyCtxt<'tcx>) -> IrMaps<'tcx> {
IrMaps {
tcx,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_passes/src/naked_functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ impl<'tcx> Visitor<'tcx> for CheckNakedFunctions<'tcx> {

fn visit_fn(
&mut self,
fk: FnKind<'v>,
fk: FnKind<'_>,
_fd: &'tcx hir::FnDecl<'tcx>,
body_id: hir::BodyId,
span: Span,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_passes/src/reachable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use rustc_target::spec::abi::Abi;
// Returns true if the given item must be inlined because it may be
// monomorphized or it was marked with `#[inline]`. This will only return
// true for functions.
fn item_might_be_inlined(tcx: TyCtxt<'tcx>, item: &hir::Item<'_>, attrs: &CodegenFnAttrs) -> bool {
fn item_might_be_inlined(tcx: TyCtxt<'_>, item: &hir::Item<'_>, attrs: &CodegenFnAttrs) -> bool {
if attrs.requests_inline() {
return true;
}
Expand Down
Loading