Skip to content

[beta] [also fit for beta rollup] [HOTFIX] Don't delay a bug on malformed meta items involving interpolated tokens #140601

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

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
f05087f
bump channel
BoxyUwU Mar 31, 2025
2d814ae
replace version placeholder
BoxyUwU Mar 31, 2025
45165c8
Auto merge of #139185 - BoxyUwU:beta, r=BoxyUwU
bors Apr 1, 2025
8e37a0b
bump stage0
BoxyUwU Apr 4, 2025
e6ed56a
Auto merge of #139360 - BoxyUwU:bump_beta_bootstrap, r=kobzol
bors Apr 5, 2025
35dae58
[beta-1.87] Update cargo
weihanglo Apr 7, 2025
a22ecb5
Auto merge of #139463 - weihanglo:update-beta-cargo, r=weihanglo
bors Apr 7, 2025
2f68518
Revert "Remove `prev_index_to_index` field from `CurrentDepGraph`"
Zoxc Apr 10, 2025
a594829
Auto merge of #139625 - Zoxc:revert-pr138824, r=oli-obk
bors Apr 12, 2025
d8fad75
[beta] Delay `hash_extract_if` stabilization from 1.87 to 1.88
dtolnay Apr 13, 2025
84ed87a
Fix 2024 edition doctest panic output
GuillaumeGomez Apr 3, 2025
3d4b571
Add regression test for #137970
GuillaumeGomez Apr 3, 2025
10e682e
Use `eprint!` instead of `eprintln!`
GuillaumeGomez Apr 3, 2025
d1cd5ee
make `Arguments::as_statically_known_str` doc(hidden)
mejrs Apr 4, 2025
4782bbc
Revert "Deduplicate template parameter creation"
petrochenkov Apr 15, 2025
e71ad4a
sync::mpsc: add miri reproducer of double free
petrosagg Apr 10, 2025
f31cf5c
sync::mpsc: prevent double free on `Drop`
petrosagg Apr 8, 2025
386abeb
Auto merge of #139988 - cuviper:beta-next, r=cuviper
bors Apr 19, 2025
67737df
Do not mix normalized and unnormalized caller bounds when constructin…
compiler-errors Mar 25, 2025
39721fa
Ignore zero-sized types in wasm future-compat warning
alexcrichton Apr 7, 2025
eaa7d3a
Don't warn about `v128` in wasm ABI transition
alexcrichton Apr 14, 2025
2aec882
Revert overzealous parse recovery for single colons
fmease Apr 24, 2025
7ef0050
Bless ui/associated-consts/issue-93835
cuviper Apr 24, 2025
74f40c4
Auto merge of #140269 - cuviper:beta-next, r=cuviper
bors Apr 26, 2025
9d6fe3d
Auto merge of #139765 - dtolnay:hashextractif, r=ChrisDenton
bors Apr 28, 2025
3864645
Don't delay a bug on malformed meta items involving interpolated tokens
fmease May 2, 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
15 changes: 6 additions & 9 deletions compiler/rustc_attr_parsing/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use rustc_ast_pretty::pprust;
use rustc_errors::DiagCtxtHandle;
use rustc_hir::{self as hir, AttrPath};
use rustc_span::symbol::{Ident, kw, sym};
use rustc_span::{ErrorGuaranteed, Span, Symbol};
use rustc_span::{Span, Symbol};

pub struct SegmentIterator<'a> {
offset: usize,
Expand Down Expand Up @@ -176,7 +176,7 @@ impl<'a> ArgParser<'a> {
pub enum MetaItemOrLitParser<'a> {
MetaItemParser(MetaItemParser<'a>),
Lit(MetaItemLit),
Err(Span, ErrorGuaranteed),
Err(Span),
}

impl<'a> MetaItemOrLitParser<'a> {
Expand All @@ -186,7 +186,7 @@ impl<'a> MetaItemOrLitParser<'a> {
generic_meta_item_parser.span()
}
MetaItemOrLitParser::Lit(meta_item_lit) => meta_item_lit.span,
MetaItemOrLitParser::Err(span, _) => *span,
MetaItemOrLitParser::Err(span) => *span,
}
}

