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 #92694

Closed
wants to merge 29 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 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
336c85a
rustdoc: Preserve rendering of macro_rules matchers when possible
dtolnay Dec 27, 2021
544a6bb
Replace &DocCtxt -> TyCtxt in macro matcher rendering
dtolnay Dec 28, 2021
0f8415b
Add a test of rustdoc on macro-generated macro
dtolnay Dec 28, 2021
622a394
Allow handle_alloc_error to unwind
Amanieu Aug 17, 2021
f4545cc
Mark __rgl_oom and __rd_oom as "C-unwind"
Amanieu Oct 4, 2021
72cb1bd
silence tidy errors
yaahc Jan 7, 2022
6a1f9e6
mangling_v0: Update tests for the rust-demangler tool
petrochenkov Dec 26, 2021
1b8daf8
mangling_v0: Add a test for mangling of foreign types
petrochenkov Dec 27, 2021
333a5cc
mangling_v0: Skip extern blocks during mangling
petrochenkov Dec 27, 2021
c4471b0
rustc_metadata: Stop passing `CrateMetadataRef` by reference
petrochenkov Dec 24, 2021
d9b023c
Rollup merge of #91938 - yaahc:error-reporter, r=m-ou-se
matthiaskrgr Jan 9, 2022
d284cd8
Rollup merge of #92248 - compiler-errors:normalize-type-for-pointee, …
matthiaskrgr Jan 9, 2022
cb3f5f8
Rollup merge of #92277 - petrochenkov:cmrval2, r=jackh726
matthiaskrgr Jan 9, 2022
b34a770
Rollup merge of #92316 - petrochenkov:extmangle, r=wesleywiser
matthiaskrgr Jan 9, 2022
86e463b
Rollup merge of #92334 - dtolnay:rustdocmatcher, r=camelid,GuillaumeG…
matthiaskrgr Jan 9, 2022
6650a6f
Rollup merge of #92535 - Amanieu:oom_hook_unwind, r=m-ou-se
matthiaskrgr Jan 9, 2022
a8edbfe
Rollup merge of #92636 - compiler-errors:normalize-generator-const-ex…
matthiaskrgr Jan 9, 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
196 changes: 98 additions & 98 deletions compiler/rustc_metadata/src/rmeta/decoder.rs

Large diffs are not rendered by default.

9 changes: 6 additions & 3 deletions compiler/rustc_middle/src/ty/sty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2143,9 +2143,12 @@ impl<'tcx> TyS<'tcx> {
}

