Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Simplified TypeInfo, take 2: factor common code in #3206

Merged
merged 18 commits into from
Sep 7, 2020

Conversation

andralex
Copy link
Member

@andralex andralex commented Sep 5, 2020

After working for a while on #3174, I figured I was straying increasingly in breaking compatibility territory. This PR starts from the other end - the currently hardcoded typeinfo implementations are factored into common templates.

@dlang-bot
Copy link
Contributor

Thanks for your pull request, @andralex!

Bugzilla references

Your PR doesn't reference any Bugzilla issue.

If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub run digger -- build "master + druntime#3206"

@MoonlightSentinel
Copy link
Contributor

MoonlightSentinel commented Sep 5, 2020

That's quite an impressive diff.

After working for a while on #3174, I figured I was straying increasingly in breaking compatibility territory.

I would strongly suggest adding more tests before doing this transition- The current coverage is pretty low, see https://codecov.io/gh/dlang/druntime/tree/master/src/rt/typeinfo.

@andralex
Copy link
Member Author

andralex commented Sep 5, 2020

@MoonlightSentinel yah, 2000 negative LOC is quite satisfying. I'm thinking of adding tests after this is pulled so as to not make it even more hairy. Is there a way to see coverage for this PR?

@wilzbach
Copy link
Member

wilzbach commented Sep 5, 2020

@MoonlightSentinel yah, 2000 negative LOC is quite satisfying. I'm thinking of adding tests after this is pulled so as to not make it even more hairy. Is there a way to see coverage for this PR?

Look for CodeCov:

https://github.com/dlang/druntime/pull/3206/checks?check_run_id=1076583494
https://codecov.io/gh/dlang/druntime/pull/3206/tree

@MoonlightSentinel
Copy link
Contributor

I'm thinking of adding tests after this is pulled so as to not make it even more hairy.

It would be better if these tests were based on the current implementation and merged in another PR. That should catch subtle changes in behaviour far more reliably.

Is there a way to see coverage for this PR?

Look for codecov/patch-> Details among the other CI checks.

@andralex
Copy link
Member Author

andralex commented Sep 6, 2020

Actually I saw that coverage hints were right in the diff view - really nice! Added a few, let's see how it works.

@andralex andralex force-pushed the builtin_typeinfo branch 2 times, most recently from f3d9de4 to 2421d94 Compare September 6, 2020 02:02
@andralex
Copy link
Member Author

andralex commented Sep 6, 2020

@MoonlightSentinel thanks for bringing coverage up... turns out that TypeInfo_C was dead code!

@andralex
Copy link
Member Author

andralex commented Sep 6, 2020

Bunch of changes in the generated docs because this eliminates all useless pages such as https://dlang.org/phobos/rt_typeinfo_ti_Along.html.

src/rt/util/typeinfo.d Outdated Show resolved Hide resolved
src/rt/util/typeinfo.d Outdated Show resolved Hide resolved
src/rt/util/typeinfo.d Show resolved Hide resolved
@andralex andralex force-pushed the builtin_typeinfo branch 3 times, most recently from 9a49c7f to 7eae5c7 Compare September 6, 2020 19:24
@andralex
Copy link
Member Author

andralex commented Sep 7, 2020

I have a couple more thoughts, but this step is good enough. Will set auto-merge. Thanks for reviewing!

@dlang-bot dlang-bot merged commit 7771010 into dlang:master Sep 7, 2020
@andralex andralex deleted the builtin_typeinfo branch September 7, 2020 05:00
Copy link
Contributor

@MoonlightSentinel MoonlightSentinel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The module description needs to be updated as well.

On the bright side, the unittests pass with the old & new implementation.

Comment on lines +270 to +275
// Reduces to `T` if `cond` is `true` or `U` otherwise.
private template Select(bool cond, T, U)
{
static if (cond) alias Select = T;
else alias Select = U;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Belongs into core.internal.traits

}

static if (is(T == Base))
override @property size_t tsize() nothrow pure
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Attributes are redundant

}

static if (is(T == Base) || RTInfo!T != RTInfo!Base)
override @property immutable(void)* rtInfo() nothrow pure const @safe
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

@andralex
Copy link
Member Author

andralex commented Sep 8, 2020

@MoonlightSentinel rhanks for reviewing, see #3208

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants