Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
076064f
Mark method receivers in builtin derives as being from the derive.
Jarcho Nov 26, 2025
69d9576
refactor: move doc(rust_logo) check to parser
mehdiakiki Mar 17, 2026
48987fd
refactor: reuse doc attr helper for rust_logo
mehdiakiki Mar 18, 2026
bf42a53
delete several `ui/consts` tests
cyrgani Mar 30, 2026
e61842d
Update `mir-opt` 64-bit panic-abort tests for `Alignment` rename
jyn514 Mar 30, 2026
d29c489
add self-referential param-env normalization regression
TaKO8Ki Mar 8, 2026
6518de3
Skip suggestions pointing to extern macro def for assert_eq
chenyukang Mar 30, 2026
59fe28d
compiler-builtins: Clean up features
tgross35 Jun 18, 2025
2d87df1
Add a test for a now fixed ICE with `offset_of!()`
jakubadamw Mar 30, 2026
7f00560
Rollup merge of #142659 - tgross35:builtins-features, r=Amanieu
tgross35 Mar 31, 2026
6cf0b6e
Rollup merge of #149350 - Jarcho:derive_recv_ctxt, r=jackh726
tgross35 Mar 31, 2026
bdf3384
Rollup merge of #153574 - TaKO8Ki:self-referential-param-env-normaliz…
tgross35 Mar 31, 2026
15e4952
Rollup merge of #153980 - mehdiakiki:pr-check_attrs-rust_logo, r=jdon…
tgross35 Mar 31, 2026
61c831c
Rollup merge of #154551 - chenyukang:yukang-fix-146204-assert-ne-sugg…
tgross35 Mar 31, 2026
d272d49
Rollup merge of #154574 - cyrgani:less-const-tests, r=Kivooeo
tgross35 Mar 31, 2026
d6e38b6
Rollup merge of #154577 - ferrocene:jyn/bless-mir-opt, r=jieyouxu
tgross35 Mar 31, 2026
74301ac
Rollup merge of #154612 - jakubadamw:issue-125805, r=Kivooeo
tgross35 Mar 31, 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
24 changes: 20 additions & 4 deletions compiler/rustc_attr_parsing/src/attributes/doc.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
use rustc_ast::ast::{AttrStyle, LitKind, MetaItemLit};
use rustc_errors::msg;
use rustc_feature::template;
use rustc_hir::Target;
use rustc_hir::attrs::{
AttributeKind, CfgEntry, CfgHideShow, CfgInfo, DocAttribute, DocInline, HideOrShow,
};
use rustc_hir::lints::AttributeLintKind;
use rustc_session::parse::feature_err;
use rustc_span::{Span, Symbol, edition, sym};
use thin_vec::ThinVec;

Expand Down Expand Up @@ -481,15 +483,19 @@ impl DocParser {
}
macro_rules! no_args_and_crate_level {
($ident: ident) => {{
no_args_and_crate_level!($ident, |span| {});
}};
($ident: ident, |$span:ident| $extra_validation:block) => {{
if let Err(span) = args.no_args() {
expected_no_args(cx, span);
return;
}
let span = path.span();
if !check_attr_crate_level(cx, span) {
let $span = path.span();
if !check_attr_crate_level(cx, $span) {
return;
}
self.attribute.$ident = Some(span);
$extra_validation
self.attribute.$ident = Some($span);
}};
}
macro_rules! string_arg_and_crate_level {
Expand Down Expand Up @@ -553,7 +559,17 @@ impl DocParser {
),
Some(sym::fake_variadic) => no_args_and_not_crate_level!(fake_variadic),
Some(sym::search_unbox) => no_args_and_not_crate_level!(search_unbox),
Some(sym::rust_logo) => no_args_and_crate_level!(rust_logo),
Some(sym::rust_logo) => no_args_and_crate_level!(rust_logo, |span| {
if !cx.features().rustdoc_internals() {
feature_err(
cx.sess(),
sym::rustdoc_internals,
span,
msg!("the `#[doc(rust_logo)]` attribute is used for Rust branding"),
)
.emit();
}
}),
Some(sym::auto_cfg) => self.parse_auto_cfg(cx, path, args),
Some(sym::test) => {
let Some(list) = args.list() else {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_builtin_macros/src/deriving/generic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1052,7 +1052,7 @@ impl<'a> MethodDef<'a> {

let args = {
let self_arg = explicit_self.map(|explicit_self| {
let ident = Ident::with_dummy_span(kw::SelfLower).with_span_pos(span);
let ident = Ident::new(kw::SelfLower, span);
ast::Param::from_self(ast::AttrVec::default(), explicit_self, ident)
});
let nonself_args =
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_expand/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ impl<'a> ExtCtxt<'a> {
self.expr_path(self.path_ident(span, id))
}
pub fn expr_self(&self, span: Span) -> Box<ast::Expr> {
self.expr_ident(span, Ident::with_dummy_span(kw::SelfLower))
self.expr_ident(span, Ident::new(kw::SelfLower, span))
}

pub fn expr_macro_call(&self, span: Span, call: Box<ast::MacCall>) -> Box<ast::Expr> {
Expand Down
15 changes: 2 additions & 13 deletions compiler/rustc_passes/src/check_attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1188,7 +1188,8 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
html_no_source: _,
// already checked in attr_parsing
issue_tracker_base_url: _,
rust_logo,
// already checked in attr_parsing
rust_logo: _,
// allowed anywhere
test_attrs: _,
// already checked in attr_parsing
Expand Down Expand Up @@ -1217,18 +1218,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {

self.check_doc_inline(hir_id, target, inline);

if let Some(span) = rust_logo
&& !self.tcx.features().rustdoc_internals()
{
feature_err(
&self.tcx.sess,
sym::rustdoc_internals,
*span,
msg!("the `#[doc(rust_logo)]` attribute is used for Rust branding"),
)
.emit();
}

if let Some(span) = masked {
self.check_doc_masked(*span, hir_id, target);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -545,8 +545,12 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
.all(|obligation| self.predicate_may_hold(obligation))
}) && steps > 0
{
if span.in_external_macro(self.tcx.sess.source_map()) {
return false;
}
let derefs = "*".repeat(steps);
let msg = "consider dereferencing here";

let call_node = self.tcx.hir_node(*call_hir_id);
let is_receiver = matches!(
call_node,
Expand Down Expand Up @@ -593,7 +597,6 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
})
{
// Suggest dereferencing the LHS, RHS, or both terms of a binop if possible

let trait_pred = predicate.unwrap_or(trait_pred);
let lhs_ty = self.tcx.instantiate_bound_regions_with_erased(trait_pred.self_ty());
let lhs_autoderef = (self.autoderef_steps)(lhs_ty);
Expand Down Expand Up @@ -644,6 +647,9 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
})
{
let make_sugg = |mut expr: &Expr<'_>, mut steps| {
if expr.span.in_external_macro(self.tcx.sess.source_map()) {
return None;
}
let mut prefix_span = expr.span.shrink_to_lo();
let mut msg = "consider dereferencing here";
if let hir::ExprKind::AddrOf(_, _, inner) = expr.kind {
Expand All @@ -661,10 +667,10 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
}
// Empty suggestions with empty spans ICE with debug assertions
if steps == 0 {
return (
return Some((
msg.trim_end_matches(" and dereferencing instead"),
vec![(prefix_span, String::new())],
);
));
}
let derefs = "*".repeat(steps);
let needs_parens = steps > 0 && expr_needs_parens(expr);
Expand All @@ -686,16 +692,21 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
if !prefix_span.is_empty() {
suggestion.push((prefix_span, String::new()));
}
(msg, suggestion)
Some((msg, suggestion))
};

if let Some(lsteps) = lsteps
&& let Some(rsteps) = rsteps
&& lsteps > 0
&& rsteps > 0
{
let mut suggestion = make_sugg(lhs, lsteps).1;
suggestion.append(&mut make_sugg(rhs, rsteps).1);
let Some((_, mut suggestion)) = make_sugg(lhs, lsteps) else {
return false;
};
let Some((_, mut rhs_suggestion)) = make_sugg(rhs, rsteps) else {
return false;
};
suggestion.append(&mut rhs_suggestion);
err.multipart_suggestion(
"consider dereferencing both sides of the expression",
suggestion,
Expand All @@ -705,13 +716,17 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
} else if let Some(lsteps) = lsteps
&& lsteps > 0
{
let (msg, suggestion) = make_sugg(lhs, lsteps);
let Some((msg, suggestion)) = make_sugg(lhs, lsteps) else {
return false;
};
err.multipart_suggestion(msg, suggestion, Applicability::MachineApplicable);
return true;
} else if let Some(rsteps) = rsteps
&& rsteps > 0
{
let (msg, suggestion) = make_sugg(rhs, rsteps);
let Some((msg, suggestion)) = make_sugg(rhs, rsteps) else {
return false;
};
err.multipart_suggestion(msg, suggestion, Applicability::MachineApplicable);
return true;
}
Expand Down Expand Up @@ -4824,6 +4839,9 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
candidate_impls: &[ImplCandidate<'tcx>],
span: Span,
) {
if span.in_external_macro(self.tcx.sess.source_map()) {
return;
}
// We can only suggest the slice coercion for function and binary operation arguments,
// since the suggestion would make no sense in turbofish or call
let (ObligationCauseCode::BinOp { .. } | ObligationCauseCode::FunctionArg { .. }) =
Expand Down
19 changes: 7 additions & 12 deletions compiler/rustc_trait_selection/src/traits/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,19 +300,14 @@ fn do_normalize_predicates<'tcx>(
Ok(predicates) => Ok(predicates),
Err(fixup_err) => {
// If we encounter a fixup error, it means that some type
// variable wound up unconstrained. I actually don't know
// if this can happen, and I certainly don't expect it to
// happen often, but if it did happen it probably
// represents a legitimate failure due to some kind of
// unconstrained variable.
//
// @lcnr: Let's still ICE here for now. I want a test case
// for that.
span_bug!(
// variable wound up unconstrained. That can happen for
// ill-formed impls, so we delay a bug here instead of
// immediately ICEing and let type checking report the
// actual user-facing errors.
Err(tcx.dcx().span_delayed_bug(
span,
"inference variables in normalized parameter environment: {}",
fixup_err
);
format!("inference variables in normalized parameter environment: {fixup_err}"),
))
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion library/alloc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ bench = false

[dependencies]
core = { path = "../core", public = true }
compiler_builtins = { path = "../compiler-builtins/compiler-builtins", features = ["rustc-dep-of-std"] }
compiler_builtins = { path = "../compiler-builtins/compiler-builtins", features = ["compiler-builtins"] }

[features]
compiler-builtins-mem = ['compiler_builtins/mem']
Expand Down
8 changes: 3 additions & 5 deletions library/compiler-builtins/builtins-shim/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ test = false
cc = { version = "1.2", optional = true }

[features]
default = ["compiler-builtins"]
default = []

# Enable compilation of C code in compiler-rt, filling in some more optimized
# implementations and also filling in unimplemented intrinsics
Expand All @@ -50,7 +50,8 @@ c = ["dep:cc"]
# the generic versions on all platforms.
no-asm = []

# Flag this library as the unstable compiler-builtins lib
# Flag this library as the unstable compiler-builtins lib. This must be enabled
# when using as `std`'s dependency.'
compiler-builtins = []

# Generate memory-related intrinsics like memcpy
Expand All @@ -60,9 +61,6 @@ mem = []
# compiler-rt implementations. Also used for testing
mangled-names = []

# Only used in the compiler's build system
rustc-dep-of-std = ["compiler-builtins"]

# This makes certain traits and function specializations public that
# are not normally public but are required by the `builtins-test`
unstable-public-internals = []
10 changes: 4 additions & 6 deletions library/compiler-builtins/compiler-builtins/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ core = { path = "../../core", optional = true }
cc = { version = "1.2", optional = true }

[features]
default = ["compiler-builtins"]
default = []

# Enable compilation of C code in compiler-rt, filling in some more optimized
# implementations and also filling in unimplemented intrinsics
Expand All @@ -45,8 +45,9 @@ c = ["dep:cc"]
# the generic versions on all platforms.
no-asm = []

# Flag this library as the unstable compiler-builtins lib
compiler-builtins = []
# Flag this library as the unstable compiler-builtins lib. This must be enabled
# when using as `std`'s dependency.'
compiler-builtins = ["dep:core"]

# Generate memory-related intrinsics like memcpy
mem = []
Expand All @@ -55,9 +56,6 @@ mem = []
# compiler-rt implementations. Also used for testing
mangled-names = []

# Only used in the compiler's build system
rustc-dep-of-std = ["compiler-builtins", "dep:core"]

# This makes certain traits and function specializations public that
# are not normally public but are required by the `builtins-test`
unstable-public-internals = []
16 changes: 0 additions & 16 deletions tests/crashes/120033.rs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
StorageLive(_12);
StorageLive(_13);
- _13 = boxed::box_new_uninit(const <() as std::mem::SizedTypeProperties>::LAYOUT) -> [return: bb2, unwind unreachable];
+ _13 = boxed::box_new_uninit(const Layout {{ size: 0_usize, align: std::mem::Alignment {{ _inner_repr_trick: std::ptr::alignment::AlignmentEnum::_Align1Shl0 }} }}) -> [return: bb2, unwind unreachable];
+ _13 = boxed::box_new_uninit(const Layout {{ size: 0_usize, align: std::mem::Alignment {{ _inner_repr_trick: mem::alignment::AlignmentEnum::_Align1Shl0 }} }}) -> [return: bb2, unwind unreachable];
}

bb1: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@

bb3: {
- _1 = move ((_2 as Some).0: std::alloc::Layout);
+ _1 = const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(8 bytes) }: usize, align: std::mem::Alignment {{ _inner_repr_trick: Scalar(0x0000000000000000): std::ptr::alignment::AlignmentEnum }} }};
+ _1 = const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(8 bytes) }: usize, align: std::mem::Alignment {{ _inner_repr_trick: Scalar(0x0000000000000000): mem::alignment::AlignmentEnum }} }};
StorageDead(_8);
StorageDead(_2);
StorageLive(_3);
Expand All @@ -73,8 +73,8 @@
StorageLive(_7);
- _7 = copy _1;
- _6 = std::alloc::Global::alloc_impl_runtime(move _7, const false) -> [return: bb4, unwind unreachable];
+ _7 = const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(8 bytes) }: usize, align: std::mem::Alignment {{ _inner_repr_trick: Scalar(0x0000000000000000): std::ptr::alignment::AlignmentEnum }} }};
+ _6 = std::alloc::Global::alloc_impl_runtime(const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(8 bytes) }: usize, align: std::mem::Alignment {{ _inner_repr_trick: Scalar(0x0000000000000000): std::ptr::alignment::AlignmentEnum }} }}, const false) -> [return: bb4, unwind unreachable];
+ _7 = const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(8 bytes) }: usize, align: std::mem::Alignment {{ _inner_repr_trick: Scalar(0x0000000000000000): mem::alignment::AlignmentEnum }} }};
+ _6 = std::alloc::Global::alloc_impl_runtime(const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(8 bytes) }: usize, align: std::mem::Alignment {{ _inner_repr_trick: Scalar(0x0000000000000000): mem::alignment::AlignmentEnum }} }}, const false) -> [return: bb4, unwind unreachable];
}

bb4: {
Expand Down
19 changes: 0 additions & 19 deletions tests/ui/consts/const-bound.rs

This file was deleted.

11 changes: 0 additions & 11 deletions tests/ui/consts/const-enum-tuple.rs

This file was deleted.

11 changes: 0 additions & 11 deletions tests/ui/consts/const-enum-tuple2.rs

This file was deleted.

12 changes: 0 additions & 12 deletions tests/ui/consts/const-enum-tuplestruct2.rs

This file was deleted.

Loading
Loading