Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f433fa4

Browse files
committed
Auto merge of #139845 - Zalathar:rollup-u5u5y1v, r=Zalathar
Rollup of 17 pull requests Successful merges: - #138374 (Enable contracts for const functions) - #138380 (ci: add runners for vanilla LLVM 20) - #138393 (Allow const patterns of matches to contain pattern types) - #139517 (std: sys: process: uefi: Use NULL stdin by default) - #139554 (std: add Output::exit_ok) - #139660 (compiletest: Add an experimental new executor to replace libtest) - #139669 (Overhaul `AssocItem`) - #139671 (Proc macro span API redesign: Replace proc_macro::SourceFile by Span::{file, local_file}) - #139750 (std/thread: Use default stack size from menuconfig for NuttX) - #139772 (Remove `hir::Map`) - #139785 (Let CStrings be either 1 or 2 byte aligned.) - #139789 (do not unnecessarily leak auto traits in item bounds) - #139791 (drop global where-bounds before merging candidates) - #139798 (normalize: prefer `ParamEnv` over `AliasBound` candidates) - #139822 (Fix: Map EOPNOTSUPP to ErrorKind::Unsupported on Unix) - #139833 (Fix some HIR pretty-printing problems) - #139836 (Basic tests of MPMC receiver cloning) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 58c2dd9 + 783b081 commit f433fa4

File tree

173 files changed

+2498
-993
lines changed

Some content is hidden

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

173 files changed

+2498
-993
lines changed

‎compiler/rustc_ast_lowering/src/delegation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
8585
.delegation_fn_sigs
8686
.get(&local_def_id)
8787
.is_some_and(|sig| sig.has_self),
88-
None => self.tcx.associated_item(def_id).fn_has_self_parameter,
88+
None => self.tcx.associated_item(def_id).is_method(),
8989
},
9090
_ => span_bug!(span, "unexpected DefKind for delegation item"),
9191
}

‎compiler/rustc_ast_lowering/src/expr.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -399,12 +399,16 @@ impl<'hir> LoweringContext<'_, 'hir> {
399399
&mut self,
400400
expr: &'hir hir::Expr<'hir>,
401401
span: Span,
402-
check_ident: Ident,
403-
check_hir_id: HirId,
402+
cond_ident: Ident,
403+
cond_hir_id: HirId,
404404
) -> &'hir hir::Expr<'hir> {
405-
let checker_fn = self.expr_ident(span, check_ident, check_hir_id);
406-
let span = self.mark_span_with_reason(DesugaringKind::Contract, span, None);
407-
self.expr_call(span, checker_fn, std::slice::from_ref(expr))
405+
let cond_fn = self.expr_ident(span, cond_ident, cond_hir_id);
406+
let call_expr = self.expr_call_lang_item_fn_mut(
407+
span,
408+
hir::LangItem::ContractCheckEnsures,
409+
arena_vec![self; *cond_fn, *expr],
410+
);
411+
self.arena.alloc(call_expr)
408412
}
409413

