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

privacy: normalize associated types before visiting #126076

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jswrenn
Copy link
Member

@jswrenn jswrenn commented Jun 6, 2024

This permits associated types to reference private types and traits, so long as the normalized type does not itself violate type privacy.

Fixes #45713

@rustbot
Copy link
Collaborator

rustbot commented Jun 6, 2024

r? @compiler-errors

rustbot has assigned @compiler-errors.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jun 6, 2024
@petrochenkov petrochenkov self-assigned this Jun 6, 2024
let ty = self.tcx.type_of(self.item_def_id).instantiate_identity();

// if `in_assoc_ty`, attempt to normalize `ty`
let maybe_normalized_ty = if self.in_assoc_ty {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This visitor is supposed to normalize everywhere, not just in associated types.

If that's not possible for some technical reasons, then it's fine to normalize only in a subset of cases, just need to leave an explaining comment.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, removing the self.in_assoc_ty check caused quite a few unexpected errors (e.g., recursion limit errors). I'll leave a comment to that effect.

I don't quite have the expertise to debug these in short-order, and the narrow issue of normalization in associated types is what's blocking me from releasing zerocopy 0.8. If it's possible to merge this narrow fix before 1.80 branches from master, I'd be quite grateful.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we're delaying it to 1.81 anyway, let's try out both using the new solver and always trying to normalize, even for non-assoc types.

@petrochenkov
Copy link
Contributor

The general direction is right, technical details I'll leave to compiler-errors.

@petrochenkov petrochenkov removed their assignment Jun 6, 2024
@compiler-errors
Copy link
Member

I thought I had commented but I guess I didn't.

I have a bit of concern about rushing to land this for 1.80 -- beta branches tomorrow, and I'm not confident that this is a sufficient solution to prevent overflows1, and I really want to think about this further. I want to stress that the consequence of getting this wrong means that users will have overflow errors that they simply cannot fix, and we'd likely catch this during beta crater runs and then have to scramble to revert this PR, putting us in the same position as moving carefully. So sorry 😅 I think you'll just need to wait for 1.81 for this.

The special casing of this to associated type definitions here also feels kinda artificial. You can easily come up with an example that we'd want to eagerly normalize outside of associated type definitions, e.g.:

trait Mirror {
    type Assoc;
}
impl<T> Mirror for T {
    type Assoc = T;
}

pub trait Foo: Iterator<Item = <i32 as Mirror>::Assoc> {}
    // the identity projection ^^^^^^^^^^^^^^^^^^^^^^^

I think we can actually just use the new trait solver to avoid the overflows, since we've recently FCP'd policy to use the new trait solver in lints and the like, though I'd want to have a confidence check from @lcnr that this fits that policy.

Footnotes

  1. And unfortunately, unless you can provide a really good reason for why we shouldn't ever have overflows when normalizing associated type definitions, then I'm then obligated as a reviewer to think very hard for a counterexample. Just because the test suite doesn't have any failures is a pretty weak signal that this is correct 😅

// Ideally, we would normalize in all circumstances, but doing so
// currently causes some unexpected type errors.
let maybe_normalized_ty = if self.in_assoc_ty {
let param_env = self.tcx.param_env(self.item_def_id);
Copy link
Member

@compiler-errors compiler-errors Jun 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, let's actually try using the new trait solver, and do it everywhere. So you'll need to actually do like how @lcnr originally suggested to you 😆

I would also pull this into a helper function so that you can just propagate the error out, then do:

let infcx = tcx.infer_ctxt().with_new_trait_solver(true).build();
let ocx = ObligationCtxt::new(&infcx);
let Ok(ty) = ocx.deeply_normalize(/* more args go here */, ty) else { return Err(()) };
let errors = ocx.select_all_or_error();
if !errors.is_empty() { return Err(()); }

Copy link
Member Author

@jswrenn jswrenn Jun 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done! This narrows us down to a single ICE on tests/ui/const-generics/issues/issue-83288.rs, that can be replicated with:

./x test ui -- tests/ui/const-generics/issues/issue-83288.rs

...which produces an ICE here:

ty::ConstKind::Bound(..) | ty::ConstKind::Placeholder(_) => {
bug!("unexpected const {:?}", ct)
}

The full output is:

error: internal compiler error: compiler/rustc_infer/src/infer/freshen.rs:176:17: unexpected const !1: usize

thread 'rustc' panicked at compiler/rustc_infer/src/infer/freshen.rs:176:17:
Box<dyn Any>
stack backtrace:
   0:     0x7f76a736d0c6 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hc6f7188f457d2bbd
   1:     0x7f76a73d986b - core::fmt::write::h15210aeb282b288e
   2:     0x7f76a739a809 - std::io::Write::write_fmt::hc5c861224043a6d1
   3:     0x7f76a736ceff - std::sys_common::backtrace::print::hb97fd65c9958399d
   4:     0x7f76a735b229 - std::panicking::default_hook::{{closure}}::h95df17654d61b2c0
   5:     0x7f76a735b031 - std::panicking::default_hook::ha0668ff74803c87a
   6:     0x7f76a7ef1a49 - <alloc[587ff061a4add891]::boxed::Box<rustc_driver_impl[7c407987b01bf8cc]::install_ice_hook::{closure#0}> as core[b901df56f7100974]::ops::function::Fn<(&dyn for<'a, 'b> core[b901df56f7100974]::ops::function::Fn<(&'a core[b901df56f7100974]::panic::panic_info::PanicInfo<'b>,), Output = ()> + core[b901df56f7100974]::marker::Sync + core[b901df56f7100974]::marker::Send, &core[b901df56f7100974]::panic::panic_info::PanicInfo)>>::call
   7:     0x7f76a735b6f6 - std::panicking::rust_panic_with_hook::h33328749bace0874
   8:     0x7f76aa9152fb - std[15469114d45899b1]::panicking::begin_panic::<rustc_errors[c87af3ac1f6c8edf]::ExplicitBug>::{closure#0}
   9:     0x7f76aa9152a9 - std[15469114d45899b1]::sys_common::backtrace::__rust_end_short_backtrace::<std[15469114d45899b1]::panicking::begin_panic<rustc_errors[c87af3ac1f6c8edf]::ExplicitBug>::{closure#0}, !>
  10:     0x7f76a7e3abb9 - std[15469114d45899b1]::panicking::begin_panic::<rustc_errors[c87af3ac1f6c8edf]::ExplicitBug>
  11:     0x7f76aa8f9c89 - std[15469114d45899b1]::panic::panic_any::<rustc_errors[c87af3ac1f6c8edf]::ExplicitBug>
  12:     0x7f76aa8f9e86 - <rustc_errors[c87af3ac1f6c8edf]::diagnostic::BugAbort as rustc_errors[c87af3ac1f6c8edf]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  13:     0x7f76aa5ef90a - <rustc_errors[c87af3ac1f6c8edf]::diagnostic::Diag<rustc_errors[c87af3ac1f6c8edf]::diagnostic::BugAbort>>::emit
  14:     0x7f76aa59494c - <rustc_errors[c87af3ac1f6c8edf]::DiagCtxt>::bug::<alloc[587ff061a4add891]::string::String>
  15:     0x7f76aa692b41 - rustc_middle[3225073a0293a413]::util::bug::opt_span_bug_fmt::<rustc_span[90405a0d169ad75f]::span_encoding::Span>::{closure#0}
  16:     0x7f76aa6929dc - rustc_middle[3225073a0293a413]::ty::context::tls::with_opt::<rustc_middle[3225073a0293a413]::util::bug::opt_span_bug_fmt<rustc_span[90405a0d169ad75f]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  17:     0x7f76aa692974 - rustc_middle[3225073a0293a413]::ty::context::tls::with_context_opt::<rustc_middle[3225073a0293a413]::ty::context::tls::with_opt<rustc_middle[3225073a0293a413]::util::bug::opt_span_bug_fmt<rustc_span[90405a0d169ad75f]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  18:     0x7f76aa692989 - rustc_middle[3225073a0293a413]::ty::context::tls::with_opt::<rustc_middle[3225073a0293a413]::util::bug::opt_span_bug_fmt<rustc_span[90405a0d169ad75f]::span_encoding::Span>::{closure#0}, !>
  19:     0x7f76aa692a7c - rustc_middle[3225073a0293a413]::util::bug::opt_span_bug_fmt::<rustc_span[90405a0d169ad75f]::span_encoding::Span>
  20:     0x7f76a7e24291 - rustc_middle[3225073a0293a413]::util::bug::bug_fmt
  21:     0x7f76a9dc51e6 - <rustc_infer[3ba290eb763f499]::infer::freshen::TypeFreshener as rustc_type_ir[dca2940381de7990]::fold::TypeFolder<rustc_middle[3225073a0293a413]::ty::context::TyCtxt>>::fold_const
  22:     0x7f76a9b24969 - <rustc_middle[3225073a0293a413]::ty::generic_args::GenericArg as rustc_type_ir[dca2940381de7990]::fold::TypeFoldable<rustc_middle[3225073a0293a413]::ty::context::TyCtxt>>::try_fold_with::<rustc_infer[3ba290eb763f499]::infer::freshen::TypeFreshener>
  23:     0x7f76a999d201 - <&rustc_middle[3225073a0293a413]::ty::list::RawList<(), rustc_middle[3225073a0293a413]::ty::generic_args::GenericArg> as rustc_type_ir[dca2940381de7990]::fold::TypeFoldable<rustc_middle[3225073a0293a413]::ty::context::TyCtxt>>::try_fold_with::<rustc_infer[3ba290eb763f499]::infer::freshen::TypeFreshener>
  24:     0x7f76a99ba4dc - <rustc_middle[3225073a0293a413]::ty::predicate::TraitPredicate as rustc_type_ir[dca2940381de7990]::fold::TypeFoldable<rustc_middle[3225073a0293a413]::ty::context::TyCtxt>>::try_fold_with::<rustc_infer[3ba290eb763f499]::infer::freshen::TypeFreshener>
  25:     0x7f76a99ada8e - <rustc_middle[3225073a0293a413]::ty::sty::Binder<rustc_middle[3225073a0293a413]::ty::predicate::TraitPredicate> as rustc_type_ir[dca2940381de7990]::fold::TypeSuperFoldable<rustc_middle[3225073a0293a413]::ty::context::TyCtxt>>::super_fold_with::<rustc_infer[3ba290eb763f499]::infer::freshen::TypeFreshener>
  26:     0x7f76a9a311de - <rustc_infer[3ba290eb763f499]::infer::freshen::TypeFreshener as rustc_type_ir[dca2940381de7990]::fold::FallibleTypeFolder<rustc_middle[3225073a0293a413]::ty::context::TyCtxt>>::try_fold_binder::<rustc_middle[3225073a0293a413]::ty::predicate::TraitPredicate>
  27:     0x7f76a99ad88e - <rustc_middle[3225073a0293a413]::ty::sty::Binder<rustc_middle[3225073a0293a413]::ty::predicate::TraitPredicate> as rustc_type_ir[dca2940381de7990]::fold::TypeFoldable<rustc_middle[3225073a0293a413]::ty::context::TyCtxt>>::fold_with::<rustc_infer[3ba290eb763f499]::infer::freshen::TypeFreshener>
  28:     0x7f76a9ada331 - <rustc_trait_selection[141eeb03ef3b9526]::traits::select::SelectionContext>::poly_select
  29:     0x7f76a9ac392d - <rustc_trait_selection[141eeb03ef3b9526]::traits::select::SelectionContext>::select
  30:     0x7f76a932cedb - rustc_traits[1b46a35ab3eb3b6e]::codegen::codegen_select_candidate
  31:     0x7f76a96731cc - rustc_query_impl[7e84afb844c0dc58]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[7e84afb844c0dc58]::query_impl::codegen_select_candidate::dynamic_query::{closure#2}::{closure#0}, rustc_middle[3225073a0293a413]::query::erase::Erased<[u8; 16usize]>>
  32:     0x7f76a9687f13 - <rustc_query_impl[7e84afb844c0dc58]::query_impl::codegen_select_candidate::dynamic_query::{closure#2} as core[b901df56f7100974]::ops::function::FnOnce<(rustc_middle[3225073a0293a413]::ty::context::TyCtxt, (rustc_middle[3225073a0293a413]::ty::ParamEnv, rustc_middle[3225073a0293a413]::ty::predicate::TraitRef))>>::call_once
  33:     0x7f76a94331c7 - <std[15469114d45899b1]::thread::local::LocalKey<core[b901df56f7100974]::cell::Cell<*const ()>>>::with::<rustc_middle[3225073a0293a413]::ty::context::tls::enter_context<rustc_query_system[6530a4bac8984ae5]::query::plumbing::execute_job_non_incr<rustc_query_impl[7e84afb844c0dc58]::DynamicConfig<rustc_query_system[6530a4bac8984ae5]::query::caches::DefaultCache<(rustc_middle[3225073a0293a413]::ty::ParamEnv, rustc_middle[3225073a0293a413]::ty::predicate::TraitRef), rustc_middle[3225073a0293a413]::query::erase::Erased<[u8; 16usize]>>, false, false, false>, rustc_query_impl[7e84afb844c0dc58]::plumbing::QueryCtxt>::{closure#0}, rustc_middle[3225073a0293a413]::query::erase::Erased<[u8; 16usize]>>::{closure#0}, rustc_middle[3225073a0293a413]::query::erase::Erased<[u8; 16usize]>>
  34:     0x7f76a958054f - rustc_query_system[6530a4bac8984ae5]::query::plumbing::try_execute_query::<rustc_query_impl[7e84afb844c0dc58]::DynamicConfig<rustc_query_system[6530a4bac8984ae5]::query::caches::DefaultCache<(rustc_middle[3225073a0293a413]::ty::ParamEnv, rustc_middle[3225073a0293a413]::ty::predicate::TraitRef), rustc_middle[3225073a0293a413]::query::erase::Erased<[u8; 16usize]>>, false, false, false>, rustc_query_impl[7e84afb844c0dc58]::plumbing::QueryCtxt, false>
  35:     0x7f76a9688870 - rustc_query_impl[7e84afb844c0dc58]::query_impl::codegen_select_candidate::get_query_non_incr::__rust_end_short_backtrace
  36:     0x7f76a8e62abd - rustc_ty_utils[1ee9e922b5e056c8]::instance::resolve_instance
  37:     0x7f76a9666ecc - rustc_query_impl[7e84afb844c0dc58]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[7e84afb844c0dc58]::query_impl::resolve_instance::dynamic_query::{closure#2}::{closure#0}, rustc_middle[3225073a0293a413]::query::erase::Erased<[u8; 32usize]>>
  38:     0x7f76a95e2923 - <rustc_query_impl[7e84afb844c0dc58]::query_impl::resolve_instance::dynamic_query::{closure#2} as core[b901df56f7100974]::ops::function::FnOnce<(rustc_middle[3225073a0293a413]::ty::context::TyCtxt, rustc_middle[3225073a0293a413]::ty::ParamEnvAnd<(rustc_span[90405a0d169ad75f]::def_id::DefId, &rustc_middle[3225073a0293a413]::ty::list::RawList<(), rustc_middle[3225073a0293a413]::ty::generic_args::GenericArg>)>)>>::call_once
  39:     0x7f76a9431697 - <std[15469114d45899b1]::thread::local::LocalKey<core[b901df56f7100974]::cell::Cell<*const ()>>>::with::<rustc_middle[3225073a0293a413]::ty::context::tls::enter_context<rustc_query_system[6530a4bac8984ae5]::query::plumbing::execute_job_non_incr<rustc_query_impl[7e84afb844c0dc58]::DynamicConfig<rustc_query_system[6530a4bac8984ae5]::query::caches::DefaultCache<rustc_middle[3225073a0293a413]::ty::ParamEnvAnd<(rustc_span[90405a0d169ad75f]::def_id::DefId, &rustc_middle[3225073a0293a413]::ty::list::RawList<(), rustc_middle[3225073a0293a413]::ty::generic_args::GenericArg>)>, rustc_middle[3225073a0293a413]::query::erase::Erased<[u8; 32usize]>>, false, false, false>, rustc_query_impl[7e84afb844c0dc58]::plumbing::QueryCtxt>::{closure#0}, rustc_middle[3225073a0293a413]::query::erase::Erased<[u8; 32usize]>>::{closure#0}, rustc_middle[3225073a0293a413]::query::erase::Erased<[u8; 32usize]>>
  40:     0x7f76a9547b24 - rustc_query_system[6530a4bac8984ae5]::query::plumbing::try_execute_query::<rustc_query_impl[7e84afb844c0dc58]::DynamicConfig<rustc_query_system[6530a4bac8984ae5]::query::caches::DefaultCache<rustc_middle[3225073a0293a413]::ty::ParamEnvAnd<(rustc_span[90405a0d169ad75f]::def_id::DefId, &rustc_middle[3225073a0293a413]::ty::list::RawList<(), rustc_middle[3225073a0293a413]::ty::generic_args::GenericArg>)>, rustc_middle[3225073a0293a413]::query::erase::Erased<[u8; 32usize]>>, false, false, false>, rustc_query_impl[7e84afb844c0dc58]::plumbing::QueryCtxt, false>
  41:     0x7f76a95e2f46 - rustc_query_impl[7e84afb844c0dc58]::query_impl::resolve_instance::get_query_non_incr::__rust_end_short_backtrace
  42:     0x7f76aa626f13 - <rustc_middle[3225073a0293a413]::ty::instance::Instance>::resolve
  43:     0x7f76aa614104 - <rustc_middle[3225073a0293a413]::ty::context::TyCtxt>::const_eval_resolve
  44:     0x7f76a9834dd0 - <rustc_middle[3225073a0293a413]::mir::consts::Const>::eval
  45:     0x7f76a987d7e9 - <rustc_const_eval[c5bff4a87f7085c]::interpret::eval_context::InterpCx<rustc_const_eval[c5bff4a87f7085c]::const_eval::machine::CompileTimeInterpreter>>::push_stack_frame
  46:     0x7f76a99473e4 - rustc_const_eval[c5bff4a87f7085c]::const_eval::eval_queries::eval_in_interpreter::<rustc_middle[3225073a0293a413]::mir::consts::ConstAlloc>
  47:     0x7f76a988dfa4 - rustc_const_eval[c5bff4a87f7085c]::const_eval::eval_queries::eval_to_allocation_raw_provider
  48:     0x7f76a966f2a4 - rustc_query_impl[7e84afb844c0dc58]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[7e84afb844c0dc58]::query_impl::eval_to_allocation_raw::dynamic_query::{closure#2}::{closure#0}, rustc_middle[3225073a0293a413]::query::erase::Erased<[u8; 24usize]>>
  49:     0x7f76a96c53ab - <rustc_query_impl[7e84afb844c0dc58]::query_impl::eval_to_allocation_raw::dynamic_query::{closure#2} as core[b901df56f7100974]::ops::function::FnOnce<(rustc_middle[3225073a0293a413]::ty::context::TyCtxt, rustc_middle[3225073a0293a413]::ty::ParamEnvAnd<rustc_middle[3225073a0293a413]::mir::interpret::GlobalId>)>>::call_once
  50:     0x7f76a94313f5 - <std[15469114d45899b1]::thread::local::LocalKey<core[b901df56f7100974]::cell::Cell<*const ()>>>::with::<rustc_middle[3225073a0293a413]::ty::context::tls::enter_context<rustc_query_system[6530a4bac8984ae5]::query::plumbing::execute_job_non_incr<rustc_query_impl[7e84afb844c0dc58]::DynamicConfig<rustc_query_system[6530a4bac8984ae5]::query::caches::DefaultCache<rustc_middle[3225073a0293a413]::ty::ParamEnvAnd<rustc_middle[3225073a0293a413]::mir::interpret::GlobalId>, rustc_middle[3225073a0293a413]::query::erase::Erased<[u8; 24usize]>>, false, false, false>, rustc_query_impl[7e84afb844c0dc58]::plumbing::QueryCtxt>::{closure#0}, rustc_middle[3225073a0293a413]::query::erase::Erased<[u8; 24usize]>>::{closure#0}, rustc_middle[3225073a0293a413]::query::erase::Erased<[u8; 24usize]>>
  51:     0x7f76a9542722 - rustc_query_system[6530a4bac8984ae5]::query::plumbing::try_execute_query::<rustc_query_impl[7e84afb844c0dc58]::DynamicConfig<rustc_query_system[6530a4bac8984ae5]::query::caches::DefaultCache<rustc_middle[3225073a0293a413]::ty::ParamEnvAnd<rustc_middle[3225073a0293a413]::mir::interpret::GlobalId>, rustc_middle[3225073a0293a413]::query::erase::Erased<[u8; 24usize]>>, false, false, false>, rustc_query_impl[7e84afb844c0dc58]::plumbing::QueryCtxt, false>
  52:     0x7f76a96c59e3 - rustc_query_impl[7e84afb844c0dc58]::query_impl::eval_to_allocation_raw::get_query_non_incr::__rust_end_short_backtrace
  53:     0x7f76a9895342 - rustc_const_eval[c5bff4a87f7085c]::const_eval::valtrees::eval_to_valtree
  54:     0x7f76a98a49c3 - <rustc_const_eval[c5bff4a87f7085c]::provide::{closure#0} as core[b901df56f7100974]::ops::function::FnOnce<(rustc_middle[3225073a0293a413]::ty::context::TyCtxt, rustc_middle[3225073a0293a413]::ty::ParamEnvAnd<rustc_middle[3225073a0293a413]::mir::interpret::GlobalId>)>>::call_once
  55:     0x7f76a9663834 - rustc_query_impl[7e84afb844c0dc58]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[7e84afb844c0dc58]::query_impl::eval_to_valtree::dynamic_query::{closure#2}::{closure#0}, rustc_middle[3225073a0293a413]::query::erase::Erased<[u8; 24usize]>>
  56:     0x7f76a94921cb - <rustc_query_impl[7e84afb844c0dc58]::query_impl::eval_to_valtree::dynamic_query::{closure#2} as core[b901df56f7100974]::ops::function::FnOnce<(rustc_middle[3225073a0293a413]::ty::context::TyCtxt, rustc_middle[3225073a0293a413]::ty::ParamEnvAnd<rustc_middle[3225073a0293a413]::mir::interpret::GlobalId>)>>::call_once
  57:     0x7f76a94313f5 - <std[15469114d45899b1]::thread::local::LocalKey<core[b901df56f7100974]::cell::Cell<*const ()>>>::with::<rustc_middle[3225073a0293a413]::ty::context::tls::enter_context<rustc_query_system[6530a4bac8984ae5]::query::plumbing::execute_job_non_incr<rustc_query_impl[7e84afb844c0dc58]::DynamicConfig<rustc_query_system[6530a4bac8984ae5]::query::caches::DefaultCache<rustc_middle[3225073a0293a413]::ty::ParamEnvAnd<rustc_middle[3225073a0293a413]::mir::interpret::GlobalId>, rustc_middle[3225073a0293a413]::query::erase::Erased<[u8; 24usize]>>, false, false, false>, rustc_query_impl[7e84afb844c0dc58]::plumbing::QueryCtxt>::{closure#0}, rustc_middle[3225073a0293a413]::query::erase::Erased<[u8; 24usize]>>::{closure#0}, rustc_middle[3225073a0293a413]::query::erase::Erased<[u8; 24usize]>>
  58:     0x7f76a9542722 - rustc_query_system[6530a4bac8984ae5]::query::plumbing::try_execute_query::<rustc_query_impl[7e84afb844c0dc58]::DynamicConfig<rustc_query_system[6530a4bac8984ae5]::query::caches::DefaultCache<rustc_middle[3225073a0293a413]::ty::ParamEnvAnd<rustc_middle[3225073a0293a413]::mir::interpret::GlobalId>, rustc_middle[3225073a0293a413]::query::erase::Erased<[u8; 24usize]>>, false, false, false>, rustc_query_impl[7e84afb844c0dc58]::plumbing::QueryCtxt, false>
  59:     0x7f76a9350623 - rustc_query_impl[7e84afb844c0dc58]::query_impl::eval_to_valtree::get_query_non_incr::__rust_end_short_backtrace
  60:     0x7f76aa613366 - rustc_middle[3225073a0293a413]::query::plumbing::query_get_at::<rustc_query_system[6530a4bac8984ae5]::query::caches::DefaultCache<rustc_middle[3225073a0293a413]::ty::ParamEnvAnd<rustc_middle[3225073a0293a413]::mir::interpret::GlobalId>, rustc_middle[3225073a0293a413]::query::erase::Erased<[u8; 24usize]>>>
  61:     0x7f76aa6153cf - <rustc_middle[3225073a0293a413]::ty::context::TyCtxt>::const_eval_global_id_for_typeck
  62:     0x7f76aa614643 - <rustc_middle[3225073a0293a413]::ty::context::TyCtxt>::const_eval_resolve_for_typeck
  63:     0x7f76a9d162cb - <rustc_infer[3ba290eb763f499]::infer::InferCtxt>::const_eval_resolve
  64:     0x7f76a9d11b46 - <rustc_infer[3ba290eb763f499]::infer::InferCtxt>::try_const_eval_resolve
  65:     0x7f76a9b808fa - <rustc_trait_selection[141eeb03ef3b9526]::solve::eval_ctxt::EvalCtxt>::normalize_at_least_one_step
  66:     0x7f76a9a35500 - <rustc_infer[3ba290eb763f499]::infer::InferCtxt>::probe::<core[b901df56f7100974]::result::Result<rustc_type_ir[dca2940381de7990]::canonical::Canonical<rustc_middle[3225073a0293a413]::ty::context::TyCtxt, rustc_middle[3225073a0293a413]::traits::solve::Response>, rustc_middle[3225073a0293a413]::traits::query::NoSolution>, <rustc_trait_selection[141eeb03ef3b9526]::solve::eval_ctxt::probe::ProbeCtxt<<rustc_trait_selection[141eeb03ef3b9526]::solve::eval_ctxt::EvalCtxt>::compute_normalizes_to_goal::{closure#0}::{closure#0}, core[b901df56f7100974]::result::Result<rustc_type_ir[dca2940381de7990]::canonical::Canonical<rustc_middle[3225073a0293a413]::ty::context::TyCtxt, rustc_middle[3225073a0293a413]::traits::solve::Response>, rustc_middle[3225073a0293a413]::traits::query::NoSolution>>>::enter<<rustc_trait_selection[141eeb03ef3b9526]::solve::eval_ctxt::EvalCtxt>::compute_normalizes_to_goal::{closure#0}::{closure#1}>::{closure#0}>
  67:     0x7f76a9b55a90 - <rustc_trait_selection[141eeb03ef3b9526]::solve::eval_ctxt::probe::ProbeCtxt<<rustc_trait_selection[141eeb03ef3b9526]::solve::eval_ctxt::EvalCtxt>::compute_normalizes_to_goal::{closure#0}::{closure#0}, core[b901df56f7100974]::result::Result<rustc_type_ir[dca2940381de7990]::canonical::Canonical<rustc_middle[3225073a0293a413]::ty::context::TyCtxt, rustc_middle[3225073a0293a413]::traits::solve::Response>, rustc_middle[3225073a0293a413]::traits::query::NoSolution>>>::enter::<<rustc_trait_selection[141eeb03ef3b9526]::solve::eval_ctxt::EvalCtxt>::compute_normalizes_to_goal::{closure#0}::{closure#1}>
  68:     0x7f76a9b7a43c - <rustc_trait_selection[141eeb03ef3b9526]::solve::eval_ctxt::EvalCtxt>::compute_goal
  69:     0x7f76a9bf55bd - <rustc_trait_selection[141eeb03ef3b9526]::solve::eval_ctxt::EvalCtxt>::enter_canonical::<core[b901df56f7100974]::result::Result<rustc_type_ir[dca2940381de7990]::canonical::Canonical<rustc_middle[3225073a0293a413]::ty::context::TyCtxt, rustc_middle[3225073a0293a413]::traits::solve::Response>, rustc_middle[3225073a0293a413]::traits::query::NoSolution>, <rustc_trait_selection[141eeb03ef3b9526]::solve::eval_ctxt::EvalCtxt>::evaluate_canonical_goal::{closure#0}::{closure#0}::{closure#0}::{closure#0}>
  70:     0x7f76a9c0c507 - <rustc_query_system[6530a4bac8984ae5]::dep_graph::graph::DepGraph<rustc_middle[3225073a0293a413]::dep_graph::DepsType>>::with_anon_task::<rustc_middle[3225073a0293a413]::ty::context::TyCtxt, <rustc_trait_selection[141eeb03ef3b9526]::solve::search_graph::SearchGraph>::with_new_goal<<rustc_trait_selection[141eeb03ef3b9526]::solve::eval_ctxt::EvalCtxt>::evaluate_canonical_goal::{closure#0}::{closure#0}::{closure#0}>::{closure#3}, (rustc_trait_selection[141eeb03ef3b9526]::solve::search_graph::StackEntry, core[b901df56f7100974]::result::Result<rustc_type_ir[dca2940381de7990]::canonical::Canonical<rustc_middle[3225073a0293a413]::ty::context::TyCtxt, rustc_middle[3225073a0293a413]::traits::solve::Response>, rustc_middle[3225073a0293a413]::traits::query::NoSolution>)>
  71:     0x7f76a9be0165 - <rustc_trait_selection[141eeb03ef3b9526]::solve::search_graph::SearchGraph>::with_new_goal::<<rustc_trait_selection[141eeb03ef3b9526]::solve::eval_ctxt::EvalCtxt>::evaluate_canonical_goal::{closure#0}::{closure#0}::{closure#0}>
  72:     0x7f76a9b7981b - <rustc_trait_selection[141eeb03ef3b9526]::solve::eval_ctxt::EvalCtxt>::evaluate_goal_raw
  73:     0x7f76a9b79419 - <rustc_trait_selection[141eeb03ef3b9526]::solve::eval_ctxt::EvalCtxt>::evaluate_goal
  74:     0x7f76a9bf4db3 - <rustc_trait_selection[141eeb03ef3b9526]::solve::eval_ctxt::EvalCtxt>::enter_root::<core[b901df56f7100974]::result::Result<(bool, rustc_middle[3225073a0293a413]::traits::solve::Certainty), rustc_middle[3225073a0293a413]::traits::query::NoSolution>, <rustc_infer[3ba290eb763f499]::infer::InferCtxt as rustc_trait_selection[141eeb03ef3b9526]::solve::eval_ctxt::InferCtxtEvalExt>::evaluate_root_goal::{closure#0}>
  75:     0x7f76a99c692a - <rustc_infer[3ba290eb763f499]::infer::InferCtxt as rustc_trait_selection[141eeb03ef3b9526]::solve::eval_ctxt::InferCtxtEvalExt>::evaluate_root_goal
  76:     0x7f76a9b4dfc1 - <rustc_trait_selection[141eeb03ef3b9526]::solve::fulfill::FulfillmentCtxt as rustc_infer[3ba290eb763f499]::traits::engine::TraitEngine>::select_where_possible
  77:     0x7f76a9a5930b - <rustc_infer[3ba290eb763f499]::infer::InferCtxt as rustc_trait_selection[141eeb03ef3b9526]::traits::query::evaluate_obligation::InferCtxtExt>::evaluate_obligation::{closure#0}
  78:     0x7f76a9a3a2c9 - <rustc_infer[3ba290eb763f499]::infer::InferCtxt>::probe::<core[b901df56f7100974]::result::Result<rustc_middle[3225073a0293a413]::traits::select::EvaluationResult, rustc_middle[3225073a0293a413]::traits::select::OverflowError>, <rustc_infer[3ba290eb763f499]::infer::InferCtxt as rustc_trait_selection[141eeb03ef3b9526]::traits::query::evaluate_obligation::InferCtxtExt>::evaluate_obligation::{closure#0}>
  79:     0x7f76a99c7a86 - <rustc_infer[3ba290eb763f499]::infer::InferCtxt as rustc_trait_selection[141eeb03ef3b9526]::traits::query::evaluate_obligation::InferCtxtExt>::evaluate_obligation
  80:     0x7f76a99c7d50 - <rustc_infer[3ba290eb763f499]::infer::InferCtxt as rustc_trait_selection[141eeb03ef3b9526]::traits::query::evaluate_obligation::InferCtxtExt>::evaluate_obligation_no_overflow
  81:     0x7f76a99c79ea - <rustc_infer[3ba290eb763f499]::infer::InferCtxt as rustc_trait_selection[141eeb03ef3b9526]::traits::query::evaluate_obligation::InferCtxtExt>::predicate_may_hold
  82:     0x7f76a99c4bab - <rustc_trait_selection[141eeb03ef3b9526]::solve::normalize::NormalizationFolder>::normalize_unevaluated_const
  83:     0x7f76a99c5c5f - <rustc_trait_selection[141eeb03ef3b9526]::solve::normalize::NormalizationFolder as rustc_type_ir[dca2940381de7990]::fold::FallibleTypeFolder<rustc_middle[3225073a0293a413]::ty::context::TyCtxt>>::try_fold_const
  84:     0x7f76a9a216f8 - <rustc_middle[3225073a0293a413]::ty::consts::Const as rustc_type_ir[dca2940381de7990]::fold::TypeFoldable<rustc_middle[3225073a0293a413]::ty::context::TyCtxt>>::try_fold_with::<rustc_trait_selection[141eeb03ef3b9526]::solve::normalize::NormalizationFolder>
  85:     0x7f76a99cb886 - <rustc_middle[3225073a0293a413]::ty::Ty as rustc_type_ir[dca2940381de7990]::fold::TypeSuperFoldable<rustc_middle[3225073a0293a413]::ty::context::TyCtxt>>::try_super_fold_with::<rustc_trait_selection[141eeb03ef3b9526]::solve::normalize::NormalizationFolder>
  86:     0x7f76a99c5342 - <rustc_trait_selection[141eeb03ef3b9526]::solve::normalize::NormalizationFolder as rustc_type_ir[dca2940381de7990]::fold::FallibleTypeFolder<rustc_middle[3225073a0293a413]::ty::context::TyCtxt>>::try_fold_ty
  87:     0x7f76a8dd94a8 - <rustc_middle[3225073a0293a413]::ty::Ty as rustc_type_ir[dca2940381de7990]::fold::TypeFoldable<rustc_middle[3225073a0293a413]::ty::context::TyCtxt>>::try_fold_with::<rustc_trait_selection[141eeb03ef3b9526]::solve::normalize::NormalizationFolder>
  88:     0x7f76a8df5f15 - rustc_trait_selection[141eeb03ef3b9526]::solve::normalize::deeply_normalize::<rustc_middle[3225073a0293a413]::ty::Ty>
  89:     0x7f76a8df132c - <rustc_infer[3ba290eb763f499]::infer::at::At as rustc_trait_selection[141eeb03ef3b9526]::traits::normalize::NormalizeExt>::deeply_normalize::<rustc_middle[3225073a0293a413]::ty::Ty>
  90:     0x7f76a8dd65c1 - <rustc_trait_selection[141eeb03ef3b9526]::traits::engine::ObligationCtxt>::deeply_normalize::<rustc_middle[3225073a0293a413]::ty::Ty>
  91:     0x7f76a8db94eb - <rustc_privacy[cde37e8f24eab9c8]::SearchInterfaceForPrivateItemsVisitor>::ty
  92:     0x7f76a8dbafed - rustc_privacy[cde37e8f24eab9c8]::check_private_in_public
  (additional frames elided)

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: please make sure that you have updated to the latest nightly

note: rustc 1.79.0-dev running on x86_64-unknown-linux-gnu

note: compiler flags: -Z threads=1 -Z simulate-remapped-rust-src-base=/rustc/FAKE_PREFIX -Z translate-remapped-path-to-local-path=no -Z ignore-directory-in-diagnostics-source-blocks=/home/ubuntu/.cargo -Z ignore-directory-in-diagnostics-source-blocks=/home/ubuntu/projects/rust/vendor -C codegen-units=1 -Z ui-testing -Z deduplicate-diagnostics=no -Z write-long-types-to-disk=no -C strip=debuginfo -C prefer-dynamic -C rpath -C debuginfo=0

query stack during panic:
#0 [codegen_select_candidate] computing candidate for `<!0 as Indices<!1>>`
#1 [resolve_instance] resolving instance `<!0 as Indices<!1>>::NUM_ELEMS`
#2 [eval_to_allocation_raw] const-evaluating + checking `Tensor::data::{constant#0}`
#3 [eval_to_valtree] evaluating type-level constant
#4 [check_private_in_public] checking for private elements in public interfaces
#5 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 1 previous error

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*it gets us down to own ICE if I fallback to the unnormalized type in the event of errors. If I don't do that and .unwrap instead, there are many more ICEs:

    [ui] tests/ui/associated-consts/issue-88599-ref-self.rs
    [ui] tests/ui/associated-inherent-types/generic-const-exprs.rs
    [ui] tests/ui/const-generics/generic_const_exprs/assoc_const_unification/const_equate_assoc_consts.rs
    [ui] tests/ui/const-generics/generic_const_exprs/abstract-const-as-cast-1.rs
    [ui] tests/ui/const-generics/generic_const_exprs/eval-privacy.rs
    [ui] tests/ui/const-generics/generic_const_exprs/abstract-const-as-cast-2.rs
    [ui] tests/ui/const-generics/generic_const_exprs/issue-86710.rs
    [ui] tests/ui/const-generics/generic_const_exprs/issue-84408.rs
    [ui] tests/ui/const-generics/generic_const_exprs/issue-97047-ice-1.rs
    [ui] tests/ui/const-generics/generic_const_exprs/issue-96699.rs
    [ui] tests/ui/const-generics/generic_const_exprs/nested_uneval_unification-2.rs
    [ui] tests/ui/const-generics/generic_const_exprs/nested_uneval_unification-1.rs
    [ui] tests/ui/const-generics/generic_const_exprs/issue-82268.rs
    [ui] tests/ui/const-generics/generic_const_exprs/ty-alias-substitution.rs
    [ui] tests/ui/const-generics/generic_const_exprs/poly-const-uneval-ice-106423.rs
    [ui] tests/ui/const-generics/generic_const_exprs/issue-97047-ice-2.rs
    [ui] tests/ui/const-generics/inhabited-assoc-ty-ice-1.rs
    [ui] tests/ui/const-generics/inhabited-assoc-ty-ice-2.rs
    [ui] tests/ui/const-generics/issues/issue-105821.rs
    [ui] tests/ui/const-generics/issues/issue-83288.rs
    [ui] tests/ui/const-generics/issues/issue-90455.rs
    [ui] tests/ui/const-generics/parent_generics_of_encoding.rs
    [ui] tests/ui/const-generics/try_unify_ignore_lifetimes.rs
    [ui] tests/ui/consts/issue-104396.rs
    [ui] tests/ui/generic-const-items/evaluatable-bounds.rs
    [ui] tests/ui/privacy/where-priv-type.rs
    [ui] tests/ui/rfcs/rfc-2632-const-trait-impl/const-trait-bounds.rs
    [ui] tests/ui/specialization/specialization-projection-alias.rs
    [ui] tests/ui/traits/issue-82830.rs

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#![feature(generic_const_exprs)] means you can just move the test back into tests/crashes and mark it known-bug and reopen the issue it refers to.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done! Unfortunately, I don't have the permissions to re-open #83288 (though I presume we wouldn't do so until this is merged, anyways).

jswrenn added a commit to jswrenn/rust that referenced this pull request Jun 11, 2024
@rustbot
Copy link
Collaborator

rustbot commented Jun 11, 2024

These commits modify the Cargo.lock file. Unintentional changes to Cargo.lock can be introduced when switching branches and rebasing PRs.

If this was unintentional then you should revert the changes before this PR is merged.
Otherwise, you can ignore this comment.

@compiler-errors
Copy link
Member

since we're not in a rush, I'd like to do a crater run just to get any regressions out of the way... would rather catch this rather than during beta crater

@bors try

@bors
Copy link
Contributor

bors commented Jun 12, 2024

🔒 Merge conflict

This pull request and the master branch diverged in a way that cannot be automatically merged. Please rebase on top of the latest master branch, and let the reviewer approve again.

How do I rebase?

Assuming self is your fork and upstream is this repository, you can resolve the conflict following these steps:

  1. git checkout fix-45713 (switch to your branch)
  2. git fetch upstream master (retrieve the latest master)
  3. git rebase upstream/master -p (rebase on top of it)
  4. Follow the on-screen instruction to resolve conflicts (check git status if you got lost).
  5. git push self fix-45713 --force-with-lease (update this PR)

You may also read Git Rebasing to Resolve Conflicts by Drew Blessing for a short tutorial.

Please avoid the "Resolve conflicts" button on GitHub. It uses git merge instead of git rebase which makes the PR commit history more difficult to read.

Sometimes step 4 will complete without asking for resolution. This is usually due to difference between how Cargo.lock conflict is handled during merge and rebase. This is normal, and you should still perform step 5 to update this PR.

Error message
Auto-merging compiler/rustc_privacy/src/lib.rs
CONFLICT (content): Merge conflict in compiler/rustc_privacy/src/lib.rs
Auto-merging compiler/rustc_privacy/Cargo.toml
CONFLICT (content): Merge conflict in compiler/rustc_privacy/Cargo.toml
Auto-merging Cargo.lock
CONFLICT (content): Merge conflict in Cargo.lock
warning: inexact rename detection was skipped due to too many files.
warning: you may want to set your merge.renamelimit variable to at least 1604 and retry the command.
Automatic merge failed; fix conflicts and then commit the result.

@lcnr
Copy link
Contributor

lcnr commented Jun 12, 2024

I would block this until the current set of optimizations necessary for bootstrap + fuchsia land, worried that this is going to cause too many hangs if we don't do that. Should take a few weeks

jswrenn added a commit to jswrenn/rust that referenced this pull request Jun 12, 2024
@rustbot rustbot added A-testsuite Area: The testsuite used to check the correctness of rustc T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Jun 12, 2024
@jswrenn
Copy link
Member Author

jswrenn commented Jun 12, 2024

Rebased! Let's see if I have the ability to kick off a try...

@bors try

@bors
Copy link
Contributor

bors commented Jun 12, 2024

@jswrenn: 🔑 Insufficient privileges: not in try users

@compiler-errors
Copy link
Member

@bors try

@bors
Copy link
Contributor

bors commented Jun 12, 2024

⌛ Trying commit c2af856 with merge a317fd9...

bors added a commit to rust-lang-ci/rust that referenced this pull request Jun 12, 2024
privacy: normalize associated types before visiting

This permits associated types to reference private types and traits, so long as the normalized type does not itself violate type privacy.

Fixes rust-lang#45713

<!--
If this PR is related to an unstable feature or an otherwise tracked effort,
please link to the relevant tracking issue here. If you don't know of a related
tracking issue or there are none, feel free to ignore this.

This PR will get automatically assigned to a reviewer. In case you would like
a specific user to review your work, you can assign it to them by using

    r​? <reviewer name>
-->
@bors
Copy link
Contributor

bors commented Jun 13, 2024

💥 Test timed out

@compiler-errors
Copy link
Member

Hrm... this seems to hang a dist build.

Try ./x.py dist locally, perhaps?

@rust-log-analyzer

This comment has been minimized.

@jswrenn
Copy link
Member Author

jswrenn commented Jun 13, 2024

Try ./x.py dist locally, perhaps?

That succeeded locally.

@rust-log-analyzer

This comment has been minimized.

@compiler-errors
Copy link
Member

Could try it again I guess, but otherwise you may need to reach out for help on zulip or spend more time investigating this.

@bors try

bors added a commit to rust-lang-ci/rust that referenced this pull request Jun 18, 2024
privacy: normalize associated types before visiting

This permits associated types to reference private types and traits, so long as the normalized type does not itself violate type privacy.

Fixes rust-lang#45713

<!--
If this PR is related to an unstable feature or an otherwise tracked effort,
please link to the relevant tracking issue here. If you don't know of a related
tracking issue or there are none, feel free to ignore this.

This PR will get automatically assigned to a reviewer. In case you would like
a specific user to review your work, you can assign it to them by using

    r​? <reviewer name>
-->
@bors
Copy link
Contributor

bors commented Jun 18, 2024

⌛ Trying commit c2af856 with merge eac951e...

@bors
Copy link
Contributor

bors commented Jun 18, 2024

💥 Test timed out

@rust-log-analyzer

This comment has been minimized.

@lqd
Copy link
Member

lqd commented Jun 18, 2024

Try to launch the dist builder image locally to reproduce the hang: there’s documentation about testing with docker in the rustc dev guide.

@compiler-errors
Copy link
Member

Probably blocked on the new trait solver. If you still want to land this in some capacity given the hangs in the solver, you should probably reach out over zulip on the t-types stream so we can have a convo w/ @lcnr on what their thoughts are.

@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 9, 2024
@bors
Copy link
Contributor

bors commented Jul 29, 2024

☔ The latest upstream changes (presumably #125443) made this pull request unmergeable. Please resolve the merge conflicts.

jswrenn added a commit to jswrenn/rust that referenced this pull request Aug 21, 2024
@rust-log-analyzer

This comment has been minimized.

@jswrenn
Copy link
Member Author

jswrenn commented Aug 23, 2024

I would block this until the current set of optimizations necessary for bootstrap + fuchsia land, worried that this is going to cause too many hangs if we don't do that. Should take a few weeks

@lcnr How's this going?

@lcnr
Copy link
Contributor

lcnr commented Sep 3, 2024

#128828 has landed now. Other optimizations aren't quite there yet, e.g. one is blocked on #128776 which is currently in the queue.

This permits associated types to reference private types and
traits, so long as the normalized type does not itself violate
type privacy.

Fixes rust-lang#45713
@rust-log-analyzer
Copy link
Collaborator

The job x86_64-gnu-tools failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)

@jswrenn
Copy link
Member Author

jswrenn commented Sep 7, 2024

Yeah, unfortunately, it looks like this still times out. :(

@bors
Copy link
Contributor

bors commented Sep 23, 2024

☔ The latest upstream changes (presumably #130724) made this pull request unmergeable. Please resolve the merge conflicts.

@Dylan-DPC Dylan-DPC added S-blocked Status: Blocked on something else such as an RFC or other implementation work. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-testsuite Area: The testsuite used to check the correctness of rustc S-blocked Status: Blocked on something else such as an RFC or other implementation work. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

private_in_public lint triggered for pub associated type computed using non-pub trait
10 participants