Skip to content
Draft
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
3 changes: 3 additions & 0 deletions src/Lean/Compiler/LCNF/Irrelevant.lean
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ public structure TrivialStructureInfo where
Return `some fieldIdx` if `declName` is the name of an inductive datatype s.t.
- It does not have builtin support in the runtime.
- It has only one constructor.
- The constructor must be as visible as the type, otherwise the compiler may attempt to access
not-imported data.
- This constructor has only one computationally relevant field.
-/
public def Irrelevant.hasTrivialStructure?
Expand All @@ -57,6 +59,7 @@ where fillCache : CoreM (Option TrivialStructureInfo) := do
let .inductInfo info ← getConstInfo declName | return none
if info.isUnsafe || info.isRec then return none
let [ctorName] := info.ctors | return none
if isPrivateName ctorName && !isPrivateName declName then return none
let ctorType ← getOtherDeclBaseType ctorName []
if ctorType.isErased then return none
let mask ← getRelevantCtorFields ctorName trivialType
Expand Down
4 changes: 4 additions & 0 deletions src/Lean/Compiler/LCNF/ToImpureType.lean
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ where fillCache : CoreM Expr := do
let numCtors := ctorNames.length
let mut numScalarCtors := 0
for ctorName in ctorNames do
if isPrivateName ctorName && !isPrivateName name then
-- If the constructor is private but the type is not, we cannot access the constructor's
-- fields and thus must assume it has a non-scalar layout.
return ImpureType.tobject
let some (.ctorInfo ctorInfo) := env.find? ctorName | unreachable!
let hasRelevantField ← Meta.MetaM.run' <|
Meta.forallTelescope ctorInfo.type fun params _ => do
Expand Down
805 changes: 408 additions & 397 deletions stage0/stdlib/Init/Grind/Config.c

Large diffs are not rendered by default.

Loading
Loading