Skip to content

Commit c44b3d5

Browse files
committed
Auto merge of #133803 - matthiaskrgr:rollup-8ag5ncy, r=matthiaskrgr
Rollup of 9 pull requests Successful merges: - #132612 (Gate async fn trait bound modifier on `async_trait_bounds`) - #133545 (Lint against Symbol::intern on a string literal) - #133558 (Structurally resolve in `probe_adt`) - #133696 (stabilize const_collections_with_hasher and build_hasher_default_const_new) - #133753 (Reduce false positives on some common cases from if-let-rescope lint) - #133762 (stabilize const_{size,align}_of_val) - #133777 (document -Zrandomize-layout in the unstable book) - #133779 (Use correct `hir_id` for array const arg infers) - #133796 (Update the definition of `borrowing_sub`) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 490b2cc + b78ab2f commit c44b3d5

File tree

106 files changed

+438
-224
lines changed

Some content is hidden

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

106 files changed

+438
-224
lines changed

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2011,7 +2011,8 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
20112011
ExprKind::Underscore => {
20122012
if self.tcx.features().generic_arg_infer() {
20132013
let ct_kind = hir::ConstArgKind::Infer(self.lower_span(c.value.span));
2014-
self.arena.alloc(hir::ConstArg { hir_id: self.next_id(), kind: ct_kind })
2014+
self.arena
2015+
.alloc(hir::ConstArg { hir_id: self.lower_node_id(c.id), kind: ct_kind })
20152016
} else {
20162017
feature_err(
20172018
&self.tcx.sess,

compiler/rustc_ast_passes/src/feature_gate.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ use rustc_ast::{NodeId, PatKind, attr, token};
44
use rustc_feature::{AttributeGate, BUILTIN_ATTRIBUTE_MAP, BuiltinAttribute, Features, GateIssue};
55
use rustc_session::Session;
66
use rustc_session::parse::{feature_err, feature_err_issue, feature_warn};
7+
use rustc_span::Span;
78
use rustc_span::source_map::Spanned;
8-
use rustc_span::symbol::sym;
9-
use rustc_span::{Span, Symbol};
9+
use rustc_span::symbol::{Symbol, sym};
1010
use rustc_target::spec::abi;
1111
use thin_vec::ThinVec;
1212

@@ -516,6 +516,11 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session, features: &Features) {
516516
"async closures are unstable",
517517
"to use an async block, remove the `||`: `async {`"
518518
);
519+
gate_all!(
520+
async_trait_bounds,
521+
"`async` trait bounds are unstable",
522+
"use the desugared name of the async trait, such as `AsyncFn`"
523+
);
519524
gate_all!(async_for_loop, "`for await` loops are experimental");
520525
gate_all!(
521526
closure_lifetime_binder,
@@ -690,6 +695,7 @@ fn check_new_solver_banned_features(sess: &Session, features: &Features) {
690695
.find(|feat| feat.gate_name == sym::generic_const_exprs)
691696
.map(|feat| feat.attr_sp)
692697
{
698+
#[cfg_attr(not(bootstrap), allow(rustc::symbol_intern_string_literal))]
693699
sess.dcx().emit_err(errors::IncompatibleFeatures {
694700
spans: vec![gce_span],
695701
f1: Symbol::intern("-Znext-solver=globally"),

compiler/rustc_borrowck/src/universal_regions.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ use rustc_middle::ty::{
3333
TyCtxt, TypeVisitableExt,
3434
};
3535
use rustc_middle::{bug, span_bug};
36+
use rustc_span::ErrorGuaranteed;
3637
use rustc_span::symbol::{kw, sym};
37-
use rustc_span::{ErrorGuaranteed, Symbol};
3838
use tracing::{debug, instrument};
3939

4040
use crate::BorrowckInferCtxt;
@@ -524,7 +524,7 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
524524

525525
let reg_vid = self
526526
.infcx
527-
.next_nll_region_var(FR, || RegionCtxt::Free(Symbol::intern("c-variadic")))
527+
.next_nll_region_var(FR, || RegionCtxt::Free(sym::c_dash_variadic))
528528
.as_var();
529529

530530
let region = ty::Region::new_var(self.infcx.tcx, reg_vid);
@@ -540,10 +540,8 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
540540
}
541541
}
542542

543-
let fr_fn_body = self
544-
.infcx
545-
.next_nll_region_var(FR, || RegionCtxt::Free(Symbol::intern("fn_body")))
546-
.as_var();
543+
let fr_fn_body =
544+
self.infcx.next_nll_region_var(FR, || RegionCtxt::Free(sym::fn_body)).as_var();
547545

548546
let num_universals = self.infcx.num_region_vars();
549547

compiler/rustc_codegen_cranelift/src/driver/jit.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ fn create_jit_module(
7474
jit_builder.symbol("__clif_jit_fn", clif_jit_fn as *const u8);
7575
let mut jit_module = UnwindModule::new(JITModule::new(jit_builder), false);
7676

77-
let cx = crate::CodegenCx::new(tcx, jit_module.isa(), false, Symbol::intern("dummy_cgu_name"));
77+
let cx = crate::CodegenCx::new(tcx, jit_module.isa(), false, sym::dummy_cgu_name);
7878

7979
crate::allocator::codegen(tcx, &mut jit_module);
8080

@@ -276,12 +276,7 @@ fn jit_fn(instance_ptr: *const Instance<'static>, trampoline_ptr: *const u8) ->
276276

277277
jit_module.module.prepare_for_function_redefine(func_id).unwrap();
278278

279-
let mut cx = crate::CodegenCx::new(
280-
tcx,
281-
jit_module.isa(),
282-
false,
283-
Symbol::intern("dummy_cgu_name"),
284-
);
279+
let mut cx = crate::CodegenCx::new(tcx, jit_module.isa(), false, sym::dummy_cgu_name);
285280
codegen_and_compile_fn(tcx, &mut cx, &mut Context::new(), jit_module, instance);
286281

287282
assert!(cx.global_asm.is_empty());

compiler/rustc_codegen_cranelift/src/lib.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -189,18 +189,13 @@ impl CodegenBackend for CraneliftCodegenBackend {
189189
// FIXME return the actually used target features. this is necessary for #[cfg(target_feature)]
190190
if sess.target.arch == "x86_64" && sess.target.os != "none" {
191191
// x86_64 mandates SSE2 support
192-
vec![Symbol::intern("fxsr"), sym::sse, Symbol::intern("sse2")]
192+
vec![sym::fsxr, sym::sse, sym::sse2]
193193
} else if sess.target.arch == "aarch64" {
194194
match &*sess.target.os {
195195
"none" => vec![],
196196
// On macOS the aes, sha2 and sha3 features are enabled by default and ring
197197
// fails to compile on macOS when they are not present.
198-
"macos" => vec![
199-
sym::neon,
200-
Symbol::intern("aes"),
201-
Symbol::intern("sha2"),
202-
Symbol::intern("sha3"),
203-
],
198+
"macos" => vec![sym::neon, sym::aes, sym::sha2, sym::sha3],
204199
// AArch64 mandates Neon support
205200
_ => vec![sym::neon],
206201
}

compiler/rustc_feature/src/unstable.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,8 @@ declare_features! (
394394
(unstable, async_fn_track_caller, "1.73.0", Some(110011)),
395395
/// Allows `for await` loops.
396396
(unstable, async_for_loop, "1.77.0", Some(118898)),
397+
/// Allows `async` trait bound modifier.
398+
(unstable, async_trait_bounds, "CURRENT_RUSTC_VERSION", Some(62290)),
397399
/// Allows using C-variadics.
398400
(unstable, c_variadic, "1.34.0", Some(44930)),
399401
/// Allows the use of `#[cfg(<true/false>)]`.

compiler/rustc_hir_analysis/src/collect/generics_of.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ pub(super) fn generics_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Generics {
419419
if let Node::ConstBlock(_) = node {
420420
own_params.push(ty::GenericParamDef {
421421
index: next_index(),
422-
name: Symbol::intern("<const_ty>"),
422+
name: rustc_span::sym::const_ty_placeholder,
423423
def_id: def_id.to_def_id(),
424424
pure_wrt_drop: false,
425425
kind: ty::GenericParamDefKind::Type { has_default: false, synthetic: false },

compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,11 @@ impl<'tcx> HirTyLowerer<'tcx> for FnCtxt<'_, 'tcx> {
307307
ty::Alias(ty::Projection | ty::Inherent | ty::Weak, _)
308308
if !ty.has_escaping_bound_vars() =>
309309
{
310-
self.normalize(span, ty).ty_adt_def()
310+
if self.next_trait_solver() {
311+
self.try_structurally_resolve_type(span, ty).ty_adt_def()
312+
} else {
313+
self.normalize(span, ty).ty_adt_def()
314+
}
311315
}
312316
_ => None,
313317
}

compiler/rustc_hir_typeck/src/method/suggest.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
664664
let is_write = sugg_span.ctxt().outer_expn_data().macro_def_id.is_some_and(|def_id| {
665665
tcx.is_diagnostic_item(sym::write_macro, def_id)
666666
|| tcx.is_diagnostic_item(sym::writeln_macro, def_id)
667-
}) && item_name.name == Symbol::intern("write_fmt");
667+
}) && item_name.name == sym::write_fmt;
668668
let mut err = if is_write && let SelfSource::MethodCall(rcvr_expr) = source {
669669
self.suggest_missing_writer(rcvr_ty, rcvr_expr)
670670
} else {

compiler/rustc_lint/messages.ftl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -775,6 +775,9 @@ lint_suspicious_double_ref_clone =
775775
lint_suspicious_double_ref_deref =
776776
using `.deref()` on a double reference, which returns `{$ty}` instead of dereferencing the inner type
777777
778+
lint_symbol_intern_string_literal = using `Symbol::intern` on a string literal
779+
.help = consider adding the symbol to `compiler/rustc_span/src/symbol.rs`
780+
778781
lint_trailing_semi_macro = trailing semicolon in macro used in expression position
779782
.note1 = macro invocations at the end of a block are treated as expressions
780783
.note2 = to ignore the value produced by the macro, add a semicolon after the invocation of `{$name}`

0 commit comments

Comments
 (0)