Skip to content

Commit d3848cb

Browse files
committed
Auto merge of #92064 - matthiaskrgr:rollup-tgj2pai, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - #91858 (pass -Wl,-z,origin to set DF_ORIGIN when using rpath) - #91923 (Remove `in_band_lifetimes` from `rustc_query_impl`) - #91925 (Remove `in_band_lifetimes` from `rustc_privacy`) - #91977 (Clean up search code and unify function returned values) - #92018 (Fix typo in "new region bound" suggestion) - #92022 (Eliminate duplicate codes of expected_found_bool) - #92032 (hir: Do not introduce dummy type names for `extern` blocks in def paths) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents d3f3004 + 5e8f934 commit d3848cb

File tree

33 files changed

+183
-192
lines changed

33 files changed

+183
-192
lines changed

compiler/rustc_codegen_ssa/src/back/rpath.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,12 @@ pub fn get_rpath_flags(config: &mut RPathConfig<'_>) -> Vec<String> {
2323
let rpaths = get_rpaths(config);
2424
let mut flags = rpaths_to_flags(&rpaths);
2525

26-
// Use DT_RUNPATH instead of DT_RPATH if available
2726
if config.linker_is_gnu {
27+
// Use DT_RUNPATH instead of DT_RPATH if available
2828
flags.push("-Wl,--enable-new-dtags".to_owned());
29+
30+
// Set DF_ORIGIN for substitute $ORIGIN
31+
flags.push("-Wl,-z,origin".to_owned());
2932
}
3033

3134
flags

compiler/rustc_hir/src/definitions.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,8 @@ pub enum DefPathData {
267267
// Different kinds of items and item-like things:
268268
/// An impl.
269269
Impl,
270+
/// An `extern` block.
271+
ForeignMod,
270272
/// Something in the type namespace.
271273
TypeNs(Symbol),
272274
/// Something in the value namespace.
@@ -469,7 +471,9 @@ impl DefPathData {
469471
match *self {
470472
TypeNs(name) | ValueNs(name) | MacroNs(name) | LifetimeNs(name) => Some(name),
471473

472-
Impl | CrateRoot | Misc | ClosureExpr | Ctor | AnonConst | ImplTrait => None,
474+
Impl | ForeignMod | CrateRoot | Misc | ClosureExpr | Ctor | AnonConst | ImplTrait => {
475+
None
476+
}
473477
}
474478
}
475479

@@ -482,6 +486,7 @@ impl DefPathData {
482486
// Note that this does not show up in user print-outs.
483487
CrateRoot => DefPathDataName::Anon { namespace: kw::Crate },
484488
Impl => DefPathDataName::Anon { namespace: kw::Impl },
489+
ForeignMod => DefPathDataName::Anon { namespace: kw::Extern },
485490
Misc => DefPathDataName::Anon { namespace: sym::misc },
486491
ClosureExpr => DefPathDataName::Anon { namespace: sym::closure },
487492
Ctor => DefPathDataName::Anon { namespace: sym::constructor },

compiler/rustc_infer/src/infer/combine.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ use crate::traits::{Obligation, PredicateObligations};
3737
use rustc_data_structures::sso::SsoHashMap;
3838
use rustc_hir::def_id::DefId;
3939
use rustc_middle::traits::ObligationCause;
40-
use rustc_middle::ty::error::TypeError;
40+
use rustc_middle::ty::error::{ExpectedFound, TypeError};
4141
use rustc_middle::ty::relate::{self, Relate, RelateResult, TypeRelation};
4242
use rustc_middle::ty::subst::SubstsRef;
4343
use rustc_middle::ty::{self, InferConst, ToPredicate, Ty, TyCtxt, TypeFoldable};
@@ -790,23 +790,23 @@ pub fn const_unification_error<'tcx>(
790790
a_is_expected: bool,
791791
(a, b): (&'tcx ty::Const<'tcx>, &'tcx ty::Const<'tcx>),
792792
) -> TypeError<'tcx> {
793-
TypeError::ConstMismatch(ty::relate::expected_found_bool(a_is_expected, a, b))
793+
TypeError::ConstMismatch(ExpectedFound::new(a_is_expected, a, b))
794794
}
795795

796796
fn int_unification_error<'tcx>(
797797
a_is_expected: bool,
798798
v: (ty::IntVarValue, ty::IntVarValue),
799799
) -> TypeError<'tcx> {
800800
let (a, b) = v;
801-
TypeError::IntMismatch(ty::relate::expected_found_bool(a_is_expected, a, b))
801+
TypeError::IntMismatch(ExpectedFound::new(a_is_expected, a, b))
802802
}
803803

