-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #55701 - tromey:ice-fix, r=matthewjasper
Fix emission of niche-filling discriminant values Bug #55606 points out a regression introduced by #54004; namely that an assertion can erroneously fire when a niche-filling discriminant value is emitted. This fixes the bug by removing the assertion, and furthermore by arranging for the discriminant value to be masked according to the size of the niche. This makes handling the discriminant a bit simpler for debuggers. The test case is from Jonathan Turner. Closes #55606
- Loading branch information
Showing
2 changed files
with
67 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT | ||
// file at the top-level directory of this distribution and at | ||
// http://rust-lang.org/COPYRIGHT. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
// This test depends on a patch that was committed to upstream LLVM | ||
// before 7.0, then backported to the Rust LLVM fork. It tests that | ||
// optimized enum debug info accurately reflects the enum layout. | ||
|
||
// ignore-tidy-linelength | ||
// ignore-windows | ||
// min-system-llvm-version 7.0 | ||
|
||
// compile-flags: -g -C no-prepopulate-passes | ||
|
||
// CHECK: {{.*}}DICompositeType{{.*}}tag: DW_TAG_variant_part,{{.*}}size: 32,{{.*}} | ||
// CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}name: "Placeholder",{{.*}}extraData: i64 4294967295{{[,)].*}} | ||
// CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}name: "Error",{{.*}}extraData: i64 0{{[,)].*}} | ||
|
||
#![feature(never_type)] | ||
#![feature(nll)] | ||
|
||
#[derive(Copy, Clone)] | ||
pub struct Entity { | ||
private: std::num::NonZeroU32, | ||
} | ||
|
||
#[derive(Copy, Clone, PartialEq, Eq)] | ||
pub struct Declaration; | ||
|
||
impl TypeFamily for Declaration { | ||
type Base = Base; | ||
type Placeholder = !; | ||
|
||
fn intern_base_data(_: BaseKind<Self>) {} | ||
} | ||
|
||
#[derive(Copy, Clone)] | ||
pub struct Base; | ||
|
||
pub trait TypeFamily: Copy + 'static { | ||
type Base: Copy; | ||
type Placeholder: Copy; | ||
|
||
fn intern_base_data(_: BaseKind<Self>); | ||
} | ||
|
||
#[derive(Copy, Clone)] | ||
pub enum BaseKind<F: TypeFamily> { | ||
Named(Entity), | ||
Placeholder(F::Placeholder), | ||
Error, | ||
} | ||
|
||
pub fn main() { | ||
let x = BaseKind::Error::<Declaration>; | ||
let y = 7; | ||
} |