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

Improvements of librustc_resolve and add missing error codes #26898

Merged
merged 10 commits into from
Jul 17, 2015

Conversation

GuillaumeGomez
Copy link
Member

r? @eddyb

First part of the improvement. I then intend to improve resolve_error as indicated by @eddyb. Do not merge for now (please !).

@@ -948,7 +948,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
span_err!(self.session, span, E0259,
"an external crate named `{}` has already \
been imported into this module",
&token::get_name(name));
&name);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The & is not necessary (same in a few other places below).

@GuillaumeGomez GuillaumeGomez changed the title Improvements of librustc_resolve Improvements of librustc_resolve and add missing error codes Jul 12, 2015
@GuillaumeGomez
Copy link
Member Author

I'm done here. Can you take a look @eddyb please ?

token::get_name(key),
"#", i + 1, "#"));
key,
"#", i + 1, "#");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason why # can't be part of the format string?

@GuillaumeGomez
Copy link
Member Author

cc @pnkfelix

// NB: This module needs to be declared first so diagnostics are
// registered before they are used.
pub mod diagnostics;

macro_rules! resolve_err {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I continue to argue that this macro is not necessary.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In particular, if all of the places where you current write resolve_err! instead called into one centralized error method in Resolver, then that central error method would then be the place that says, at the beginning:

if !resolver.emit_errors { return; }

@GuillaumeGomez
Copy link
Member Author

Updated.

CannotCaptureDynamicEnvironmentInFnItem(&'b Resolver<'a, 'tcx>, syntax::codemap::Span),
/// error E0435: attempt to use a non-constant value in a constant
AttemptToUseNonConstantValueInConstant(&'b Resolver<'a, 'tcx>, syntax::codemap::Span),
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see why every variant has to repeat the same two fields.

@GuillaumeGomez
Copy link
Member Author

Arguments are now passed directly to the function.

mod check_unused;
mod record_exports;
mod build_reduced_graph;
mod resolve_imports;

pub enum ResolutionError<'b> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be just 'a now.

/// error E0427: cannot use `ref` binding mode with ...
CannotUseRefBindingModeWith(&'b str),
/// error E0428: duplicate definition
DuplicateDefinition(&'b str, &'b str),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Second value can be an ast::Name.

@GuillaumeGomez
Copy link
Member Author

The macro has been removed and few other updates.

AttemptToUseNonConstantValueInConstant,
}

fn resolve_error<'b, 'a:'b, 'tcx:'a>(resolver: &'b Resolver<'a, 'tcx>, span: syntax::codemap::Span,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why does resolution_error need to be a reference?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't, I totally forgot to remove it...

@GuillaumeGomez
Copy link
Member Author

Updated.

@GuillaumeGomez
Copy link
Member Author

r+ or there is something else to be updated ?

@eddyb
Copy link
Member

eddyb commented Jul 15, 2015

@bors r+

@bors
Copy link
Contributor

bors commented Jul 15, 2015

📌 Commit 60133aa has been approved by eddyb

@pnkfelix
Copy link
Member

(This looks great, thanks for all the effort you put into the various revisions here, @GuillaumeGomez ! )

Manishearth added a commit to Manishearth/rust that referenced this pull request Jul 16, 2015
 r? @eddyb

First part of the improvement. I then intend to improve resolve_error as indicated by @eddyb. Do not merge for now (please !).
@GuillaumeGomez
Copy link
Member Author

(You're very welcome @pnkfelix =D)

@bors bors merged commit 60133aa into rust-lang:master Jul 17, 2015
@GuillaumeGomez GuillaumeGomez deleted the fixup branch July 17, 2015 08:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants