Merge pull request #121816 from hercules-ci/revert-99132-recursive-type-deprecation

Revert 99132 recursive type deprecation
This commit is contained in:
Silvan Mosberger 2021-05-05 22:43:17 +02:00 committed by GitHub
commit 6a50580cb0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 58 deletions

View file

@ -515,20 +515,11 @@ rec {
# yield a value computed from the definitions
value = if opt ? apply then opt.apply res.mergedValue else res.mergedValue;
# Issue deprecation warnings recursively over all nested types of the
# given type. But don't recurse if a type with the same name was already
# visited before in order to prevent infinite recursion. So this only
# warns once per type name.
# Returns the new set of visited type names
recursiveWarn = visited: type:
let
maybeWarn = warnIf (type.deprecationMessage != null)
"The type `types.${type.name}' of option `${showOption loc}' defined in ${showFiles opt.declarations} is deprecated. ${type.deprecationMessage}";
in
if visited ? ${type.name} then visited
else lib.foldl' recursiveWarn (maybeWarn visited // { ${type.name} = null; }) (lib.attrValues type.nestedTypes);
warnDeprecation =
warnIf (opt.type.deprecationMessage != null)
"The type `types.${opt.type.name}' of option `${showOption loc}' defined in ${showFiles opt.declarations} is deprecated. ${opt.type.deprecationMessage}";
in builtins.seq (recursiveWarn {} opt.type) opt //
in warnDeprecation opt //
{ value = builtins.addErrorContext "while evaluating the option `${showOption loc}':" value;
inherit (res.defsFinal') highestPrio;
definitions = map (def: def.value) res.defsFinal;

View file

@ -272,12 +272,6 @@ checkConfigError 'A definition for option .fun.\[function body\]. is not of type
checkConfigOutput "b a" config.result ./functionTo/list-order.nix
checkConfigOutput "a c" config.result ./functionTo/merging-attrs.nix
## Type deprecation
checkConfigError 'The type `types.simple'\'' of option `simple'\'' defined in .* is deprecated. simple shall not be used' config.simple ./type-deprecation.nix
checkConfigError 'The type `types.infinite'\'' of option `infinite'\'' defined in .* is deprecated. infinite shall not be used' config.infinite ./type-deprecation.nix
checkConfigError 'The type `types.left'\'' of option `nested'\'' defined in .* is deprecated. left shall not be used' config.nested ./type-deprecation.nix
checkConfigError 'The type `types.right'\'' of option `nested'\'' defined in .* is deprecated. right shall not be used' config.nested ./type-deprecation.nix
cat <<EOF
====== module tests ======
$pass Pass

View file

@ -1,39 +0,0 @@
{ lib, ... }: {
options.simple = lib.mkOption {
type = lib.mkOptionType {
name = "simple";
deprecationMessage = "simple shall not be used";
};
default = throw "";
};
options.infinite = lib.mkOption {
type =
let
t = lib.mkOptionType {
name = "infinite";
deprecationMessage = "infinite shall not be used";
};
r = lib.types.either t (lib.types.attrsOf r);
in r;
default = throw "";
};
options.nested = lib.mkOption {
type =
let
left = lib.mkOptionType {
name = "left";
deprecationMessage = "left shall not be used";
};
right = lib.mkOptionType {
name = "right";
deprecationMessage = "right shall not be used";
};
in lib.types.either left right;
default = throw "";
};
}