You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Servo’s memory safety unfortunately still depends on a custom lint that checks that GC pointers on the stack are properly rooted: https://github.com/servo/servo/tree/cef98d2e5179/components/script_plugins
I would love to find another solution, this plugin is regularly giving us headaches. But until we do, if the plugin API is removed Servo will be unable to upgrade and will be stuck on an old Rust Nightly.
So there has been no movement since last time we discussed this. That's unfortunate. At some point however, I think it stops being reasonable for rustc to indefinitely maintain the plugin interface solely for the benefit of servo. What would it take to get rid of your reliance on this?
It would take building an alternative.
This thread is to discuss what alternative mechanisms already exist or could be added.
Requirements
Having custom attributes in source code (e.g. on struct definitions), ignored without warning by rustc.
Currently we rely on rustc_plugin::registry::Registry::register_attribute.
My reading of Tracking issue: RFC 2103 - attributes for tools #44690 is that the rustfmt:: and clippy:: attribute namespaces are hard-coded for now, and that the RFC-proposed mechanism for registering more such namespaces / tools is not implemented yet.
The ability to write custom “lints”: arbitrary code that analyses a given crate and can reject it based on:
Access to everything in a crate: type definitions, expressions and sub-expressions
Access to span information, to report the location of an error when there is one
Access to full type information. For example in let x = foo.bar(); the lint wants to find out whether the struct definition for the concrete type of x has one of the previously mentioned custom attributes, even if bar is a trait method that returns an associated type.
The lint only runs for selected crates. Or at least it has access to the crate name (and can exit early based on its own allow-list.)
Running the lint after (or during) a normal cargo build -p script (where script is the crate being linted) does not require recompiling dependencies, nor duplicating much of Cargo’s logic.
As far as I understand, resolving types requires metadata for dependency crates. It’s fine if the lint runs separately from rustc, but reverse-engineering Cargo to find out which of multiple libfoo*.rlib with different hashes in their name is the correct one would be fragile.
Using Rust Nightly through rustup.
Many years ago Servo had custom builds of rustc. It was a pain.
Nice to have
Access to rustc’s mechanism for emitting nicely-formatted diagnostics (not just access to line and column numbers)
The lint being part of normal compilation / checking is ideal.
Reducing reliance on rustc-internal APIs that change often would be nice, to help reduce the frequency of PRs like this: Upgrade to rustc 1.38.0-nightly (273f42b59 2019-07-21) servo/servo#23822. (We’re averaging at 20 days between Nightly upgrades in the last year, mostly because of this.)
I do realize this is in contradiction with many of the other points.
Would it be crazy for RLS to have a non-interactive mode where it dumps everything it knows about a crate into a giant JSON file?
Continuing from #62727 (comment):
It would take building an alternative.
This thread is to discuss what alternative mechanisms already exist or could be added.
Requirements
Having custom attributes in source code (e.g. onstructdefinitions), ignored without warning by rustc.Currently we rely onrustc_plugin::registry::Registry::register_attribute.My reading of Tracking issue: RFC 2103 - attributes for tools #44690 is that therustfmt::andclippy::attribute namespaces are hard-coded for now, and that the RFC-proposed mechanism for registering more such namespaces / tools is not implemented yet.Edit: This is now taken care of by
#![register_tool]: Tracking issue for#![register_tool]#66079The ability to write custom “lints”: arbitrary code that analyses a given crate and can reject it based on:
let x = foo.bar();the lint wants to find out whether the struct definition for the concrete type ofxhas one of the previously mentioned custom attributes, even ifbaris a trait method that returns an associated type.The lint only runs for selected crates. Or at least it has access to the crate name (and can exit early based on its own allow-list.)
Running the lint after (or during) a normal
cargo build -p script(wherescriptis the crate being linted) does not require recompiling dependencies, nor duplicating much of Cargo’s logic.As far as I understand, resolving types requires metadata for dependency crates. It’s fine if the lint runs separately from rustc, but reverse-engineering Cargo to find out which of multiple
libfoo*.rlibwith different hashes in their name is the correct one would be fragile.Using Rust Nightly through rustup.
Many years ago Servo had custom builds of rustc. It was a pain.
Nice to have
Access to rustc’s mechanism for emitting nicely-formatted diagnostics (not just access to line and column numbers)
Running the lint after either
cargo buildorcargo checkdoes not require recompiling/rechecking dependencies. Consider allowing reuse of metadata betweencargo checkandcargo buildcargo#3501 may be relevant.Reducing reliance on rustc-internal APIs that change often would be nice, to help reduce the frequency of PRs like this: Upgrade to rustc 1.38.0-nightly (273f42b59 2019-07-21) servo/servo#23822. (We’re averaging at 20 days between Nightly upgrades in the last year, mostly because of this.)
I do realize this is in contradiction with many of the other points.
@jdm, @Manishearth, @nox: anything to add?