Skip to content
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

Rollup of 7 pull requests #111089

Merged
merged 39 commits into from
May 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
05c1e6b
stabilize debugger visualizer attribute
gibbyfree Mar 2, 2023
5c34f77
whitespace, delete unstable book page
gibbyfree Mar 2, 2023
4510439
Refactor core::char::EscapeDefault and co. structures
mina86 Nov 29, 2022
be413ae
Remove all in target_thread_local cfg
Ayush1325 Apr 27, 2023
518d348
Implement `StructuralEq` for integers, `bool` and `char`
WaffleLapkin Feb 17, 2023
9a716da
Add a `ConstParamTy` trait
WaffleLapkin Feb 17, 2023
c8844e1
`derive(Eq)` in a test
WaffleLapkin Feb 22, 2023
81a2b85
Remove `feature(const_param_ty_trait)`, use `adt_const_params` instead
WaffleLapkin Feb 22, 2023
c45c4f2
Rename/move a test
WaffleLapkin Feb 22, 2023
1c54410
Check the correct trait when checking `ConstParamTy` impls
WaffleLapkin Feb 23, 2023
7234d63
Add `!StructuralEq` test for `ConstParamTy`
WaffleLapkin Feb 23, 2023
2205c3f
Add a macro to conveniently implement marker traits
WaffleLapkin Mar 3, 2023
1bf6bbb
Impl `StructuralEq` & `ConstParamTy` for `str`, `&T`, `[T; N]` and `[T]`
WaffleLapkin Mar 3, 2023
2c5e716
Add FIXMEs
WaffleLapkin Mar 3, 2023
51355ad
Add a test for `[NotParam; 0]: ConstParamTy` (not holding)
WaffleLapkin Mar 3, 2023
bdb5502
Fix some marker impls
WaffleLapkin Mar 3, 2023
26417a8
Add `ConstParamTy` tests
WaffleLapkin Mar 3, 2023
2f70d02
Fix compile test so it normalizes (un)expected error messages
WaffleLapkin Apr 27, 2023
1f44a24
--bless `ConstParamTy` ui tests
WaffleLapkin Apr 27, 2023
182eee2
fixup tests wrt new normalization
WaffleLapkin Apr 28, 2023
5c99175
uplift `clippy::clone_double_ref` as `suspicious_double_ref_op`
fee1-dead Apr 28, 2023
e928067
fix rustdoc and core test
fee1-dead Apr 29, 2023
475378f
add match to diagnostic messages
fee1-dead Apr 29, 2023
4d0f7e2
review
mina86 Apr 30, 2023
76c9947
a bit more usize::from
mina86 Apr 30, 2023
c317546
Fix `StructuralEq` impls for `&T`, `[T]` and `[T; N]`
WaffleLapkin May 1, 2023
0bcfff4
Simplify type_parameter_bounds_in_generics
compiler-errors Apr 18, 2023
8ea71f2
Do not consider associated type bounds for super_predicates_that_defi…
compiler-errors Apr 18, 2023
bec7193
Don't use implied trait predicates in gather_explicit_predicates_of
compiler-errors Apr 19, 2023
b00e5f3
remove bootstrap from tests
gibbyfree Mar 6, 2023
c9653a6
fix stderrs
gibbyfree Mar 6, 2023
7411468
Mark RPITIT and AFIT as no longer incomplete
compiler-errors May 1, 2023
f916c44
Rollup merge of #105076 - mina86:a, r=scottmcm
Dylan-DPC May 2, 2023
b727132
Rollup merge of #108161 - WaffleLapkin:const_param_ty, r=BoxyUwU
Dylan-DPC May 2, 2023
f379a58
Rollup merge of #108668 - gibbyfree:stabilizedebuggervisualizer, r=we…
Dylan-DPC May 2, 2023
be4f9f5
Rollup merge of #110512 - compiler-errors:fix-elaboration-with-associ…
Dylan-DPC May 2, 2023
f47a63c
Rollup merge of #110895 - Ayush1325:thread-local-fix, r=thomcc
Dylan-DPC May 2, 2023
40c4ed4
Rollup merge of #110955 - fee1-dead-contrib:sus-operation, r=compiler…
Dylan-DPC May 2, 2023
2e3373c
Rollup merge of #111048 - compiler-errors:rpitit-not-incomplete, r=ja…
Dylan-DPC May 2, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 3 additions & 4 deletions compiler/rustc_codegen_ssa/src/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ use regex::Regex;
use tempfile::Builder as TempFileBuilder;

use itertools::Itertools;
use std::borrow::Borrow;
use std::cell::OnceCell;
use std::collections::BTreeSet;
use std::ffi::OsString;
Expand Down Expand Up @@ -576,17 +575,17 @@ fn link_dwarf_object<'a>(

impl<Relocations> ThorinSession<Relocations> {
fn alloc_mmap(&self, data: Mmap) -> &Mmap {
(*self.arena_mmap.alloc(data)).borrow()
&*self.arena_mmap.alloc(data)
}
}

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