Expand Down Expand Up @@ -495,12 +495,9 @@ impl<'a> MetaItemListParserContext<'a> {
// where the macro didn't expand to a literal. An error is already given
// for this at this point, and then we do continue. This makes this path
// reachable...
let e = self.dcx.span_delayed_bug(
*span,
"expr in place where literal is expected (builtin attr parsing)",
);

return Some(MetaItemOrLitParser::Err(*span, e));
// NOTE: For backward compatibility we can't emit any error / delayed bug here (yet).
// See <https://github.com/rust-lang/rust/issues/140612>
return Some(MetaItemOrLitParser::Err(*span));
} else {
self.next_path()?
};
Expand Down
36 changes: 13 additions & 23 deletions compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1314,31 +1314,21 @@ fn build_generic_type_param_di_nodes<'ll, 'tcx>(
ty: Ty<'tcx>,
) -> SmallVec<Option<&'ll DIType>> {
if let ty::Adt(def, args) = *ty.kind() {
let generics = cx.tcx.generics_of(def.did());
return get_template_parameters(cx, generics, args);
}

return smallvec![];
}

pub(super) fn get_template_parameters<'ll, 'tcx>(
cx: &CodegenCx<'ll, 'tcx>,
generics: &ty::Generics,
args: ty::GenericArgsRef<'tcx>,
) -> SmallVec<Option<&'ll DIType>> {
if args.types().next().is_some() {
let names = get_parameter_names(cx, generics);
let template_params: SmallVec<_> = iter::zip(args, names)
.filter_map(|(kind, name)| {
kind.as_type().map(|ty| {
let actual_type = cx.tcx.normalize_erasing_regions(cx.typing_env(), ty);
let actual_type_di_node = type_di_node(cx, actual_type);
Some(cx.create_template_type_parameter(name.as_str(), actual_type_di_node))
if args.types().next().is_some() {
let generics = cx.tcx.generics_of(def.did());
let names = get_parameter_names(cx, generics);
let template_params: SmallVec<_> = iter::zip(args, names)
.filter_map(|(kind, name)| {
kind.as_type().map(|ty| {
let actual_type = cx.tcx.normalize_erasing_regions(cx.typing_env(), ty);
let actual_type_di_node = type_di_node(cx, actual_type);
Some(cx.create_template_type_parameter(name.as_str(), actual_type_di_node))
})
})
})
.collect();
.collect();

return template_params;
return template_params;
}
}

return smallvec![];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,6 @@ fn build_coroutine_variant_struct_type_di_node<'ll, 'tcx>(

state_specific_fields.into_iter().chain(common_fields).collect()
},
// FIXME: this is a no-op. `build_generic_type_param_di_nodes` only works for Adts.
|cx| build_generic_type_param_di_nodes(cx, coroutine_type_and_layout.ty),
)
.di_node
Expand Down
34 changes: 32 additions & 2 deletions compiler/rustc_codegen_llvm/src/debuginfo/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

use std::cell::{OnceCell, RefCell};
use std::ops::Range;
use std::ptr;
use std::sync::Arc;
use std::{iter, ptr};

use libc::c_uint;
use metadata::create_subroutine_type;
Expand Down Expand Up @@ -486,10 +486,40 @@ impl<'ll, 'tcx> DebugInfoCodegenMethods<'tcx> for CodegenCx<'ll, 'tcx> {
generics: &ty::Generics,
args: GenericArgsRef<'tcx>,
) -> &'ll DIArray {
let template_params = metadata::get_template_parameters(cx, generics, args);
if args.types().next().is_none() {
return create_DIArray(DIB(cx), &[]);
}

// Again, only create type information if full debuginfo is enabled
let template_params: Vec<_> = if cx.sess().opts.debuginfo == DebugInfo::Full {
let names = get_parameter_names(cx, generics);
iter::zip(args, names)
.filter_map(|(kind, name)| {
kind.as_type().map(|ty| {
let actual_type = cx.tcx.normalize_erasing_regions(cx.typing_env(), ty);
let actual_type_metadata = type_di_node(cx, actual_type);
Some(cx.create_template_type_parameter(
name.as_str(),
actual_type_metadata,
))
})
})
.collect()
} else {
vec![]
};

create_DIArray(DIB(cx), &template_params)
}

