Repository: rust
Issue: panic at debug model with "Span must not be empty and have no suggestion"
Labels: I-ICE,T-compiler,C-bug,requires-debug-assertions

<!--
Thank you for filing a bug report! 🐛 Please provide a short summary of the bug,
along with any information you feel relevant to replicating the bug.
-->

This code will panic at debug mode, but not in release version:

```rust


struct S;
impl S {
    fn f(&self) -> &'static str {"s"}
}
fn g(s: &S) -> &str {
    s.f()
}

#[derive(Debug)]
struct S<'a> {
    x: &'a u32,
}
impl<'b> S<'b> {
    fn f(&self) -> &'static str {
        "hello"
    }
}
fn g(s: &S<'_>) -> &'static str {
    s.f()
}
```fn main() {}
```

I expected to see this happen: regular error report

Instead, this happened: 
```
error: unknown start of token: `
   |
22 | ```fn main() {}
   | ^^^
   |
   = note: character appears 2 more times
help: Unicode character '`' (Grave Accent) looks like ''' (Single Quote), but it is not
   |
22 | '''fn main() {}
   | ~~~

error[E0428]: the name `g` is defined multiple times
   |
7  | fn g(s: &S) -> &str {
   | ------------------- previous definition of the value `g` here
...
19 | fn g(s: &S<'_>) -> &'static str {
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `g` redefined here
   |
   = note: `g` must be defined only once in the value namespace of this module

error[E0428]: the name `S` is defined multiple times
   |
3  | struct S;
   | --------- previous definition of the type `S` here
...
11 | struct S<'a> {
   | ^^^^^^^^^^^^ `S` redefined here
   |
   = note: `S` must be defined only once in the type namespace of this module

thread 'rustc' panicked at /rust/compiler/rustc_errors/src/diagnostic.rs:706:9:
Span must not be empty and have no suggestion
```

### Meta
<!--
If you're using the stable version of the compiler, you should also check if the
bug also exists in the beta or nightly versions.
-->

`commit id`:
```
e286f25ec058276c2c83b809f18eaa7e3db52d99
```

<!--
Include a backtrace in the code block by setting `RUST_BACKTRACE=1` in your
environment. E.g. `RUST_BACKTRACE=1 cargo build`.
-->
<details><summary>Backtrace</summary>
<p>

```
thread 'rustc' panicked at /home/ywz/Ruzzing/rust/compiler/rustc_errors/src/diagnostic.rs:706:9:
Span must not be empty and have no suggestion
stack backtrace:
   0: rust_begin_unwind
             at /rustc/439d066bcf9496b1b8c8dde8bef3bce607a621bb/library/std/src/panicking.rs:617:5
   1: core::panicking::panic_fmt
             at /rustc/439d066bcf9496b1b8c8dde8bef3bce607a621bb/library/core/src/panicking.rs:67:14
   2: rustc_errors::diagnostic::Diagnostic::span_suggestion_with_style
             at ./rust/compiler/rustc_errors/src/diagnostic.rs:706:9
   3: rustc_errors::diagnostic::Diagnostic::span_suggestion
             at ./rust/compiler/rustc_errors/src/diagnostic.rs:687:9
   4: rustc_hir_analysis::structured_errors::wrong_number_of_generic_args::WrongNumberOfGenericArgs::suggest_removing_args_or_generics
             at ./rust/compiler/rustc_hir_analysis/src/structured_errors/wrong_number_of_generic_args.rs:984:17
   5: rustc_hir_analysis::structured_errors::wrong_number_of_generic_args::WrongNumberOfGenericArgs::suggest
             at ./rust/compiler/rustc_hir_analysis/src/structured_errors/wrong_number_of_generic_args.rs:555:21
   6: <rustc_hir_analysis::structured_errors::wrong_number_of_generic_args::WrongNumberOfGenericArgs as rustc_hir_analysis::structured_errors::StructuredDiagnostic>::diagnostic_common
             at ./rust/compiler/rustc_hir_analysis/src/structured_errors/wrong_number_of_generic_args.rs:1070:9
   7: rustc_hir_analysis::structured_errors::StructuredDiagnostic::diagnostic
             at ./rust/compiler/rustc_hir_analysis/src/structured_errors.rs:18:19
   8: rustc_hir_analysis::astconv::generics::check_generic_arg_count::{{closure}}
             at ./rust/compiler/rustc_hir_analysis/src/astconv/generics.rs:472:24
   9: rustc_hir_analysis::astconv::generics::check_generic_arg_count
             at ./rust/compiler/rustc_hir_analysis/src/astconv/generics.rs:491:29
  10: <dyn rustc_hir_analysis::astconv::AstConv>::create_args_for_ast_path::{{closure}}
             at ./rust/compiler/rustc_hir_analysis/src/astconv/mod.rs:382:25
  11: <dyn rustc_hir_analysis::astconv::AstConv>::create_args_for_ast_path
             at ./rust/compiler/rustc_hir_analysis/src/astconv/mod.rs:349:5
  12: <dyn rustc_hir_analysis::astconv::AstConv>::ast_path_args_for_ty
             at ./rust/compiler/rustc_hir_analysis/src/astconv/mod.rs:301:25
  13: <dyn rustc_hir_analysis::astconv::AstConv>::ast_path_to_ty
             at ./rust/compiler/rustc_hir_analysis/src/astconv/mod.rs:912:20
  14: <dyn rustc_hir_analysis::astconv::AstConv>::res_to_ty
             at ./rust/compiler/rustc_hir_analysis/src/astconv/mod.rs:2172:17
  15: <dyn rustc_hir_analysis::astconv::AstConv>::ast_ty_to_ty_inner::{{closure}}
             at ./rust/compiler/rustc_hir_analysis/src/astconv/mod.rs:2452:17
  16: <dyn rustc_hir_analysis::astconv::AstConv>::ast_ty_to_ty_inner
             at ./rust/compiler/rustc_hir_analysis/src/astconv/mod.rs:2406:5
  17: <dyn rustc_hir_analysis::astconv::AstConv>::ast_ty_to_ty
             at ./rust/compiler/rustc_hir_analysis/src/astconv/mod.rs:2395:9
  18: rustc_hir_analysis::collect::ItemCtxt::to_ty
             at ./rust/compiler/rustc_hir_analysis/src/collect.rs:344:9
  19: rustc_hir_analysis::collect::type_of::type_of
             at ./rust/compiler/rustc_hir_analysis/src/collect/type_of.rs:425:26
  20: rustc_query_impl::query_impl::type_of::dynamic_query::{{closure}}::{{closure}}
             at ./rust/compiler/rustc_query_impl/src/plumbing.rs:582:47
      [... omitted 21 frames ...]
  21: rustc_middle::query::plumbing::query_ensure
             at ./rust/compiler/rustc_middle/src/query/plumbing.rs:171:9
  22: rustc_middle::query::<impl rustc_middle::query::plumbing::TyCtxtEnsure>::type_of
             at ./rust/compiler/rustc_middle/src/query/plumbing.rs:346:17
  23: rustc_hir_analysis::collect::convert_item
             at ./rust/compiler/rustc_hir_analysis/src/collect.rs:587:13
  24: <rustc_hir_analysis::collect::CollectItemTypesVisitor as rustc_hir::intravisit::Visitor>::visit_item
             at ./rust/compiler/rustc_hir_analysis/src/collect.rs:276:9
  25: rustc_middle::hir::map::Map::visit_item_likes_in_module
             at ./rust/compiler/rustc_middle/src/hir/map/mod.rs:605:13
  26: rustc_hir_analysis::collect::collect_mod_item_types
             at ./rust/compiler/rustc_hir_analysis/src/collect.rs:52:5
  27: rustc_query_impl::query_impl::collect_mod_item_types::dynamic_query::{{closure}}::{{closure}}
             at ./rust/compiler/rustc_query_impl/src/plumbing.rs:582:47
      [... omitted 21 frames ...]
  28: rustc_middle::query::plumbing::query_ensure
             at ./rust/compiler/rustc_middle/src/query/plumbing.rs:171:9
  29: rustc_middle::query::<impl rustc_middle::query::plumbing::TyCtxtEnsure>::collect_mod_item_types
             at ./rust/compiler/rustc_middle/src/query/plumbing.rs:346:17
  30: rustc_hir_analysis::check_crate::{{closure}}::{{closure}}::{{closure}}
             at ./rust/compiler/rustc_hir_analysis/src/lib.rs:195:48
  31: rustc_middle::hir::map::Map::for_each_module
             at ./rust/compiler/rustc_middle/src/hir/map/mod.rs:624:13
  32: rustc_hir_analysis::check_crate::{{closure}}::{{closure}}
             at ./rust/compiler/rustc_hir_analysis/src/lib.rs:195:13
  33: rustc_data_structures::profiling::VerboseTimingGuard::run
             at ./rust/compiler/rustc_data_structures/src/profiling.rs:752:9
  34: rustc_session::utils::<impl rustc_session::session::Session>::time
             at ./rust/compiler/rustc_session/src/utils.rs:12:9
  35: rustc_hir_analysis::check_crate::{{closure}}
             at ./rust/compiler/rustc_hir_analysis/src/lib.rs:194:9
  36: rustc_session::session::Session::track_errors
             at ./rust/compiler/rustc_session/src/session.rs:626:22
  37: rustc_hir_analysis::check_crate
             at ./rust/compiler/rustc_hir_analysis/src/lib.rs:193:5
  38: rustc_interface::passes::analysis
             at ./rust/compiler/rustc_interface/src/passes.rs:761:5
  39: rustc_query_impl::query_impl::analysis::dynamic_query::{{closure}}::{{closure}}
             at ./rust/compiler/rustc_query_impl/src/plumbing.rs:582:47
      [... omitted 21 frames ...]
  40: rustc_middle::query::plumbing::query_get_at
             at ./rust/compiler/rustc_middle/src/query/plumbing.rs:155:17
  41: rustc_middle::query::<impl rustc_middle::query::plumbing::TyCtxtAt>::analysis
             at ./rust/compiler/rustc_middle/src/query/mod.rs:2213:1
  42: rustc_middle::query::<impl rustc_middle::ty::context::TyCtxt>::analysis
             at ./rust/compiler/rustc_middle/src/query/plumbing.rs:376:35
  43: rustc_driver_impl::run_compiler::{{closure}}::{{closure}}::{{closure}}
             at ./rust/compiler/rustc_driver_impl/src/lib.rs:442:52
  44: rustc_middle::ty::context::GlobalCtxt::enter::{{closure}}
             at ./rust/compiler/rustc_middle/src/ty/context.rs:587:37
  45: rustc_middle::ty::context::tls::enter_context::{{closure}}
             at ./rust/compiler/rustc_middle/src/ty/context/tls.rs:82:9
  46: std::thread::local::LocalKey<T>::try_with
             at /rustc/439d066bcf9496b1b8c8dde8bef3bce607a621bb/library/std/src/thread/local.rs:270:16
  47: std::thread::local::LocalKey<T>::with
             at /rustc/439d066bcf9496b1b8c8dde8bef3bce607a621bb/library/std/src/thread/local.rs:246:9
  48: rustc_middle::ty::context::tls::enter_context
             at ./rust/compiler/rustc_middle/src/ty/context/tls.rs:79:9
  49: rustc_middle::ty::context::GlobalCtxt::enter
             at ./rust/compiler/rustc_middle/src/ty/context.rs:587:9
  50: rustc_interface::queries::QueryResult<&rustc_middle::ty::context::GlobalCtxt>::enter
             at ./rust/compiler/rustc_interface/src/queries.rs:70:9
  51: rustc_driver_impl::run_compiler::{{closure}}::{{closure}}
             at ./rust/compiler/rustc_driver_impl/src/lib.rs:442:13
  52: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
             at ./rust/compiler/rustc_interface/src/queries.rs:406:19
  53: rustc_driver_impl::run_compiler::{{closure}}
             at ./rust/compiler/rustc_driver_impl/src/lib.rs:383:22
  54: rustc_interface::interface::run_compiler::{{closure}}::{{closure}}
             at ./rust/compiler/rustc_interface/src/interface.rs:339:21
  55: rustc_span::set_source_map
             at ./rust/compiler/rustc_span/src/lib.rs:1042:5
  56: rustc_interface::interface::run_compiler::{{closure}}
             at ./rust/compiler/rustc_interface/src/interface.rs:333:13
  57: 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
  58: rustc_span::create_session_globals_then
             at ./rust/compiler/rustc_span/src/lib.rs:121:5
  59: rustc_interface::util::run_in_thread_pool_with_globals::{{closure}}::{{closure}}
             at ./rust/compiler/rustc_interface/src/util.rs:163:38
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
```

</p>
</details>