Skip to content

Commit 7b99493

Browse files
committed
Auto merge of #111089 - Dylan-DPC:rollup-b8oj6du, r=Dylan-DPC
Rollup of 7 pull requests Successful merges: - #105076 (Refactor core::char::EscapeDefault and co. structures) - #108161 (Add `ConstParamTy` trait) - #108668 (Stabilize debugger_visualizer) - #110512 (Fix elaboration with associated type bounds) - #110895 (Remove `all` in target_thread_local cfg) - #110955 (uplift `clippy::clone_double_ref` as `suspicious_double_ref_op`) - #111048 (Mark`feature(return_position_impl_trait_in_trait)` and`feature(async_fn_in_trait)` as not incomplete) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 5133e15 + 2e3373c commit 7b99493

File tree

134 files changed

+1699
-1153
lines changed

Some content is hidden

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

134 files changed

+1699
-1153
lines changed

compiler/rustc_codegen_ssa/src/back/link.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ use regex::Regex;
4040
use tempfile::Builder as TempFileBuilder;
4141

4242
use itertools::Itertools;
43-
use std::borrow::Borrow;
4443
use std::cell::OnceCell;
4544
use std::collections::BTreeSet;
4645
use std::ffi::OsString;
@@ -576,17 +575,17 @@ fn link_dwarf_object<'a>(
576575

577576
impl<Relocations> ThorinSession<Relocations> {
578577
fn alloc_mmap(&self, data: Mmap) -> &Mmap {
579-
(*self.arena_mmap.alloc(data)).borrow()
578+
&*self.arena_mmap.alloc(data)
580579
}
581580
}
582581

