Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 7036449

Browse files
committed
Auto merge of rust-lang#98447 - JohnTitor:rollup-pponoo3, r=JohnTitor
Rollup of 9 pull requests Successful merges: - rust-lang#91264 (Add macro support in jump to definition feature) - rust-lang#96955 (Remove (transitive) reliance on sorting by DefId in pretty-printer) - rust-lang#97633 (Session object: Set OS/ABI) - rust-lang#98039 (Fix `panic` message for `BTreeSet`'s `range` API and document `panic` cases) - rust-lang#98214 (rustc_target: Remove some redundant target properties) - rust-lang#98280 (Improve suggestion for calling fn-like expr on type mismatch) - rust-lang#98394 (Fixup missing renames from `#[main]` to `#[rustc_main]`) - rust-lang#98411 (Update tendril) - rust-lang#98419 (Remove excess rib while resolving closures) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents d017d59 + 5e98e55 commit 7036449

File tree

42 files changed

+603
-259
lines changed

Some content is hidden

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

42 files changed

+603
-259
lines changed

Cargo.lock

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1428,9 +1428,9 @@ checksum = "d79238883cf0307100b90aba4a755d8051a3182305dfe7f649a1e9dc0517006f"
14281428

14291429
[[package]]
14301430
name = "futf"
1431-
version = "0.1.4"
1431+
version = "0.1.5"
14321432
source = "registry+https://github.com/rust-lang/crates.io-index"
1433-
checksum = "7c9c1ce3fa9336301af935ab852c437817d14cd33690446569392e65170aac3b"
1433+
checksum = "df420e2e84819663797d1ec6544b13c5be84629e7bb00dc960d6917db2987843"
14341434
dependencies = [
14351435
"mac",
14361436
"new_debug_unreachable",
@@ -1713,6 +1713,7 @@ version = "0.12.0"
17131713
source = "registry+https://github.com/rust-lang/crates.io-index"
17141714
checksum = "8c21d40587b92fa6a6c6e3c1bdbf87d75511db5672f9c93175574b3a00df1758"
17151715
dependencies = [
1716+
"ahash",
17161717
"compiler_builtins",
17171718
"rustc-std-workspace-alloc",
17181719
"rustc-std-workspace-core",
@@ -2571,6 +2572,18 @@ dependencies = [
25712572
"memchr",
25722573
]
25732574

2575+
[[package]]
2576+
name = "object"
2577+
version = "0.29.0"
2578+
source = "registry+https://github.com/rust-lang/crates.io-index"
2579+
checksum = "21158b2c33aa6d4561f1c0a6ea283ca92bc54802a93b263e910746d679a7eb53"
2580+
dependencies = [
2581+
"crc32fast",
2582+
"hashbrown 0.12.0",
2583+
"indexmap",
2584+
"memchr",
2585+
]
2586+
25742587
[[package]]
25752588
name = "odht"
25762589
version = "0.3.1"
@@ -3720,7 +3733,7 @@ dependencies = [
37203733
"itertools",
37213734
"jobserver",
37223735
"libc",
3723-
"object 0.28.4",
3736+
"object 0.29.0",
37243737
"pathdiff",
37253738
"regex",
37263739
"rustc_apfloat",
@@ -5191,9 +5204,9 @@ dependencies = [
51915204

51925205
[[package]]
51935206
name = "tendril"
5194-
version = "0.4.1"
5207+
version = "0.4.3"
51955208
source = "registry+https://github.com/rust-lang/crates.io-index"
5196-
checksum = "707feda9f2582d5d680d733e38755547a3e8fb471e7ba11452ecfd9ce93a5d3b"
5209+
checksum = "d24a120c5fc464a3458240ee02c299ebcb9d67b5249c8848b09d639dca8d7bb0"
51975210
dependencies = [
51985211
"futf",
51995212
"mac",

compiler/rustc_ast/src/entry.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
pub enum EntryPointType {
33
None,
44
MainNamed,
5-
MainAttr,
5+
RustcMainAttr,
66
Start,
77
OtherMain, // Not an entry point, but some other function named main
88
}

compiler/rustc_builtin_macros/src/test_harness.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ fn entry_point_type(sess: &Session, item: &ast::Item, depth: usize) -> EntryPoin
147147
if sess.contains_name(&item.attrs, sym::start) {
148148
EntryPointType::Start
149149
} else if sess.contains_name(&item.attrs, sym::rustc_main) {
150-
EntryPointType::MainAttr
150+
EntryPointType::RustcMainAttr
151151
} else if item.ident.name == sym::main {
152152
if depth == 0 {
153153
// This is a top-level function so can be 'main'
@@ -177,12 +177,12 @@ impl<'a> MutVisitor for EntryPointCleaner<'a> {
177177
let item = noop_flat_map_item(i, self).expect_one("noop did something");
178178
self.depth -= 1;
179179

180-
// Remove any #[main] or #[start] from the AST so it doesn't
180+
// Remove any #[rustc_main] or #[start] from the AST so it doesn't
181181
// clash with the one we're going to add, but mark it as
182182
// #[allow(dead_code)] to avoid printing warnings.
183183
let item = match entry_point_type(self.sess, &item, self.depth) {
184-
EntryPointType::MainNamed | EntryPointType::MainAttr | EntryPointType::Start => item
185-
.map(|ast::Item { id, ident, attrs, kind, vis, span, tokens }| {
184+
EntryPointType::MainNamed | EntryPointType::RustcMainAttr | EntryPointType::Start => {
185+
item.map(|ast::Item { id, ident, attrs, kind, vis, span, tokens }| {
186186
let allow_ident = Ident::new(sym::allow, self.def_site);
187187
let dc_nested =
188188
attr::mk_nested_word_item(Ident::new(sym::dead_code, self.def_site));
@@ -197,7 +197,8 @@ impl<'a> MutVisitor for EntryPointCleaner<'a> {
197197
.collect();
198198

199199
ast::Item { id, ident, attrs, kind, vis, span, tokens }
200-
}),
200+
})
201+
}
201202
EntryPointType::None | EntryPointType::OtherMain => item,
202203
};
203204

compiler/rustc_codegen_llvm/src/context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -906,7 +906,7 @@ impl<'ll> CodegenCx<'ll, '_> {
906906
return eh_catch_typeinfo;
907907
}
908908
let tcx = self.tcx;
909-
assert!(self.sess().target.is_like_emscripten);
909+
assert!(self.sess().target.os == "emscripten");
910910
let eh_catch_typeinfo = match tcx.lang_items().eh_catch_typeinfo() {
911911
Some(def_id) => self.get_static(def_id),
912912
_ => {

compiler/rustc_codegen_llvm/src/intrinsic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ fn try_intrinsic<'ll>(
441441
bx.store(bx.const_i32(0), dest, ret_align);
442442
} else if wants_msvc_seh(bx.sess()) {
443443
codegen_msvc_try(bx, try_func, data, catch_func, dest);
444-
} else if bx.sess().target.is_like_emscripten {
444+
} else if bx.sess().target.os == "emscripten" {
445445
codegen_emcc_try(bx, try_func, data, catch_func, dest);
446446
} else {
447447
codegen_gnu_try(bx, try_func, data, catch_func, dest);

compiler/rustc_codegen_ssa/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,6 @@ rustc_target = { path = "../rustc_target" }
4242
rustc_session = { path = "../rustc_session" }
4343

4444
[dependencies.object]
45-
version = "0.28.4"
45+
version = "0.29.0"
4646
default-features = false
4747
features = ["read_core", "elf", "macho", "pe", "unaligned", "archive", "write"]

compiler/rustc_codegen_ssa/src/back/link.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2031,7 +2031,7 @@ fn add_order_independent_options(
20312031

20322032
add_link_script(cmd, sess, tmpdir, crate_type);
20332033

2034-
if sess.target.is_like_fuchsia && crate_type == CrateType::Executable {
2034+
if sess.target.os == "fuchsia" && crate_type == CrateType::Executable {
20352035
let prefix = if sess.opts.debugging_opts.sanitizer.contains(SanitizerSet::ADDRESS) {
20362036
"asan/"
20372037
} else {
@@ -2051,7 +2051,7 @@ fn add_order_independent_options(
20512051
cmd.no_crt_objects();
20522052
}
20532053

2054-
if sess.target.is_like_emscripten {
2054+
if sess.target.os == "emscripten" {
20552055
cmd.arg("-s");
20562056
cmd.arg(if sess.panic_strategy() == PanicStrategy::Abort {
20572057
"DISABLE_EXCEPTION_CATCHING=1"

compiler/rustc_codegen_ssa/src/back/metadata.rs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ pub(crate) fn create_object_file(sess: &Session) -> Option<write::Object<'static
130130
};
131131

132132
let mut file = write::Object::new(binary_format, architecture, endianness);
133-
match architecture {
133+
let e_flags = match architecture {
134134
Architecture::Mips => {
135135
let arch = match sess.target.options.cpu.as_ref() {
136136
"mips1" => elf::EF_MIPS_ARCH_1,
@@ -149,7 +149,7 @@ pub(crate) fn create_object_file(sess: &Session) -> Option<write::Object<'static
149149
if sess.target.options.cpu.contains("r6") {
150150
e_flags |= elf::EF_MIPS_NAN2008;
151151
}
152-
file.flags = FileFlags::Elf { e_flags };
152+
e_flags
153153
}
154154
Architecture::Mips64 => {
155155
// copied from `mips64el-linux-gnuabi64-gcc foo.c -c`
@@ -160,17 +160,26 @@ pub(crate) fn create_object_file(sess: &Session) -> Option<write::Object<'static
160160
} else {
161161
elf::EF_MIPS_ARCH_64R2
162162
};
163-
file.flags = FileFlags::Elf { e_flags };
163+
e_flags
164164
}
165165
Architecture::Riscv64 if sess.target.options.features.contains("+d") => {
166166
// copied from `riscv64-linux-gnu-gcc foo.c -c`, note though
167167
// that the `+d` target feature represents whether the double
168168
// float abi is enabled.
169169
let e_flags = elf::EF_RISCV_RVC | elf::EF_RISCV_FLOAT_ABI_DOUBLE;
170-
file.flags = FileFlags::Elf { e_flags };
170+
e_flags
171171
}
172-
_ => {}
172+
_ => 0,
173+
};
174+
// adapted from LLVM's `MCELFObjectTargetWriter::getOSABI`
175+
let os_abi = match sess.target.options.os.as_ref() {
176+
"hermit" => elf::ELFOSABI_STANDALONE,
177+
"freebsd" => elf::ELFOSABI_FREEBSD,
178+
"solaris" => elf::ELFOSABI_SOLARIS,
179+
_ => elf::ELFOSABI_NONE,
173180
};
181+
let abi_version = 0;
182+
file.flags = FileFlags::Elf { os_abi, abi_version, e_flags };
174183
Some(file)
175184
}
176185

compiler/rustc_metadata/src/creader.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,10 @@ impl CStore {
133133
CrateNum::new(self.metas.len() - 1)
134134
}
135135

136+
pub fn has_crate_data(&self, cnum: CrateNum) -> bool {
137+
self.metas[cnum].is_some()
138+
}
139+
136140
pub(crate) fn get_crate_data(&self, cnum: CrateNum) -> CrateMetadataRef<'_> {
137141
let cdata = self.metas[cnum]
138142
.as_ref()

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

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::ty::{
55
TypeSuperFoldable,
66
};
77
use rustc_apfloat::ieee::{Double, Single};
8-
use rustc_data_structures::fx::FxHashMap;
8+
use rustc_data_structures::fx::{FxHashMap, FxIndexMap};
99
use rustc_data_structures::sso::SsoHashSet;
1010
use rustc_hir as hir;
1111
use rustc_hir::def::{self, CtorKind, DefKind, Namespace};
@@ -779,8 +779,8 @@ pub trait PrettyPrinter<'tcx>:
779779
// by looking up the projections associated with the def_id.
780780
let bounds = self.tcx().bound_explicit_item_bounds(def_id);
781781

782-
let mut traits = BTreeMap::new();
783-
let mut fn_traits = BTreeMap::new();
782+
let mut traits = FxIndexMap::default();
783+
let mut fn_traits = FxIndexMap::default();
784784
let mut is_sized = false;
785785

786786
for predicate in bounds.transpose_iter().map(|e| e.map_bound(|(p, _)| *p)) {
@@ -856,7 +856,7 @@ pub trait PrettyPrinter<'tcx>:
856856
p!(")");
857857
if let Term::Ty(ty) = return_ty.skip_binder() {
858858
if !ty.is_unit() {
859-
p!("-> ", print(return_ty));
859+
p!(" -> ", print(return_ty));
860860
}
861861
}
862862
p!(write("{}", if paren_needed { ")" } else { "" }));
@@ -970,11 +970,11 @@ pub trait PrettyPrinter<'tcx>:
970970
&mut self,
971971
trait_ref: ty::PolyTraitRef<'tcx>,
972972
proj_ty: Option<(DefId, ty::Binder<'tcx, Term<'tcx>>)>,
973-
traits: &mut BTreeMap<
973+
traits: &mut FxIndexMap<
974974
ty::PolyTraitRef<'tcx>,
975-
BTreeMap<DefId, ty::Binder<'tcx, Term<'tcx>>>,
975+
FxIndexMap<DefId, ty::Binder<'tcx, Term<'tcx>>>,
976976
>,
977-
fn_traits: &mut BTreeMap<ty::PolyTraitRef<'tcx>, OpaqueFnEntry<'tcx>>,
977+
fn_traits: &mut FxIndexMap<ty::PolyTraitRef<'tcx>, OpaqueFnEntry<'tcx>>,
978978
) {
979979
let trait_def_id = trait_ref.def_id();
980980

@@ -1110,19 +1110,18 @@ pub trait PrettyPrinter<'tcx>:
11101110
// Builtin bounds.
11111111
// FIXME(eddyb) avoid printing twice (needed to ensure
11121112
// that the auto traits are sorted *and* printed via cx).
1113-
let mut auto_traits: Vec<_> =
1114-
predicates.auto_traits().map(|did| (self.tcx().def_path_str(did), did)).collect();
1113+
let mut auto_traits: Vec<_> = predicates.auto_traits().collect();
11151114

11161115
// The auto traits come ordered by `DefPathHash`. While
11171116
// `DefPathHash` is *stable* in the sense that it depends on
11181117
// neither the host nor the phase of the moon, it depends
11191118
// "pseudorandomly" on the compiler version and the target.
11201119
//
1121-
// To avoid that causing instabilities in compiletest
1120+
// To avoid causing instabilities in compiletest
11221121
// output, sort the auto-traits alphabetically.
1123-
auto_traits.sort();
1122+
auto_traits.sort_by_cached_key(|did| self.tcx().def_path_str(*did));
11241123

1125-
for (_, def_id) in auto_traits {
1124+
for def_id in auto_traits {
11261125
if !first {
11271126
p!(" + ");
11281127
}

0 commit comments

Comments
 (0)