fn get_parameter_names(cx: &CodegenCx<'_, '_>, generics: &ty::Generics) -> Vec<Symbol> {
let mut names = generics.parent.map_or_else(Vec::new, |def_id| {
get_parameter_names(cx, cx.tcx.generics_of(def_id))
});
names.extend(generics.own_params.iter().map(|param| param.name));
names
}

/// Returns a scope, plus `true` if that's a type scope for "class" methods,
/// otherwise `false` for plain namespace scopes.
fn get_containing_scope<'ll, 'tcx>(
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_feature/src/accepted.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ declare_features! (
/// Allows using `const` operands in inline assembly.
(accepted, asm_const, "1.82.0", Some(93332)),
/// Allows using `label` operands in inline assembly.
(accepted, asm_goto, "CURRENT_RUSTC_VERSION", Some(119364)),
(accepted, asm_goto, "1.87.0", Some(119364)),
/// Allows using `sym` operands in inline assembly.
(accepted, asm_sym, "1.66.0", Some(93333)),
/// Allows the definition of associated constants in `trait` or `impl` blocks.
Expand Down Expand Up @@ -332,7 +332,7 @@ declare_features! (
/// Allows `use<'a, 'b, A, B>` in `impl Trait + use<...>` for precise capture of generic args.
(accepted, precise_capturing, "1.82.0", Some(123432)),
/// Allows `use<..>` precise capturign on impl Trait in traits.
(accepted, precise_capturing_in_traits, "CURRENT_RUSTC_VERSION", Some(130044)),
(accepted, precise_capturing_in_traits, "1.87.0", Some(130044)),
/// Allows procedural macros in `proc-macro` crates.
(accepted, proc_macro, "1.29.0", Some(38356)),
/// Allows multi-segment paths in attributes and derives.
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_feature/src/removed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ declare_features! (
/// Allows unnamed fields of struct and union type
(removed, unnamed_fields, "1.83.0", Some(49804), Some("feature needs redesign")),
(removed, unsafe_no_drop_flag, "1.0.0", None, None),
(removed, unsized_tuple_coercion, "CURRENT_RUSTC_VERSION", Some(42877),
(removed, unsized_tuple_coercion, "1.87.0", Some(42877),
Some("The feature restricts possible layouts for tuples, and this restriction is not worth it.")),
/// Allows `union` fields that don't implement `Copy` as long as they don't have any drop glue.
(removed, untagged_unions, "1.13.0", Some(55149),
Expand Down
10 changes: 5 additions & 5 deletions compiler/rustc_feature/src/unstable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ declare_features! (
/// Allows `dyn* Trait` objects.
(incomplete, dyn_star, "1.65.0", Some(102425)),
/// Allows the .use postfix syntax `x.use` and use closures `use |x| { ... }`
(incomplete, ergonomic_clones, "CURRENT_RUSTC_VERSION", Some(132290)),
(incomplete, ergonomic_clones, "1.87.0", Some(132290)),
/// Allows exhaustive pattern matching on types that contain uninhabited types.
(unstable, exhaustive_patterns, "1.13.0", Some(51085)),
/// Allows explicit tail calls via `become` expression.
Expand Down Expand Up @@ -510,7 +510,7 @@ declare_features! (
/// Allows generic parameters and where-clauses on free & associated const items.
(incomplete, generic_const_items, "1.73.0", Some(113521)),
/// Allows the type of const generics to depend on generic parameters
(incomplete, generic_const_parameter_types, "CURRENT_RUSTC_VERSION", Some(137626)),
(incomplete, generic_const_parameter_types, "1.87.0", Some(137626)),
/// Allows any generic constants being used as pattern type range ends
(incomplete, generic_pattern_types, "1.86.0", Some(136574)),
/// Allows registering static items globally, possibly across crates, to iterate over at runtime.
Expand Down Expand Up @@ -603,7 +603,7 @@ declare_features! (
/// Allows macro attributes on expressions, statements and non-inline modules.
(unstable, proc_macro_hygiene, "1.30.0", Some(54727)),
/// Allows the use of raw-dylibs on ELF platforms
(incomplete, raw_dylib_elf, "CURRENT_RUSTC_VERSION", Some(135694)),
(incomplete, raw_dylib_elf, "1.87.0", Some(135694)),
/// Makes `&` and `&mut` patterns eat only one layer of references in Rust 2024.
(incomplete, ref_pat_eat_one_layer_2024, "1.79.0", Some(123076)),
/// Makes `&` and `&mut` patterns eat only one layer of references in Rust 2024—structural variant
Expand Down Expand Up @@ -663,14 +663,14 @@ declare_features! (
/// Allows using the `#[used(linker)]` (or `#[used(compiler)]`) attribute.
(unstable, used_with_arg, "1.60.0", Some(93798)),
/// Allows use of attributes in `where` clauses.
(unstable, where_clause_attrs, "CURRENT_RUSTC_VERSION", Some(115590)),
(unstable, where_clause_attrs, "1.87.0", Some(115590)),
/// Allows use of x86 `AMX` target-feature attributes and intrinsics
(unstable, x86_amx_intrinsics, "1.81.0", Some(126622)),
/// Allows use of the `xop` target-feature
(unstable, xop_target_feature, "1.81.0", Some(127208)),
/// Allows `do yeet` expressions
(unstable, yeet_expr, "1.62.0", Some(96373)),
(unstable, yield_expr, "CURRENT_RUSTC_VERSION", Some(43122)),
(unstable, yield_expr, "1.87.0", Some(43122)),
// !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!!
// Features are listed in alphabetical order. Tidy will fail if you don't keep it this way.
// !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!!
Expand Down
11 changes: 11 additions & 0 deletions compiler/rustc_monomorphize/src/mono_checks/abi_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,12 @@ fn wasm_abi_safe<'tcx>(tcx: TyCtxt<'tcx>, arg: &ArgAbi<'tcx, Ty<'tcx>>) -> bool
return true;
}

// Both the old and the new ABIs treat vector types like `v128` the same
// way.
if uses_vector_registers(&arg.mode, &arg.layout.backend_repr) {
return true;
}

// This matches `unwrap_trivial_aggregate` in the wasm ABI logic.
if arg.layout.is_aggregate() {
let cx = LayoutCx::new(tcx, TypingEnv::fully_monomorphized());
Expand All @@ -111,6 +117,11 @@ fn wasm_abi_safe<'tcx>(tcx: TyCtxt<'tcx>, arg: &ArgAbi<'tcx, Ty<'tcx>>) -> bool
}
}

// Zero-sized types are dropped in both ABIs, so they're safe
if arg.layout.is_zst() {
return true;
}

false
}

Expand Down
11 changes: 11 additions & 0 deletions compiler/rustc_parse/src/parser/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2066,6 +2066,17 @@ impl<'a> Parser<'a> {
}
self.expect_field_ty_separator()?;
let ty = self.parse_ty()?;
if self.token == token::Colon && self.look_ahead(1, |t| *t != token::Colon) {
self.dcx()
.struct_span_err(self.token.span, "found single colon in a struct field type path")
.with_span_suggestion_verbose(
self.token.span,
"write a path separator here",
"::",
Applicability::MaybeIncorrect,
)
.emit();
}
let default = if self.token == token::Eq {
self.bump();
let const_expr = self.parse_expr_anon_const()?;
Expand Down
20 changes: 7 additions & 13 deletions compiler/rustc_parse/src/parser/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,19 +248,13 @@ impl<'a> Parser<'a> {
segments.push(segment);

if self.is_import_coupler() || !self.eat_path_sep() {
let ok_for_recovery = self.may_recover()
&& match style {
PathStyle::Expr => true,
PathStyle::Type if let Some((ident, _)) = self.prev_token.ident() => {
self.token == token::Colon
&& ident.as_str().chars().all(|c| c.is_lowercase())
&& self.token.span.lo() == self.prev_token.span.hi()
&& self
.look_ahead(1, |token| self.token.span.hi() == token.span.lo())
}
_ => false,
};
if ok_for_recovery
// IMPORTANT: We can *only ever* treat single colons as typo'ed double colons in
// expression contexts (!) since only there paths cannot possibly be followed by
// a colon and still form a syntactically valid construct. In pattern contexts,
// a path may be followed by a type annotation. E.g., `let pat:ty`. In type
// contexts, a path may be followed by a list of bounds. E.g., `where ty:bound`.
if self.may_recover()
&& style == PathStyle::Expr // (!)
&& self.token == token::Colon
&& self.look_ahead(1, |token| token.is_ident() && !token.is_reserved_ident())
{
Expand Down
Loading
Loading