Skip to content

Commit

Permalink
Rollup merge of #98609 - TaKO8Ki:fix-ice-for-associated-constant-gene…
Browse files Browse the repository at this point in the history
…rics, r=lcnr

Fix ICE for associated constant generics

Fixes #98432
  • Loading branch information
matthiaskrgr authored Jun 28, 2022
2 parents 28d2c4b + 8c7d9f6 commit a1b0638
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion compiler/rustc_span/src/source_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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={:?}",
Expand Down
9 changes: 9 additions & 0 deletions src/test/ui/generics/issue-98432.rs
Original file line number Diff line number Diff line change
@@ -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() {}
14 changes: 14 additions & 0 deletions src/test/ui/generics/issue-98432.stderr
Original file line number Diff line number Diff line change
@@ -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`.

0 comments on commit a1b0638

Please sign in to comment.