Skip to content

Rollup of 7 pull requests #92659

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

Closed
wants to merge 28 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
59df6c8
Try commiting again
seanchen1991 Oct 22, 2021
6a59d0e
Have `pretty` and `show_backtrace` accept booleans
seanchen1991 Oct 22, 2021
c6de413
Change `source` field to `error`
seanchen1991 Oct 22, 2021
c0f14cb
Attempt to fix tidy errors
seanchen1991 Oct 27, 2021
aa853bd
Add `rust` annotation to doctest
seanchen1991 Oct 27, 2021
d2f49ee
Format doctest
seanchen1991 Oct 27, 2021
32bcb81
Fix broken doctest
seanchen1991 Oct 27, 2021
1386a15
Update std::error::Report based on feedback
yaahc Dec 14, 2021
4420cc3
Update report output and fix examples
yaahc Dec 16, 2021
078b112
add a panicking example
yaahc Dec 16, 2021
9be1cc9
more docs improvements
yaahc Dec 16, 2021
5b3902f
attempt to make Report usable with Box dyn Error and fn main
yaahc Dec 17, 2021
e9fbe79
Remove &self from PrintState::to_string
dtolnay Dec 28, 2021
65f7fbc
mangling_v0: Update tests for the rust-demangler tool
petrochenkov Dec 26, 2021
14cd80d
mangling_v0: Add a test for mangling of foreign types
petrochenkov Dec 27, 2021
6bbbaf9
mangling_v0: Skip extern blocks during mangling
petrochenkov Dec 27, 2021
3632f41
Stabilize `#[feature(available_parallelism)]`
yoshuawuyts Jan 7, 2022
5ebe97b
rustc_metadata: Stop passing `CrateMetadataRef` by reference
petrochenkov Dec 24, 2021
130ba47
Fix typo in `StableCrateId` docs
pierwill Jan 7, 2022
836addc
Consolidate checking for msvc when generating debuginfo
wesleywiser Dec 28, 2021
72cb1bd
silence tidy errors
yaahc Jan 7, 2022
38b04ef
Rollup merge of #91938 - yaahc:error-reporter, r=m-ou-se
matthiaskrgr Jan 8, 2022
3d6aef3
Rollup merge of #92277 - petrochenkov:cmrval2, r=jackh726
matthiaskrgr Jan 8, 2022
f3e9260
Rollup merge of #92316 - petrochenkov:extmangle, r=wesleywiser
matthiaskrgr Jan 8, 2022
581491e
Rollup merge of #92336 - dtolnay:printstateself, r=michaelwoerister
matthiaskrgr Jan 8, 2022
6715e53
Rollup merge of #92375 - wesleywiser:consolidate_debuginfo_msvc_check…
matthiaskrgr Jan 8, 2022
7c8ceda
Rollup merge of #92632 - yoshuawuyts:stabilize-available-parallelism,…
matthiaskrgr Jan 8, 2022
2d50a8c
Rollup merge of #92650 - pierwill:patch-2, r=michaelwoerister
matthiaskrgr Jan 8, 2022
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
4 changes: 2 additions & 2 deletions compiler/rustc_ast_pretty/src/pprust/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,11 @@ pub fn attribute_to_string(attr: &ast::Attribute) -> String {
}

