Skip to content

Commit 5f23ef7

Browse files
committed
Auto merge of rust-lang#134582 - matthiaskrgr:rollup-i0oyqjw, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - rust-lang#134556 ([tiny] fix missing ns units in bootstrap's benchmark rendering) - rust-lang#134560 (mri: add track_caller to thread spawning methods for better backtraces) - rust-lang#134561 (Reduce the amount of explicit FatalError.raise()) - rust-lang#134562 (tests/codegen/asm: Remove uses of rustc_attrs and lang_items features by using minicore) - rust-lang#134567 (Remove some dead code around import library generation) - rust-lang#134570 (remove reference to dangling from slice::Iter) - rust-lang#134573 (unimplement `PointerLike` for trait objects) - rust-lang#134574 (next-solver: disable unnecessary hack) r? `@ghost` `@rustbot` modify labels: rollup
2 parents bad2aa4 + 10a7405 commit 5f23ef7

File tree

39 files changed

+297
-299
lines changed

39 files changed

+297
-299
lines changed

compiler/rustc_borrowck/src/region_infer/opaque_types.rs

+7-6
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,13 @@ impl<'tcx> RegionInferenceContext<'tcx> {
134134
// the hidden type becomes the opaque type itself. In this case, this was an opaque
135135
// usage of the opaque type and we can ignore it. This check is mirrored in typeck's
136136
// writeback.
137-
// FIXME(-Znext-solver): This should be unnecessary with the new solver.
138-
if let ty::Alias(ty::Opaque, alias_ty) = ty.kind()
139-
&& alias_ty.def_id == opaque_type_key.def_id.to_def_id()
140-
&& alias_ty.args == opaque_type_key.args
141-
{
142-
continue;
137+
if !infcx.next_trait_solver() {
138+
if let ty::Alias(ty::Opaque, alias_ty) = ty.kind()
139+
&& alias_ty.def_id == opaque_type_key.def_id.to_def_id()
140+
&& alias_ty.args == opaque_type_key.args
141+
{
142+
continue;
143+
}
143144
}
144145
// Sometimes two opaque types are the same only after we remap the generic parameters
145146
// back to the opaque type definition. E.g. we may have `OpaqueType<X, Y>` mapped to

compiler/rustc_codegen_llvm/src/llvm/ffi.rs

-28
Original file line numberDiff line numberDiff line change
@@ -56,25 +56,6 @@ pub enum LLVMRustResult {
5656
Failure,
5757
}
5858

59-
// Rust version of the C struct with the same name in rustc_llvm/llvm-wrapper/RustWrapper.cpp.
60-
#[repr(C)]
61-
pub struct LLVMRustCOFFShortExport {
62-
pub name: *const c_char,
63-
pub ordinal_present: bool,
64-
/// value of `ordinal` only important when `ordinal_present` is true
65-
pub ordinal: u16,
66-
}
67-
68-
impl LLVMRustCOFFShortExport {
69-
pub fn new(name: *const c_char, ordinal: Option<u16>) -> LLVMRustCOFFShortExport {
70-
LLVMRustCOFFShortExport {
71-
name,
72-
ordinal_present: ordinal.is_some(),
73-
ordinal: ordinal.unwrap_or(0),
74-
}
75-
}
76-
}
77-
7859
/// Translation of LLVM's MachineTypes enum, defined in llvm\include\llvm\BinaryFormat\COFF.h.
7960
///
8061
/// We include only architectures supported on Windows.
@@ -2347,15 +2328,6 @@ unsafe extern "C" {
23472328
) -> &'a mut RustArchiveMember<'a>;
23482329
pub fn LLVMRustArchiveMemberFree<'a>(Member: &'a mut RustArchiveMember<'a>);
23492330

2350-
pub fn LLVMRustWriteImportLibrary(
2351-
ImportName: *const c_char,
2352-
Path: *const c_char,
2353-
Exports: *const LLVMRustCOFFShortExport,
2354-
NumExports: usize,
2355-
Machine: u16,
2356-
MinGW: bool,
2357-
) -> LLVMRustResult;
2358-
23592331
pub fn LLVMRustSetDataLayoutFromTargetMachine<'a>(M: &'a Module, TM: &'a TargetMachine);
23602332

23612333
pub fn LLVMRustPositionBuilderAtStart<'a>(B: &Builder<'a>, BB: &'a BasicBlock);

compiler/rustc_codegen_ssa/src/back/link.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use rustc_ast::CRATE_NODE_ID;
1515
use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
1616
use rustc_data_structures::memmap::Mmap;
1717
use rustc_data_structures::temp_dir::MaybeTempDir;
18-
use rustc_errors::{DiagCtxtHandle, FatalError};
18+
use rustc_errors::DiagCtxtHandle;
1919
use rustc_fs_util::{fix_windows_verbatim_for_gcc, try_canonicalize};
2020
use rustc_hir::def_id::{CrateNum, LOCAL_CRATE};
2121
use rustc_metadata::fs::{METADATA_FILENAME, copy_to_stdout, emit_wrapper_file};
@@ -1038,22 +1038,22 @@ fn link_natively(
10381038
Err(e) => {
10391039
let linker_not_found = e.kind() == io::ErrorKind::NotFound;
10401040

1041-
if linker_not_found {
1042-
sess.dcx().emit_err(errors::LinkerNotFound { linker_path, error: e });
1041+
let err = if linker_not_found {
1042+
sess.dcx().emit_err(errors::LinkerNotFound { linker_path, error: e })
10431043
} else {
10441044
sess.dcx().emit_err(errors::UnableToExeLinker {
10451045
linker_path,
10461046
error: e,
10471047
command_formatted: format!("{cmd:?}"),
1048-
});
1049-
}
1048+
})
1049+
};
10501050

10511051
if sess.target.is_like_msvc && linker_not_found {
10521052
sess.dcx().emit_note(errors::MsvcMissingLinker);
10531053
sess.dcx().emit_note(errors::CheckInstalledVisualStudio);
10541054
sess.dcx().emit_note(errors::InsufficientVSCodeProduct);
10551055
}
1056-
FatalError.raise();
1056+
err.raise_fatal();
10571057
}
10581058
}
10591059

