schema internal MAINTENANCE removed new_mods set

... because it is not necessary to have it in the ::lys_parser_ctx.
And it is not used at all in the yang_parse_sub/module or
yin_parse_sub/module functions. In other functions
(lys_resolve_import_include, lys_parse_submodule,
lysp_load_submodules), new_mods is passed as a parameter.
diff --git a/src/parser_internal.h b/src/parser_internal.h
index d8114fc..559d254 100644
--- a/src/parser_internal.h
+++ b/src/parser_internal.h
@@ -91,11 +91,9 @@
  * @param[in] in Input structure.
  * @param[in,out] mod Prepared module structure where the parsed information, including the parsed
  * module structure, will be filled in.
- * @param[in,out] new_mods Set of all the new mods added to the context. Includes this module and all of its imports.
  * @return LY_ERR values.
  */
-LY_ERR yang_parse_module(struct lys_yang_parser_ctx **context, struct ly_in *in, struct lys_module *mod,
-        struct ly_set *new_mods);
+LY_ERR yang_parse_module(struct lys_yang_parser_ctx **context, struct ly_in *in, struct lys_module *mod);
 
 /**
  * @brief Parse module from YIN data.
@@ -104,11 +102,9 @@
  * @param[in] in Input structure.
  * @param[in,out] mod Prepared module structure where the parsed information, including the parsed
  * module structure, will be filled in.
- * @param[in,out] new_mods Set of all the new mods added to the context. Includes this module and all of its imports.
  * @return LY_ERR values.
  */
-LY_ERR yin_parse_module(struct lys_yin_parser_ctx **yin_ctx, struct ly_in *in, struct lys_module *mod,
-        struct ly_set *new_mods);
+LY_ERR yin_parse_module(struct lys_yin_parser_ctx **yin_ctx, struct ly_in *in, struct lys_module *mod);
 
 /**
  * @brief Parse submodule from YIN data.
diff --git a/src/parser_yang.c b/src/parser_yang.c
index fc10bc4..aa35b81 100644
--- a/src/parser_yang.c
+++ b/src/parser_yang.c
@@ -4556,7 +4556,6 @@
     *context = calloc(1, sizeof **context);
     LY_CHECK_ERR_RET(!(*context), LOGMEM(ly_ctx), LY_EMEM);
     (*context)->format = LYS_IN_YANG;
-    (*context)->new_mods = main_ctx->new_mods;
     (*context)->in = in;
 
     mod_p = calloc(1, sizeof *mod_p);
@@ -4617,7 +4616,7 @@
 }
 
 LY_ERR
-yang_parse_module(struct lys_yang_parser_ctx **context, struct ly_in *in, struct lys_module *mod, struct ly_set *new_mods)
+yang_parse_module(struct lys_yang_parser_ctx **context, struct ly_in *in, struct lys_module *mod)
 {
     LY_ERR ret = LY_SUCCESS;
     char *word;
@@ -4629,7 +4628,6 @@
     *context = calloc(1, sizeof **context);
     LY_CHECK_ERR_RET(!(*context), LOGMEM(mod->ctx), LY_EMEM);
     (*context)->format = LYS_IN_YANG;
-    (*context)->new_mods = new_mods;
     (*context)->in = in;
 
     mod_p = calloc(1, sizeof *mod_p);
diff --git a/src/parser_yin.c b/src/parser_yin.c
index c7a2307..ea056cb 100644
--- a/src/parser_yin.c
+++ b/src/parser_yin.c
@@ -3704,7 +3704,6 @@
     *yin_ctx = calloc(1, sizeof **yin_ctx);
     LY_CHECK_ERR_RET(!(*yin_ctx), LOGMEM(ctx), LY_EMEM);
     (*yin_ctx)->format = LYS_IN_YIN;
-    (*yin_ctx)->new_mods = main_ctx->new_mods;
     LY_CHECK_RET(lyxml_ctx_new(ctx, in, &(*yin_ctx)->xmlctx));
 
     mod_p = calloc(1, sizeof *mod_p);
@@ -3760,7 +3759,7 @@
 }
 
 LY_ERR
-yin_parse_module(struct lys_yin_parser_ctx **yin_ctx, struct ly_in *in, struct lys_module *mod, struct ly_set *new_mods)
+yin_parse_module(struct lys_yin_parser_ctx **yin_ctx, struct ly_in *in, struct lys_module *mod)
 {
     LY_ERR ret = LY_SUCCESS;
     enum ly_stmt kw = LY_STMT_NONE;
@@ -3770,7 +3769,6 @@
     *yin_ctx = calloc(1, sizeof **yin_ctx);
     LY_CHECK_ERR_RET(!(*yin_ctx), LOGMEM(mod->ctx), LY_EMEM);
     (*yin_ctx)->format = LYS_IN_YIN;
-    (*yin_ctx)->new_mods = new_mods;
     LY_CHECK_RET(lyxml_ctx_new(mod->ctx, in, &(*yin_ctx)->xmlctx));
 
     mod_p = calloc(1, sizeof *mod_p);
diff --git a/src/tree_schema.c b/src/tree_schema.c
index cebc59d..21188e2 100644
--- a/src/tree_schema.c
+++ b/src/tree_schema.c
@@ -1101,7 +1101,7 @@
 }
 
 static LY_ERR
-lys_resolve_import_include(struct lys_parser_ctx *pctx, struct lysp_module *pmod)
+lys_resolve_import_include(struct lys_parser_ctx *pctx, struct lysp_module *pmod, struct ly_set *new_mods)
 {
     struct lysp_import *imp;
     LY_ARRAY_COUNT_TYPE u, v;
@@ -1110,8 +1110,7 @@
     LY_ARRAY_FOR(pmod->imports, u) {
         imp = &pmod->imports[u];
         if (!imp->module) {
-            LY_CHECK_RET(lys_parse_load(PARSER_CTX(pctx), imp->name, imp->rev[0] ? imp->rev : NULL,
-                    pctx->new_mods, &imp->module));
+            LY_CHECK_RET(lys_parse_load(PARSER_CTX(pctx), imp->name, imp->rev[0] ? imp->rev : NULL, new_mods, &imp->module));
         }
         /* check for importing the same module twice */
         for (v = 0; v < u; ++v) {
@@ -1120,7 +1119,7 @@
             }
         }
     }
