Skip to content

Commit d8795fa

Browse files
committed
Auto merge of rust-lang#2821 - RalfJung:rustup, r=RalfJung
Rustup
2 parents 3c2adeb + 4f8534f commit d8795fa

File tree

208 files changed

+3130
-1797
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

208 files changed

+3130
-1797
lines changed

.mailmap

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ Alexander Ronald Altman <[email protected]>
2929
Alexandre Martin <[email protected]>
3030
Alexis Beingessner <[email protected]>
3131
Alfie John <[email protected]> Alfie John <[email protected]>
32+
Alona Enraght-Moony <[email protected]> <[email protected]>
33+
Alona Enraght-Moony <[email protected]> <[email protected]>
3234
3335
Ana-Maria Mihalache <[email protected]>
3436
Anatoly Ikorsky <[email protected]>
@@ -415,7 +417,6 @@ Nicolas Abram <[email protected]>
415417
Nicole Mazzuca <[email protected]>
416418
417419
418-
Nixon Enraght-Moony <[email protected]>
419420
420421
421422

Cargo.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1128,9 +1128,9 @@ dependencies = [
11281128

11291129
[[package]]
11301130
name = "curl-sys"
1131-
version = "0.4.59+curl-7.86.0"
1131+
version = "0.4.61+curl-8.0.1"
11321132
source = "registry+https://github.com/rust-lang/crates.io-index"
1133-
checksum = "6cfce34829f448b08f55b7db6d0009e23e2e86a34e8c2b366269bf5799b4a407"
1133+
checksum = "14d05c10f541ae6f3bc5b3d923c20001f47db7d5f0b2bc6ad16490133842db79"
11341134
dependencies = [
11351135
"cc",
11361136
"libc",

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ use rustc_span::hygiene::DesugaringKind;
2424
use rustc_span::symbol::{kw, sym};
2525
use rustc_span::{BytePos, Span, Symbol};
2626
use rustc_trait_selection::infer::InferCtxtExt;
27+
use rustc_trait_selection::traits::ObligationCtxt;
2728

2829
use crate::borrow_set::TwoPhaseActivation;
2930
use crate::borrowck_errors;
@@ -760,20 +761,12 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
760761
else { return; };
761762
// Try to find predicates on *generic params* that would allow copying `ty`
762763
let infcx = tcx.infer_ctxt().build();
763-
let copy_did = infcx.tcx.require_lang_item(LangItem::Copy, Some(span));
764-
let cause = ObligationCause::new(
765-
span,
766-
self.mir_def_id(),
767-
rustc_infer::traits::ObligationCauseCode::MiscObligation,
768-
);
769-
let errors = rustc_trait_selection::traits::fully_solve_bound(
770-
&infcx,
771-
cause,
772-
self.param_env,
773-
// Erase any region vids from the type, which may not be resolved
774-
infcx.tcx.erase_regions(ty),
775-
copy_did,
776-
);
764+
let ocx = ObligationCtxt::new(&infcx);
765+
let copy_did = tcx.require_lang_item(LangItem::Copy, Some(span));
766+
let cause = ObligationCause::misc(span, self.mir_def_id());
767+
768+
ocx.register_bound(cause, self.param_env, infcx.tcx.erase_regions(ty), copy_did);
769+
let errors = ocx.select_all_or_error();
777770

778771
// Only emit suggestion if all required predicates are on generic
779772
let predicates: Result<Vec<_>, _> = errors

compiler/rustc_borrowck/src/diagnostics/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1078,7 +1078,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
10781078
self.param_env,
10791079
tcx.mk_imm_ref(tcx.lifetimes.re_erased, tcx.erase_regions(ty)),
10801080
def_id,
1081-
DUMMY_SP,
10821081
)
10831082
}
10841083
_ => false,

