Fix ICE in const_trait check code

This fixes #102156.
This commit is contained in:
Deadbeef 2022-09-27 13:42:32 +00:00
parent 57ee5cf5a9
commit 27b280e1b5
3 changed files with 35 additions and 1 deletions

View File

@ -199,7 +199,7 @@ fn visit_item(&mut self, item: &'tcx hir::Item<'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

View File

@ -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() {}

View File

@ -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`.