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

Assertion fail in debug mode #116502

Closed
thomasyonug opened this issue Oct 7, 2023 · 0 comments · Fixed by #125135
Closed

Assertion fail in debug mode #116502

thomasyonug opened this issue Oct 7, 2023 · 0 comments · Fixed by #125135
Assignees
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-debug-assertions This issue requires a build of rustc or tooling with debug-assertions in some way T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@thomasyonug
Copy link

Code

// run-pass
#![allow(dead_code)]
#![allow(unused_variables)]
macro_rules! Tuple {
    { $A:ty,$B:ty } => { ($A, $B) }
}

fn main() {
    let x: Tuple!(i32, i32) = (1, 2);
}

fn issue_36540() {
    let _ = 0;
    macro_rules! m { () => { _ } }
    struct S<T = m!()>(m!(), T) where T: Trait<m!()>;

    let x: m!() = m!();
    std::cell::Cell::<m!()>::new(m!());
    impl<T> std::ops::Index<m!()> for dyn Trait<(m!(), T)>
        where T: Trait<m!()>
    {
        type Output = m!();
        fn index(&self, i: m!()) -> &m!() {
            unimplemented!()
        }
    }
}

trait Trait<T> {}
impl Trait<i32> for i32 {}

Meta

Error output

thread 'rustc' panicked at rust/compiler/rustc_errors/src/diagnostic.rs:642:9:
assertion `left == right` failed: suggestion must not have overlapping parts
  left: Some([SubstitutionPart { span: fuzz_input.rs:15:30: 15:31 (#5), snippet: "U" }, SubstitutionPart { span: fuzz_input.rs:15:30: 15:31 (#6), snippet: "U" }])
 right: None
Backtrace

stack backtrace:
   0: rust_begin_unwind
             at /rustc/0288f2e1955b154262e0669ec5f7bb9a4c6cf5aa/library/std/src/panicking.rs:597:5
   1: core::panicking::panic_fmt
             at /rustc/0288f2e1955b154262e0669ec5f7bb9a4c6cf5aa/library/core/src/panicking.rs:72:14
   2: core::panicking::assert_failed_inner
   3: core::panicking::assert_failed
             at /rustc/0288f2e1955b154262e0669ec5f7bb9a4c6cf5aa/library/core/src/panicking.rs:270:5
   4: rustc_errors::diagnostic::Diagnostic::multipart_suggestion_with_style
             at ./rust/compiler/rustc_errors/src/diagnostic.rs:642:9
   5: rustc_errors::diagnostic::Diagnostic::multipart_suggestion
             at ./rust/compiler/rustc_errors/src/diagnostic.rs:598:9
   6: rustc_errors::diagnostic_builder::DiagnosticBuilder<G>::multipart_suggestion
             at ./rust/compiler/rustc_errors/src/diagnostic_builder.rs:466:35
   7: rustc_hir_analysis::collect::placeholder_type_error_diag
             at ./rust/compiler/rustc_hir_analysis/src/collect.rs:236:13
   8: rustc_hir_analysis::collect::placeholder_type_error
             at ./rust/compiler/rustc_hir_analysis/src/collect.rs:169:5
   9: rustc_hir_analysis::collect::reject_placeholder_type_signatures_in_item
             at ./rust/compiler/rustc_hir_analysis/src/collect.rs:267:5
  10: <rustc_hir_analysis::collect::CollectItemTypesVisitor as rustc_hir::intravisit::Visitor>::visit_item
             at ./rust/compiler/rustc_hir_analysis/src/collect.rs:279:9
  11: rustc_middle::hir::map::Map::visit_item_likes_in_module
             at ./rust/compiler/rustc_middle/src/hir/map/mod.rs:606:13
  12: rustc_hir_analysis::collect::collect_mod_item_types
             at ./rust/compiler/rustc_hir_analysis/src/collect.rs:53:5
  13: rustc_query_impl::query_impl::collect_mod_item_types::dynamic_query::{{closure}}::{{closure}}
             at ./rust/compiler/rustc_query_impl/src/plumbing.rs:585:47
      [... omitted 21 frames ...]
  14: rustc_middle::query::plumbing::query_ensure
             at ./rust/compiler/rustc_middle/src/query/plumbing.rs:172:9
  15: rustc_middle::query::<impl rustc_middle::query::plumbing::TyCtxtEnsure>::collect_mod_item_types
             at ./rust/compiler/rustc_middle/src/query/plumbing.rs:347:17
  16: rustc_hir_analysis::check_crate::{{closure}}::{{closure}}::{{closure}}
             at ./rust/compiler/rustc_hir_analysis/src/lib.rs:171:48
  17: rustc_middle::hir::map::Map::for_each_module
             at ./rust/compiler/rustc_middle/src/hir/map/mod.rs:625:13
  18: rustc_hir_analysis::check_crate::{{closure}}::{{closure}}
             at ./rust/compiler/rustc_hir_analysis/src/lib.rs:171:13
  19: rustc_data_structures::profiling::VerboseTimingGuard::run
             at ./rust/compiler/rustc_data_structures/src/profiling.rs:752:9
  20: rustc_session::utils::<impl rustc_session::session::Session>::time
             at ./rust/compiler/rustc_session/src/utils.rs:12:9
  21: rustc_hir_analysis::check_crate::{{closure}}
             at ./rust/compiler/rustc_hir_analysis/src/lib.rs:170:9
  22: rustc_session::session::Session::track_errors
             at ./rust/compiler/rustc_session/src/session.rs:578:22
  23: rustc_hir_analysis::check_crate
             at ./rust/compiler/rustc_hir_analysis/src/lib.rs:169:5
  24: rustc_interface::passes::analysis
             at ./rust/compiler/rustc_interface/src/passes.rs:775:5
  25: rustc_query_impl::query_impl::analysis::dynamic_query::{{closure}}::{{closure}}
             at ./rust/compiler/rustc_query_impl/src/plumbing.rs:585:47
      [... omitted 21 frames ...]
  26: rustc_middle::query::plumbing::query_get_at
             at ./rust/compiler/rustc_middle/src/query/plumbing.rs:156:17
  27: rustc_middle::query::<impl rustc_middle::query::plumbing::TyCtxtAt>::analysis
             at ./rust/compiler/rustc_middle/src/query/mod.rs:2199:1
  28: rustc_middle::query::<impl rustc_middle::ty::context::TyCtxt>::analysis
             at ./rust/compiler/rustc_middle/src/query/plumbing.rs:377:35
  29: rustc_driver_impl::run_compiler::{{closure}}::{{closure}}::{{closure}}
             at ./rust/compiler/rustc_driver_impl/src/lib.rs:446:52
  30: rustc_middle::ty::context::GlobalCtxt::enter::{{closure}}
             at ./rust/compiler/rustc_middle/src/ty/context.rs:598:37
  31: rustc_middle::ty::context::tls::enter_context::{{closure}}
             at ./rust/compiler/rustc_middle/src/ty/context/tls.rs:82:9
  32: std::thread::local::LocalKey<T>::try_with
             at /rustc/0288f2e1955b154262e0669ec5f7bb9a4c6cf5aa/library/std/src/thread/local.rs:270:16
  33: std::thread::local::LocalKey<T>::with
             at /rustc/0288f2e1955b154262e0669ec5f7bb9a4c6cf5aa/library/std/src/thread/local.rs:246:9
  34: rustc_middle::ty::context::tls::enter_context
             at ./rust/compiler/rustc_middle/src/ty/context/tls.rs:79:9
  35: rustc_middle::ty::context::GlobalCtxt::enter
             at ./rust/compiler/rustc_middle/src/ty/context.rs:598:9
  36: rustc_driver_impl::run_compiler::{{closure}}::{{closure}}
             at ./rust/compiler/rustc_driver_impl/src/lib.rs:446:13
  37: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
             at ./rust/compiler/rustc_interface/src/queries.rs:373:19
  38: rustc_driver_impl::run_compiler::{{closure}}
             at ./rust/compiler/rustc_driver_impl/src/lib.rs:387:22
  39: rustc_interface::interface::run_compiler::{{closure}}::{{closure}}
             at ./rust/compiler/rustc_interface/src/interface.rs:346:21
  40: rustc_span::set_source_map
             at ./rust/compiler/rustc_span/src/lib.rs:1063:5
  41: rustc_interface::interface::run_compiler::{{closure}}
             at ./rust/compiler/rustc_interface/src/interface.rs:340:13
  42: scoped_tls::ScopedKey<T>::set
             at /home/ywz/.cargo/registry/src/index.crates.io-6f17d22bba15001f/scoped-tls-1.0.1/src/lib.rs:137:9
  43: rustc_span::create_session_globals_then
             at ./rust/compiler/rustc_span/src/lib.rs:123:5
  44: rustc_interface::util::run_in_thread_with_globals::{{closure}}::{{closure}}
             at ./rust/compiler/rustc_interface/src/util.rs:163:38

@thomasyonug thomasyonug added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 7, 2023
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Oct 7, 2023
@chenyukang chenyukang self-assigned this Oct 7, 2023
@saethlin saethlin removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Oct 7, 2023
@jieyouxu jieyouxu added the requires-debug-assertions This issue requires a build of rustc or tooling with debug-assertions in some way label Feb 20, 2024
@bors bors closed this as completed in 5f1a120 May 15, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue May 15, 2024
Rollup merge of rust-lang#125135 - chenyukang:yukang-fix-116502, r=compiler-errors

Fix the dedup error because of spans from suggestion

Fixes rust-lang#116502

I believe this kind of issue is supposed resolved by rust-lang#118057, but the `==` in `span` respect syntax context, here we should only care that they point to the same bytes of source text, so should use `source_equal`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-debug-assertions This issue requires a build of rustc or tooling with debug-assertions in some way T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
5 participants