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 25 pull requests #138044

Closed
wants to merge 76 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
477a2ee
std::fs: slightly reformat `remove_dir_all` error docs
jieyouxu Feb 18, 2025
2c752bc
Undeprecate env::home_dir
arlosi Feb 20, 2025
9323ba5
Remove MaybeForgetReturn suggestion
compiler-errors Feb 20, 2025
b340545
[illumos] attempt to use posix_spawn to spawn processes
sunshowers Feb 11, 2025
78615ff
Stablize `string_extend_from_within`
aDotInTheVoid Feb 24, 2025
a7bd4a3
Add DWARF test case for non-C-like `repr128` enums
beetrees Feb 25, 2025
b60aeb0
Stop passing --lib to cargo test
bjorn3 Feb 26, 2025
b491494
Also test coretests when running ./x.py test core
bjorn3 Feb 19, 2025
169e731
Fix unused import in coretests on wasm32
bjorn3 Feb 26, 2025
0ca1c9c
Count char width at most once in Formatter::pad
thaliaarchi Feb 6, 2025
b2bb7cc
Fix char count in Display for ByteStr
thaliaarchi Feb 28, 2025
41dd80a
add test to reproduce #137662 (using ty decl macro fragment in an att…
jdonszelmann Feb 26, 2025
476b098
adjust Layout debug printing to match the internal field names
RalfJung Feb 28, 2025
91034ad
Do not require that unsafe fields lack drop glue
jswrenn Feb 28, 2025
86aae8e
uefi: Add Service Binding Protocol abstraction
Ayush1325 Feb 23, 2025
3998690
compiletest: remove legacy `Makefile`-based `run-make` support
jieyouxu Feb 5, 2025
413b824
run-make: remove `tools.mk`
jieyouxu Feb 5, 2025
9b17c98
run-make: update test suite README
jieyouxu Feb 5, 2025
ed168e7
run-make-support: remove outdated comments
jieyouxu Mar 1, 2025
efec638
tidy: remove legacy `Makefile` checks
jieyouxu Feb 5, 2025
b0d6a84
rustc-dev-guide: remove mentions of legacy `Makefile` run-make infra
jieyouxu Feb 5, 2025
95b030f
triagebot: stop backlinking to the test porting tracking issue
jieyouxu Feb 5, 2025
a0ed304
float: Update some constants to `pub(crate)`
tgross35 Dec 9, 2024
5a2da96
dec2flt: Update documentation of existing methods
tgross35 Dec 9, 2024
49a2d4c
dec2flt: Rename `Decimal` to `DecimalSeq`
tgross35 Dec 9, 2024
626d2c5
dec2flt: Rename `Number` to `Decimal`
tgross35 Dec 9, 2024
6c34daf
dec2flt: Rename fields to be consistent with documented notation
tgross35 Dec 9, 2024
19a909a
dec2flt: Refactor float traits
tgross35 Dec 9, 2024
37e223c
dec2flt: Refactor the fast path
tgross35 Dec 9, 2024
a23566a
Provide more context on resolve error caused from incorrect RTN
estebank Feb 28, 2025
ab31129
Point of macro expansion from call expr if it involves macro var
compiler-errors Feb 24, 2025
e4dfca8
Point out macro expansion ident in resolver errors too
compiler-errors Feb 24, 2025
0607246
Fix associated type errors too
compiler-errors Feb 24, 2025
09e5846
Also note struct access, and fix macro expansion from foreign crates
compiler-errors Feb 24, 2025
69c4651
ci: use ubuntu 24 on arm large runner
marcoieni Mar 4, 2025
da3e736
Clarify why InhabitedPredicate::instantiate_opt exists
meithecatte Feb 28, 2025
a3d63fb
InhabitedPredicate: avoid using a wildcard branch
meithecatte Mar 3, 2025
c392cf7
Added documentation for flushing
pcorwin Feb 10, 2025
3d62b27
Ensure that negative auto impls are always applicable
compiler-errors Feb 28, 2025
05a8060
Make rustdoc tests use always applicable negative auto impls
compiler-errors Feb 28, 2025
d759958
Only use implied bounds hack if bevy, and use deeply normalize in imp…
compiler-errors Mar 4, 2025
1f32f7b
compiler: add `ExternAbi::is_rustic_abi`
workingjubilee Mar 5, 2025
08b5783
compiler: use `is_rustic_abi` in mir_transform
workingjubilee Mar 5, 2025
5abf36b
compiler: use `is_rustic_abi` in ImproperCTypesVisitor
workingjubilee Mar 5, 2025
e81fbe3
compiler: use `is_rustic_abi` in abi_check
workingjubilee Mar 5, 2025
8a68987
compiler: use `is_rustic_abi` in ty_utils
workingjubilee Mar 5, 2025
31e612b
move `rust.description` to `build.description`
onur-ozkan Feb 27, 2025
92956e8
add change-entry
onur-ozkan Feb 27, 2025
853e34d
pass `CFG_VER_DESCRIPTION` to tool builds
onur-ozkan Feb 27, 2025
9646c2f
replace `rust.description` with `build.description`
onur-ozkan Feb 27, 2025
b1731a1
Update bootstrap to edition 2024
Kobzol Feb 25, 2025
cfe2bfd
Rollup merge of #134063 - tgross35:dec2flt-refactoring, r=Noratrieb
workingjubilee Mar 5, 2025
6dd3260
Rollup merge of #136581 - jieyouxu:makefile-be-gone, r=Kobzol
workingjubilee Mar 5, 2025
c5df847
Rollup merge of #136662 - thaliaarchi:formatter-pad-char-count, r=m-o…
workingjubilee Mar 5, 2025
6142691
Rollup merge of #136798 - pcorwin:master, r=tgross35
workingjubilee Mar 5, 2025
0472bf6
Rollup merge of #137240 - jieyouxu:remove_dir_all, r=Mark-Simulacrum
workingjubilee Mar 5, 2025
45f00c1
Rollup merge of #137303 - compiler-errors:maybe-forgor, r=cjgillot
workingjubilee Mar 5, 2025
cd4c30c
Rollup merge of #137327 - arlosi:home-dir, r=Mark-Simulacrum
workingjubilee Mar 5, 2025
50ddf35
Rollup merge of #137463 - sunshowers:illumos-posix-spawn, r=Mark-Simu…
workingjubilee Mar 5, 2025
c8404a9
Rollup merge of #137477 - Ayush1325:uefi-service-binding, r=Noratrieb
workingjubilee Mar 5, 2025
bcf40c6
Rollup merge of #137565 - compiler-errors:macro-ex, r=estebank
workingjubilee Mar 5, 2025
9d50e7d
Rollup merge of #137569 - aDotInTheVoid:for-iurii, r=ibraheemdev
workingjubilee Mar 5, 2025
d9cd12c
Rollup merge of #137612 - Kobzol:bootstrap-2024, r=onur-ozkan
workingjubilee Mar 5, 2025
0a23e08
Rollup merge of #137633 - compiler-errors:no-implied-bounds-hack-unle…
workingjubilee Mar 5, 2025
9e340e9
Rollup merge of #137643 - beetrees:repr128-dwarf-variant-test, r=jiey…
workingjubilee Mar 5, 2025
9530af8
Rollup merge of #137679 - bjorn3:coretests_improvements, r=jieyouxu,o…
workingjubilee Mar 5, 2025
958b022
Rollup merge of #137723 - onur-ozkan:cfg-ver-description, r=pietroalb…
workingjubilee Mar 5, 2025
4fad28f
Rollup merge of #137758 - jdonszelmann:fix-137662, r=nnethercote
workingjubilee Mar 5, 2025
19705be
Rollup merge of #137764 - compiler-errors:always-applicable-negative-…
workingjubilee Mar 5, 2025
6033e1b
Rollup merge of #137772 - thaliaarchi:bstr-display, r=joshtriplett
workingjubilee Mar 5, 2025
b25a17f
Rollup merge of #137798 - marcoieni:ubuntu-24-large-runner-arm, r=Kobzol
workingjubilee Mar 5, 2025
b41fb2f
Rollup merge of #137805 - RalfJung:layout-debug-print, r=Noratrieb
workingjubilee Mar 5, 2025
3d11e5a
Rollup merge of #137808 - jswrenn:droppy-unsafe-fields, r=nnethercote
workingjubilee Mar 5, 2025
54b404c
Rollup merge of #137820 - meithecatte:instantiate-opt, r=BoxyUwU
workingjubilee Mar 5, 2025
49b74ce
Rollup merge of #137825 - estebank:rtn-sugg-2, r=compiler-errors
workingjubilee Mar 5, 2025
2d6b3c2
Rollup merge of #138028 - workingjubilee:is-rustic-abi, r=compiler-er…
workingjubilee Mar 5, 2025
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
11 changes: 11 additions & 0 deletions compiler/rustc_abi/src/extern_abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,17 @@ impl StableOrd for ExternAbi {
}