410414
pub(crate) fn lower_const_block(&mut self, c: &AnonConst) -> hir::ConstBlock {

‎compiler/rustc_ast_lowering/src/item.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1206,8 +1206,13 @@ impl<'hir> LoweringContext<'_, 'hir> {
12061206
let precond = if let Some(req) = &contract.requires {
12071207
// Lower the precondition check intrinsic.
12081208
let lowered_req = this.lower_expr_mut(&req);
1209+
let req_span = this.mark_span_with_reason(
1210+
DesugaringKind::Contract,
1211+
lowered_req.span,
1212+
None,
1213+
);
12091214
let precond = this.expr_call_lang_item_fn_mut(
1210-
req.span,
1215+
req_span,
12111216
hir::LangItem::ContractCheckRequires,
12121217
&*arena_vec![this; lowered_req],
12131218
);
@@ -1217,6 +1222,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
12171222
};
12181223
let (postcond, body) = if let Some(ens) = &contract.ensures {
12191224
let ens_span = this.lower_span(ens.span);
1225+
let ens_span =
1226+
this.mark_span_with_reason(DesugaringKind::Contract, ens_span, None);
12201227
// Set up the postcondition `let` statement.
12211228
let check_ident: Ident =
12221229
Ident::from_str_and_span("__ensures_checker", ens_span);

‎compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
647647
&& tc.polarity() == ty::PredicatePolarity::Positive
648648
&& supertrait_def_ids(tcx, tc.def_id())
649649
.flat_map(|trait_did| tcx.associated_items(trait_did).in_definition_order())
650-
.any(|item| item.fn_has_self_parameter)
650+
.any(|item| item.is_method())
651651
})
652652
}) {
653653
return None;

‎compiler/rustc_borrowck/src/type_check/mod.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1557,11 +1557,15 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
15571557
}
15581558
}
15591559
CastKind::Transmute => {
1560-
span_mirbug!(
1561-
self,
1562-
rvalue,
1563-
"Unexpected CastKind::Transmute, which is not permitted in Analysis MIR",
1564-
);
1560+
let ty_from = op.ty(self.body, tcx);
1561+
match ty_from.kind() {
1562+
ty::Pat(base, _) if base == ty => {}
1563+
_ => span_mirbug!(
1564+
self,
1565+
rvalue,
1566+
"Unexpected CastKind::Transmute {ty_from:?} -> {ty:?}, which is not permitted in Analysis MIR",
1567+
),
1568+
}
15651569
}
15661570
}
15671571
}

‎compiler/rustc_codegen_cranelift/src/main_shim.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use cranelift_frontend::{FunctionBuilder, FunctionBuilderContext};
22
use rustc_hir::LangItem;
3-
use rustc_middle::ty::{AssocKind, GenericArg};
3+
use rustc_middle::ty::{AssocTag, GenericArg};
44
use rustc_session::config::EntryFnType;
55
use rustc_span::{DUMMY_SP, Ident};
66

