From 0775845130f4c1e2bac6d42274e20c6226bc7aec Mon Sep 17 00:00:00 2001 From: Mathias LANG Date: Thu, 6 Apr 2023 16:00:34 +0200 Subject: [PATCH] expressionsem: Remove redundant dependency to dmd.root.file (#15083) FileManager.lookup will already attempt to read the file if it is not cached, and will insert it in the list of files if it manages to read it, so only the 'if (!readResult.success)' branch was reachable. This in turn allows us to remove expressionsem's dependency to dmd.root.file. --- compiler/src/dmd/expressionsem.d | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/compiler/src/dmd/expressionsem.d b/compiler/src/dmd/expressionsem.d index 9880487a00cc..c0a050beaa91 100644 --- a/compiler/src/dmd/expressionsem.d +++ b/compiler/src/dmd/expressionsem.d @@ -65,7 +65,6 @@ import dmd.parse; import dmd.printast; import dmd.root.array; import dmd.root.ctfloat; -import dmd.root.file; import dmd.root.filename; import dmd.common.outbuffer; import dmd.root.rootobject; @@ -6318,19 +6317,8 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor } else { - auto readResult = File.read(resolvedNamez); - if (!readResult.success) - { - e.error("cannot read file `%s`", resolvedNamez.ptr); - return setError(); - } - else - { - // take ownership of buffer (probably leaking) - auto data = readResult.extractSlice(); - se = new StringExp(e.loc, data); - global.fileManager.add(fileName, data); - } + e.error("cannot read file `%s`", resolvedNamez.ptr); + return setError(); } } result = se.expressionSemantic(sc);