diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2022-09-30 23:38:24 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-09-30 23:38:24 +0200 |
| commit | c07ebeb74bdcc61a432c873035a0623df5465894 (patch) | |
| tree | da53c5676b19f7c6907df729c0fb03402ff67554 | |
| parent | 877877a19a408421486a5077d36e1bfef090e42e (diff) | |
| parent | d7fe44d98814f98354dd29532e01f1836b046d9e (diff) | |
| download | rust-c07ebeb74bdcc61a432c873035a0623df5465894.tar.gz rust-c07ebeb74bdcc61a432c873035a0623df5465894.zip | |
Rollup merge of #102361 - fee1-dead-contrib:fix-102156, r=eholk
Fix ICE in const_trait check code This fixes #102156.
| -rw-r--r-- | compiler/rustc_passes/src/check_const.rs | 2 | ||||
| -rw-r--r-- | src/test/ui/rfc-2632-const-trait-impl/issue-102156.rs | 15 | ||||
| -rw-r--r-- | src/test/ui/rfc-2632-const-trait-impl/issue-102156.stderr | 19 |
3 files changed, 35 insertions, 1 deletions
diff --git a/compiler/rustc_passes/src/check_const.rs b/compiler/rustc_passes/src/check_const.rs index 4062862ad74..116aaf48349 100644 --- a/compiler/rustc_passes/src/check_const.rs +++ b/compiler/rustc_passes/src/check_const.rs @@ -198,8 +198,8 @@ impl<'tcx> Visitor<'tcx> for CheckConstVisitor<'tcx> { of_trait: Some(trait_ref), .. }) = item.kind + && let Some(def_id) = trait_ref.trait_def_id() { - let def_id = trait_ref.trait_def_id().unwrap(); let source_map = tcx.sess.source_map(); if !tcx.has_attr(def_id, sym::const_trait) { tcx.sess diff --git a/src/test/ui/rfc-2632-const-trait-impl/issue-102156.rs b/src/test/ui/rfc-2632-const-trait-impl/issue-102156.rs new file mode 100644 index 00000000000..fe4e9108130 --- /dev/null +++ b/src/test/ui/rfc-2632-const-trait-impl/issue-102156.rs @@ -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() {} diff --git a/src/test/ui/rfc-2632-const-trait-impl/issue-102156.stderr b/src/test/ui/rfc-2632-const-trait-impl/issue-102156.stderr new file mode 100644 index 00000000000..8bf00eaff1f --- /dev/null +++ b/src/test/ui/rfc-2632-const-trait-impl/issue-102156.stderr @@ -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`. |