583582
impl<Relocations> thorin::Session<Relocations> for ThorinSession<Relocations> {
584583
fn alloc_data(&self, data: Vec<u8>) -> &[u8] {
585-
(*self.arena_data.alloc(data)).borrow()
584+
&*self.arena_data.alloc(data)
586585
}
587586

588587
fn alloc_relocation(&self, data: Relocations) -> &Relocations {
589-
(*self.arena_relocations.alloc(data)).borrow()
588+
&*self.arena_relocations.alloc(data)
590589
}
591590

592591
fn read_input(&self, path: &Path) -> std::io::Result<&[u8]> {

compiler/rustc_feature/src/accepted.rs

+2
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@ declare_features! (
130130
(accepted, copy_closures, "1.26.0", Some(44490), None),
131131
/// Allows `crate` in paths.
132132
(accepted, crate_in_paths, "1.30.0", Some(45477), None),
133+
/// Allows using `#[debugger_visualizer]` attribute.
134+
(accepted, debugger_visualizer, "CURRENT_RUSTC_VERSION", Some(95939), None),
133135
/// Allows rustc to inject a default alloc_error_handler
134136
(accepted, default_alloc_error_handler, "1.68.0", Some(66741), None),
135137
/// Allows using assigning a default type to type parameters in algebraic data type definitions.

compiler/rustc_feature/src/active.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ declare_features! (
310310
/// Allows `async || body` closures.
311311
(active, async_closure, "1.37.0", Some(62290), None),
312312
/// Allows async functions to be declared, implemented, and used in traits.
313-
(incomplete, async_fn_in_trait, "1.66.0", Some(91611), None),
313+
(active, async_fn_in_trait, "1.66.0", Some(91611), None),
314314
/// Treat `extern "C"` function as nounwind.
315315
(active, c_unwind, "1.52.0", Some(74990), None),
316316
/// Allows using C-variadics.
@@ -363,8 +363,6 @@ declare_features! (
363363
(active, custom_inner_attributes, "1.30.0", Some(54726), None),
364364
/// Allows custom test frameworks with `#![test_runner]` and `#[test_case]`.
365365
(active, custom_test_frameworks, "1.30.0", Some(50297), None),
366-
/// Allows using `#[debugger_visualizer]`.
367-
(active, debugger_visualizer, "1.62.0", Some(95939), None),
368366
/// Allows declarative macros 2.0 (`macro`).
369367
(active, decl_macro, "1.17.0", Some(39412), None),
370368
/// Allows default type parameters to influence type inference.
@@ -496,7 +494,7 @@ declare_features! (
496494
/// Allows `repr(simd)` and importing the various simd intrinsics.
497495
(active, repr_simd, "1.4.0", Some(27731), None),
498496
/// Allows return-position `impl Trait` in traits.
499-
(incomplete, return_position_impl_trait_in_trait, "1.65.0", Some(91611), None),
497+
(active, return_position_impl_trait_in_trait, "1.65.0", Some(91611), None),
500498
/// Allows bounding the return type of AFIT/RPITIT.
501499
(incomplete, return_type_notation, "1.70.0", Some(109417), None),
502500
/// Allows `extern "rust-cold"`.

compiler/rustc_feature/src/builtin_attrs.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -403,16 +403,16 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
403403
doc, Normal, template!(List: "hidden|inline|...", NameValueStr: "string"), DuplicatesOk
404404
),
405405

406+
// Debugging
407+
ungated!(
408+
debugger_visualizer, Normal,
409+
template!(List: r#"natvis_file = "...", gdb_script_file = "...""#), DuplicatesOk
410+
),
411+
406412
// ==========================================================================
407413
// Unstable attributes:
408414
// ==========================================================================
409415

410-
// RFC #3191: #[debugger_visualizer] support
411-
gated!(
412-
debugger_visualizer, Normal, template!(List: r#"natvis_file = "...", gdb_script_file = "...""#),
413-
DuplicatesOk, experimental!(debugger_visualizer)
414-
),
415-
416416
// Linking:
417417
gated!(
418418
naked, Normal, template!(Word), WarnFollowing, @only_local: true,

compiler/rustc_hir/src/lang_items.rs

+2
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,8 @@ language_item_table! {
293293

294294
PointerLike, sym::pointer_like, pointer_like, Target::Trait, GenericRequirement::Exact(0);
295295

296+
ConstParamTy, sym::const_param_ty, const_param_ty_trait, Target::Trait, GenericRequirement::Exact(0);
297+
296298
Poll, sym::Poll, poll, Target::Enum, GenericRequirement::None;
297299
PollReady, sym::Ready, poll_ready_variant, Target::Variant, GenericRequirement::None;
298300
PollPending, sym::Pending, poll_pending_variant, Target::Variant, GenericRequirement::None;

compiler/rustc_hir_analysis/messages.ftl

+4
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ hir_analysis_field_already_declared =
3535
3636
hir_analysis_expected_used_symbol = expected `used`, `used(compiler)` or `used(linker)`
3737
38+
hir_analysis_const_param_ty_impl_on_non_adt =
39+
the trait `ConstParamTy` may not be implemented for this type
40+
.label = type is not a structure or enumeration
41+
3842
hir_analysis_ambiguous_lifetime_bound =
3943
ambiguous lifetime bound, explicit lifetime bound required
4044

compiler/rustc_hir_analysis/src/astconv/mod.rs

+56-14
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ use std::slice;
5656
#[derive(Debug)]
5757
pub struct PathSeg(pub DefId, pub usize);
5858

59+
#[derive(Copy, Clone, Debug)]
60+
pub struct OnlySelfBounds(pub bool);
61+
5962
pub trait AstConv<'tcx> {
6063
fn tcx(&self) -> TyCtxt<'tcx>;
6164

@@ -670,6 +673,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
670673
args: &GenericArgs<'_>,
671674
infer_args: bool,
672675
self_ty: Ty<'tcx>,
676+
only_self_bounds: OnlySelfBounds,
673677
) -> GenericArgCountResult {
674678
let (substs, arg_count) = self.create_substs_for_ast_path(
675679
trait_ref_span,
@@ -706,6 +710,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
706710
&mut dup_bindings,
707711
binding_span.unwrap_or(binding.span),
708712
constness,
713+
only_self_bounds,
709714
);
710715
// Okay to ignore `Err` because of `ErrorGuaranteed` (see above).
711716
}
@@ -741,6 +746,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
741746
self_ty: Ty<'tcx>,
742747
bounds: &mut Bounds<'tcx>,
743748
speculative: bool,
749+
only_self_bounds: OnlySelfBounds,
744750
) -> GenericArgCountResult {
745751
let hir_id = trait_ref.hir_ref_id;
746752
let binding_span = None;
@@ -766,6 +772,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
766772
args,
767773
infer_args,
768774
self_ty,
775+
only_self_bounds,
769776
)
770777
}
771778

@@ -777,6 +784,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
777784
args: &GenericArgs<'_>,
778785
self_ty: Ty<'tcx>,
779786
bounds: &mut Bounds<'tcx>,
787+
only_self_bounds: OnlySelfBounds,
780788
) {
781789
let binding_span = Some(span);
782790
let constness = ty::BoundConstness::NotConst;
@@ -799,6 +807,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
799807
args,
800808
infer_args,
801809
self_ty,
810+
only_self_bounds,
802811
);
803812
}
804813

@@ -947,6 +956,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
947956
ast_bounds: I,
948957
bounds: &mut Bounds<'tcx>,
949958
bound_vars: &'tcx ty::List<ty::BoundVariableKind>,
959+
only_self_bounds: OnlySelfBounds,
950960
) {
951961
for ast_bound in ast_bounds {
952962
match ast_bound {
@@ -964,11 +974,18 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
964974
param_ty,
965975
bounds,
966976
false,
977+
only_self_bounds,
967978
);
968979
}
969980
&hir::GenericBound::LangItemTrait(lang_item, span, hir_id, args) => {
970981
self.instantiate_lang_item_trait_ref(
971-
lang_item, span, hir_id, args, param_ty, bounds,
982+
lang_item,
983+
span,
984+
hir_id,
985+
args,
986+
param_ty,
987+
bounds,
988+
only_self_bounds,
972989
);
973990
}
974991
hir::GenericBound::Outlives(lifetime) => {
@@ -1006,8 +1023,19 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
10061023
&self,
10071024
param_ty: Ty<'tcx>,
10081025
ast_bounds: &[hir::GenericBound<'_>],
1026+
only_self_bounds: OnlySelfBounds,
10091027
) -> Bounds<'tcx> {
1010-
self.compute_bounds_inner(param_ty, ast_bounds)
1028+
let mut bounds = Bounds::default();
1029+
self.add_bounds(
1030+
param_ty,
1031+
ast_bounds.iter(),
1032+
&mut bounds,
1033+
ty::List::empty(),
1034+
only_self_bounds,
1035+
);
1036+
debug!(?bounds);
1037+
1038+
bounds
10111039
}
10121040

10131041
/// Convert the bounds in `ast_bounds` that refer to traits which define an associated type
@@ -1029,17 +1057,14 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
10291057
}
10301058
}
10311059

1032-
self.compute_bounds_inner(param_ty, &result)
1033-
}
1034-
1035-
fn compute_bounds_inner(
1036-
&self,
1037-
param_ty: Ty<'tcx>,
1038-
ast_bounds: &[hir::GenericBound<'_>],
1039-
) -> Bounds<'tcx> {
10401060
let mut bounds = Bounds::default();
1041-
1042-
self.add_bounds(param_ty, ast_bounds.iter(), &mut bounds, ty::List::empty());
1061+
self.add_bounds(
1062+
param_ty,
1063+
result.iter(),
1064+
&mut bounds,
1065+
ty::List::empty(),
1066+
OnlySelfBounds(true),
1067+
);
10431068
debug!(?bounds);
10441069

10451070
bounds
@@ -1062,6 +1087,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
10621087
dup_bindings: &mut FxHashMap<DefId, Span>,
10631088
path_span: Span,
10641089
constness: ty::BoundConstness,
1090+
only_self_bounds: OnlySelfBounds,
10651091
) -> Result<(), ErrorGuaranteed> {
10661092
// Given something like `U: SomeTrait<T = X>`, we want to produce a
10671093
// predicate like `<U as SomeTrait>::T = X`. This is somewhat
@@ -1361,8 +1387,20 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
13611387
//
13621388
// Calling `skip_binder` is okay, because `add_bounds` expects the `param_ty`
13631389
// parameter to have a skipped binder.
1364-
let param_ty = tcx.mk_alias(ty::Projection, projection_ty.skip_binder());
1365-
self.add_bounds(param_ty, ast_bounds.iter(), bounds, projection_ty.bound_vars());
1390+
//
1391+
// NOTE: If `only_self_bounds` is true, do NOT expand this associated
1392+
// type bound into a trait predicate, since we only want to add predicates
1393+
// for the `Self` type.
1394+
if !only_self_bounds.0 {
1395+
let param_ty = tcx.mk_alias(ty::Projection, projection_ty.skip_binder());
1396+
self.add_bounds(
1397+
param_ty,
1398+
ast_bounds.iter(),
1399+
bounds,
1400+
projection_ty.bound_vars(),
1401+
only_self_bounds,
1402+
);
1403+
}
13661404
}
13671405
}
13681406
Ok(())
@@ -1403,6 +1441,10 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
14031441
dummy_self,
14041442
&mut bounds,
14051443
false,
1444+
// FIXME: This should be `true`, but we don't really handle
1445+
// associated type bounds or type aliases in objects in a way
1446+
// that makes this meaningful, I think.
1447+
OnlySelfBounds(false),
14061448
) {
14071449
potential_assoc_types.extend(cur_potential_assoc_types);
14081450
}

0 commit comments

Comments
 (0)