Skip to content

Rollup of 17 pull requests #139845

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 53 commits into from
Apr 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
b9754f9
Enable contracts for const functions
celinval Feb 25, 2025
3feac59
Fix unreachable expression warning
celinval Apr 8, 2025
13f1c84
Apply suggestions from code review
celinval Apr 10, 2025
6788ce7
Remove proc_macro::SourceFile::is_real().
m-ou-se Apr 11, 2025
3962069
Replace proc_macro::SourceFile by Span::{file, local_file}.
m-ou-se Apr 11, 2025
5113f5e
Update rust-analyzer for new proc_macro span api.
m-ou-se Apr 11, 2025
15a93c5
std/thread: Use default stack size from menuconfig for NuttX
no1wudi Apr 13, 2025
a404015
std: sys: process: uefi: Use NULL stdin by default
Ayush1325 Apr 8, 2025
af25995
std: sys: stdio: uefi: Tread UNSUPPORTED Status as read(0)
Ayush1325 Apr 13, 2025
d994fef
std: sys: process: uefi: Allow specifying Stdin
Ayush1325 Apr 10, 2025
75558b2
Remove unused `StaticLifetimeVisitor`.
nnethercote Apr 1, 2025
7c5f226
Remove unused `Map` field from `TraitObjectVisitor`.
nnethercote Apr 1, 2025
1a3dee4
Remove `rustc_middle::hir::Map`.
nnethercote Apr 1, 2025
9734e44
Documentation fixes.
nnethercote Apr 2, 2025
abce592
Use `Symbol` in `LateContext::get_associated_type`.
nnethercote Apr 11, 2025
ce2aa97
Move `has_self` field to `hir::AssocKind::Fn`.
nnethercote Apr 10, 2025
1ac3d6b
Let CStrings be either 1 or 2 byte aligned.
fneddy Apr 14, 2025
2c2c9df
drop global where-bounds before merging candidates
lcnr Apr 14, 2025
ce9d867
do not leak auto traits in item bounds
lcnr Apr 14, 2025
2e79f7c
move tests
lcnr Apr 14, 2025
836ea25
add RPITIT tests: method compat auto trait leakage
lcnr Apr 14, 2025
9c88eb6
normalize: prefer ParamEnv over AliasBound
lcnr Apr 14, 2025
7ad1697
Allow const patterns of matches to contain pattern types
oli-obk Jan 24, 2025
1f3199c
Disable some r-a tests in bootstrap.
m-ou-se Apr 14, 2025
188d44d
Fix: Map EOPNOTSUPP to ErrorKind::Unsupported on Unix
0x79de Apr 14, 2025
b26f3d4
Move `opt_rpitit_info` field to `hir::AssocKind::Type`.
nnethercote Apr 11, 2025
89e93a5
Move two methods from `AssocKind` to `AssocItem`.
nnethercote Apr 14, 2025
78599d8
Move `name` field from `AssocItem` to `AssocKind` variants.
nnethercote Apr 14, 2025
c2712bc
ci: add runners for vanilla LLVM 20
cuviper Mar 12, 2025
9676d4a
std: add Output::exit_ok
lolbinarycat Apr 8, 2025
f8edc83
Pretty-print `PatKind::Missing` as `_`.
nnethercote Apr 15, 2025
16670e1
Fix HIR pretty-printing of fns with just a variadic arg.
nnethercote Apr 15, 2025
1376810
Basic tests of MPMC receiver cloning
glyn Apr 15, 2025
4c23295
Use a constant for unstable features needed by compiletest
Zalathar Apr 3, 2025
6fda3e5
compiletest: Extract libtest-specific executor code to a submodule
Zalathar Apr 11, 2025
e3d6813
compiletest: Add an experimental new executor to replace libtest
Zalathar Apr 6, 2025
380ad1b
Rollup merge of #138374 - celinval:issue-136925-const-contract, r=com…
Zalathar Apr 15, 2025
b8413ab
Rollup merge of #138380 - cuviper:ci-llvm-20, r=Kobzol
Zalathar Apr 15, 2025
aa9a80c
Rollup merge of #138393 - oli-obk:pattern-type-in-pattern, r=BoxyUwU
Zalathar Apr 15, 2025
46b197a
Rollup merge of #139517 - Ayush1325:uefi-cmd-stdin-null, r=joboet
Zalathar Apr 15, 2025
6a9d27d
Rollup merge of #139554 - lolbinarycat:std-output-exit_ok, r=tgross35
Zalathar Apr 15, 2025
efcf4f9
Rollup merge of #139660 - Zalathar:new-executor, r=jieyouxu
Zalathar Apr 15, 2025
13cd525
Rollup merge of #139669 - nnethercote:overhaul-AssocItem, r=oli-obk
Zalathar Apr 15, 2025
bc4e7ad
Rollup merge of #139671 - m-ou-se:proc-macro-span, r=dtolnay
Zalathar Apr 15, 2025
36df548
Rollup merge of #139750 - no1wudi:fix, r=tgross35
Zalathar Apr 15, 2025
9d6c95d
Rollup merge of #139772 - nnethercote:rm-hir-Map, r=Zalathar
Zalathar Apr 15, 2025
5a9455f
Rollup merge of #139785 - fneddy:fix_test_cstring_merging_alignment, …
Zalathar Apr 15, 2025
8118fca
Rollup merge of #139789 - lcnr:opaques-auto-trait-leakage, r=compiler…
Zalathar Apr 15, 2025
e8c9dcc
Rollup merge of #139791 - lcnr:ignore-global-where-bounds, r=compiler…
Zalathar Apr 15, 2025
b21c5cd
Rollup merge of #139798 - lcnr:where-bounds-gt-alias-bound, r=compile…
Zalathar Apr 15, 2025
45b644b
Rollup merge of #139822 - 0x79de:fix-eopnotsupp-mapping, r=dtolnay
Zalathar Apr 15, 2025
4d5284a
Rollup merge of #139833 - nnethercote:fix-139633, r=oli-obk
Zalathar Apr 15, 2025
783b081
Rollup merge of #139836 - glyn:test-mpmc-receiver-cloning, r=jhpratt
Zalathar Apr 15, 2025
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
2 changes: 1 addition & 1 deletion compiler/rustc_ast_lowering/src/delegation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
.delegation_fn_sigs
.get(&local_def_id)
.is_some_and(|sig| sig.has_self),
None => self.tcx.associated_item(def_id).fn_has_self_parameter,
None => self.tcx.associated_item(def_id).is_method(),
},
_ => span_bug!(span, "unexpected DefKind for delegation item"),
}
Expand Down
14 changes: 9 additions & 5 deletions compiler/rustc_ast_lowering/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -399,12 +399,16 @@ impl<'hir> LoweringContext<'_, 'hir> {
&mut self,
expr: &'hir hir::Expr<'hir>,
span: Span,
check_ident: Ident,
check_hir_id: HirId,
cond_ident: Ident,
cond_hir_id: HirId,
) -> &'hir hir::Expr<'hir> {
let checker_fn = self.expr_ident(span, check_ident, check_hir_id);
let span = self.mark_span_with_reason(DesugaringKind::Contract, span, None);
self.expr_call(span, checker_fn, std::slice::from_ref(expr))
let cond_fn = self.expr_ident(span, cond_ident, cond_hir_id);
let call_expr = self.expr_call_lang_item_fn_mut(
span,
hir::LangItem::ContractCheckEnsures,
arena_vec![self; *cond_fn, *expr],
);
self.arena.alloc(call_expr)
}