fn alloc_relocation(&self, data: Relocations) -> &Relocations {
(*self.arena_relocations.alloc(data)).borrow()
&*self.arena_relocations.alloc(data)
}

fn read_input(&self, path: &Path) -> std::io::Result<&[u8]> {
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_feature/src/accepted.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ declare_features! (
(accepted, copy_closures, "1.26.0", Some(44490), None),
/// Allows `crate` in paths.
(accepted, crate_in_paths, "1.30.0", Some(45477), None),
/// Allows using `#[debugger_visualizer]` attribute.
(accepted, debugger_visualizer, "CURRENT_RUSTC_VERSION", Some(95939), None),
/// Allows rustc to inject a default alloc_error_handler
(accepted, default_alloc_error_handler, "1.68.0", Some(66741), None),
/// Allows using assigning a default type to type parameters in algebraic data type definitions.
Expand Down
6 changes: 2 additions & 4 deletions compiler/rustc_feature/src/active.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ declare_features! (
/// Allows `async || body` closures.
(active, async_closure, "1.37.0", Some(62290), None),
/// Allows async functions to be declared, implemented, and used in traits.
(incomplete, async_fn_in_trait, "1.66.0", Some(91611), None),
(active, async_fn_in_trait, "1.66.0", Some(91611), None),
/// Treat `extern "C"` function as nounwind.
(active, c_unwind, "1.52.0", Some(74990), None),
/// Allows using C-variadics.
Expand Down Expand Up @@ -363,8 +363,6 @@ declare_features! (
(active, custom_inner_attributes, "1.30.0", Some(54726), None),
/// Allows custom test frameworks with `#![test_runner]` and `#[test_case]`.
(active, custom_test_frameworks, "1.30.0", Some(50297), None),
/// Allows using `#[debugger_visualizer]`.
(active, debugger_visualizer, "1.62.0", Some(95939), None),
/// Allows declarative macros 2.0 (`macro`).
(active, decl_macro, "1.17.0", Some(39412), None),
/// Allows default type parameters to influence type inference.
Expand Down Expand Up @@ -496,7 +494,7 @@ declare_features! (
/// Allows `repr(simd)` and importing the various simd intrinsics.
(active, repr_simd, "1.4.0", Some(27731), None),
/// Allows return-position `impl Trait` in traits.
(incomplete, return_position_impl_trait_in_trait, "1.65.0", Some(91611), None),
(active, return_position_impl_trait_in_trait, "1.65.0", Some(91611), None),
/// Allows bounding the return type of AFIT/RPITIT.
(incomplete, return_type_notation, "1.70.0", Some(109417), None),
/// Allows `extern "rust-cold"`.
Expand Down
12 changes: 6 additions & 6 deletions compiler/rustc_feature/src/builtin_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -403,16 +403,16 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
doc, Normal, template!(List: "hidden|inline|...", NameValueStr: "string"), DuplicatesOk
),

// Debugging
ungated!(
debugger_visualizer, Normal,
template!(List: r#"natvis_file = "...", gdb_script_file = "...""#), DuplicatesOk
),

// ==========================================================================
// Unstable attributes:
// ==========================================================================

// RFC #3191: #[debugger_visualizer] support
gated!(
debugger_visualizer, Normal, template!(List: r#"natvis_file = "...", gdb_script_file = "...""#),
DuplicatesOk, experimental!(debugger_visualizer)
),

// Linking:
gated!(
naked, Normal, template!(Word), WarnFollowing, @only_local: true,
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 @@ -293,6 +293,8 @@ language_item_table! {

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

ConstParamTy, sym::const_param_ty, const_param_ty_trait, Target::Trait, GenericRequirement::Exact(0);

Poll, sym::Poll, poll, Target::Enum, GenericRequirement::None;
PollReady, sym::Ready, poll_ready_variant, Target::Variant, GenericRequirement::None;
PollPending, sym::Pending, poll_pending_variant, Target::Variant, GenericRequirement::None;
Expand Down
4 changes: 4 additions & 0 deletions compiler/rustc_hir_analysis/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ hir_analysis_field_already_declared =

hir_analysis_expected_used_symbol = expected `used`, `used(compiler)` or `used(linker)`

hir_analysis_const_param_ty_impl_on_non_adt =
the trait `ConstParamTy` may not be implemented for this type
.label = type is not a structure or enumeration

hir_analysis_ambiguous_lifetime_bound =
ambiguous lifetime bound, explicit lifetime bound required

Expand Down
70 changes: 56 additions & 14 deletions compiler/rustc_hir_analysis/src/astconv/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ use std::slice;
#[derive(Debug)]
pub struct PathSeg(pub DefId, pub usize);

#[derive(Copy, Clone, Debug)]
pub struct OnlySelfBounds(pub bool);

pub trait AstConv<'tcx> {
fn tcx(&self) -> TyCtxt<'tcx>;

Expand Down Expand Up @@ -670,6 +673,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
args: &GenericArgs<'_>,
infer_args: bool,
self_ty: Ty<'tcx>,
only_self_bounds: OnlySelfBounds,
) -> GenericArgCountResult {
let (substs, arg_count) = self.create_substs_for_ast_path(
trait_ref_span,
Expand Down Expand Up @@ -706,6 +710,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
&mut dup_bindings,
binding_span.unwrap_or(binding.span),
constness,
only_self_bounds,
);
// Okay to ignore `Err` because of `ErrorGuaranteed` (see above).
}
Expand Down Expand Up @@ -741,6 +746,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
self_ty: Ty<'tcx>,
bounds: &mut Bounds<'tcx>,
speculative: bool,
only_self_bounds: OnlySelfBounds,
) -> GenericArgCountResult {
let hir_id = trait_ref.hir_ref_id;
let binding_span = None;
Expand All @@ -766,6 +772,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
args,
infer_args,
self_ty,
only_self_bounds,
)
}

Expand All @@ -777,6 +784,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
args: &GenericArgs<'_>,
self_ty: Ty<'tcx>,
bounds: &mut Bounds<'tcx>,
only_self_bounds: OnlySelfBounds,
) {
let binding_span = Some(span);
let constness = ty::BoundConstness::NotConst;
Expand All @@ -799,6 +807,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
args,
infer_args,
self_ty,
only_self_bounds,
);
}

Expand Down Expand Up @@ -947,6 +956,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
ast_bounds: I,
bounds: &mut Bounds<'tcx>,
bound_vars: &'tcx ty::List<ty::BoundVariableKind>,
only_self_bounds: OnlySelfBounds,
) {
for ast_bound in ast_bounds {
match ast_bound {
Expand All @@ -964,11 +974,18 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
param_ty,
bounds,
false,
only_self_bounds,
);
}
&hir::GenericBound::LangItemTrait(lang_item, span, hir_id, args) => {
self.instantiate_lang_item_trait_ref(
lang_item, span, hir_id, args, param_ty, bounds,
lang_item,
span,
hir_id,
args,
param_ty,
bounds,
only_self_bounds,
);
}
hir::GenericBound::Outlives(lifetime) => {
Expand Down Expand Up @@ -1006,8 +1023,19 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
&self,
param_ty: Ty<'tcx>,
ast_bounds: &[hir::GenericBound<'_>],
only_self_bounds: OnlySelfBounds,
) -> Bounds<'tcx> {
self.compute_bounds_inner(param_ty, ast_bounds)
let mut bounds = Bounds::default();
self.add_bounds(
param_ty,
ast_bounds.iter(),
&mut bounds,
ty::List::empty(),
only_self_bounds,
);
debug!(?bounds);

bounds
}

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

self.compute_bounds_inner(param_ty, &result)
}

fn compute_bounds_inner(
&self,
param_ty: Ty<'tcx>,
ast_bounds: &[hir::GenericBound<'_>],
) -> Bounds<'tcx> {
let mut bounds = Bounds::default();

self.add_bounds(param_ty, ast_bounds.iter(), &mut bounds, ty::List::empty());
self.add_bounds(
param_ty,
result.iter(),
&mut bounds,
ty::List::empty(),
OnlySelfBounds(true),
);
debug!(?bounds);

bounds
Expand All @@ -1062,6 +1087,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
dup_bindings: &mut FxHashMap<DefId, Span>,
path_span: Span,
constness: ty::BoundConstness,
only_self_bounds: OnlySelfBounds,
) -> Result<(), ErrorGuaranteed> {
// Given something like `U: SomeTrait<T = X>`, we want to produce a
// predicate like `<U as SomeTrait>::T = X`. This is somewhat
Expand Down Expand Up @@ -1361,8 +1387,20 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
//
// Calling `skip_binder` is okay, because `add_bounds` expects the `param_ty`
// parameter to have a skipped binder.
let param_ty = tcx.mk_alias(ty::Projection, projection_ty.skip_binder());
self.add_bounds(param_ty, ast_bounds.iter(), bounds, projection_ty.bound_vars());
//
// NOTE: If `only_self_bounds` is true, do NOT expand this associated
// type bound into a trait predicate, since we only want to add predicates
// for the `Self` type.
if !only_self_bounds.0 {
let param_ty = tcx.mk_alias(ty::Projection, projection_ty.skip_binder());
self.add_bounds(
param_ty,
ast_bounds.iter(),
bounds,
projection_ty.bound_vars(),
only_self_bounds,
);
}
}
}
Ok(())
Expand Down Expand Up @@ -1403,6 +1441,10 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
dummy_self,
&mut bounds,
false,
// FIXME: This should be `true`, but we don't really handle
// associated type bounds or type aliases in objects in a way
// that makes this meaningful, I think.
OnlySelfBounds(false),
) {
potential_assoc_types.extend(cur_potential_assoc_types);
}
Expand Down