Repository navigation
imports: own schemas only through package::, parent:: or self:: - #285
Merged
Merged
Conversation
added 2 commits
November 15, 2026 06:31
A bare path to one of the package's own schemas is an error at once, import::bare-own-schema-path, in each form of a use. It carries a fix that writes package:: in front of the path. Paths starting with std, a dependency's name or a relative prefix are as they were, and a path that matches nothing is still import::unresolved. Pin the specification at 6e42967 (specification#12, the imports cases) and vendor its cases. Fixtures, the oracle's rendering, std-free examples and doc tests write package::. Refs #281.
Kinflou
marked this pull request as ready for review
November 14, 2026 22:49
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #282. Refs #281. Rule: Own schemas only through relative paths (docs#178, docs#181). Cases: ComlineProject/specification#12 (part of specification#11).
The rule
Within a package, its own schemas are reached only as
package::...,parent::...orself::.... An absolute first segment of ausemeansstdor a dependency. A bare path that reaches one of the package's own schemas is an error at once, no edition and no warning period.import::bare-own-schema-path(error),import_resolver::BARE_OWN_SCHEMA_PATH. Message:'types::{User, Post}' is one of this package's own schemas, reached by a bare path; context:an absolute path starts with `std` or a dependency's name; 'types' is neither; help:write `package::types::{User, Post}`: a package's own schemas are reached as `package::...`, `parent::...` or `self::...`. Raised bycheck_imports(which the build,check_and_from_declarationsand the language server's mirror already use), for each form of ause: a single item, a whole namespace,{...}and*, with or withoutas.self/parent/package, notstd, not a declared dependency's name, and the path reaches one of the package's own schemas. A path that reaches nothing (use typse::User) is stillimport::unresolved, with its "did you mean".Fixwith one edit, an insertion ofpackage::at the start of the path (titleWrite `package::types::User`), computed from the schema's text (read from its code map) and theusedeclaration's span. It is not offered if the declaration isn'tuse, whitespace, then the path.Fix::applyyields the rewritten file. Qualified references need no rewrite: what an import brings in is the schema's namespace whichever path reached it, sotypes::Userafteruse typesis the same afteruse package::types(a test builds the fixed text with that reference). There was therefore no multi-edit to make, thoughFixsupports one.comline fix: not wired. The CLI'scomline fixappliesDiagnostic::fixfrom source-only checks (edition::check_config,edition::deprecations);check_importsneeds aProjectContextof the package, and nothing in core builds one for the CLI to ask for fixes. The fix is on the public diagnostic; applying it across the package is cli#162.reserved_dependency_name(std,package,parent,self),reject_shadowing_namespaces(core#256), the wordparent. A dependency's andstd's own schemas are still not checked in the consumer (check_importsreturns early for them), as before.Specification pin
comline-catalogandcore/tests/spec/REVat6e42967(head of specification#12; to be re-pinned to the merge commit once it lands), withtests/spec/casesre-vendored byvendor.sh: new groupimports(the cases below), andboundedwritingpackage::models::Blob. TheVendored specification filesjob checks the vendored copy. The cases run incompiler_cases.rsunchanged and pass.Cases (
imports/):bare-own-item|namespace|multi|glob|nested(errorimport::bare-own-schema-path);package-item|namespace|multi|glob|nested,parent-item,self-item(build);dependency-path,std-path(build);unknown-first-segment(import::unresolved);own-schema-named-like-dependency;dependency-named-std|package|parent|self.Changed in core
core/src/schema/ir/compiler/import_resolver.rs: the code,absolute_first_segment, the error and its fix, the check incheck_imports, doc comments; unit-level tests below.core/tests/schema/ir/imports.rs: new tests (each form of ausewith the fix's output, the fixed text builds with its qualified reference, the message, a nested directory, relative forms not flagged, dependency andstdnot flagged, a typo staysimport::unresolved); existing cross-file tests writepackage::.package:::tests/schema/ir/{imports,dataless_arrays,alias_validators}.rs,tests/package/{from_sources,unverified,unverified_inner,unverified_strict,unverified_oracle}.rs,tests/cas/dependency_vendoring_tests.rs(a dependency compiled on its own now writespackage::too),src/doc.rs(doc test sources),examples/imports/src/hole.ids.core/oracle/src/model.rs: the proptest oracle rendersuse package::s0::Tfor a schema of the package itself.tests/spec/{REV,cases/*}andcore/Cargo.toml(thecomline-catalogrev). NoCargo.lockis tracked.std(core_stdlib) has nouseof its own schemas; nothing to change there.No test is weakened, ignored or loosened.
cargo test --workspace --features depspasses locally.Downstream inventory (read-only; nothing edited)
Bare own-schema paths that break or go stale when the repo pins a core with this rule. "Breaks" means a build through core's
check_imports(compile_package,PackageSources) rejects it; "stale" means a fixture or doc that doesn't build through it today but should saypackage::.codegen/src/validation.rs:594(use limits::BASE) andcodegen/src/features.rs:1265("use other", a detail string), bothIncrementalInterpreter::from_source, which checks no imports. Conformance fixtures are frozen IR, not text. No.idsfilescodegen/tests/compiles.rs:1392,use match::Kw(from_source). No.idsfilescodegen/tests/generate.rs:1834-1835(use names::class,use names::function),:1915-1916(use shapes::Layout,use shapes::Promise), viafrom_source. No.idsfilesstd::or a dependency (shared::,greeting::);tests/fixtures/*/src/*.idshave no bare own pathcheck_importsthroughresolve_namespaceand so still accepts them until language-server#122. First segments:types80,a16,b6,other6,rules5,api5,shapes2,more2,chat2,models1; inanalysis/{diagnostics,import_check,imports,project}.rs,handlers/{code_actions,completion,definition,hovers,rename}. Also behaviour, not just fixtures: the "Adduse types::Message" code action (handlers/code_actions.rs:535) anduse-path completion offer own schemas as bare paths. (14shared::lines are a dependency and fine)chat/chat.ids:1,use types::Message(the playground compiles every example:app/src/examples.test.ts).ids(lessons/chat.ids) has nousewasm/src/lib.rs:1281(use other::Thing); breaks through thecomline-examplesdependency aboveruntime/conformance/spec/compiler/cases/bounded.json(use models::Blob, three cases), whichpackage::in the next vendoring replacescapacity-managementalready writesuse package::server::Serverguides/idl/use.md(themypackage::examples at lines 8-10,use other::Userat 45, the error table at 71-72),guides/idl/index.md:61,guides/codegen/generating-code.md:292(use types::Greeting as G); the proposal pages that show the "before" form on purpose (use-paths-and-groups/relative-use.md:27-28,index.md:20) are as they should be. Tracked in docs#182..idsfiles there: 4, none withuse.idsand no matching text(The scan: every
.ids,.rs,.md,.ts,.json,.pyand similar file foruse <word>that isn't Rust's own, classified by whether the first word names a dependency orstd.)CI
Draft; tests run in CI, per job below.