compiler/rustc_driver_impl/src/pretty.rs

+2-7
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use std::cell::Cell;
44
use std::fmt::Write;
55

66
use rustc_ast_pretty::pprust as pprust_ast;
7-
use rustc_errors::FatalError;
87
use rustc_middle::bug;
98
use rustc_middle::mir::{write_mir_graphviz, write_mir_pretty};
109
use rustc_middle::ty::{self, TyCtxt};
@@ -311,9 +310,7 @@ pub fn print<'tcx>(sess: &Session, ppm: PpMode, ex: PrintExtra<'tcx>) {
311310
let tcx = ex.tcx();
312311
let mut out = String::new();
313312
rustc_hir_analysis::check_crate(tcx);
314-
if tcx.dcx().has_errors().is_some() {
315-
FatalError.raise();
316-
}
313+
tcx.dcx().abort_if_errors();
317314
debug!("pretty printing THIR tree");
318315
for did in tcx.hir().body_owners() {
319316
let _ = writeln!(out, "{:?}:\n{}\n", did, tcx.thir_tree(did));
@@ -324,9 +321,7 @@ pub fn print<'tcx>(sess: &Session, ppm: PpMode, ex: PrintExtra<'tcx>) {
324321
let tcx = ex.tcx();
325322
let mut out = String::new();
326323
rustc_hir_analysis::check_crate(tcx);
327-
if tcx.dcx().has_errors().is_some() {
328-
FatalError.raise();
329-
}
324+
tcx.dcx().abort_if_errors();
330325
debug!("pretty printing THIR flat");
331326
for did in tcx.hir().body_owners() {
332327
let _ = writeln!(out, "{:?}:\n{}\n", did, tcx.thir_flat(did));

compiler/rustc_feature/src/builtin_attrs.rs

+10-1
Original file line numberDiff line numberDiff line change
@@ -912,11 +912,20 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
912912
rustc_attr!(
913913
rustc_deny_explicit_impl,
914914
AttributeType::Normal,
915-
template!(List: "implement_via_object = (true|false)"),
915+
template!(Word),
916916
ErrorFollowing,
917917
EncodeCrossCrate::No,
918918
"#[rustc_deny_explicit_impl] enforces that a trait can have no user-provided impls"
919919
),
920+
rustc_attr!(
921+
rustc_do_not_implement_via_object,
922+
AttributeType::Normal,
923+
template!(Word),
924+
ErrorFollowing,
925+
EncodeCrossCrate::No,
926+
"#[rustc_do_not_implement_via_object] opts out of the automatic trait impl for trait objects \
927+
(`impl Trait for dyn Trait`)"
928+
),
920929
rustc_attr!(
921930
rustc_has_incoherent_inherent_impls, AttributeType::Normal, template!(Word),
922931
ErrorFollowing, EncodeCrossCrate::Yes,

compiler/rustc_hir_analysis/src/coherence/mod.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,9 @@ fn check_object_overlap<'tcx>(
206206
// so this is valid.
207207
} else {
208208
let mut supertrait_def_ids = tcx.supertrait_def_ids(component_def_id);
209-
if supertrait_def_ids.any(|d| d == trait_def_id) {
209+
if supertrait_def_ids
210+
.any(|d| d == trait_def_id && tcx.trait_def(d).implement_via_object)
211+
{
210212
let span = tcx.def_span(impl_def_id);
211213
return Err(struct_span_code_err!(
212214
tcx.dcx(),

compiler/rustc_hir_analysis/src/collect.rs

+2-43
Original file line numberDiff line numberDiff line change
@@ -1261,49 +1261,8 @@ fn trait_def(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::TraitDef {
12611261
no_dups.then_some(list)
12621262
});
12631263

1264-
let mut deny_explicit_impl = false;
1265-
let mut implement_via_object = true;
1266-
if let Some(attr) = tcx.get_attr(def_id, sym::rustc_deny_explicit_impl) {
1267-
deny_explicit_impl = true;
1268-
let mut seen_attr = false;
1269-
for meta in attr.meta_item_list().iter().flatten() {
1270-
if let Some(meta) = meta.meta_item()
1271-
&& meta.name_or_empty() == sym::implement_via_object
1272-
&& let Some(lit) = meta.name_value_literal()
1273-
{
1274-
if seen_attr {
1275-
tcx.dcx().span_err(meta.span, "duplicated `implement_via_object` meta item");
1276-
}
1277-
seen_attr = true;
1278-
1279-
match lit.symbol {
1280-
kw::True => {
1281-
implement_via_object = true;
1282-
}
1283-
kw::False => {
1284-
implement_via_object = false;
1285-
}
1286-
_ => {
1287-
tcx.dcx().span_err(
1288-
meta.span,
1289-
format!(
1290-
"unknown literal passed to `implement_via_object` attribute: {}",
1291-
lit.symbol
1292-
),
1293-
);
1294-
}
1295-
}
1296-
} else {
1297-
tcx.dcx().span_err(
1298-
meta.span(),
1299-
format!("unknown meta item passed to `rustc_deny_explicit_impl` {meta:?}"),
1300-
);
1301-
}
1302-
}
1303-
if !seen_attr {
1304-
tcx.dcx().span_err(attr.span, "missing `implement_via_object` meta item");
1305-
}
1306-
}
1264+
let deny_explicit_impl = tcx.has_attr(def_id, sym::rustc_deny_explicit_impl);
1265+
let implement_via_object = !tcx.has_attr(def_id, sym::rustc_do_not_implement_via_object);
13071266

13081267
ty::TraitDef {
13091268
def_id: def_id.to_def_id(),

compiler/rustc_hir_typeck/src/writeback.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -554,11 +554,13 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
554554
let hidden_type = self.resolve(decl.hidden_type, &decl.hidden_type.span);
555555
let opaque_type_key = self.resolve(opaque_type_key, &decl.hidden_type.span);
556556

557-
if let ty::Alias(ty::Opaque, alias_ty) = hidden_type.ty.kind()
558-
&& alias_ty.def_id == opaque_type_key.def_id.to_def_id()
559-
&& alias_ty.args == opaque_type_key.args
560-
{
561-
continue;
557+
if !self.fcx.next_trait_solver() {
558+
if let ty::Alias(ty::Opaque, alias_ty) = hidden_type.ty.kind()
559+
&& alias_ty.def_id == opaque_type_key.def_id.to_def_id()
560+
&& alias_ty.args == opaque_type_key.args
561+
{
562+
continue;
563+
}
562564
}
563565

564566
// Here we only detect impl trait definition conflicts when they

compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp

-50
Original file line numberDiff line numberDiff line change
@@ -1796,56 +1796,6 @@ extern "C" LLVMValueRef LLVMRustBuildMaxNum(LLVMBuilderRef B, LLVMValueRef LHS,
17961796
return wrap(unwrap(B)->CreateMaxNum(unwrap(LHS), unwrap(RHS)));
17971797
}
17981798

1799-
// This struct contains all necessary info about a symbol exported from a DLL.
1800-
struct LLVMRustCOFFShortExport {
1801-
const char *name;
1802-
bool ordinal_present;
1803-
// The value of `ordinal` is only meaningful if `ordinal_present` is true.
1804-
uint16_t ordinal;
1805-
};
1806-
1807-
// Machine must be a COFF machine type, as defined in PE specs.
1808-
extern "C" LLVMRustResult
1809-
LLVMRustWriteImportLibrary(const char *ImportName, const char *Path,
1810-
const LLVMRustCOFFShortExport *Exports,
1811-
size_t NumExports, uint16_t Machine, bool MinGW) {
1812-
std::vector<llvm::object::COFFShortExport> ConvertedExports;
1813-
ConvertedExports.reserve(NumExports);
1814-
1815-
for (size_t i = 0; i < NumExports; ++i) {
1816-
bool ordinal_present = Exports[i].ordinal_present;
1817-
uint16_t ordinal = ordinal_present ? Exports[i].ordinal : 0;
1818-
ConvertedExports.push_back(llvm::object::COFFShortExport{
1819-
Exports[i].name, // Name
1820-
std::string{}, // ExtName
1821-
std::string{}, // SymbolName
1822-
std::string{}, // AliasTarget
1823-
#if LLVM_VERSION_GE(19, 0)
1824-
std::string{}, // ExportAs
1825-
#endif
1826-
ordinal, // Ordinal
1827-
ordinal_present, // Noname
1828-
false, // Data
1829-
false, // Private
1830-
false // Constant
1831-
});
1832-
}
1833-
1834-
auto Error = llvm::object::writeImportLibrary(
1835-
ImportName, Path, ConvertedExports,
1836-
static_cast<llvm::COFF::MachineTypes>(Machine), MinGW);
1837-
if (Error) {
1838-
std::string errorString;
1839-
auto stream = llvm::raw_string_ostream(errorString);
1840-
stream << Error;
1841-
stream.flush();
1842-
LLVMRustSetLastError(errorString.c_str());
1843-
return LLVMRustResult::Failure;
1844-
} else {
1845-
return LLVMRustResult::Success;
1846-
}
1847-
}
1848-
18491799
// Transfers ownership of DiagnosticHandler unique_ptr to the caller.
18501800
extern "C" DiagnosticHandler *
18511801
LLVMRustContextGetDiagnosticHandler(LLVMContextRef C) {

compiler/rustc_middle/src/ty/trait_def.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,12 @@ pub struct TraitDef {
7070

7171
/// Whether to add a builtin `dyn Trait: Trait` implementation.
7272
/// This is enabled for all traits except ones marked with
73-
/// `#[rustc_deny_explicit_impl(implement_via_object = false)]`.
73+
/// `#[rustc_do_not_implement_via_object]`.
7474
pub implement_via_object: bool,
7575

7676
/// Whether a trait is fully built-in, and any implementation is disallowed.
7777
/// This only applies to built-in traits, and is marked via
78-
/// `#[rustc_deny_explicit_impl(implement_via_object = ...)]`.
78+
/// `#[rustc_deny_explicit_impl]`.
7979
pub deny_explicit_impl: bool,
8080
}
8181

compiler/rustc_parse/src/parser/diagnostics.rs

+5-12
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ use rustc_ast_pretty::pprust;
1616
use rustc_data_structures::fx::FxHashSet;
1717
use rustc_data_structures::sync::Lrc;
1818
use rustc_errors::{
19-
Applicability, Diag, DiagCtxtHandle, ErrorGuaranteed, FatalError, PResult, Subdiagnostic,
20-
Suggestions, pluralize,
19+
Applicability, Diag, DiagCtxtHandle, ErrorGuaranteed, PResult, Subdiagnostic, Suggestions,
20+
pluralize,
2121
};
2222
use rustc_session::errors::ExprParenthesesNeeded;
2323
use rustc_span::edit_distance::find_best_match_for_name;
@@ -3023,17 +3023,10 @@ impl<'a> Parser<'a> {
30233023
}
30243024

30253025
pub(super) fn recover_vcs_conflict_marker(&mut self) {
3026-
if let Err(err) = self.err_vcs_conflict_marker() {
3027-
err.emit();
3028-
FatalError.raise();
3029-
}
3030-
}
3031-
3032-
pub(crate) fn err_vcs_conflict_marker(&mut self) -> PResult<'a, ()> {
30333026
// <<<<<<<
30343027
let Some(start) = self.conflict_marker(&TokenKind::BinOp(token::Shl), &TokenKind::Lt)
30353028
else {
3036-
return Ok(());
3029+
return;
30373030
};
30383031
let mut spans = Vec::with_capacity(3);
30393032
spans.push(start);
@@ -3063,7 +3056,7 @@ impl<'a> Parser<'a> {
30633056
self.bump();
30643057
}
30653058

3066-
let mut err = self.dcx().struct_span_err(spans, "encountered diff marker");
3059+
let mut err = self.dcx().struct_span_fatal(spans, "encountered diff marker");
30673060
match middlediff3 {
30683061
// We're using diff3
30693062
Some(middlediff3) => {
@@ -3106,7 +3099,7 @@ impl<'a> Parser<'a> {
31063099
visit <https://git-scm.com/book/en/v2/Git-Tools-Advanced-Merging#_checking_out_conflicts>",
31073100
);
31083101

3109-
Err(err)
3102+
err.emit();
31103103
}
31113104

31123105
/// Parse and throw away a parenthesized comma separated

compiler/rustc_parse/src/parser/path.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -597,8 +597,7 @@ impl<'a> Parser<'a> {
597597
// When encountering severely malformed code where there are several levels of
598598
// nested unclosed angle args (`f::<f::<f::<f::<...`), we avoid severe O(n^2)
599599
// behavior by bailing out earlier (#117080).
600-
e.emit();
601-
rustc_errors::FatalError.raise();
600+
e.emit().raise_fatal();
602601
}
603602
Err(e) if is_first_invocation && self.unmatched_angle_bracket_count > 0 => {
604603
self.angle_bracket_nesting -= 1;

compiler/rustc_passes/src/check_attr.rs

+1
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
186186
[sym::rustc_coinductive, ..]
187187
| [sym::rustc_must_implement_one_of, ..]
188188
| [sym::rustc_deny_explicit_impl, ..]
189+
| [sym::rustc_do_not_implement_via_object, ..]
189190
| [sym::const_trait, ..] => self.check_must_be_applied_to_trait(attr, span, target),
190191
[sym::collapse_debuginfo, ..] => self.check_collapse_debuginfo(attr, span, target),
191192
[sym::must_not_suspend, ..] => self.check_must_not_suspend(attr, span, target),

0 commit comments

Comments
 (0)