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

Revert 99132 recursive type deprecation

authored by Silvan Mosberger and committed by GitHub 6a50580c a7da21b1

+4 -58
+4 -13
lib/modules.nix
··· 515 # yield a value computed from the definitions 516 value = if opt ? apply then opt.apply res.mergedValue else res.mergedValue; 517 518 - # Issue deprecation warnings recursively over all nested types of the 519 - # given type. But don't recurse if a type with the same name was already 520 - # visited before in order to prevent infinite recursion. So this only 521 - # warns once per type name. 522 - # Returns the new set of visited type names 523 - recursiveWarn = visited: type: 524 - let 525 - maybeWarn = warnIf (type.deprecationMessage != null) 526 - "The type `types.${type.name}' of option `${showOption loc}' defined in ${showFiles opt.declarations} is deprecated. ${type.deprecationMessage}"; 527 - in 528 - if visited ? ${type.name} then visited 529 - else lib.foldl' recursiveWarn (maybeWarn visited // { ${type.name} = null; }) (lib.attrValues type.nestedTypes); 530 531 - in builtins.seq (recursiveWarn {} opt.type) opt // 532 { value = builtins.addErrorContext "while evaluating the option `${showOption loc}':" value; 533 inherit (res.defsFinal') highestPrio; 534 definitions = map (def: def.value) res.defsFinal;
··· 515 # yield a value computed from the definitions 516 value = if opt ? apply then opt.apply res.mergedValue else res.mergedValue; 517 518 + warnDeprecation = 519 + warnIf (opt.type.deprecationMessage != null) 520 + "The type `types.${opt.type.name}' of option `${showOption loc}' defined in ${showFiles opt.declarations} is deprecated. ${opt.type.deprecationMessage}"; 521 522 + in warnDeprecation opt // 523 { value = builtins.addErrorContext "while evaluating the option `${showOption loc}':" value; 524 inherit (res.defsFinal') highestPrio; 525 definitions = map (def: def.value) res.defsFinal;
-6
lib/tests/modules.sh
··· 272 checkConfigOutput "b a" config.result ./functionTo/list-order.nix 273 checkConfigOutput "a c" config.result ./functionTo/merging-attrs.nix 274 275 - ## Type deprecation 276 - checkConfigError 'The type `types.simple'\'' of option `simple'\'' defined in .* is deprecated. simple shall not be used' config.simple ./type-deprecation.nix 277 - checkConfigError 'The type `types.infinite'\'' of option `infinite'\'' defined in .* is deprecated. infinite shall not be used' config.infinite ./type-deprecation.nix 278 - checkConfigError 'The type `types.left'\'' of option `nested'\'' defined in .* is deprecated. left shall not be used' config.nested ./type-deprecation.nix 279 - checkConfigError 'The type `types.right'\'' of option `nested'\'' defined in .* is deprecated. right shall not be used' config.nested ./type-deprecation.nix 280 - 281 cat <<EOF 282 ====== module tests ====== 283 $pass Pass
··· 272 checkConfigOutput "b a" config.result ./functionTo/list-order.nix 273 checkConfigOutput "a c" config.result ./functionTo/merging-attrs.nix 274 275 cat <<EOF 276 ====== module tests ====== 277 $pass Pass
-39
lib/tests/modules/type-deprecation.nix
··· 1 - { lib, ... }: { 2 - 3 - options.simple = lib.mkOption { 4 - type = lib.mkOptionType { 5 - name = "simple"; 6 - deprecationMessage = "simple shall not be used"; 7 - }; 8 - default = throw ""; 9 - }; 10 - 11 - options.infinite = lib.mkOption { 12 - type = 13 - let 14 - t = lib.mkOptionType { 15 - name = "infinite"; 16 - deprecationMessage = "infinite shall not be used"; 17 - }; 18 - r = lib.types.either t (lib.types.attrsOf r); 19 - in r; 20 - default = throw ""; 21 - }; 22 - 23 - options.nested = lib.mkOption { 24 - type = 25 - let 26 - left = lib.mkOptionType { 27 - name = "left"; 28 - deprecationMessage = "left shall not be used"; 29 - }; 30 - right = lib.mkOptionType { 31 - name = "right"; 32 - deprecationMessage = "right shall not be used"; 33 - }; 34 - in lib.types.either left right; 35 - 36 - default = throw ""; 37 - }; 38 - 39 - }
···