impl ExternAbi {
/// An ABI "like Rust"
///
/// These ABIs are fully controlled by the Rust compiler, which means they
/// - support unwinding with `-Cpanic=unwind`, unlike `extern "C"`
/// - often diverge from the C ABI
/// - are subject to change between compiler versions
pub fn is_rustic_abi(self) -> bool {
use ExternAbi::*;
matches!(self, Rust | RustCall | RustIntrinsic | RustCold)
}

pub fn supports_varargs(self) -> bool {
// * C and Cdecl obviously support varargs.
// * C can be based on Aapcs, SysV64 or Win64, so they must support varargs.
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_abi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1812,7 +1812,7 @@ where
f.debug_struct("Layout")
.field("size", size)
.field("align", align)
.field("abi", backend_repr)
.field("backend_repr", backend_repr)
.field("fields", fields)
.field("largest_niche", largest_niche)
.field("uninhabited", uninhabited)
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_ast_lowering/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -926,7 +926,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
if let Some(first_char) = constraint.ident.as_str().chars().next()
&& first_char.is_ascii_lowercase()
{
tracing::info!(?data, ?data.inputs);
let err = match (&data.inputs[..], &data.output) {
([_, ..], FnRetTy::Default(_)) => {
errors::BadReturnTypeNotation::Inputs { span: data.inputs_span }
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_ast_lowering/src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
}
GenericArgs::Parenthesized(data) => match generic_args_mode {
GenericArgsMode::ReturnTypeNotation => {
tracing::info!(?data, ?data.inputs);
let err = match (&data.inputs[..], &data.output) {
([_, ..], FnRetTy::Default(_)) => {
BadReturnTypeNotation::Inputs { span: data.inputs_span }
Expand Down
9 changes: 9 additions & 0 deletions compiler/rustc_attr_parsing/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,15 @@ impl<'a> MetaItemListParserContext<'a> {
{
self.inside_delimiters.next();
return Some(MetaItemOrLitParser::Lit(lit));
} else if let Some(TokenTree::Delimited(.., Delimiter::Invisible(_), inner_tokens)) =
self.inside_delimiters.peek()
{
self.inside_delimiters.next();
return MetaItemListParserContext {
inside_delimiters: inner_tokens.iter().peekable(),
dcx: self.dcx,
}
.next();
}

// or a path.
Expand Down
10 changes: 6 additions & 4 deletions compiler/rustc_data_structures/src/marker.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::alloc::Allocator;

#[rustc_on_unimplemented(message = "`{Self}` doesn't implement `DynSend`. \
Add it to `rustc_data_structures::marker` or use `IntoDynSyncSend` if it's already `Send`")]
// This is an auto trait for types which can be sent across threads if `sync::is_dyn_thread_safe()`
Expand Down Expand Up @@ -28,8 +30,8 @@ impls_dyn_send_neg!(
[*const T where T: ?Sized]
[*mut T where T: ?Sized]
[std::ptr::NonNull<T> where T: ?Sized]
[std::rc::Rc<T> where T: ?Sized]
[std::rc::Weak<T> where T: ?Sized]
[std::rc::Rc<T, A> where T: ?Sized, A: Allocator]
[std::rc::Weak<T, A> where T: ?Sized, A: Allocator]
[std::sync::MutexGuard<'_, T> where T: ?Sized]
[std::sync::RwLockReadGuard<'_, T> where T: ?Sized]
[std::sync::RwLockWriteGuard<'_, T> where T: ?Sized]
Expand Down Expand Up @@ -96,8 +98,8 @@ impls_dyn_sync_neg!(
[std::cell::RefCell<T> where T: ?Sized]
[std::cell::UnsafeCell<T> where T: ?Sized]
[std::ptr::NonNull<T> where T: ?Sized]
[std::rc::Rc<T> where T: ?Sized]
[std::rc::Weak<T> where T: ?Sized]
[std::rc::Rc<T, A> where T: ?Sized, A: Allocator]
[std::rc::Weak<T, A> where T: ?Sized, A: Allocator]
[std::cell::OnceCell<T> where T]
[std::sync::mpsc::Receiver<T> where T]
[std::sync::mpsc::Sender<T> where T]
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_errors/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,6 @@ pub enum StashKey {
MaybeFruTypo,
CallAssocMethod,
AssociatedTypeSuggestion,
MaybeForgetReturn,
/// Query cycle detected, stashing in favor of a better error.
Cycle,
UndeterminedMacroResolution,
Expand Down
9 changes: 2 additions & 7 deletions compiler/rustc_hir_analysis/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -278,13 +278,6 @@ hir_analysis_invalid_union_field =
hir_analysis_invalid_union_field_sugg =
wrap the field type in `ManuallyDrop<...>`

hir_analysis_invalid_unsafe_field =
field must implement `Copy` or be wrapped in `ManuallyDrop<...>` to be unsafe
.note = unsafe fields must not have drop side-effects, which is currently enforced via either `Copy` or `ManuallyDrop<...>`

hir_analysis_invalid_unsafe_field_sugg =
wrap the field type in `ManuallyDrop<...>`

hir_analysis_late_bound_const_in_apit = `impl Trait` can only mention const parameters from an fn or impl
.label = const parameter declared here

Expand Down Expand Up @@ -620,6 +613,8 @@ hir_analysis_variances_of = {$variances}
hir_analysis_where_clause_on_main = `main` function is not allowed to have a `where` clause
.label = `main` cannot have a `where` clause

hir_analysis_within_macro = due to this macro variable

hir_analysis_wrong_number_of_generic_arguments_to_intrinsic =
intrinsic has wrong number of {$descr} parameters: found {$found}, expected {$expected}
.label = expected {$expected} {$descr} {$expected ->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
//! This module contains methods that assist in checking that impls are general
//! enough, i.e. that they always apply to every valid instantaiton of the ADT
//! they're implemented for.
//!
//! This is necessary for `Drop` and negative impls to be well-formed.

use rustc_data_structures::fx::FxHashSet;
use rustc_errors::codes::*;
use rustc_errors::{ErrorGuaranteed, struct_span_code_err};
use rustc_infer::infer::{RegionResolutionError, TyCtxtInferExt};
use rustc_infer::traits::{ObligationCause, ObligationCauseCode};
use rustc_middle::span_bug;
use rustc_middle::ty::util::CheckRegions;
use rustc_middle::ty::{self, GenericArgsRef, Ty, TyCtxt, TypingMode};
use rustc_trait_selection::regions::InferCtxtRegionExt;
Expand All @@ -27,11 +34,12 @@ use crate::hir::def_id::{DefId, LocalDefId};
/// 3. Any bounds on the generic parameters must be reflected in the
/// struct/enum definition for the nominal type itself (i.e.
/// cannot do `struct S<T>; impl<T:Clone> Drop for S<T> { ... }`).
///
pub(crate) fn check_drop_impl(
tcx: TyCtxt<'_>,
drop_impl_did: DefId,
) -> Result<(), ErrorGuaranteed> {
let drop_impl_did = drop_impl_did.expect_local();

match tcx.impl_polarity(drop_impl_did) {
ty::ImplPolarity::Positive => {}
ty::ImplPolarity::Negative => {
Expand All @@ -45,55 +53,107 @@ pub(crate) fn check_drop_impl(
}));
}
}
let dtor_self_type = tcx.type_of(drop_impl_did).instantiate_identity();
match dtor_self_type.kind() {

tcx.ensure_ok().orphan_check_impl(drop_impl_did)?;

let dtor_impl_trait_ref = tcx.impl_trait_ref(drop_impl_did).unwrap().instantiate_identity();

match dtor_impl_trait_ref.self_ty().kind() {
ty::Adt(adt_def, adt_to_impl_args) => {
ensure_drop_params_and_item_params_correspond(
ensure_impl_params_and_item_params_correspond(
tcx,
drop_impl_did.expect_local(),
drop_impl_did,
adt_def.did(),
adt_to_impl_args,
)?;

ensure_drop_predicates_are_implied_by_item_defn(
ensure_impl_predicates_are_implied_by_item_defn(
tcx,
drop_impl_did.expect_local(),
adt_def.did().expect_local(),
drop_impl_did,
adt_def.did(),
adt_to_impl_args,
)
}
_ => {
// Destructors only work on nominal types. This was
// already checked by coherence, but compilation may
// not have been terminated.
let span = tcx.def_span(drop_impl_did);
let reported = tcx.dcx().span_delayed_bug(
span,
format!("should have been rejected by coherence check: {dtor_self_type}"),
);
Err(reported)
span_bug!(tcx.def_span(drop_impl_did), "incoherent impl of Drop");
}
}
}

fn ensure_drop_params_and_item_params_correspond<'tcx>(
pub(crate) fn check_negative_auto_trait_impl<'tcx>(
tcx: TyCtxt<'tcx>,
drop_impl_did: LocalDefId,
self_type_did: DefId,
impl_def_id: LocalDefId,
impl_trait_ref: ty::TraitRef<'tcx>,
polarity: ty::ImplPolarity,
) -> Result<(), ErrorGuaranteed> {
let ty::ImplPolarity::Negative = polarity else {
return Ok(());
};

if !tcx.trait_is_auto(impl_trait_ref.def_id) {
return Ok(());
}

if tcx.defaultness(impl_def_id).is_default() {
tcx.dcx().span_delayed_bug(tcx.def_span(impl_def_id), "default impl cannot be negative");
}

tcx.ensure_ok().orphan_check_impl(impl_def_id)?;

match impl_trait_ref.self_ty().kind() {
ty::Adt(adt_def, adt_to_impl_args) => {
ensure_impl_params_and_item_params_correspond(
tcx,
impl_def_id,
adt_def.did(),
adt_to_impl_args,
)?;

ensure_impl_predicates_are_implied_by_item_defn(
tcx,
impl_def_id,
adt_def.did(),
adt_to_impl_args,
)
}
_ => {
if tcx.features().auto_traits() {
// NOTE: We ignore the applicability check for negative auto impls
// defined in libcore. In the (almost impossible) future where we
// stabilize auto impls, then the proper applicability check MUST
// be implemented here to handle non-ADT rigid types.
Ok(())
} else {
span_bug!(tcx.def_span(impl_def_id), "incoherent impl of negative auto trait");
}
}
}
}

fn ensure_impl_params_and_item_params_correspond<'tcx>(
tcx: TyCtxt<'tcx>,
impl_def_id: LocalDefId,
adt_def_id: DefId,
adt_to_impl_args: GenericArgsRef<'tcx>,
) -> Result<(), ErrorGuaranteed> {
let Err(arg) = tcx.uses_unique_generic_params(adt_to_impl_args, CheckRegions::OnlyParam) else {
return Ok(());
};

let drop_impl_span = tcx.def_span(drop_impl_did);
let item_span = tcx.def_span(self_type_did);
let self_descr = tcx.def_descr(self_type_did);
let impl_span = tcx.def_span(impl_def_id);
let item_span = tcx.def_span(adt_def_id);
let self_descr = tcx.def_descr(adt_def_id);
let polarity = match tcx.impl_polarity(impl_def_id) {
ty::ImplPolarity::Positive | ty::ImplPolarity::Reservation => "",
ty::ImplPolarity::Negative => "!",
};
let trait_name = tcx
.item_name(tcx.trait_id_of_impl(impl_def_id.to_def_id()).expect("expected impl of trait"));
let mut err = struct_span_code_err!(
tcx.dcx(),
drop_impl_span,
impl_span,
E0366,
"`Drop` impls cannot be specialized"
"`{polarity}{trait_name}` impls cannot be specialized",
);
match arg {
ty::util::NotUniqueParam::DuplicateParam(arg) => {
Expand All @@ -116,17 +176,22 @@ fn ensure_drop_params_and_item_params_correspond<'tcx>(
/// Confirms that all predicates defined on the `Drop` impl (`drop_impl_def_id`) are able to be
/// proven from within `adt_def_id`'s environment. I.e. all the predicates on the impl are
/// implied by the ADT being well formed.
fn ensure_drop_predicates_are_implied_by_item_defn<'tcx>(
fn ensure_impl_predicates_are_implied_by_item_defn<'tcx>(
tcx: TyCtxt<'tcx>,
drop_impl_def_id: LocalDefId,
adt_def_id: LocalDefId,
impl_def_id: LocalDefId,
adt_def_id: DefId,
adt_to_impl_args: GenericArgsRef<'tcx>,
) -> Result<(), ErrorGuaranteed> {
let infcx = tcx.infer_ctxt().build(TypingMode::non_body_analysis());
let ocx = ObligationCtxt::new_with_diagnostics(&infcx);

let impl_span = tcx.def_span(drop_impl_def_id.to_def_id());

let impl_span = tcx.def_span(impl_def_id.to_def_id());
let trait_name = tcx
.item_name(tcx.trait_id_of_impl(impl_def_id.to_def_id()).expect("expected impl of trait"));
let polarity = match tcx.impl_polarity(impl_def_id) {
ty::ImplPolarity::Positive | ty::ImplPolarity::Reservation => "",
ty::ImplPolarity::Negative => "!",
};
// Take the param-env of the adt and instantiate the args that show up in
// the implementation's self type. This gives us the assumptions that the
// self ty of the implementation is allowed to know just from it being a
Expand All @@ -145,17 +210,21 @@ fn ensure_drop_predicates_are_implied_by_item_defn<'tcx>(
let adt_env =
ty::EarlyBinder::bind(tcx.param_env(adt_def_id)).instantiate(tcx, adt_to_impl_args);

let fresh_impl_args = infcx.fresh_args_for_item(impl_span, drop_impl_def_id.to_def_id());
let fresh_impl_args = infcx.fresh_args_for_item(impl_span, impl_def_id.to_def_id());
let fresh_adt_ty =
tcx.impl_trait_ref(drop_impl_def_id).unwrap().instantiate(tcx, fresh_impl_args).self_ty();
tcx.impl_trait_ref(impl_def_id).unwrap().instantiate(tcx, fresh_impl_args).self_ty();

ocx.eq(&ObligationCause::dummy_with_span(impl_span), adt_env, fresh_adt_ty, impl_adt_ty)
.unwrap();
.expect("equating fully generic trait ref should never fail");

for (clause, span) in tcx.predicates_of(drop_impl_def_id).instantiate(tcx, fresh_impl_args) {
let normalize_cause = traits::ObligationCause::misc(span, adt_def_id);
for (clause, span) in tcx.predicates_of(impl_def_id).instantiate(tcx, fresh_impl_args) {
let normalize_cause = traits::ObligationCause::misc(span, impl_def_id);
let pred = ocx.normalize(&normalize_cause, adt_env, clause);
let cause = traits::ObligationCause::new(span, adt_def_id, ObligationCauseCode::DropImpl);
let cause = traits::ObligationCause::new(
span,
impl_def_id,
ObligationCauseCode::AlwaysApplicableImpl,
);
ocx.register_obligation(traits::Obligation::new(tcx, cause, adt_env, pred));
}

Expand All @@ -173,13 +242,13 @@ fn ensure_drop_predicates_are_implied_by_item_defn<'tcx>(
let root_predicate = error.root_obligation.predicate;
if root_predicates.insert(root_predicate) {
let item_span = tcx.def_span(adt_def_id);
let self_descr = tcx.def_descr(adt_def_id.to_def_id());
let self_descr = tcx.def_descr(adt_def_id);
guar = Some(
struct_span_code_err!(
tcx.dcx(),
error.root_obligation.cause.span,
E0367,
"`Drop` impl requires `{root_predicate}` \
"`{polarity}{trait_name}` impl requires `{root_predicate}` \
but the {self_descr} it is implemented for does not",
)
.with_span_note(item_span, "the implementor must specify the same requirement")
Expand All @@ -190,12 +259,12 @@ fn ensure_drop_predicates_are_implied_by_item_defn<'tcx>(
return Err(guar.unwrap());
}

let errors = ocx.infcx.resolve_regions(adt_def_id, adt_env, []);
let errors = ocx.infcx.resolve_regions(impl_def_id, adt_env, []);
if !errors.is_empty() {
let mut guar = None;
for error in errors {
let item_span = tcx.def_span(adt_def_id);
let self_descr = tcx.def_descr(adt_def_id.to_def_id());
let self_descr = tcx.def_descr(adt_def_id);
let outlives = match error {
RegionResolutionError::ConcreteFailure(_, a, b) => format!("{b}: {a}"),
RegionResolutionError::GenericBoundFailure(_, generic, r) => {
Expand All @@ -212,7 +281,7 @@ fn ensure_drop_predicates_are_implied_by_item_defn<'tcx>(
tcx.dcx(),
error.origin().span(),
E0367,
"`Drop` impl requires `{outlives}` \
"`{polarity}{trait_name}` impl requires `{outlives}` \
but the {self_descr} it is implemented for does not",
)
.with_span_note(item_span, "the implementor must specify the same requirement")
Expand Down
Loading
Loading