/// Returns the type of metadata for (potentially fat) pointers to this type.
pub fn ptr_metadata_ty(&'tcx self, tcx: TyCtxt<'tcx>) -> Ty<'tcx> {
// FIXME: should this normalize?
let tail = tcx.struct_tail_without_normalization(self);
pub fn ptr_metadata_ty(
&'tcx self,
tcx: TyCtxt<'tcx>,
normalize: impl FnMut(Ty<'tcx>) -> Ty<'tcx>,
) -> Ty<'tcx> {
let tail = tcx.struct_tail_with_normalize(self, normalize);
match tail.kind() {
// Sized types
ty::Infer(ty::IntVar(_) | ty::FloatVar(_))
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/ty/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ impl<'tcx> TyCtxt<'tcx> {
pub fn struct_tail_with_normalize(
self,
mut ty: Ty<'tcx>,
normalize: impl Fn(Ty<'tcx>) -> Ty<'tcx>,
mut normalize: impl FnMut(Ty<'tcx>) -> Ty<'tcx>,
) -> Ty<'tcx> {
let recursion_limit = self.recursion_limit();
for iteration in 0.. {
Expand Down
10 changes: 6 additions & 4 deletions compiler/rustc_mir_transform/src/generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -726,9 +726,13 @@ fn sanitize_witness<'tcx>(
saved_locals: &GeneratorSavedLocals,
) {
let did = body.source.def_id();
let allowed_upvars = tcx.erase_regions(upvars);
let param_env = tcx.param_env(did);

let allowed_upvars = tcx.normalize_erasing_regions(param_env, upvars);
let allowed = match witness.kind() {
&ty::GeneratorWitness(s) => tcx.erase_late_bound_regions(s),
&ty::GeneratorWitness(interior_tys) => {
tcx.normalize_erasing_late_bound_regions(param_env, interior_tys)
}
_ => {
tcx.sess.delay_span_bug(
body.span,
Expand All @@ -738,8 +742,6 @@ fn sanitize_witness<'tcx>(
}
};

let param_env = tcx.param_env(did);

for (local, decl) in body.local_decls.iter_enumerated() {
// Ignore locals which are internal or not saved between yields.
if !saved_locals.contains(local) || decl.internal {
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_symbol_mangling/src/v0.rs
Original file line number Diff line number Diff line change
Expand Up @@ -771,9 +771,9 @@ impl<'tcx> Printer<'tcx> for &mut SymbolMangler<'tcx> {
disambiguated_data: &DisambiguatedDefPathData,
) -> Result<Self::Path, Self::Error> {
let ns = match disambiguated_data.data {
// FIXME: It shouldn't be necessary to add anything for extern block segments,
// but we add 't' for backward compatibility.
DefPathData::ForeignMod => 't',
// Extern block segments can be skipped, names from extern blocks
// are effectively living in their parent modules.
DefPathData::ForeignMod => return print_prefix(self),

// Uppercase categories are more stable than lowercase ones.
DefPathData::TypeNs(_) => 't',
Expand Down
38 changes: 32 additions & 6 deletions compiler/rustc_trait_selection/src/traits/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1400,8 +1400,17 @@ fn assemble_candidates_from_impls<'cx, 'tcx>(
// Any type with multiple potential metadata types is therefore not eligible.
let self_ty = selcx.infcx().shallow_resolve(obligation.predicate.self_ty());

// FIXME: should this normalize?
let tail = selcx.tcx().struct_tail_without_normalization(self_ty);
let tail = selcx.tcx().struct_tail_with_normalize(self_ty, |ty| {
normalize_with_depth(
selcx,
obligation.param_env,
obligation.cause.clone(),
obligation.recursion_depth + 1,
ty,
)
.value
});

match tail.kind() {
ty::Bool
| ty::Char
Expand Down Expand Up @@ -1435,7 +1444,12 @@ fn assemble_candidates_from_impls<'cx, 'tcx>(
| ty::Bound(..)
| ty::Placeholder(..)
| ty::Infer(..)
| ty::Error(_) => false,
| ty::Error(_) => {
if tail.has_infer_types() {
candidate_set.mark_ambiguous();
}
false
},
}
}
super::ImplSource::Param(..) => {
Expand Down Expand Up @@ -1640,18 +1654,30 @@ fn confirm_pointee_candidate<'cx, 'tcx>(
_: ImplSourcePointeeData,
) -> Progress<'tcx> {
let tcx = selcx.tcx();

let self_ty = selcx.infcx().shallow_resolve(obligation.predicate.self_ty());
let substs = tcx.mk_substs([self_ty.into()].iter());

let mut obligations = vec![];
let metadata_ty = self_ty.ptr_metadata_ty(tcx, |ty| {
normalize_with_depth_to(
selcx,
obligation.param_env,
obligation.cause.clone(),
obligation.recursion_depth + 1,
ty,
&mut obligations,
)
});

let substs = tcx.mk_substs([self_ty.into()].iter());
let metadata_def_id = tcx.require_lang_item(LangItem::Metadata, None);

let predicate = ty::ProjectionPredicate {
projection_ty: ty::ProjectionTy { substs, item_def_id: metadata_def_id },
ty: self_ty.ptr_metadata_ty(tcx),
ty: metadata_ty,
};

confirm_param_env_candidate(selcx, obligation, ty::Binder::dummy(predicate), false)
.with_addl_obligations(obligations)
}

fn confirm_fn_pointer_candidate<'cx, 'tcx>(
Expand Down
6 changes: 2 additions & 4 deletions library/alloc/src/alloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,6 @@ extern "Rust" {
// This is the magic symbol to call the global alloc error handler. rustc generates
// it to call `__rg_oom` if there is a `#[alloc_error_handler]`, or to call the
// default implementations below (`__rdl_oom`) otherwise.
#[rustc_allocator_nounwind]
fn __rust_alloc_error_handler(size: usize, align: usize) -> !;
}

Expand All @@ -367,7 +366,6 @@ extern "Rust" {
#[stable(feature = "global_alloc", since = "1.28.0")]
#[rustc_const_unstable(feature = "const_alloc_error", issue = "92523")]
#[cfg(all(not(no_global_oom_handling), not(test)))]
#[rustc_allocator_nounwind]
#[cold]
pub const fn handle_alloc_error(layout: Layout) -> ! {
const fn ct_error(_: Layout) -> ! {
Expand Down Expand Up @@ -398,13 +396,13 @@ pub mod __alloc_error_handler {

// if there is no `#[alloc_error_handler]`
#[rustc_std_internal_symbol]
pub unsafe extern "C" fn __rdl_oom(size: usize, _align: usize) -> ! {
pub unsafe extern "C-unwind" fn __rdl_oom(size: usize, _align: usize) -> ! {
panic!("memory allocation of {} bytes failed", size)
}

// if there is an `#[alloc_error_handler]`
#[rustc_std_internal_symbol]
pub unsafe extern "C" fn __rg_oom(size: usize, align: usize) -> ! {
pub unsafe extern "C-unwind" fn __rg_oom(size: usize, align: usize) -> ! {
let layout = unsafe { Layout::from_size_align_unchecked(size, align) };
extern "Rust" {
#[lang = "oom"]
Expand Down
1 change: 1 addition & 0 deletions library/alloc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@
#![cfg_attr(test, feature(test))]
#![feature(unboxed_closures)]
#![feature(unsized_fn_params)]
#![feature(c_unwind)]
//
// Rustdoc features:
#![feature(doc_cfg)]
Expand Down
Loading