-    LY_CHECK_RET(lysp_load_submodules(pctx, pmod));
+    LY_CHECK_RET(lysp_load_submodules(pctx, pmod, new_mods));
 
     pmod->parsing = 0;
 
@@ -1130,7 +1129,7 @@
 LY_ERR
 lys_parse_submodule(struct ly_ctx *ctx, struct ly_in *in, LYS_INFORMAT format, struct lys_parser_ctx *main_ctx,
         LY_ERR (*custom_check)(const struct ly_ctx *, struct lysp_module *, struct lysp_submodule *, void *),
-        void *check_data, struct lysp_submodule **submodule)
+        void *check_data, struct ly_set *new_mods, struct lysp_submodule **submodule)
 {
     LY_ERR ret;
     struct lysp_submodule *submod = NULL, *latest_sp;
@@ -1192,7 +1191,7 @@
     lys_parser_fill_filepath(ctx, in, &submod->filepath);
 
     /* resolve imports and includes */
-    LY_CHECK_GOTO(ret = lys_resolve_import_include(pctx, (struct lysp_module *)submod), error);
+    LY_CHECK_GOTO(ret = lys_resolve_import_include(pctx, (struct lysp_module *)submod, new_mods), error);
 
     /* remap possibly changed and reallocated typedefs and groupings list back to the main context */
     memcpy(&main_ctx->tpdfs_nodes, &pctx->tpdfs_nodes, sizeof main_ctx->tpdfs_nodes);
@@ -1457,11 +1456,11 @@
     /* parse */
     switch (format) {
     case LYS_IN_YIN:
-        ret = yin_parse_module(&yinctx, in, mod, new_mods);
+        ret = yin_parse_module(&yinctx, in, mod);
         pctx = (struct lys_parser_ctx *)yinctx;
         break;
     case LYS_IN_YANG:
-        ret = yang_parse_module(&yangctx, in, mod, new_mods);
+        ret = yang_parse_module(&yangctx, in, mod);
         pctx = (struct lys_parser_ctx *)yangctx;
         break;
     default:
@@ -1570,7 +1569,7 @@
     ctx->change_count++;
 
     /* resolve includes and all imports */
-    LY_CHECK_GOTO(ret = lys_resolve_import_include(pctx, mod->parsed), cleanup);
+    LY_CHECK_GOTO(ret = lys_resolve_import_include(pctx, mod->parsed, new_mods), cleanup);
 
     /* check name collisions */
     LY_CHECK_GOTO(ret = lysp_check_dup_typedefs(pctx, mod->parsed), cleanup);
diff --git a/src/tree_schema_helpers.c b/src/tree_schema_helpers.c
index 865231b..4eea7f0 100644
--- a/src/tree_schema_helpers.c
+++ b/src/tree_schema_helpers.c
@@ -668,7 +668,7 @@
     check_data.path = filepath;
     check_data.submoduleof = main_name;
     if (main_ctx) {
-        ret = lys_parse_submodule(ctx, in, format, main_ctx, lysp_load_module_check, &check_data,
+        ret = lys_parse_submodule(ctx, in, format, main_ctx, lysp_load_module_check, &check_data, new_mods,
                 (struct lysp_submodule **)&mod);
     } else {
         ret = lys_parse_in(ctx, in, format, lysp_load_module_check, &check_data, new_mods, (struct lys_module **)&mod);
@@ -903,7 +903,7 @@
 }
 
 LY_ERR
-lysp_load_submodules(struct lys_parser_ctx *pctx, struct lysp_module *pmod)
+lysp_load_submodules(struct lys_parser_ctx *pctx, struct lysp_module *pmod, struct ly_set *new_mods)
 {
     LY_ARRAY_COUNT_TYPE u;
     struct ly_ctx *ctx = PARSER_CTX(pctx);
@@ -941,7 +941,7 @@
                     check_data.name = inc->name;
                     check_data.revision = inc->rev[0] ? inc->rev : NULL;
                     check_data.submoduleof = pctx->parsed_mod->mod->name;
-                    lys_parse_submodule(ctx, in, format, pctx, lysp_load_module_check, &check_data, &submod);
+                    lys_parse_submodule(ctx, in, format, pctx, lysp_load_module_check, &check_data, new_mods, &submod);
 
                     /* update inc pointer - parsing another (YANG 1.0) submodule can cause injecting
                      * submodule's include into main module, where it is missing */
diff --git a/src/tree_schema_internal.h b/src/tree_schema_internal.h
index 279fcbf..33abb83 100644
--- a/src/tree_schema_internal.h
+++ b/src/tree_schema_internal.h
@@ -147,7 +147,6 @@
     struct ly_set tpdfs_nodes;      /**< set of typedef nodes */
     struct ly_set grps_nodes;       /**< set of grouping nodes */
     struct lysp_module *parsed_mod; /**< (sub)module being parsed */
-    struct ly_set *new_mods;        /**< all modules added to context */
 };
 
 /**
@@ -158,7 +157,6 @@
     struct ly_set tpdfs_nodes;      /**< set of typedef nodes */
     struct ly_set grps_nodes;       /**< set of grouping nodes */
     struct lysp_module *parsed_mod; /**< (sub)module being parsed */
-    struct ly_set *new_mods;        /**< all modules added to context */
     struct ly_in *in;               /**< input handler for the parser */
     uint64_t indent;                /**< current position on the line for YANG indentation */
     uint32_t depth;                 /**< current number of nested blocks, see ::LY_MAX_BLOCK_DEPTH */
@@ -177,7 +175,6 @@
     struct ly_set tpdfs_nodes;     /**< set of typedef nodes */
     struct ly_set grps_nodes;      /**< set of grouping nodes */
     struct lysp_module *parsed_mod;/**< (sub)module being parsed */
-    struct ly_set *new_mods;        /**< all modules added to context */
     struct lyxml_ctx *xmlctx;      /**< context for xml parser */
 };
 
@@ -314,9 +311,10 @@
  *
  * @param[in] pctx main parser context
  * @param[in] pmod Parsed module with the includes array to be processed.
+ * @param[in,out] new_mods Set of all the new mods added to the context. Includes this module and all of its imports.
  * @return LY_ERR value.
  */
-LY_ERR lysp_load_submodules(struct lys_parser_ctx *pctx, struct lysp_module *pmod);
+LY_ERR lysp_load_submodules(struct lys_parser_ctx *pctx, struct lysp_module *pmod, struct ly_set *new_mods);
 
 /**
  * @brief Free a parsed restriction.
@@ -590,11 +588,12 @@
  * @param[in] main_ctx Parser context of the main module.
  * @param[in] custom_check Callback to check the parsed schema before it is accepted.
  * @param[in] check_data Caller's data to pass to the custom_check callback.
+ * @param[in] new_mods Set of all the new mods added to the context. Includes this module and all of its imports.
  * @param[out] submodule Parsed submodule.
  * @return LY_ERR value.
  */
 LY_ERR lys_parse_submodule(struct ly_ctx *ctx, struct ly_in *in, LYS_INFORMAT format, struct lys_parser_ctx *main_ctx,
-        lys_custom_check custom_check, void *check_data, struct lysp_submodule **submodule);
+        lys_custom_check custom_check, void *check_data, struct ly_set *new_mods, struct lysp_submodule **submodule);
 
 /**
  * @brief Fill filepath value if available in input handler @p in
diff --git a/tests/utests/schema/test_parser_yang.c b/tests/utests/schema/test_parser_yang.c
index 3190d40..e48abc4 100644
--- a/tests/utests/schema/test_parser_yang.c
+++ b/tests/utests/schema/test_parser_yang.c
@@ -589,7 +589,6 @@
     struct lysp_module *mod = NULL;
     struct lysp_submodule *submod = NULL;
     struct lys_module *m;
-    struct ly_set new_mods = {0};
     struct lys_yang_parser_ctx *ctx_p;
 
     mod = mod_renew(YCTX);
@@ -761,7 +760,7 @@
     in.current = "module " SCHEMA_BEGINNING "} module q {namespace urn:q;prefixq;}";
     m = calloc(1, sizeof *m);
     m->ctx = YCTX->parsed_mod->mod->ctx;
-    assert_int_equal(LY_EVALID, yang_parse_module(&ctx_p, &in, m, &new_mods));
+    assert_int_equal(LY_EVALID, yang_parse_module(&ctx_p, &in, m));
     CHECK_LOG_CTX("Trailing garbage \"module q {names...\" after module, expected end-of-input.", "Line number 1.");
     yang_parser_ctx_free(ctx_p);
     lys_module_free(m);
@@ -769,7 +768,7 @@
     in.current = "prefix " SCHEMA_BEGINNING "}";
     m = calloc(1, sizeof *m);
     m->ctx = YCTX->parsed_mod->mod->ctx;
-    assert_int_equal(LY_EVALID, yang_parse_module(&ctx_p, &in, m, &new_mods));
+    assert_int_equal(LY_EVALID, yang_parse_module(&ctx_p, &in, m));
     CHECK_LOG_CTX("Invalid keyword \"prefix\", expected \"module\" or \"submodule\".", "Line number 1.");
     yang_parser_ctx_free(ctx_p);
     lys_module_free(m);
@@ -777,7 +776,7 @@
     in.current = "module " SCHEMA_BEGINNING "leaf enum {type enumeration {enum seven { position 7;}}}}";
     m = calloc(1, sizeof *m);
     m->ctx = YCTX->parsed_mod->mod->ctx;
-    assert_int_equal(LY_EVALID, yang_parse_module(&ctx_p, &in, m, &new_mods));
+    assert_int_equal(LY_EVALID, yang_parse_module(&ctx_p, &in, m));
     CHECK_LOG_CTX("Invalid keyword \"position\" as a child of \"enum\".", "Line number 1.");
     yang_parser_ctx_free(ctx_p);
     lys_module_free(m);
diff --git a/tests/utests/schema/test_parser_yin.c b/tests/utests/schema/test_parser_yin.c
index 66b454d..21d5994 100644
--- a/tests/utests/schema/test_parser_yin.c
+++ b/tests/utests/schema/test_parser_yin.c
@@ -3681,7 +3681,6 @@
     struct lys_module *mod;
     struct lys_yin_parser_ctx *yin_ctx = NULL;
     struct ly_in *in = NULL;
-    struct ly_set new_mods = {0};
 
     mod = calloc(1, sizeof *mod);
     mod->ctx = UTEST_LYCTX;
@@ -3707,10 +3706,9 @@
             "    </md:annotation>\n"
             "</module>\n";
     assert_int_equal(ly_in_new_memory(data, &in), LY_SUCCESS);
-    assert_int_equal(yin_parse_module(&yin_ctx, in, mod, &new_mods), LY_SUCCESS);
+    assert_int_equal(yin_parse_module(&yin_ctx, in, mod), LY_SUCCESS);
     assert_null(mod->parsed->exts->child->next->child);
     assert_string_equal(mod->parsed->exts->child->next->arg, "test");
-    ly_set_erase(&new_mods, NULL);
     lys_module_free(mod);
     yin_parser_ctx_free(yin_ctx);
     ly_in_free(in, 0);
@@ -3748,8 +3746,7 @@
             "    </list>\n"
             "</module>\n";
     assert_int_equal(ly_in_new_memory(data, &in), LY_SUCCESS);
-    assert_int_equal(yin_parse_module(&yin_ctx, in, mod, &new_mods), LY_SUCCESS);
-    ly_set_erase(&new_mods, NULL);
+    assert_int_equal(yin_parse_module(&yin_ctx, in, mod), LY_SUCCESS);
     lys_module_free(mod);
     yin_parser_ctx_free(yin_ctx);
     ly_in_free(in, 0);
@@ -3764,8 +3761,7 @@
             "    <prefix value=\"foo\"/>\n"
             "</module>\n";
     assert_int_equal(ly_in_new_memory(data, &in), LY_SUCCESS);
-    assert_int_equal(yin_parse_module(&yin_ctx, in, mod, &new_mods), LY_SUCCESS);
-    ly_set_erase(&new_mods, NULL);
+    assert_int_equal(yin_parse_module(&yin_ctx, in, mod), LY_SUCCESS);
     lys_module_free(mod);
     yin_parser_ctx_free(yin_ctx);
     ly_in_free(in, 0);
@@ -3777,7 +3773,7 @@
     data = "<submodule name=\"example-foo\" xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\">"
             "</submodule>\n";
     assert_int_equal(ly_in_new_memory(data, &in), LY_SUCCESS);
-    assert_int_equal(yin_parse_module(&yin_ctx, in, mod, &new_mods), LY_EINVAL);
+    assert_int_equal(yin_parse_module(&yin_ctx, in, mod), LY_EINVAL);
     CHECK_LOG_CTX("Input data contains submodule which cannot be parsed directly without its main module.", NULL);
     lys_module_free(mod);
     yin_parser_ctx_free(yin_ctx);
@@ -3792,7 +3788,7 @@
             "</module>\n"
             "<module>";
     assert_int_equal(ly_in_new_memory(data, &in), LY_SUCCESS);
-    assert_int_equal(yin_parse_module(&yin_ctx, in, mod, &new_mods), LY_EVALID);
+    assert_int_equal(yin_parse_module(&yin_ctx, in, mod), LY_EVALID);
     CHECK_LOG_CTX("Trailing garbage \"<module>\" after module, expected end-of-input.", "Line number 6.");
     lys_module_free(mod);
     yin_parser_ctx_free(yin_ctx);