Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
93c8b74
document that t-lang does not need involvement for unobservable intri…
RalfJung Aug 24, 2026
1b08f98
Slightly extend `tests/run-make/target-specs/rmake.rs`
nnethercote Aug 27, 2026
39ca15c
Adjust when "This is the default target CPU..." message is printed
nnethercote Aug 27, 2026
ac05dbe
Explicitly set the `cpu` field for `avr-none`
nnethercote Aug 27, 2026
0911b0a
Simplify `OwnedTargetMachine`
nnethercote Aug 31, 2026
7f0581d
Fix initialization cycle in `target_config`
nnethercote Aug 26, 2026
bc21abb
Garbage-collect old incremental compilation sessions
charliermarsh Sep 3, 2026
f178bea
Preserve the current finalized incremental session
charliermarsh Sep 4, 2026
768091d
fix: don't panic on doc comments attached to literal expressions
Aditya-PS-05 Sep 4, 2026
f8326c9
ide: fix doc comment offset calculation
dimxy Sep 6, 2026
af3f278
internal: Add regression test for 'failed to unify type errors' panic
Wilfred Sep 7, 2026
fcdf7f6
Merge pull request #23309 from Wilfred/fix/term-search-unify-regressi…
ChayimFriedman2 Sep 7, 2026
071f269
fix: restore the `#[deprecated]` attr
ada4a Sep 3, 2026
ccfeaac
remove `allow`s that are no longer necessary
ada4a Aug 11, 2026
1aa9a9e
Fix `hir::Type` owner mismatches between anon consts
ChayimFriedman2 Sep 8, 2026
0de0415
Remove some unused code
ChayimFriedman2 Sep 8, 2026
2cd39c2
Merge pull request #23316 from ChayimFriedman2/remove-unused
ChayimFriedman2 Sep 8, 2026
a57cd31
Do not fill the body for `Drop::drop()` and `#[rustc_must_implement_o…
ChayimFriedman2 Sep 8, 2026
9fdf3cd
Do not run the "Generate lints and feature flags" CI workflow on forks
ChayimFriedman2 Sep 8, 2026
f625440
Merge pull request #23321 from ChayimFriedman2/no-lints-workflow-fork
ChayimFriedman2 Sep 8, 2026
45dda07
Merge pull request #23300 from dimxy/fix-doc-comment-nav-panic
ChayimFriedman2 Sep 8, 2026
1793d1e
Stop at eager macro recursion overflow
ChayimFriedman2 Sep 8, 2026
77db98f
use `expect` for lints we actually expect
ada4a Aug 11, 2026
3bae6b7
follow the suggestions of the lints
ada4a Aug 11, 2026
27e05d3
triage `clippy::disallowed_types`
ada4a Sep 7, 2026
93bf99f
underscore-prefix the field storing `EnteredSpan`
ada4a Sep 9, 2026
e6c7cf4
a few more misc clean-ups
ada4a Aug 11, 2026
065aa82
fix: Don't support const blocks in patterns
Wilfred Sep 7, 2026
c596c7d
fix: do not panic on json with invalid field name
A4-Tacks Sep 9, 2026
f82e963
fix: correct incorrect_case suggestion for raw identifiers
edragain2nd Sep 9, 2026
178a4df
Merge pull request #23311 from ada4a/push-lwkopltlwnlt
ChayimFriedman2 Sep 9, 2026
d22bc72
Merge pull request #23307 from Wilfred/fix/const-block-double-infer
ChayimFriedman2 Sep 9, 2026
3cdd184
Merge pull request #23330 from A4-Tacks/json-invalid-field-name
ChayimFriedman2 Sep 9, 2026
e3fefe4
Merge pull request #23333 from edragain2nd/fix/incorrect_upper_camel_…
ChayimFriedman2 Sep 9, 2026
a538446
Merge pull request #23295 from Aditya-PS-05/fix-doc-comment-literal-p…
ChayimFriedman2 Sep 9, 2026
ff71565
fix: correct incorrect_case suggestion for enum variants with raw key…
edragain2nd Sep 10, 2026
cea6437
Merge pull request #23340 from edragain2nd/fix/incorrect_upper_camel_…
A4-Tacks Sep 10, 2026
8ff7045
Merge pull request #23315 from ChayimFriedman2/anon-const-owner
Veykril Sep 11, 2026
fc45e8c
Merge pull request #23317 from ChayimFriedman2/force-empty-body
Veykril Sep 11, 2026
60aff9f
Merge pull request #23323 from ChayimFriedman2/eager-recursion-limit
Veykril Sep 11, 2026
f28bf11
Add regression test for previous overflow evaluating the requirement
lsunsi Sep 11, 2026
b4361c9
Move guard into is_old_enough_to_be_collected branch
charliermarsh Sep 11, 2026
603380e
Avoid some `struct_foo(..).emit()` chains
nnethercote Sep 9, 2026
09bf6de
Remove `EmissionGuarantee`
nnethercote Sep 9, 2026
0b5a666
libtest: avoid allocating the tests we do not even run
RalfJung Aug 27, 2026
cf705a0
avoid iterating the full test list for max_name_len
RalfJung Aug 27, 2026
1fcd35e
make all tests cloneable
RalfJung Aug 27, 2026
f8de0af
use static instead of const for TestDescAndFn
RalfJung Aug 27, 2026
fa07215
dont early-exit inside test_main
RalfJung Aug 28, 2026
20ceed7
regression test for valtree leaf const
malezjaa Sep 13, 2026
df4f90d
panic when we call impls_trait for types associated with builtin deri…
anatawa12 Sep 13, 2026
1be3e33
Add regression test for unexpected type for constructor
lsunsi Sep 13, 2026
b14856a
Merge pull request #23352 from anatawa12/fix-panic-with-is-impl-with-…
ChayimFriedman2 Sep 13, 2026
9282e0a
Remove the interner/db argument from `empty()` and `default_types()`
ChayimFriedman2 Sep 9, 2026
05c806d
Do not fill unstable methods in "Implement default members"
ChayimFriedman2 Sep 8, 2026
e9e9680
Merge pull request #23325 from ChayimFriedman2/no-interner-interneds
ChayimFriedman2 Sep 13, 2026
62bfc83
Merge pull request #23318 from ChayimFriedman2/add-impl-members-unstable
ChayimFriedman2 Sep 13, 2026
f0eb4b5
Remove pointless A: Allocator bounds in boxed.rs
maxdexh Sep 13, 2026
a6aae86
cleanups
sjwang05 Sep 13, 2026
b86d5ea
Rollup merge of #162752 - lnicola:sync-from-ra, r=lnicola
JonathanBrouwer Sep 14, 2026
a5bbebc
Rollup merge of #161868 - RalfJung:libtest-less-alloc, r=Mark-Simulacrum
JonathanBrouwer Sep 14, 2026
f63939d
Rollup merge of #161903 - nnethercote:fix-target_config-cycle, r=nikic
JonathanBrouwer Sep 14, 2026
98eb915
Rollup merge of #162240 - charliermarsh:charlie/incremental-session-g…
JonathanBrouwer Sep 14, 2026
775529c
Rollup merge of #161675 - RalfJung:intrinsic-approval, r=traviscross,…
JonathanBrouwer Sep 14, 2026
c877842
Rollup merge of #162630 - nnethercote:simplify-Diag-G, r=oli-obk
JonathanBrouwer Sep 14, 2026
48f073b
Rollup merge of #162647 - lsunsi:issue219, r=mu001999
JonathanBrouwer Sep 14, 2026
2b0f3ce
Rollup merge of #162703 - malezjaa:regression-test-valtree-leaf-const…
JonathanBrouwer Sep 14, 2026
3f49d5f
Rollup merge of #162723 - lsunsi:issue162393, r=chenyukang
JonathanBrouwer Sep 14, 2026
3521d56
Rollup merge of #162735 - maxdexh:boundless-fun, r=jhpratt
JonathanBrouwer Sep 14, 2026
3b068cd
Rollup merge of #162736 - sjwang05:162032-followup, r=lcnr
JonathanBrouwer Sep 14, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions compiler/rustc_abi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ use rustc_data_structures::stable_hash::StableOrd;
#[cfg(feature = "nightly")]
use rustc_error_messages::{DiagArgValue, IntoDiagArg};
#[cfg(feature = "nightly")]
use rustc_errors::{Diag, DiagCtxtHandle, Diagnostic, EmissionGuarantee, Level, msg};
use rustc_errors::{Diag, DiagCtxtHandle, Diagnostic, Level, msg};
use rustc_hashes::Hash64;
use rustc_index::{Idx, IndexSlice, IndexVec};
#[cfg(feature = "nightly")]
Expand Down Expand Up @@ -399,7 +399,7 @@ pub enum TargetDataLayoutError<'a> {
}

#[cfg(feature = "nightly")]
impl<G: EmissionGuarantee> Diagnostic<'_, G> for TargetDataLayoutError<'_> {
impl<G> Diagnostic<'_, G> for TargetDataLayoutError<'_> {
fn into_diag(self, dcx: DiagCtxtHandle<'_>, level: Level) -> Diag<'_, G> {
match self {
TargetDataLayoutError::InvalidAddressSpace { addr_space, err, cause } => {
Expand Down
4 changes: 1 addition & 3 deletions compiler/rustc_ast_lowering/src/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -800,9 +800,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
fn lower_variant(&mut self, item_kind: &ItemKind, v: &Variant) -> hir::Variant<'hir> {
if v.ident.name == kw::Underscore && self.tcx.features().unnamed_enum_variants() {
// FIXME(#156628): lower unnamed enum variants to HIR.
self.dcx()
.struct_span_fatal(v.span, "unnamed enum variants are not yet implemented")
.emit()
self.dcx().span_fatal(v.span, "unnamed enum variants are not yet implemented");
}
let hir_id = self.lower_node_id(v.id);
self.lower_attrs(hir_id, &v.attrs, v.span, Target::Variant);
Expand Down
13 changes: 6 additions & 7 deletions compiler/rustc_ast_lowering/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1798,9 +1798,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
if expr::WillCreateDefIdsVisitor.visit_expr(expr).is_break() {
// FIXME(mgca): make this non-fatal once we have a better way to handle
// nested items in invalid `direct_const_arg!()` arguments.
self.dcx().struct_span_fatal(span, msg).emit()
self.dcx().span_fatal(span, msg)
} else {
self.dcx().struct_span_err(span, msg).emit()
self.dcx().span_err(span, msg)
}
}

Expand Down Expand Up @@ -2960,9 +2960,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
let literal = self.lower_lit(literal, span);

let kind = if !matches!(literal.node, LitKind::Int(..)) {
let err =
self.dcx().struct_span_err(expr.span, "negated literal must be an integer");
hir::ConstArgKind::Error(err.emit())
let err = self.dcx().span_err(expr.span, "negated literal must be an integer");
hir::ConstArgKind::Error(err)
} else {
hir::ConstArgKind::Literal { lit: literal.node, negated: true }
};
Expand Down Expand Up @@ -3366,9 +3365,9 @@ impl UnrepresentableConstArgError {
// FIXME(mgca): make this non-fatal once we have a better way to handle
// nested items in const args
// Issue: https://github.com/rust-lang/rust/issues/154539
lowering_context.dcx().struct_span_fatal(self.span, msg).emit()
lowering_context.dcx().span_fatal(self.span, msg)
} else {
lowering_context.dcx().struct_span_err(self.span, msg).emit()
lowering_context.dcx().span_err(self.span, msg)
};

ConstArg {
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_ast_passes/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use rustc_abi::ExternAbi;
use rustc_errors::codes::*;
use rustc_errors::{Applicability, Diag, EmissionGuarantee, Subdiagnostic};
use rustc_errors::{Applicability, Diag, Subdiagnostic};
use rustc_macros::{Diagnostic, Subdiagnostic};
use rustc_span::{Ident, Span, Symbol};

Expand Down Expand Up @@ -663,7 +663,7 @@ pub(crate) struct EmptyLabelManySpans(pub Vec<Span>);

// The derive for `Vec<Span>` does multiple calls to `span_label`, adding commas between each
impl Subdiagnostic for EmptyLabelManySpans {
fn add_to_diag<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
fn add_to_diag<G>(self, diag: &mut Diag<'_, G>) {
diag.span_labels(self.0, "");
}
}
Expand Down
18 changes: 5 additions & 13 deletions compiler/rustc_attr_parsing/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ use std::num::IntErrorKind;
use rustc_attr_ir::{AttrPath, MirDialect, MirPhase};
use rustc_errors::codes::*;
use rustc_errors::{
Applicability, Diag, DiagArgValue, DiagCtxtHandle, Diagnostic, E0264, EmissionGuarantee, Level,
MultiSpan,
Applicability, Diag, DiagArgValue, DiagCtxtHandle, Diagnostic, E0264, Level, MultiSpan,
};
use rustc_macros::{Diagnostic, Subdiagnostic};
use rustc_span::{Ident, Span, Symbol};
Expand Down Expand Up @@ -1482,9 +1481,7 @@ impl<'a> AttributeParseError<'a> {
diag: &mut Diag<'_, G>,
possibilities: &[Symbol],
strings: bool,
) where
G: EmissionGuarantee,
{
) {
let quote = if strings { '"' } else { '`' };
match possibilities {
&[] => {}
Expand Down Expand Up @@ -1517,9 +1514,7 @@ impl<'a> AttributeParseError<'a> {
diag: &mut Diag<'_, G>,
possibilities: &[Symbol],
strings: bool,
) where
G: EmissionGuarantee,
{
) {
let description = self.description();

let quote = if strings { '"' } else { '`' };
Expand Down Expand Up @@ -1548,10 +1543,7 @@ impl<'a> AttributeParseError<'a> {
}
}

fn render_suggestions<G>(&self, diag: &mut Diag<'_, G>)
where
G: EmissionGuarantee,
{
fn render_suggestions<G>(&self, diag: &mut Diag<'_, G>) {
let description = self.description();

match &self.suggestions {
Expand Down Expand Up @@ -1600,7 +1592,7 @@ impl AttributeParseErrorSuggestions {
}
}

impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for AttributeParseError<'_> {
impl<'a, G> Diagnostic<'a, G> for AttributeParseError<'_> {
fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, G> {
let name = self.path.to_string();

Expand Down
10 changes: 5 additions & 5 deletions compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use std::assert_matches;

use rustc_errors::{Applicability, Diag, EmissionGuarantee};
use rustc_errors::{Applicability, Diag};
use rustc_hir as hir;
use rustc_hir::intravisit::Visitor;
use rustc_infer::infer::NllRegionVariableOrigin;
Expand Down Expand Up @@ -55,7 +55,7 @@ impl<'tcx> BorrowExplanation<'tcx> {
pub(crate) fn is_explained(&self) -> bool {
!matches!(self, BorrowExplanation::Unexplained)
}
pub(crate) fn add_explanation_to_diagnostic<G: EmissionGuarantee>(
pub(crate) fn add_explanation_to_diagnostic<G>(
&self,
cx: &MirBorrowckCtxt<'_, '_, 'tcx>,
err: &mut Diag<'_, G>,
Expand Down Expand Up @@ -437,7 +437,7 @@ impl<'tcx> BorrowExplanation<'tcx> {
}
}

fn add_object_lifetime_default_note<G: EmissionGuarantee>(
fn add_object_lifetime_default_note<G>(
&self,
tcx: TyCtxt<'tcx>,
err: &mut Diag<'_, G>,
Expand Down Expand Up @@ -494,7 +494,7 @@ impl<'tcx> BorrowExplanation<'tcx> {
}
}

fn add_lifetime_bound_suggestion_to_diagnostic<G: EmissionGuarantee>(
fn add_lifetime_bound_suggestion_to_diagnostic<G>(
&self,
err: &mut Diag<'_, G>,
category: &ConstraintCategory<'tcx>,
Expand Down Expand Up @@ -523,7 +523,7 @@ impl<'tcx> BorrowExplanation<'tcx> {
}
}

fn suggest_rewrite_if_let<G: EmissionGuarantee>(
fn suggest_rewrite_if_let<G>(
tcx: TyCtxt<'_>,
expr: &hir::Expr<'_>,
pat: &str,
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_borrowck/src/diagnostics/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::collections::BTreeMap;
use rustc_abi::{FieldIdx, VariantIdx};
use rustc_data_structures::fx::FxIndexMap;
use rustc_errors::formatting::DiagMessageAddArg;
use rustc_errors::{Applicability, Diag, DiagMessage, EmissionGuarantee, MultiSpan, listify, msg};
use rustc_errors::{Applicability, Diag, DiagMessage, MultiSpan, listify, msg};
use rustc_hir::attrs::lang_items::LangItem;
use rustc_hir::def::{CtorKind, Namespace};
use rustc_hir::{
Expand Down Expand Up @@ -669,7 +669,7 @@ impl<'tcx> MirBorrowckCtxt<'_, '_, 'tcx> {
///
/// This is very similar to `fn suggest_static_lifetime_for_gat_from_hrtb` which handles this
/// note for failed type tests instead of outlives errors.
fn add_placeholder_from_predicate_note<G: EmissionGuarantee>(
fn add_placeholder_from_predicate_note<G>(
&self,
diag: &mut Diag<'_, G>,
path: &[OutlivesConstraint<'tcx>],
Expand Down Expand Up @@ -731,7 +731,7 @@ impl<'tcx> MirBorrowckCtxt<'_, '_, 'tcx> {

/// Add a label to region errors and borrow explanations when outlives constraints arise from
/// proving a type implements `Sized` or `Copy`.
fn add_sized_or_copy_bound_info<G: EmissionGuarantee>(
fn add_sized_or_copy_bound_info<G>(
&self,
err: &mut Diag<'_, G>,
blamed_category: ConstraintCategory<'tcx>,
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_borrowck/src/diagnostics/region_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::fmt::{self, Display};
use std::iter;

use rustc_data_structures::fx::IndexEntry;
use rustc_errors::{Diag, EmissionGuarantee};
use rustc_errors::Diag;
use rustc_hir as hir;
use rustc_hir::def::{DefKind, Res};
use rustc_middle::ty::print::RegionHighlightMode;
Expand Down Expand Up @@ -105,7 +105,7 @@ impl RegionName {
}
}

pub(crate) fn highlight_region_name<G: EmissionGuarantee>(&self, diag: &mut Diag<'_, G>) {
pub(crate) fn highlight_region_name<G>(&self, diag: &mut Diag<'_, G>) {
match &self.source {
RegionNameSource::NamedLateParamRegion(span)
| RegionNameSource::NamedEarlyParamRegion(span) => {
Expand Down
9 changes: 4 additions & 5 deletions compiler/rustc_builtin_macros/src/diagnostics.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use rustc_errors::codes::*;
use rustc_errors::formatting::DiagMessageAddArg;
use rustc_errors::{
Diag, DiagCtxtHandle, Diagnostic, EmissionGuarantee, Level, MultiSpan, SingleLabelManySpans,
Subdiagnostic, msg,
Diag, DiagCtxtHandle, Diagnostic, Level, MultiSpan, SingleLabelManySpans, Subdiagnostic, msg,
};
use rustc_macros::{Diagnostic, Subdiagnostic};
use rustc_span::{Ident, Span, Symbol};
Expand Down Expand Up @@ -543,7 +542,7 @@ pub(crate) struct EnvNotDefinedWithUserMessage {
}

// Hand-written implementation to support custom user messages.
impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for EnvNotDefinedWithUserMessage {
impl<'a, G> Diagnostic<'a, G> for EnvNotDefinedWithUserMessage {
#[track_caller]
fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, G> {
let mut diag = Diag::new(dcx, level, self.msg_from_user.to_string());
Expand Down Expand Up @@ -774,7 +773,7 @@ pub(crate) struct FormatUnusedArg {
// Allow the singular form to be a subdiagnostic of the multiple-unused
// form of diagnostic.
impl Subdiagnostic for FormatUnusedArg {
fn add_to_diag<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
fn add_to_diag<G>(self, diag: &mut Diag<'_, G>) {
diag.span_label(
self.span,
msg!(
Expand Down Expand Up @@ -958,7 +957,7 @@ pub(crate) struct AsmClobberNoReg {
pub(crate) clobbers: Vec<Span>,
}

impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for AsmClobberNoReg {
impl<'a, G> Diagnostic<'a, G> for AsmClobberNoReg {
fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, G> {
Diag::new(
dcx,
Expand Down
19 changes: 12 additions & 7 deletions compiler/rustc_builtin_macros/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

use std::{assert_matches, iter};

use rustc_ast::{self as ast, GenericParamKind, attr, join_path_idents};
use rustc_ast::{self as ast, GenericParamKind, Mutability, Safety, attr, join_path_idents};
use rustc_ast_pretty::pprust;
use rustc_attr_ir::{Attribute, AttributeKind};
use rustc_attr_parsing::AttributeParser;
Expand Down Expand Up @@ -274,16 +274,21 @@ pub(crate) fn expand_test_or_bench(
// #[doc(hidden)]
cx.attr_nested_word(sym::doc, sym::hidden, attr_sp),
],
// const $ident: test::TestDescAndFn =
ast::ItemKind::Const(
ast::ConstItem {
defaultness: ast::Defaultness::Implicit,
// static $ident: test::TestDescAndFn =
// We use a static because these things only exist to have references taken
// to them for the test case array. No reason to introduce tons of promoteds for that.
// Promoteds have the advantage that they can be merged to save space, but every one
// of these points to a different function so that will not happen.
ast::ItemKind::Static(
ast::StaticItem {
ident: Ident::new(fn_.ident.name, sp),
generics: ast::Generics::default(),
ty: cx.ty(sp, ast::TyKind::Path(None, test_path("TestDescAndFn"))),
safety: Safety::Default,
mutability: Mutability::Not,
define_opaque: None,
eii_impl: None,
// test::TestDescAndFn {
body: Some(
expr: Some(
cx.expr_struct(
sp,
test_path("TestDescAndFn"),
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_builtin_macros/src/test_harness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ fn generate_test_harness(
/// #[rustc_main]
/// pub fn main() {
/// extern crate test;
/// test::test_main_static(&[
/// test::test_main_env_args(&[
/// &test_const1,
/// &test_const2,
/// &test_const3,
Expand All @@ -286,16 +286,16 @@ fn generate_test_harness(
///
/// [`TestCtxt::reexport_test_harness_main`] provides a different name for the `main`
/// function and [`TestCtxt::test_runner`] provides a path that replaces
/// `test::test_main_static`.
/// `test::test_main_env_args`.
fn mk_main(cx: &mut TestCtxt<'_>) -> Box<ast::Item> {
let sp = cx.def_site;
let ecx = &cx.ext_cx;
let test_ident = Ident::new(sym::test, sp);

let runner_name =
if cx.panic_strategy.unwinds() { "test_main_static" } else { "test_main_static_abort" };
if cx.panic_strategy.unwinds() { "test_main_env_args" } else { "test_main_env_args_abort" };

// test::test_main_static(...)
// test::test_main_env_args(...)
let mut test_runner = cx.test_runner.clone().unwrap_or_else(|| {
ecx.path(sp, vec![test_ident, Ident::from_str_and_span(runner_name, sp)])
});
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_codegen_llvm/src/back/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
pub(crate) mod archive;
pub(crate) mod lto;
pub(crate) mod owned_mc_subtarget_info;
pub(crate) mod owned_target_machine;
mod profiling;
pub(crate) mod write;
49 changes: 49 additions & 0 deletions compiler/rustc_codegen_llvm/src/back/owned_mc_subtarget_info.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
use std::ffi::CStr;
use std::ptr::NonNull;

use rustc_data_structures::small_c_str::SmallCStr;

use crate::diagnostics::LlvmError;
use crate::llvm;

/// Responsible for safely creating and disposing llvm::MCSubtargetInfo via ffi functions.
/// Not cloneable as there is no clone function for llvm::MCSubtargetInfo.
pub(crate) struct OwnedMCSubtargetInfo {
info_unique: NonNull<llvm::MCSubtargetInfo>,
}

impl OwnedMCSubtargetInfo {
pub(crate) fn new(
triple: &CStr,
cpu: &CStr,
features: &CStr,
) -> Result<Self, LlvmError<'static>> {
// SAFETY: llvm::LLVMRustCreateMCSubtargetInfo copies pointed-to data.
let info_ptr = unsafe {
llvm::LLVMRustCreateMCSubtargetInfo(triple.as_ptr(), cpu.as_ptr(), features.as_ptr())
};

NonNull::new(info_ptr)
.map(|info_unique| Self { info_unique })
.ok_or_else(|| LlvmError::CreateMCSubtargetInfo { triple: SmallCStr::from(triple) })
}

pub(crate) fn has_feature(&self, feature: &CStr) -> bool {
// SAFETY: `new` ensures we have a valid pointer created by
// `llvm::LLVMRustCreateMCSubtargetInfo`.
unsafe {
llvm::LLVMRustMCSubtargetInfoHasFeature(self.info_unique.as_ref(), feature.as_ptr())
}
}
}

impl Drop for OwnedMCSubtargetInfo {
fn drop(&mut self) {
// SAFETY: `new` ensures we have a valid pointer created by
// `llvm::LLVMRustCreateMCSubtargetInfo` and `OwnedMCSubtargetInfo` is not copyable so
// there is no double free or use after free.
unsafe {
llvm::LLVMRustDisposeMCSubtargetInfo(self.info_unique);
}
}
}
Loading
Loading