Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The compiler sets bad krate span for plugins #23964

Closed
huonw opened this issue Apr 2, 2015 · 2 comments
Closed

The compiler sets bad krate span for plugins #23964

huonw opened this issue Apr 2, 2015 · 2 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-plugin Area: compiler plugins, doc.rust-lang.org/nightly/unstable-book/language-features/plugin.html P-low Low priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@huonw
Copy link
Member

huonw commented Apr 2, 2015

// bad_plugin_span.rs
#![crate_type="dylib"]
#![feature(plugin_registrar, rustc_private)]

extern crate rustc;

#[plugin_registrar]
pub fn plugin_registrar(reg: &mut rustc::plugin::Registry) {
    println!("{:?}", reg.krate_span);
    reg.sess.span_err(reg.krate_span, "should point to `#[plugin(...)]`");
}
// bad_plugin_span_demo.rs
#![feature(plugin)]
#![plugin(bad_plugin_span)]

fn main() {}
$ rustc bad_plugin_span.rs && rustc -L . bad_plugin_span_demo.rs
Span { lo: BytePos(27), hi: BytePos(87), expn_id: ExpnId(4294967295) }
bad_plugin_span_demo.rs:2:1: 5:12 error: should point to `#[plugin(...)]`
bad_plugin_span_demo.rs:2 #![feature(plugin)]
bad_plugin_span_demo.rs:3 #![plugin(bad_plugin_span)]
bad_plugin_span_demo.rs:4 
bad_plugin_span_demo.rs:5 fn main() {}
error: aborting due to previous error

The krate_span field of the registry should be pointing to the place that introduces the plugin, i.e. the #[plugin(...)] but it is instead pointing to the whole file (at least, from the start of the first token to the end of the last).

@huonw huonw added A-diagnostics Area: Messages for errors, warnings, and lints A-plugin Area: compiler plugins, doc.rust-lang.org/nightly/unstable-book/language-features/plugin.html labels Apr 2, 2015
@brson brson added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. P-low Low priority labels Dec 1, 2016
@brson
Copy link
Contributor

brson commented Dec 1, 2016

Is this still reproducible?

@brson brson added the I-wrong label Dec 1, 2016
@brson
Copy link
Contributor

brson commented Dec 1, 2016

Whatever. Closing because you're old, bug.

@brson brson closed this as completed Dec 1, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-plugin Area: compiler plugins, doc.rust-lang.org/nightly/unstable-book/language-features/plugin.html P-low Low priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

2 participants