@@ -107,7 +107,7 @@ pub(crate) fn maybe_create_entry_wrapper(
107107
.find_by_ident_and_kind(
108108
tcx,
109109
Ident::from_str("report"),
110-
AssocKind::Fn,
110+
AssocTag::Fn,
111111
termination_trait,
112112
)
113113
.unwrap();

‎compiler/rustc_expand/src/proc_macro_server.rs

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use std::ops::{Bound, Range};
2-
use std::sync::Arc;
32

43
use ast::token::IdentIsRaw;
54
use pm::bridge::{
@@ -18,7 +17,7 @@ use rustc_parse::parser::Parser;
1817
use rustc_parse::{exp, new_parser_from_source_str, source_str_to_stream, unwrap_or_emit_fatal};
1918
use rustc_session::parse::ParseSess;
2019
use rustc_span::def_id::CrateNum;
21-
use rustc_span::{BytePos, FileName, Pos, SourceFile,Span, Symbol, sym};
20+
use rustc_span::{BytePos, FileName, Pos, Span, Symbol, sym};
2221
use smallvec::{SmallVec, smallvec};
2322

2423
use crate::base::ExtCtxt;
@@ -458,7 +457,6 @@ impl<'a, 'b> Rustc<'a, 'b> {
458457
impl server::Types for Rustc<'_, '_> {
459458
type FreeFunctions = FreeFunctions;
460459
type TokenStream = TokenStream;
461-
type SourceFile = Arc<SourceFile>;
462460
type Span = Span;
463461
type Symbol = Symbol;
464462
}
@@ -664,28 +662,6 @@ impl server::TokenStream for Rustc<'_, '_> {
664662
}
665663
}
666664

667-
impl server::SourceFile for Rustc<'_, '_> {
668-
fn eq(&mut self, file1: &Self::SourceFile, file2: &Self::SourceFile) -> bool {
669-
Arc::ptr_eq(file1, file2)
670-
}
671-
672-
fn path(&mut self, file: &Self::SourceFile) -> String {
673-
match &file.name {
674-
FileName::Real(name) => name
675-
.local_path()
676-
.expect("attempting to get a file path in an imported file in `proc_macro::SourceFile::path`")
677-
.to_str()
678-
.expect("non-UTF8 file path in `proc_macro::SourceFile::path`")
679-
.to_string(),
680-
_ => file.name.prefer_local().to_string(),
681-
}
682-
}
683-
684-
fn is_real(&mut self, file: &Self::SourceFile) -> bool {
685-
file.is_real_file()
686-
}
687-
}
688-
689665
impl server::Span for Rustc<'_, '_> {
690666
fn debug(&mut self, span: Self::Span) -> String {
691667
if self.ecx.ecfg.span_debug {
@@ -695,8 +671,29 @@ impl server::Span for Rustc<'_, '_> {
695671
}
696672
}
697673

698-
fn source_file(&mut self, span: Self::Span) -> Self::SourceFile {
699-
self.psess().source_map().lookup_char_pos(span.lo()).file
674+
fn file(&mut self, span: Self::Span) -> String {
675+
self.psess()
676+
.source_map()
677+
.lookup_char_pos(span.lo())
678+
.file
679+
.name
680+
.prefer_remapped_unconditionaly()
681+
.to_string()
682+
}
683+
684+
fn local_file(&mut self, span: Self::Span) -> Option<String> {
685+
self.psess()
686+
.source_map()
687+
.lookup_char_pos(span.lo())
688+
.file
689+
.name
690+
.clone()
691+
.into_local_path()
692+
.map(|p| {
693+
p.to_str()
694+
.expect("non-UTF8 file path in `proc_macro::SourceFile::path`")
695+
.to_string()
696+
})
700697
}
701698

702699
fn parent(&mut self, span: Self::Span) -> Option<Self::Span> {

‎compiler/rustc_fluent_macro/src/fluent.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ fn invocation_relative_path_to_absolute(span: Span, path: &str) -> PathBuf {
2525
path.to_path_buf()
2626
} else {
2727
// `/a/b/c/foo/bar.rs` contains the current macro invocation
28+
#[cfg(bootstrap)]
2829
let mut source_file_path = span.source_file().path();
30+
#[cfg(not(bootstrap))]
31+
let mut source_file_path = span.local_file().unwrap();
2932
// `/a/b/c/foo/`
3033
source_file_path.pop();
3134
// `/a/b/c/foo/../locales/en-US/example.ftl`

‎compiler/rustc_hir/src/intravisit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
//! 1. **Shallow visit**: Get a simple callback for every item (or item-like thing) in the HIR.
77
//! - Example: find all items with a `#[foo]` attribute on them.
88
//! - How: Use the `hir_crate_items` or `hir_module_items` query to traverse over item-like ids
9-
//! (ItemId, TraitItemId, etc.) and use tcx.def_kind and `tcx.hir().item*(id)` to filter and
9+
//! (ItemId, TraitItemId, etc.) and use tcx.def_kind and `tcx.hir_item*(id)` to filter and
1010
//! access actual item-like thing, respectively.
1111
//! - Pro: Efficient; just walks the lists of item ids and gives users control whether to access
1212
//! the hir_owners themselves or not.

‎compiler/rustc_hir/src/lang_items.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,8 @@ language_item_table! {
442442
DefaultTrait3, sym::default_trait3, default_trait3_trait, Target::Trait, GenericRequirement::None;
443443
DefaultTrait2, sym::default_trait2, default_trait2_trait, Target::Trait, GenericRequirement::None;
444444
DefaultTrait1, sym::default_trait1, default_trait1_trait, Target::Trait, GenericRequirement::None;
445+
446+
ContractCheckEnsures, sym::contract_check_ensures, contract_check_ensures_fn, Target::Fn, GenericRequirement::None;
445447
}
446448

447449
/// The requirement imposed on the generics of a lang item

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /