Skip to content

Commit

Permalink
Fix ICE in const_trait check code
Browse files Browse the repository at this point in the history
This fixes #102156.
  • Loading branch information
fee1-dead committed Sep 27, 2022
1 parent 57ee5cf commit 27b280e
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
2 changes: 1 addition & 1 deletion compiler/rustc_passes/src/check_const.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ impl<'tcx> Visitor<'tcx> for CheckConstVisitor<'tcx> {
..
}) = item.kind
{
let def_id = trait_ref.trait_def_id().unwrap();
let Some(def_id) = trait_ref.trait_def_id() else { return; };
let source_map = tcx.sess.source_map();
if !tcx.has_attr(def_id, sym::const_trait) {
tcx.sess
Expand Down
15 changes: 15 additions & 0 deletions src/test/ui/rfc-2632-const-trait-impl/issue-102156.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#![feature(allocator_api)]
#![feature(const_trait_impl)]

use core::convert::{From, TryFrom};
//~^ ERROR
//~| ERROR

use std::pin::Pin;
use std::alloc::Allocator;
impl<T: ?Sized, A: Allocator> const From<Box<T, A>> for Pin<Box<T, A>>
where
A: 'static,
{}

pub fn main() {}
19 changes: 19 additions & 0 deletions src/test/ui/rfc-2632-const-trait-impl/issue-102156.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
error[E0433]: failed to resolve: maybe a missing crate `core`?
--> $DIR/issue-102156.rs:4:5
|
LL | use core::convert::{From, TryFrom};
| ^^^^ maybe a missing crate `core`?
|
= help: consider adding `extern crate core` to use the `core` crate

error[E0433]: failed to resolve: maybe a missing crate `core`?
--> $DIR/issue-102156.rs:4:5
|
LL | use core::convert::{From, TryFrom};
| ^^^^ maybe a missing crate `core`?
|
= help: consider adding `extern crate core` to use the `core` crate

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0433`.

0 comments on commit 27b280e

Please sign in to comment.