diff options
author | Matthias Krüger <matthias.krueger@famsik.de> | 2022-06-28 18:34:31 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-28 18:34:31 +0200 |
commit | a1b06388ce42ab7dd8aad1aebf87fa5299e2e08a (patch) | |
tree | d8fe8d331c5dc3aab50f5b2f16a3f71db6596371 | |
parent | 28d2c4bd695434b2627ccdb77759fb106473e847 (diff) | |
parent | 8c7d9f609212d4525cc05e2d1d4955425d78f7d8 (diff) | |
download | rust-a1b06388ce42ab7dd8aad1aebf87fa5299e2e08a.tar.gz |
Rollup merge of #98609 - TaKO8Ki:fix-ice-for-associated-constant-generics, r=lcnr
Fix ICE for associated constant generics
Fixes #98432
-rw-r--r-- | compiler/rustc_span/src/source_map.rs | 2 | ||||
-rw-r--r-- | src/test/ui/generics/issue-98432.rs | 9 | ||||
-rw-r--r-- | src/test/ui/generics/issue-98432.stderr | 14 |
3 files changed, 24 insertions, 1 deletions
diff --git a/compiler/rustc_span/src/source_map.rs b/compiler/rustc_span/src/source_map.rs index 95ea7029617..227127aed50 100644 --- a/compiler/rustc_span/src/source_map.rs +++ b/compiler/rustc_span/src/source_map.rs @@ -956,7 +956,7 @@ impl SourceMap { } pub fn generate_fn_name_span(&self, span: Span) -> Option<Span> { - let prev_span = self.span_extend_to_prev_str(span, "fn", true, true).unwrap_or(span); + let prev_span = self.span_extend_to_prev_str(span, "fn", true, true)?; if let Ok(snippet) = self.span_to_snippet(prev_span) { debug!( "generate_fn_name_span: span={:?}, prev_span={:?}, snippet={:?}", diff --git a/src/test/ui/generics/issue-98432.rs b/src/test/ui/generics/issue-98432.rs new file mode 100644 index 00000000000..780c50d6ffa --- /dev/null +++ b/src/test/ui/generics/issue-98432.rs @@ -0,0 +1,9 @@ +struct Struct<T>(T); + +impl<T> Struct<T> { + const CONST: fn() = || { + struct _Obligation where T:; //~ ERROR can't use generic parameters from outer function + }; +} + +fn main() {} diff --git a/src/test/ui/generics/issue-98432.stderr b/src/test/ui/generics/issue-98432.stderr new file mode 100644 index 00000000000..afa67b63bd9 --- /dev/null +++ b/src/test/ui/generics/issue-98432.stderr @@ -0,0 +1,14 @@ +error[E0401]: can't use generic parameters from outer function + --> $DIR/issue-98432.rs:5:34 + | +LL | impl<T> Struct<T> { + | - type parameter from outer function +LL | const CONST: fn() = || { +LL | struct _Obligation where T:; + | ^ use of generic parameter from outer function + | + = help: try using a local generic parameter instead + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0401`. |