Skip to content

Commit 8c7d9f6

Browse files
committed
fix ice for associated constant generics
1 parent d40f24e commit 8c7d9f6

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

compiler/rustc_span/src/source_map.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -956,7 +956,7 @@ impl SourceMap {
956956
}
957957

958958
pub fn generate_fn_name_span(&self, span: Span) -> Option<Span> {
959-
let prev_span = self.span_extend_to_prev_str(span, "fn", true, true).unwrap_or(span);
959+
let prev_span = self.span_extend_to_prev_str(span, "fn", true, true)?;
960960
if let Ok(snippet) = self.span_to_snippet(prev_span) {
961961
debug!(
962962
"generate_fn_name_span: span={:?}, prev_span={:?}, snippet={:?}",

src/test/ui/generics/issue-98432.rs

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
struct Struct<T>(T);
2+
3+
impl<T> Struct<T> {
4+
const CONST: fn() = || {
5+
struct _Obligation where T:; //~ ERROR can't use generic parameters from outer function
6+
};
7+
}
8+
9+
fn main() {}
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
error[E0401]: can't use generic parameters from outer function
2+
--> $DIR/issue-98432.rs:5:34
3+
|
4+
LL | impl<T> Struct<T> {
5+
| - type parameter from outer function
6+
LL | const CONST: fn() = || {
7+
LL | struct _Obligation where T:;
8+
| ^ use of generic parameter from outer function
9+
|
10+
= help: try using a local generic parameter instead
11+
12+
error: aborting due to previous error
13+
14+
For more information about this error, try `rustc --explain E0401`.

0 commit comments

Comments
 (0)