Skip to content

Commit 7036449

Browse files
committed
Auto merge of #98447 - JohnTitor:rollup-pponoo3, r=JohnTitor
Rollup of 9 pull requests Successful merges: - #91264 (Add macro support in jump to definition feature) - #96955 (Remove (transitive) reliance on sorting by DefId in pretty-printer) - #97633 (Session object: Set OS/ABI) - #98039 (Fix `panic` message for `BTreeSet`'s `range` API and document `panic` cases) - #98214 (rustc_target: Remove some redundant target properties) - #98280 (Improve suggestion for calling fn-like expr on type mismatch) - #98394 (Fixup missing renames from `#[main]` to `#[rustc_main]`) - #98411 (Update tendril) - #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

+18-5
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

+1-1
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

+6-5
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

+1-1
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

+1-1
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

+1-1
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

+2-2
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

+14-5
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

+4
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

+11-12
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
}

compiler/rustc_passes/src/entry.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ fn entry_point_type(ctxt: &EntryContext<'_>, id: ItemId, at_root: bool) -> Entry
5656
if ctxt.tcx.sess.contains_name(attrs, sym::start) {
5757
EntryPointType::Start
5858
} else if ctxt.tcx.sess.contains_name(attrs, sym::rustc_main) {
59-
EntryPointType::MainAttr
59+
EntryPointType::RustcMainAttr
6060
} else {
6161
if let Some(name) = ctxt.tcx.opt_item_name(id.def_id.to_def_id())
6262
&& name == sym::main {
@@ -95,21 +95,21 @@ fn find_item(id: ItemId, ctxt: &mut EntryContext<'_>) {
9595
EntryPointType::OtherMain => {
9696
ctxt.non_main_fns.push(ctxt.tcx.def_span(id.def_id));
9797
}
98-
EntryPointType::MainAttr => {
98+
EntryPointType::RustcMainAttr => {
9999
if ctxt.attr_main_fn.is_none() {
100100
ctxt.attr_main_fn = Some((id.def_id, ctxt.tcx.def_span(id.def_id.to_def_id())));
101101
} else {
102102
struct_span_err!(
103103
ctxt.tcx.sess,
104104
ctxt.tcx.def_span(id.def_id.to_def_id()),
105105
E0137,
106-
"multiple functions with a `#[main]` attribute"
106+
"multiple functions with a `#[rustc_main]` attribute"
107107
)
108108
.span_label(
109109
ctxt.tcx.def_span(id.def_id.to_def_id()),
110-
"additional `#[main]` function",
110+
"additional `#[rustc_main]` function",
111111
)
112-
.span_label(ctxt.attr_main_fn.unwrap().1, "first `#[main]` function")
112+
.span_label(ctxt.attr_main_fn.unwrap().1, "first `#[rustc_main]` function")
113113
.emit();
114114
}
115115
}

compiler/rustc_passes/src/weak_lang_items.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub fn check_crate<'tcx>(tcx: TyCtxt<'tcx>, items: &mut lang_items::LanguageItem
1717
if items.eh_personality().is_none() {
1818
items.missing.push(LangItem::EhPersonality);
1919
}
20-
if tcx.sess.target.is_like_emscripten && items.eh_catch_typeinfo().is_none() {
20+
if tcx.sess.target.os == "emscripten" && items.eh_catch_typeinfo().is_none() {
2121
items.missing.push(LangItem::EhCatchTypeinfo);
2222
}
2323

compiler/rustc_resolve/src/late.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -3514,7 +3514,9 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
35143514
})
35153515
});
35163516
}
3517-
ExprKind::Async(..) | ExprKind::Closure(..) => {
3517+
// For closures, ClosureOrAsyncRibKind is added in visit_fn
3518+
ExprKind::Closure(..) => visit::walk_expr(self, expr),
3519+
ExprKind::Async(..) => {
35183520
self.with_label_rib(ClosureOrAsyncRibKind, |this| visit::walk_expr(this, expr));
35193521
}
35203522
ExprKind::Repeat(ref elem, ref ct) => {

compiler/rustc_target/src/asm/aarch64.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ impl AArch64InlineAsmRegClass {
7474
}
7575

7676
pub fn target_reserves_x18(target: &Target) -> bool {
77-
target.os == "android" || target.is_like_fuchsia || target.is_like_osx || target.is_like_windows
77+
target.os == "android" || target.os == "fuchsia" || target.is_like_osx || target.is_like_windows
7878
}
7979

8080
fn reserved_x18(

compiler/rustc_target/src/spec/fuchsia_base.rs

-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ pub fn opts() -> TargetOptions {
2828
dynamic_linking: true,
2929
executables: true,
3030
families: cvs!["unix"],
31-
is_like_fuchsia: true,
3231
pre_link_args,
3332
pre_link_objects: crt_objects::new(&[
3433
(LinkOutputKind::DynamicNoPicExe, &["Scrt1.o"]),

compiler/rustc_target/src/spec/mod.rs

-12
Original file line numberDiff line numberDiff line change
@@ -1273,12 +1273,6 @@ pub struct TargetOptions {
12731273
/// - uses SEH-based unwinding,
12741274
/// - supports control flow guard mechanism.
12751275
pub is_like_msvc: bool,
1276-
/// Whether the target toolchain is like Emscripten's. Only useful for compiling with
1277-
/// Emscripten toolchain.
1278-
/// Defaults to false.
1279-
pub is_like_emscripten: bool,
1280-
/// Whether the target toolchain is like Fuchsia's.
1281-
pub is_like_fuchsia: bool,
12821276
/// Whether a target toolchain is like WASM.
12831277
pub is_like_wasm: bool,
12841278
/// Version of DWARF to use if not using the default.
@@ -1505,9 +1499,7 @@ impl Default for TargetOptions {
15051499
is_like_osx: false,
15061500
is_like_solaris: false,
15071501
is_like_windows: false,
1508-
is_like_emscripten: false,
15091502
is_like_msvc: false,
1510-
is_like_fuchsia: false,
15111503
is_like_wasm: false,
15121504
dwarf_version: None,
15131505
linker_is_gnu: true,
@@ -2112,8 +2104,6 @@ impl Target {
21122104
key!(is_like_solaris, bool);
21132105
key!(is_like_windows, bool);
21142106
key!(is_like_msvc, bool);
2115-
key!(is_like_emscripten, bool);
2116-
key!(is_like_fuchsia, bool);
21172107
key!(is_like_wasm, bool);
21182108
key!(dwarf_version, Option<u32>);
21192109
key!(linker_is_gnu, bool);
@@ -2358,8 +2348,6 @@ impl ToJson for Target {
23582348
target_option_val!(is_like_solaris);
23592349
target_option_val!(is_like_windows);
23602350
target_option_val!(is_like_msvc);
2361-
target_option_val!(is_like_emscripten);
2362-
target_option_val!(is_like_fuchsia);
23632351
target_option_val!(is_like_wasm);
23642352
target_option_val!(dwarf_version);
23652353
target_option_val!(linker_is_gnu);

0 commit comments

Comments
 (0)