804804
fn float_unification_error<'tcx>(
805805
a_is_expected: bool,
806806
v: (ty::FloatVarValue, ty::FloatVarValue),
807807
) -> TypeError<'tcx> {
808808
let (ty::FloatVarValue(a), ty::FloatVarValue(b)) = v;
809-
TypeError::FloatMismatch(ty::relate::expected_found_bool(a_is_expected, a, b))
809+
TypeError::FloatMismatch(ExpectedFound::new(a_is_expected, a, b))
810810
}
811811

812812
struct ConstInferUnifier<'cx, 'tcx> {

compiler/rustc_infer/src/infer/error_reporting/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ pub fn unexpected_hidden_region_diagnostic(
275275
fn_returns,
276276
hidden_region.to_string(),
277277
None,
278-
format!("captures {}", hidden_region),
278+
format!("captures `{}`", hidden_region),
279279
None,
280280
)
281281
}

compiler/rustc_lint/src/context.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,8 +1030,8 @@ impl<'tcx> LateContext<'tcx> {
10301030
) -> Result<Self::Path, Self::Error> {
10311031
let mut path = print_prefix(self)?;
10321032

1033-
// Skip `::{{constructor}}` on tuple/unit structs.
1034-
if let DefPathData::Ctor = disambiguated_data.data {
1033+
// Skip `::{{extern}}` blocks and `::{{constructor}}` on tuple/unit structs.
1034+
if let DefPathData::ForeignMod | DefPathData::Ctor = disambiguated_data.data {
10351035
return Ok(path);
10361036
}
10371037

compiler/rustc_middle/src/ty/print/pretty.rs

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1740,30 +1740,26 @@ impl<F: fmt::Write> Printer<'tcx> for FmtPrinter<'_, 'tcx, F> {
17401740
) -> Result<Self::Path, Self::Error> {
17411741
self = print_prefix(self)?;
17421742

1743-
// Skip `::{{constructor}}` on tuple/unit structs.
1744-
if let DefPathData::Ctor = disambiguated_data.data {
1743+
// Skip `::{{extern}}` blocks and `::{{constructor}}` on tuple/unit structs.
1744+
if let DefPathData::ForeignMod | DefPathData::Ctor = disambiguated_data.data {
17451745
return Ok(self);
17461746
}
17471747

1748-
// FIXME(eddyb) `name` should never be empty, but it
1749-
// currently is for `extern { ... }` "foreign modules".
17501748
let name = disambiguated_data.data.name();
1751-
if name != DefPathDataName::Named(kw::Empty) {
1752-
if !self.empty_path {
1753-
write!(self, "::")?;
1754-
}
1749+
if !self.empty_path {
1750+
write!(self, "::")?;
1751+
}
17551752

1756-
if let DefPathDataName::Named(name) = name {
1757-
if Ident::with_dummy_span(name).is_raw_guess() {
1758-
write!(self, "r#")?;
1759-
}
1753+
if let DefPathDataName::Named(name) = name {
1754+
if Ident::with_dummy_span(name).is_raw_guess() {
1755+
write!(self, "r#")?;
17601756
}
1757+
}
17611758

1762-
let verbose = self.tcx.sess.verbose();
1763-
disambiguated_data.fmt_maybe_verbose(&mut self, verbose)?;
1759+
let verbose = self.tcx.sess.verbose();
1760+
disambiguated_data.fmt_maybe_verbose(&mut self, verbose)?;
17641761

1765-
self.empty_path = false;
1766-
}
1762+
self.empty_path = false;
17671763

17681764
Ok(self)
17691765
}

compiler/rustc_middle/src/ty/relate.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -836,13 +836,5 @@ pub fn expected_found<R, T>(relation: &mut R, a: T, b: T) -> ExpectedFound<T>
836836
where
837837
R: TypeRelation<'tcx>,
838838
{
839-
expected_found_bool(relation.a_is_expected(), a, b)
840-
}
841-
842-
pub fn expected_found_bool<T>(a_is_expected: bool, a: T, b: T) -> ExpectedFound<T> {
843-
if a_is_expected {
844-
ExpectedFound { expected: a, found: b }
845-
} else {
846-
ExpectedFound { expected: b, found: a }
847-
}
839+
ExpectedFound::new(relation.a_is_expected(), a, b)
848840
}

compiler/rustc_privacy/src/lib.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
2-
#![feature(in_band_lifetimes)]
32
#![feature(nll)]
43
#![feature(control_flow_enum)]
54
#![feature(try_blocks)]
@@ -310,7 +309,7 @@ struct PubRestrictedVisitor<'tcx> {
310309
has_pub_restricted: bool,
311310
}
312311

313-
impl Visitor<'tcx> for PubRestrictedVisitor<'tcx> {
312+
impl<'tcx> Visitor<'tcx> for PubRestrictedVisitor<'tcx> {
314313
type Map = Map<'tcx>;
315314

316315
fn nested_visit_map(&mut self) -> NestedVisitorMap<Self::Map> {
@@ -432,7 +431,7 @@ struct ReachEverythingInTheInterfaceVisitor<'a, 'tcx> {
432431
ev: &'a mut EmbargoVisitor<'tcx>,
433432
}
434433

435-
impl EmbargoVisitor<'tcx> {
434+
impl<'tcx> EmbargoVisitor<'tcx> {
436435
fn get(&self, def_id: LocalDefId) -> Option<AccessLevel> {
437436
self.access_levels.map.get(&def_id).copied()
438437
}
@@ -674,7 +673,7 @@ impl EmbargoVisitor<'tcx> {
674673
}
675674
}
676675

677-
impl Visitor<'tcx> for EmbargoVisitor<'tcx> {
676+
impl<'tcx> Visitor<'tcx> for EmbargoVisitor<'tcx> {
678677
type Map = Map<'tcx>;
679678

680679
/// We want to visit items in the context of their containing
@@ -944,7 +943,7 @@ impl Visitor<'tcx> for EmbargoVisitor<'tcx> {
944943
}
945944
}
946945

947-
impl ReachEverythingInTheInterfaceVisitor<'_, 'tcx> {
946+
impl ReachEverythingInTheInterfaceVisitor<'_, '_> {
948947
fn generics(&mut self) -> &mut Self {
949948
for param in &self.ev.tcx.generics_of(self.item_def_id).params {
950949
match param.kind {
@@ -983,7 +982,7 @@ impl ReachEverythingInTheInterfaceVisitor<'_, 'tcx> {
983982
}
984983
}
985984

986-
impl DefIdVisitor<'tcx> for ReachEverythingInTheInterfaceVisitor<'_, 'tcx> {
985+
impl<'tcx> DefIdVisitor<'tcx> for ReachEverythingInTheInterfaceVisitor<'_, 'tcx> {
987986
fn tcx(&self) -> TyCtxt<'tcx> {
988987
self.ev.tcx
989988
}
@@ -1413,7 +1412,7 @@ impl<'tcx> Visitor<'tcx> for TypePrivacyVisitor<'tcx> {
14131412
}
14141413
}
14151414

1416-
impl DefIdVisitor<'tcx> for TypePrivacyVisitor<'tcx> {
1415+
impl<'tcx> DefIdVisitor<'tcx> for TypePrivacyVisitor<'tcx> {
14171416
fn tcx(&self) -> TyCtxt<'tcx> {
14181417
self.tcx
14191418
}
@@ -1800,7 +1799,7 @@ struct SearchInterfaceForPrivateItemsVisitor<'tcx> {
18001799
in_assoc_ty: bool,
18011800
}
18021801

1803-
impl SearchInterfaceForPrivateItemsVisitor<'tcx> {
1802+
impl SearchInterfaceForPrivateItemsVisitor<'_> {
18041803
fn generics(&mut self) -> &mut Self {
18051804
for param in &self.tcx.generics_of(self.item_def_id).params {
18061805
match param.kind {
@@ -1921,7 +1920,7 @@ impl SearchInterfaceForPrivateItemsVisitor<'tcx> {
19211920
}
19221921
}
19231922

1924-
impl DefIdVisitor<'tcx> for SearchInterfaceForPrivateItemsVisitor<'tcx> {
1923+
impl<'tcx> DefIdVisitor<'tcx> for SearchInterfaceForPrivateItemsVisitor<'tcx> {
19251924
fn tcx(&self) -> TyCtxt<'tcx> {
19261925
self.tcx
19271926
}

compiler/rustc_query_impl/src/keys.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ impl Key for (DefId, DefId) {
151151
}
152152
}
153153

154-
impl Key for (ty::Instance<'tcx>, LocalDefId) {
154+
impl<'tcx> Key for (ty::Instance<'tcx>, LocalDefId) {
155155
#[inline(always)]
156156
fn query_crate_is_local(&self) -> bool {
157157
true

compiler/rustc_query_impl/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
33
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
44
#![feature(crate_visibility_modifier)]
5-
#![feature(in_band_lifetimes)]
65
#![feature(nll)]
76
#![feature(min_specialization)]
87
#![feature(once_cell)]

0 commit comments

Comments
 (0)