pub(crate) fn lower_const_block(&mut self, c: &AnonConst) -> hir::ConstBlock {
Expand Down
9 changes: 8 additions & 1 deletion compiler/rustc_ast_lowering/src/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1206,8 +1206,13 @@ impl<'hir> LoweringContext<'_, 'hir> {
let precond = if let Some(req) = &contract.requires {
// Lower the precondition check intrinsic.
let lowered_req = this.lower_expr_mut(&req);
let req_span = this.mark_span_with_reason(
DesugaringKind::Contract,
lowered_req.span,
None,
);
let precond = this.expr_call_lang_item_fn_mut(
req.span,
req_span,
hir::LangItem::ContractCheckRequires,
&*arena_vec![this; lowered_req],
);
Expand All @@ -1217,6 +1222,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
};
let (postcond, body) = if let Some(ens) = &contract.ensures {
let ens_span = this.lower_span(ens.span);
let ens_span =
this.mark_span_with_reason(DesugaringKind::Contract, ens_span, None);
// Set up the postcondition `let` statement.
let check_ident: Ident =
Ident::from_str_and_span("__ensures_checker", ens_span);
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
&& tc.polarity() == ty::PredicatePolarity::Positive
&& supertrait_def_ids(tcx, tc.def_id())
.flat_map(|trait_did| tcx.associated_items(trait_did).in_definition_order())
.any(|item| item.fn_has_self_parameter)
.any(|item| item.is_method())
})
}) {
return None;
Expand Down
14 changes: 9 additions & 5 deletions compiler/rustc_borrowck/src/type_check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1557,11 +1557,15 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
}
}
CastKind::Transmute => {
span_mirbug!(
self,
rvalue,
"Unexpected CastKind::Transmute, which is not permitted in Analysis MIR",
);
let ty_from = op.ty(self.body, tcx);
match ty_from.kind() {
ty::Pat(base, _) if base == ty => {}
_ => span_mirbug!(
self,
rvalue,
"Unexpected CastKind::Transmute {ty_from:?} -> {ty:?}, which is not permitted in Analysis MIR",
),
}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_codegen_cranelift/src/main_shim.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use cranelift_frontend::{FunctionBuilder, FunctionBuilderContext};
use rustc_hir::LangItem;
use rustc_middle::ty::{AssocKind, GenericArg};
use rustc_middle::ty::{AssocTag, GenericArg};
use rustc_session::config::EntryFnType;
use rustc_span::{DUMMY_SP, Ident};

Expand Down Expand Up @@ -107,7 +107,7 @@ pub(crate) fn maybe_create_entry_wrapper(
.find_by_ident_and_kind(
tcx,
Ident::from_str("report"),
AssocKind::Fn,
AssocTag::Fn,
termination_trait,
)
.unwrap();
Expand Down
51 changes: 24 additions & 27 deletions compiler/rustc_expand/src/proc_macro_server.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use std::ops::{Bound, Range};
use std::sync::Arc;

use ast::token::IdentIsRaw;
use pm::bridge::{
Expand All @@ -18,7 +17,7 @@ use rustc_parse::parser::Parser;
use rustc_parse::{exp, new_parser_from_source_str, source_str_to_stream, unwrap_or_emit_fatal};
use rustc_session::parse::ParseSess;
use rustc_span::def_id::CrateNum;
use rustc_span::{BytePos, FileName, Pos, SourceFile, Span, Symbol, sym};
use rustc_span::{BytePos, FileName, Pos, Span, Symbol, sym};
use smallvec::{SmallVec, smallvec};

use crate::base::ExtCtxt;
Expand Down Expand Up @@ -458,7 +457,6 @@ impl<'a, 'b> Rustc<'a, 'b> {
impl server::Types for Rustc<'_, '_> {
type FreeFunctions = FreeFunctions;
type TokenStream = TokenStream;
type SourceFile = Arc<SourceFile>;
type Span = Span;
type Symbol = Symbol;
}
Expand Down Expand Up @@ -664,28 +662,6 @@ impl server::TokenStream for Rustc<'_, '_> {
}
}

impl server::SourceFile for Rustc<'_, '_> {
fn eq(&mut self, file1: &Self::SourceFile, file2: &Self::SourceFile) -> bool {
Arc::ptr_eq(file1, file2)
}

fn path(&mut self, file: &Self::SourceFile) -> String {
match &file.name {
FileName::Real(name) => name
.local_path()
.expect("attempting to get a file path in an imported file in `proc_macro::SourceFile::path`")
.to_str()
.expect("non-UTF8 file path in `proc_macro::SourceFile::path`")
.to_string(),
_ => file.name.prefer_local().to_string(),
}
}

fn is_real(&mut self, file: &Self::SourceFile) -> bool {
file.is_real_file()
}
}

impl server::Span for Rustc<'_, '_> {
fn debug(&mut self, span: Self::Span) -> String {
if self.ecx.ecfg.span_debug {
Expand All @@ -695,8 +671,29 @@ impl server::Span for Rustc<'_, '_> {
}
}

fn source_file(&mut self, span: Self::Span) -> Self::SourceFile {
self.psess().source_map().lookup_char_pos(span.lo()).file
fn file(&mut self, span: Self::Span) -> String {
self.psess()
.source_map()
.lookup_char_pos(span.lo())
.file
.name
.prefer_remapped_unconditionaly()
.to_string()
}

fn local_file(&mut self, span: Self::Span) -> Option<String> {
self.psess()
.source_map()
.lookup_char_pos(span.lo())
.file
.name
.clone()
.into_local_path()
.map(|p| {
p.to_str()
.expect("non-UTF8 file path in `proc_macro::SourceFile::path`")
.to_string()
})
}

fn parent(&mut self, span: Self::Span) -> Option<Self::Span> {
Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_fluent_macro/src/fluent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ fn invocation_relative_path_to_absolute(span: Span, path: &str) -> PathBuf {
path.to_path_buf()
} else {
// `/a/b/c/foo/bar.rs` contains the current macro invocation
#[cfg(bootstrap)]
let mut source_file_path = span.source_file().path();
#[cfg(not(bootstrap))]
let mut source_file_path = span.local_file().unwrap();
// `/a/b/c/foo/`
source_file_path.pop();
// `/a/b/c/foo/../locales/en-US/example.ftl`
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir/src/intravisit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//! 1. **Shallow visit**: Get a simple callback for every item (or item-like thing) in the HIR.
//! - Example: find all items with a `#[foo]` attribute on them.
//! - How: Use the `hir_crate_items` or `hir_module_items` query to traverse over item-like ids
//! (ItemId, TraitItemId, etc.) and use tcx.def_kind and `tcx.hir().item*(id)` to filter and
//! (ItemId, TraitItemId, etc.) and use tcx.def_kind and `tcx.hir_item*(id)` to filter and
//! access actual item-like thing, respectively.
//! - Pro: Efficient; just walks the lists of item ids and gives users control whether to access
//! the hir_owners themselves or not.
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_hir/src/lang_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,8 @@ language_item_table! {
DefaultTrait3, sym::default_trait3, default_trait3_trait, Target::Trait, GenericRequirement::None;
DefaultTrait2, sym::default_trait2, default_trait2_trait, Target::Trait, GenericRequirement::None;
DefaultTrait1, sym::default_trait1, default_trait1_trait, Target::Trait, GenericRequirement::None;

ContractCheckEnsures, sym::contract_check_ensures, contract_check_ensures_fn, Target::Fn, GenericRequirement::None;
}

/// The requirement imposed on the generics of a lang item
Expand Down
12 changes: 6 additions & 6 deletions compiler/rustc_hir_analysis/src/check/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -443,13 +443,13 @@ fn best_definition_site_of_opaque<'tcx>(
let impl_def_id = tcx.local_parent(parent);
for assoc in tcx.associated_items(impl_def_id).in_definition_order() {
match assoc.kind {
ty::AssocKind::Const | ty::AssocKind::Fn => {
ty::AssocKind::Const { .. } | ty::AssocKind::Fn { .. } => {
if let ControlFlow::Break(span) = locator.check(assoc.def_id.expect_local())
{
return Some(span);
}
}
ty::AssocKind::Type => {}
ty::AssocKind::Type { .. } => {}
}
}

Expand Down Expand Up @@ -740,7 +740,7 @@ pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) {

for &assoc_item in assoc_items.in_definition_order() {
match assoc_item.kind {
ty::AssocKind::Type if assoc_item.defaultness(tcx).has_value() => {
ty::AssocKind::Type { .. } if assoc_item.defaultness(tcx).has_value() => {
let trait_args = GenericArgs::identity_for_item(tcx, def_id);
let _: Result<_, rustc_errors::ErrorGuaranteed> = check_type_bounds(
tcx,
Expand Down Expand Up @@ -942,7 +942,7 @@ fn check_impl_items_against_trait<'tcx>(

if res.is_ok() {
match ty_impl_item.kind {
ty::AssocKind::Fn => {
ty::AssocKind::Fn { .. } => {
compare_impl_item::refine::check_refining_return_position_impl_trait_in_trait(
tcx,
ty_impl_item,
Expand All @@ -952,8 +952,8 @@ fn check_impl_items_against_trait<'tcx>(
.instantiate_identity(),
);
}
ty::AssocKind::Const => {}
ty::AssocKind::Type => {}
ty::AssocKind::Const { .. } => {}
ty::AssocKind::Type { .. } => {}
}
}

Expand Down
Loading