compiler/rustc_borrowck/src/region_infer/opaque_types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ impl<'tcx> InferCtxtExt<'tcx> for InferCtxt<'tcx> {
284284
// hidden type is well formed even without those bounds.
285285
let predicate = ty::Binder::dummy(ty::PredicateKind::WellFormed(definition_ty.into()));
286286

287-
let id_substs = InternalSubsts::identity_for_item(self.tcx, def_id.to_def_id());
287+
let id_substs = InternalSubsts::identity_for_item(self.tcx, def_id);
288288

289289
// Require that the hidden type actually fulfills all the bounds of the opaque type, even without
290290
// the bounds that the function supplies.

compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -176,15 +176,14 @@ fn build_pointer_or_reference_di_node<'ll, 'tcx>(
176176

177177
return_if_di_node_created_in_meantime!(cx, unique_type_id);
178178

179-
let (thin_pointer_size, thin_pointer_align) =
180-
cx.size_and_align_of(cx.tcx.mk_imm_ptr(cx.tcx.types.unit));
179+
let data_layout = &cx.tcx.data_layout;
181180
let ptr_type_debuginfo_name = compute_debuginfo_type_name(cx.tcx, ptr_type, true);
182181

183182
match fat_pointer_kind(cx, pointee_type) {
184183
None => {
185184
// This is a thin pointer. Create a regular pointer type and give it the correct name.
186185
debug_assert_eq!(
187-
(thin_pointer_size, thin_pointer_align),
186+
(data_layout.pointer_size, data_layout.pointer_align.abi),
188187
cx.size_and_align_of(ptr_type),
189188
"ptr_type={}, pointee_type={}",
190189
ptr_type,
@@ -195,8 +194,8 @@ fn build_pointer_or_reference_di_node<'ll, 'tcx>(
195194
llvm::LLVMRustDIBuilderCreatePointerType(
196195
DIB(cx),
197196
pointee_type_di_node,
198-
thin_pointer_size.bits(),
199-
thin_pointer_align.bits() as u32,
197+
data_layout.pointer_size.bits(),
198+
data_layout.pointer_align.abi.bits() as u32,
200199
0, // Ignore DWARF address space.
201200
ptr_type_debuginfo_name.as_ptr().cast(),
202201
ptr_type_debuginfo_name.len(),

compiler/rustc_codegen_ssa/src/back/symbol_export.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
1010
use rustc_middle::middle::exported_symbols::{
1111
metadata_symbol_name, ExportedSymbol, SymbolExportInfo, SymbolExportKind, SymbolExportLevel,
1212
};
13+
use rustc_middle::query::LocalCrate;
1314
use rustc_middle::ty::query::{ExternProviders, Providers};
1415
use rustc_middle::ty::subst::{GenericArgKind, SubstsRef};
1516
use rustc_middle::ty::Instance;
@@ -41,9 +42,7 @@ pub fn crates_export_threshold(crate_types: &[CrateType]) -> SymbolExportLevel {
4142
}
4243
}
4344

44-
fn reachable_non_generics_provider(tcx: TyCtxt<'_>, cnum: CrateNum) -> DefIdMap<SymbolExportInfo> {
45-
assert_eq!(cnum, LOCAL_CRATE);
46-
45+
fn reachable_non_generics_provider(tcx: TyCtxt<'_>, _: LocalCrate) -> DefIdMap<SymbolExportInfo> {
4746
if !tcx.sess.opts.output_types.should_codegen() {
4847
return Default::default();
4948
}
@@ -154,10 +153,10 @@ fn reachable_non_generics_provider(tcx: TyCtxt<'_>, cnum: CrateNum) -> DefIdMap<
154153
reachable_non_generics
155154
}
156155

157-
fn is_reachable_non_generic_provider_local(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
156+
fn is_reachable_non_generic_provider_local(tcx: TyCtxt<'_>, def_id: LocalDefId) -> bool {
158157
let export_threshold = threshold(tcx);
159158

160-
if let Some(&info) = tcx.reachable_non_generics(def_id.krate).get(&def_id) {
159+
if let Some(&info) = tcx.reachable_non_generics(LOCAL_CRATE).get(&def_id.to_def_id()) {
161160
info.level.is_below_threshold(export_threshold)
162161
} else {
163162
false
@@ -170,10 +169,8 @@ fn is_reachable_non_generic_provider_extern(tcx: TyCtxt<'_>, def_id: DefId) -> b
170169

171170
fn exported_symbols_provider_local(
172171
tcx: TyCtxt<'_>,
173-
cnum: CrateNum,
172+
_: LocalCrate,
174173
) -> &[(ExportedSymbol<'_>, SymbolExportInfo)] {
175-
assert_eq!(cnum, LOCAL_CRATE);
176-
177174
if !tcx.sess.opts.output_types.should_codegen() {
178175
return &[];
179176
}

compiler/rustc_codegen_ssa/src/codegen_attrs.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ fn linkage_by_name(tcx: TyCtxt<'_>, def_id: LocalDefId, name: &str) -> Linkage {
4343
}
4444
}
4545

46-
fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: DefId) -> CodegenFnAttrs {
46+
fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
4747
if cfg!(debug_assertions) {
4848
let def_kind = tcx.def_kind(did);
4949
assert!(
@@ -52,7 +52,6 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: DefId) -> CodegenFnAttrs {
5252
);
5353
}
5454

55-
let did = did.expect_local();
5655
let attrs = tcx.hir().attrs(tcx.hir().local_def_id_to_hir_id(did));
5756
let mut codegen_fn_attrs = CodegenFnAttrs::new();
5857
if tcx.should_inherit_track_caller(did) {

compiler/rustc_const_eval/src/const_eval/fn_queries.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ pub fn is_parent_const_impl_raw(tcx: TyCtxt<'_>, def_id: LocalDefId) -> bool {
3232
/// it is a trait impl/function, return if it has a `const` modifier. If it is an intrinsic,
3333
/// report whether said intrinsic has a `rustc_const_{un,}stable` attribute. Otherwise, return
3434
/// `Constness::NotConst`.
35-
fn constness(tcx: TyCtxt<'_>, def_id: DefId) -> hir::Constness {
36-
let def_id = def_id.expect_local();
35+
fn constness(tcx: TyCtxt<'_>, def_id: LocalDefId) -> hir::Constness {
3736
let node = tcx.hir().get_by_def_id(def_id);
3837

3938
match node {

compiler/rustc_const_eval/src/transform/check_consts/check.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ impl<'mir, 'tcx> Checker<'mir, 'tcx> {
246246
self.check_local_or_return_ty(return_ty.skip_binder(), RETURN_PLACE);
247247
}
248248

249-
if !tcx.has_attr(def_id.to_def_id(), sym::rustc_do_not_const_check) {
249+
if !tcx.has_attr(def_id, sym::rustc_do_not_const_check) {
250250
self.visit_body(&body);
251251
}
252252

compiler/rustc_const_eval/src/transform/check_consts/post_drop_elaboration.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ pub fn check_live_drops<'tcx>(tcx: TyCtxt<'tcx>, body: &mir::Body<'tcx>) {
3030
return;
3131
}
3232

33-
if tcx.has_attr(def_id.to_def_id(), sym::rustc_do_not_const_check) {
33+
if tcx.has_attr(def_id, sym::rustc_do_not_const_check) {
3434
return;
3535
}
3636

compiler/rustc_const_eval/src/transform/check_consts/qualifs.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use rustc_middle::mir;
99
use rustc_middle::mir::*;
1010
use rustc_middle::ty::{self, subst::SubstsRef, AdtDef, Ty};
1111
use rustc_trait_selection::traits::{
12-
self, ImplSource, Obligation, ObligationCause, SelectionContext,
12+
self, ImplSource, Obligation, ObligationCause, ObligationCtxt, SelectionContext,
1313
};
1414

1515
use super::ConstCx;
@@ -184,7 +184,10 @@ impl Qualif for NeedsNonConstDrop {
184184
}
185185

186186
// If we had any errors, then it's bad
187-
!traits::fully_solve_obligations(&infcx, impl_src.nested_obligations()).is_empty()
187+
let ocx = ObligationCtxt::new(&infcx);
188+
ocx.register_obligations(impl_src.nested_obligations());
189+
let errors = ocx.select_all_or_error();
190+
!errors.is_empty()
188191
}
189192

190193
fn in_adt_inherently<'tcx>(

compiler/rustc_errors/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ impl CodeSuggestion {
331331
});
332332
buf.push_str(&part.snippet);
333333
let cur_hi = sm.lookup_char_pos(part.span.hi());
334-
if cur_hi.line == cur_lo.line {
334+
if cur_hi.line == cur_lo.line && !part.snippet.is_empty() {
335335
// Account for the difference between the width of the current code and the
336336
// snippet being suggested, so that the *later* suggestions are correctly
337337
// aligned on the screen.

compiler/rustc_hir/src/hir_id.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ impl From<OwnerId> for HirId {
2222
}
2323
}
2424

25+
impl From<OwnerId> for DefId {
26+
fn from(value: OwnerId) -> Self {
27+
value.to_def_id()
28+
}
29+
}
30+
2531
impl OwnerId {
2632
#[inline]
2733
pub fn to_def_id(self) -> DefId {

compiler/rustc_hir_analysis/src/astconv/mod.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ pub trait AstConv<'tcx> {
7575
fn get_type_parameter_bounds(
7676
&self,
7777
span: Span,
78-
def_id: DefId,
78+
def_id: LocalDefId,
7979
assoc_name: Ident,
8080
) -> ty::GenericPredicates<'tcx>;
8181

@@ -1773,9 +1773,8 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
17731773
ty_param_def_id, assoc_name, span,
17741774
);
17751775

1776-
let predicates = &self
1777-
.get_type_parameter_bounds(span, ty_param_def_id.to_def_id(), assoc_name)
1778-
.predicates;
1776+
let predicates =
1777+
&self.get_type_parameter_bounds(span, ty_param_def_id, assoc_name).predicates;
17791778

17801779
debug!("find_bound_for_assoc_item: predicates={:#?}", predicates);
17811780

compiler/rustc_hir_analysis/src/check/check.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ fn check_opaque(tcx: TyCtxt<'_>, id: hir::ItemId) {
211211
return;
212212
}
213213

214-
let substs = InternalSubsts::identity_for_item(tcx, item.owner_id.to_def_id());
214+
let substs = InternalSubsts::identity_for_item(tcx, item.owner_id);
215215
let span = tcx.def_span(item.owner_id.def_id);
216216

217217
if !tcx.features().impl_trait_projections {
@@ -304,7 +304,7 @@ pub(super) fn check_opaque_for_inheriting_lifetimes(
304304
..
305305
}) = item.kind
306306
{
307-
let substs = InternalSubsts::identity_for_item(tcx, def_id.to_def_id());
307+
let substs = InternalSubsts::identity_for_item(tcx, def_id);
308308
let opaque_identity_ty = if in_trait {
309309
tcx.mk_projection(def_id.to_def_id(), substs)
310310
} else {
@@ -535,7 +535,7 @@ fn check_item_type(tcx: TyCtxt<'_>, id: hir::ItemId) {
535535
}
536536
ty::AssocKind::Type if assoc_item.defaultness(tcx).has_value() => {
537537
let trait_substs =
538-
InternalSubsts::identity_for_item(tcx, id.owner_id.to_def_id());
538+
InternalSubsts::identity_for_item(tcx, id.owner_id);
539539
let _: Result<_, rustc_errors::ErrorGuaranteed> = check_type_bounds(
540540
tcx,
541541
assoc_item,
@@ -1161,7 +1161,7 @@ fn check_enum(tcx: TyCtxt<'_>, def_id: LocalDefId) {
11611161
def.destructor(tcx); // force the destructor to be evaluated
11621162

11631163
if def.variants().is_empty() {
1164-
if let Some(attr) = tcx.get_attrs(def_id.to_def_id(), sym::repr).next() {
1164+
if let Some(attr) = tcx.get_attrs(def_id, sym::repr).next() {
11651165
struct_span_err!(
11661166
tcx.sess,
11671167
attr.span,

compiler/rustc_hir_analysis/src/check/compare_impl_item.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -583,13 +583,13 @@ fn compare_asyncness<'tcx>(
583583
#[instrument(skip(tcx), level = "debug", ret)]
584584
pub(super) fn collect_return_position_impl_trait_in_trait_tys<'tcx>(
585585
tcx: TyCtxt<'tcx>,
586-
def_id: DefId,
586+
impl_m_def_id: LocalDefId,
587587
) -> Result<&'tcx FxHashMap<DefId, Ty<'tcx>>, ErrorGuaranteed> {
588-
let impl_m = tcx.opt_associated_item(def_id).unwrap();
588+
let impl_m = tcx.opt_associated_item(impl_m_def_id.to_def_id()).unwrap();
589589
let trait_m = tcx.opt_associated_item(impl_m.trait_item_def_id.unwrap()).unwrap();
590590
let impl_trait_ref =
591591
tcx.impl_trait_ref(impl_m.impl_container(tcx).unwrap()).unwrap().subst_identity();
592-
let param_env = tcx.param_env(def_id);
592+
let param_env = tcx.param_env(impl_m_def_id);
593593

594594
// First, check a few of the same things as `compare_impl_method`,
595595
// just so we don't ICE during substitution later.
@@ -599,7 +599,6 @@ pub(super) fn collect_return_position_impl_trait_in_trait_tys<'tcx>(
599599

600600
let trait_to_impl_substs = impl_trait_ref.substs;
601601

602-
let impl_m_def_id = impl_m.def_id.expect_local();
603602
let impl_m_hir_id = tcx.hir().local_def_id_to_hir_id(impl_m_def_id);
604603
let return_span = tcx.hir().fn_decl_by_hir_id(impl_m_hir_id).unwrap().output.span();
605604
let cause = ObligationCause::new(

compiler/rustc_hir_analysis/src/check/intrinsic.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ fn equate_intrinsic_type<'tcx>(
5959
require_same_types(
6060
tcx,
6161
&cause,
62+
ty::ParamEnv::empty(), // FIXME: do all intrinsics have an empty param env?
6263
tcx.mk_fn_ptr(tcx.fn_sig(it.owner_id).subst_identity()),
6364
fty,
6465
);

compiler/rustc_hir_analysis/src/check/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ pub fn provide(providers: &mut Providers) {
109109
};
110110
}
111111

112-
fn adt_destructor(tcx: TyCtxt<'_>, def_id: DefId) -> Option<ty::Destructor> {
113-
tcx.calculate_dtor(def_id, dropck::check_drop_impl)
112+
fn adt_destructor(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Option<ty::Destructor> {
113+
tcx.calculate_dtor(def_id.to_def_id(), dropck::check_drop_impl)
114114
}
115115

116116
/// Given a `DefId` for an opaque type in return position, find its parent item's return

compiler/rustc_hir_analysis/src/check/wfcheck.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1794,7 +1794,7 @@ fn check_variances_for_type_defn<'tcx>(
17941794

17951795
// Lazily calculated because it is only needed in case of an error.
17961796
let explicitly_bounded_params = LazyCell::new(|| {
1797-
let icx = crate::collect::ItemCtxt::new(tcx, item.owner_id.to_def_id());
1797+
let icx = crate::collect::ItemCtxt::new(tcx, item.owner_id.def_id);
17981798
hir_generics
17991799
.predicates
18001800
.iter()

0 commit comments

Comments
 (0)