Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions compiler/rustc_borrowck/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@ fn mir_borrowck(
def: LocalDefId,
) -> Result<&FxIndexMap<LocalDefId, ty::DefinitionSiteHiddenType<'_>>, ErrorGuaranteed> {
assert!(!tcx.is_typeck_child(def.to_def_id()));
if tcx.is_trivial_const(def) {
debug!("Skipping borrowck because of trivial const");
let opaque_types = Default::default();
return Ok(tcx.arena.alloc(opaque_types));
}
let (input_body, _) = tcx.mir_promoted(def);
debug!("run query mir_borrowck: {}", tcx.def_path_str(def));

Expand Down
11 changes: 11 additions & 0 deletions tests/ui/traits/const-traits/trivial-const-ice-149278.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
trait Trait2: Sized {}

impl Trait2 for () {
const FOO: () = {
//~^ ERROR const `FOO` is not a member of trait `Trait2`
//~^^ ERROR item does not constrain `Assoc::{opaque#0}`
type Assoc = impl Copy; //~ ERROR `impl Trait` in type aliases is unstable
};
}

fn main() {}
37 changes: 37 additions & 0 deletions tests/ui/traits/const-traits/trivial-const-ice-149278.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
error[E0438]: const `FOO` is not a member of trait `Trait2`
--> $DIR/trivial-const-ice-149278.rs:4:5
|
LL | / const FOO: () = {
LL | |
LL | |
LL | | type Assoc = impl Copy;
LL | | };
| |______^ not a member of trait `Trait2`

error[E0658]: `impl Trait` in type aliases is unstable
--> $DIR/trivial-const-ice-149278.rs:7:22
|
LL | type Assoc = impl Copy;
| ^^^^^^^^^
|
= note: see issue #63063 <https://github.com/rust-lang/rust/issues/63063> for more information
= help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date

error: item does not constrain `Assoc::{opaque#0}`
--> $DIR/trivial-const-ice-149278.rs:4:11
|
LL | const FOO: () = {
| ^^^
|
= note: consider removing `#[define_opaque]` or adding an empty `#[define_opaque()]`
note: this opaque type is supposed to be constrained
--> $DIR/trivial-const-ice-149278.rs:7:22
|
LL | type Assoc = impl Copy;
| ^^^^^^^^^

error: aborting due to 3 previous errors

Some errors have detailed explanations: E0438, E0658.
For more information about an error, try `rustc --explain E0438`.
Loading