pub fn to_string(f: impl FnOnce(&mut State<'_>)) -> String {
State::new().to_string(f)
State::to_string(f)
}

pub fn crate_to_string_for_macros(krate: &ast::Crate) -> String {
State::new().to_string(|s| {
State::to_string(|s| {
s.print_inner_attributes(&krate.attrs);
for item in &krate.items {
s.print_item(item);
Expand Down
44 changes: 22 additions & 22 deletions compiler/rustc_ast_pretty/src/pprust/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ pub fn literal_to_string(lit: token::Lit) -> String {
}

fn visibility_qualified(vis: &ast::Visibility, s: &str) -> String {
format!("{}{}", State::new().to_string(|s| s.print_visibility(vis)), s)
format!("{}{}", State::to_string(|s| s.print_visibility(vis)), s)
}

impl std::ops::Deref for State<'_> {
Expand Down Expand Up @@ -793,55 +793,55 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
}

fn ty_to_string(&self, ty: &ast::Ty) -> String {
self.to_string(|s| s.print_type(ty))
Self::to_string(|s| s.print_type(ty))
}

fn bounds_to_string(&self, bounds: &[ast::GenericBound]) -> String {
self.to_string(|s| s.print_type_bounds("", bounds))
Self::to_string(|s| s.print_type_bounds("", bounds))
}

fn pat_to_string(&self, pat: &ast::Pat) -> String {
self.to_string(|s| s.print_pat(pat))
Self::to_string(|s| s.print_pat(pat))
}

fn expr_to_string(&self, e: &ast::Expr) -> String {
self.to_string(|s| s.print_expr(e))
Self::to_string(|s| s.print_expr(e))
}

fn tt_to_string(&self, tt: &TokenTree) -> String {
self.to_string(|s| s.print_tt(tt, false))
Self::to_string(|s| s.print_tt(tt, false))
}

fn tts_to_string(&self, tokens: &TokenStream) -> String {
self.to_string(|s| s.print_tts(tokens, false))
Self::to_string(|s| s.print_tts(tokens, false))
}

fn stmt_to_string(&self, stmt: &ast::Stmt) -> String {
self.to_string(|s| s.print_stmt(stmt))
Self::to_string(|s| s.print_stmt(stmt))
}

fn item_to_string(&self, i: &ast::Item) -> String {
self.to_string(|s| s.print_item(i))
Self::to_string(|s| s.print_item(i))
}

fn generic_params_to_string(&self, generic_params: &[ast::GenericParam]) -> String {
self.to_string(|s| s.print_generic_params(generic_params))
Self::to_string(|s| s.print_generic_params(generic_params))
}

fn path_to_string(&self, p: &ast::Path) -> String {
self.to_string(|s| s.print_path(p, false, 0))
Self::to_string(|s| s.print_path(p, false, 0))
}

fn path_segment_to_string(&self, p: &ast::PathSegment) -> String {
self.to_string(|s| s.print_path_segment(p, false))
Self::to_string(|s| s.print_path_segment(p, false))
}

fn vis_to_string(&self, v: &ast::Visibility) -> String {
self.to_string(|s| s.print_visibility(v))
Self::to_string(|s| s.print_visibility(v))
}

fn block_to_string(&self, blk: &ast::Block) -> String {
self.to_string(|s| {
Self::to_string(|s| {
// Containing cbox, will be closed by `print_block` at `}`.
s.cbox(INDENT_UNIT);
// Head-ibox, will be closed by `print_block` after `{`.
Expand All @@ -851,22 +851,22 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
}

fn meta_list_item_to_string(&self, li: &ast::NestedMetaItem) -> String {
self.to_string(|s| s.print_meta_list_item(li))
Self::to_string(|s| s.print_meta_list_item(li))
}

fn attr_item_to_string(&self, ai: &ast::AttrItem) -> String {
self.to_string(|s| s.print_attr_item(ai, ai.path.span))
Self::to_string(|s| s.print_attr_item(ai, ai.path.span))
}

fn attribute_to_string(&self, attr: &ast::Attribute) -> String {
self.to_string(|s| s.print_attribute(attr))
Self::to_string(|s| s.print_attribute(attr))
}

fn param_to_string(&self, arg: &ast::Param) -> String {
self.to_string(|s| s.print_param(arg, false))
Self::to_string(|s| s.print_param(arg, false))
}

fn to_string(&self, f: impl FnOnce(&mut State<'_>)) -> String {
fn to_string(f: impl FnOnce(&mut State<'_>)) -> String {
let mut printer = State::new();
f(&mut printer);
printer.s.eof()
Expand Down Expand Up @@ -1202,7 +1202,7 @@ impl<'a> State<'a> {
);
}
ast::ItemKind::Mod(unsafety, ref mod_kind) => {
self.head(self.to_string(|s| {
self.head(Self::to_string(|s| {
s.print_visibility(&item.vis);
s.print_unsafety(unsafety);
s.word("mod");
Expand All @@ -1228,7 +1228,7 @@ impl<'a> State<'a> {
}
}
ast::ItemKind::ForeignMod(ref nmod) => {
self.head(self.to_string(|s| {
self.head(Self::to_string(|s| {
s.print_unsafety(nmod.unsafety);
s.word("extern");
}));
Expand Down Expand Up @@ -1450,7 +1450,7 @@ impl<'a> State<'a> {
ast::CrateSugar::JustCrate => self.word_nbsp("crate"),
},
ast::VisibilityKind::Restricted { ref path, .. } => {
let path = self.to_string(|s| s.print_path(path, false, 0));
let path = Self::to_string(|s| s.print_path(path, false, 0));
if path == "self" || path == "super" {
self.word_nbsp(format!("pub({})", path))
} else {
Expand Down
28 changes: 14 additions & 14 deletions compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use crate::llvm::debuginfo::{
use crate::value::Value;

use cstr::cstr;
use rustc_codegen_ssa::debuginfo::type_names::cpp_like_debuginfo;
use rustc_codegen_ssa::traits::*;
use rustc_data_structures::fingerprint::Fingerprint;
use rustc_data_structures::fx::FxHashMap;
Expand Down Expand Up @@ -933,16 +934,16 @@ fn basic_type_metadata<'ll, 'tcx>(cx: &CodegenCx<'ll, 'tcx>, t: Ty<'tcx>) -> &'l

// When targeting MSVC, emit MSVC style type names for compatibility with
// .natvis visualizers (and perhaps other existing native debuggers?)
let msvc_like_names = cx.tcx.sess.target.is_like_msvc;
let cpp_like_debuginfo = cpp_like_debuginfo(cx.tcx);

let (name, encoding) = match t.kind() {
ty::Never => ("!", DW_ATE_unsigned),
ty::Tuple(elements) if elements.is_empty() => ("()", DW_ATE_unsigned),
ty::Bool => ("bool", DW_ATE_boolean),
ty::Char => ("char", DW_ATE_unsigned_char),
ty::Int(int_ty) if msvc_like_names => (int_ty.msvc_basic_name(), DW_ATE_signed),
ty::Uint(uint_ty) if msvc_like_names => (uint_ty.msvc_basic_name(), DW_ATE_unsigned),
ty::Float(float_ty) if msvc_like_names => (float_ty.msvc_basic_name(), DW_ATE_float),
ty::Int(int_ty) if cpp_like_debuginfo => (int_ty.msvc_basic_name(), DW_ATE_signed),
ty::Uint(uint_ty) if cpp_like_debuginfo => (uint_ty.msvc_basic_name(), DW_ATE_unsigned),
ty::Float(float_ty) if cpp_like_debuginfo => (float_ty.msvc_basic_name(), DW_ATE_float),
ty::Int(int_ty) => (int_ty.name_str(), DW_ATE_signed),
ty::Uint(uint_ty) => (uint_ty.name_str(), DW_ATE_unsigned),
ty::Float(float_ty) => (float_ty.name_str(), DW_ATE_float),
Expand All @@ -959,7 +960,7 @@ fn basic_type_metadata<'ll, 'tcx>(cx: &CodegenCx<'ll, 'tcx>, t: Ty<'tcx>) -> &'l
)
};

if !msvc_like_names {
if !cpp_like_debuginfo {
return ty_metadata;
}

Expand Down Expand Up @@ -1525,13 +1526,6 @@ fn prepare_union_metadata<'ll, 'tcx>(
// Enums
//=-----------------------------------------------------------------------------

/// DWARF variant support is only available starting in LLVM 8, but
/// on MSVC we have to use the fallback mode, because LLVM doesn't
/// lower variant parts to PDB.
fn use_enum_fallback(cx: &CodegenCx<'_, '_>) -> bool {
cx.sess().target.is_like_msvc
}

// FIXME(eddyb) maybe precompute this? Right now it's computed once
// per generator monomorphization, but it doesn't depend on substs.
fn generator_layout_and_saved_local_names<'tcx>(
Expand Down Expand Up @@ -1606,7 +1600,10 @@ impl<'ll, 'tcx> EnumMemberDescriptionFactory<'ll, 'tcx> {
_ => bug!(),
};

let fallback = use_enum_fallback(cx);
// While LLVM supports generating debuginfo for variant types (enums), it doesn't support
// lowering that debuginfo to CodeView records for msvc targets. So if we are targeting
// msvc, then we need to use a different, fallback encoding of the debuginfo.
let fallback = cpp_like_debuginfo(cx.tcx);
// This will always find the metadata in the type map.
let self_metadata = type_metadata(cx, self.enum_type, self.span);

Expand Down Expand Up @@ -2159,7 +2156,10 @@ fn prepare_enum_metadata<'ll, 'tcx>(
return FinalMetadata(discriminant_type_metadata(tag.value));
}

if use_enum_fallback(cx) {
// While LLVM supports generating debuginfo for variant types (enums), it doesn't support
// lowering that debuginfo to CodeView records for msvc targets. So if we are targeting
// msvc, then we need to use a different encoding of the debuginfo.
if cpp_like_debuginfo(tcx) {
let discriminant_type_metadata = match layout.variants {
Variants::Single { .. } => None,
Variants::Multiple { tag_encoding: TagEncoding::Niche { .. }, tag, .. }
Expand Down
Loading