mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Improve support for qualification conversions. (#5999)
* Treat `MaybeUnformed` and `partial` as qualifiers, like `const`. * Allow pointer conversions to add qualifiers. * Allow unsafe pointer conversions to remove qualifiers. * Allow conversions on non-reference expressions to drop `const`. * Allow unsafe conversions on any expression to drop `const`. * Allow unsafe conversions on non-initializing expressions to drop `partial`. For initializing expressions, we should initialize the vptr when dropping `partial`; this is not yet supported so we reject. * Allow conversions on reference expressions to add `MaybeUnformed`. * Allow unsafe conversions on reference expressions to drop `MaybeUnformed`. For non-reference expressions, additional work is required, because the value / initializing representation may not match between `T` and `MaybeUnformed(T)`, so those are rejected for now.
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
|
||||
// Exceptions. See /LICENSE for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
// INCLUDE-FILE: toolchain/testing/testdata/min_prelude/parts/destroy.carbon
|
||||
|
||||
// --- min_prelude/parts/maybe_unformed.carbon
|
||||
|
||||
package Core library "prelude/parts/maybe_unformed";
|
||||
|
||||
export import library "prelude/parts/destroy";
|
||||
|
||||
private fn Make(t: type) -> type = "maybe_unformed.make_type";
|
||||
|
||||
class MaybeUnformed(T:! type) {
|
||||
adapt Make(T);
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
|
||||
// Exceptions. See /LICENSE for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
// INCLUDE-FILE: toolchain/testing/testdata/min_prelude/parts/as.carbon
|
||||
// INCLUDE-FILE: toolchain/testing/testdata/min_prelude/parts/maybe_unformed.carbon
|
||||
// EXTRA-ARGS: --custom-core --exclude-dump-file-prefix=min_prelude/
|
||||
|
||||
// --- min_prelude/uint.carbon
|
||||
|
||||
// A minimal prelude for test involving `Core.MaybeUnformed(T)`.
|
||||
package Core library "prelude";
|
||||
|
||||
export import library "prelude/parts/as";
|
||||
export import library "prelude/parts/maybe_unformed";
|
||||
Reference in New Issue
Block a user