Skip to content

Rollup of all PRs in queue (temporary integration branch) #27066

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

Merged
merged 72 commits into from
Jul 17, 2015
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
b85aa78
fix typo: "requests function in the same [way] as other"
rutsky Jun 30, 2015
aacb5f6
add missing colon
rutsky Jun 30, 2015
dbaaa2c
remove terminating dot from caption
rutsky Jun 30, 2015
36882a0
rustdoc: Reset the title when pressing the back button
nhowell Jul 2, 2015
0d3954f
reference: improve coercions section
tshepang Jul 5, 2015
4ee7047
reference: miscellaneous fixes
tshepang Jul 5, 2015
e08c5f7
Change some free functions into methods in libsyntax/diagnostic.rs
ftxqxd Jul 6, 2015
c3fd0e1
Remove token::get_name when unneeded
GuillaumeGomez Jul 8, 2015
0bf9fbb
Suggest using `ref` inline in an error
ftxqxd Jul 6, 2015
2e00b31
We just have to replace error codes but code is good now
GuillaumeGomez Jul 11, 2015
8b731a5
Add error codes
GuillaumeGomez Jul 12, 2015
f1b231d
Remove unused method
GuillaumeGomez Jul 12, 2015
48ee57e
Update error codes
GuillaumeGomez Jul 12, 2015
cbf0b1b
Remove warnings by centralizing error codes usage
GuillaumeGomez Jul 13, 2015
4ec3ab6
diagnostics: Fix E0303 explanation.
michaelsproul Jul 13, 2015
26ef17d
Add regression test for #22312
frewsxcv Jul 12, 2015
00f7268
Add regression test for #20544
frewsxcv Jul 12, 2015
9d94ef5
Add regression tests for #23595
frewsxcv Jul 12, 2015
f52a87c
Centralize error spaning and add an enum to make this treatment easier
GuillaumeGomez Jul 13, 2015
eaee43a
Fix section of __morestack for aarch64-unknown-linux-gnu
akosthekiss Jul 13, 2015
2e1f75a
Fixed snippet to return the proper error.
Jul 13, 2015
68781e2
std: Refining crate docs
brson Jul 11, 2015
4089ba8
Fix local path
brson Jul 11, 2015
3a180d1
Address feedback
brson Jul 14, 2015
e6e6368
save-analysis: make generated_code pub
nrc Jul 14, 2015
41b0568
save-analysis: tweak constructors
nrc Jul 14, 2015
94f13ac
save-analysis: handle a few more kinds of paths
nrc Jul 14, 2015
49d3a93
save-analysis: fix def_ids for method calls
nrc Jul 14, 2015
c5f7c19
End of error code spanning centralization
GuillaumeGomez Jul 14, 2015
7954096
Add regression test for #21140
frewsxcv Jul 12, 2015
31262c2
Arguments are now passed directly to the function instead of the enum…
GuillaumeGomez Jul 14, 2015
a878f35
don't ICE when FRU is used on an enum variant
arielb1 Jul 13, 2015
86d954b
core: Revive SipHash's tests
bluss Jul 14, 2015
6d5ae6b
Address more feedback
brson Jul 14, 2015
a266ab0
Mention that removal of `#[packed]` was a breaking change in 1.2
brson Jul 14, 2015
60133aa
Remove macro, import function and enum
GuillaumeGomez Jul 14, 2015
833e88d
Don't mention packed attribute in reference.md
Stebalien Jul 14, 2015
2881bba
Address more feedback
brson Jul 14, 2015
441b1c6
Some more default implementations for the compiler driver callbacks.
nrc Jul 14, 2015
5ec1dea
Change int/uint => isize/usize in compiler docs.
Jul 14, 2015
e8a0328
Ratchet up travis to build stage1 and our own LLVM.
Gankra Jul 14, 2015
98f2872
Add specializations of read_to_end for Stdin, TcpStream and File,
AlisdairO Jul 10, 2015
cfa8e48
doc: add rel=prev/next for links to adjacent sections
vincentbernat Jul 15, 2015
e1073dd
Remove reference to gdb-pretty-struct-and-enums.rs
tamird Jul 16, 2015
feb06b1
Rollup merge of #27061 - tamird:patch-1, r=alexcrichton
Manishearth Jul 16, 2015
9847532
Rollup merge of #26693 - rutsky:patch-1, r=Manishearth
Manishearth Jul 16, 2015
9ac3f42
Rollup merge of #26695 - rutsky:patch-2, r=Manishearth
Manishearth Jul 16, 2015
3a5bc73
Rollup merge of #26977 - brson:stddoc, r=Gankro
Manishearth Jul 16, 2015
62bb71e
Rollup merge of #27013 - michaelsproul:fix-E0303, r=alexcrichton
Manishearth Jul 16, 2015
a4060d0
Rollup merge of #27020 - goyox86:goyox86/fix-error-handling-snippet, …
Manishearth Jul 16, 2015
2c49927
Rollup merge of #27028 - Gankro:travis, r=alexcrichton
Manishearth Jul 16, 2015
43bb514
Rollup merge of #27029 - nrc:save-pub-gen-code, r=alexcrichton
Manishearth Jul 16, 2015
828ebb8
Rollup merge of #26819 - P1start:ref-suggestion, r=nikomatsakis
Manishearth Jul 16, 2015
38e875a
Rollup merge of #26838 - P1start:refactor-diagnostic, r=alexcrichton
Manishearth Jul 16, 2015
1da1a46
Rollup merge of #26898 - GuillaumeGomez:fixup, r=eddyb
Manishearth Jul 16, 2015
12899e7
Rollup merge of #26950 - AlisdairO:memset, r=alexcrichton
Manishearth Jul 16, 2015
31d6716
Rollup merge of #26988 - frewsxcv:regression-tests, r=alexcrichton
Manishearth Jul 16, 2015
b64af26
Rollup merge of #27018 - arielb1:enum-update, r=eddyb
Manishearth Jul 16, 2015
b8a9c80
Rollup merge of #27019 - akiss77:pr-aarch64-morestack-section, r=alex…
Manishearth Jul 16, 2015
77d5fca
Rollup merge of #27030 - nrc:save-ctors, r=alexcrichton
Manishearth Jul 16, 2015
c8ec909
Rollup merge of #27039 - bluss:siphash-tests, r=alexcrichton
Manishearth Jul 16, 2015
2a74fa3
Rollup merge of #27046 - nrc:driver-defaults, r=alexcrichton
Manishearth Jul 16, 2015
30ac7e7
Fixup #27046 with pattern bindings
Manishearth Jul 16, 2015
7c202a3
Fixup test
Manishearth Jul 16, 2015
69e6dc0
Fix diagnostics name clash
Manishearth Jul 16, 2015
3ba0b3c
Merge branch 'fix/doc/rel-prev-next' of https://github.com/vincentber…
steveklabnik Jul 16, 2015
2fb87ed
Merge branch 'uint-usize-rustc-docs' of https://github.com/nham/rust …
steveklabnik Jul 16, 2015
c451bb8
Merge branch 'nopacked' of https://github.com/Stebalien/rust into rol…
steveklabnik Jul 16, 2015
48ddf90
Merge branch 'doc_io_traits_enums' of https://github.com/steveklabnik…
steveklabnik Jul 16, 2015
72722e3
Merge branch 'coercions' of https://github.com/tshepang/rust into rol…
steveklabnik Jul 16, 2015
d354d41
Merge branch 'more-ref-fixes' of https://github.com/tshepang/rust int…
steveklabnik Jul 16, 2015
c9e6d9a
Merge branch 'fix-26673' of https://github.com/nhowell/rust into roll…
steveklabnik Jul 16, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Centralize error spaning and add an enum to make this treatment easier
  • Loading branch information
GuillaumeGomez committed Jul 13, 2015
commit f52a87c44e84a0089819e77ad85ea24b88d547e7
133 changes: 77 additions & 56 deletions src/librustc_resolve/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,24 +116,37 @@ mod record_exports;
mod build_reduced_graph;
mod resolve_imports;

fn resolve_err_417<'a, 'tcx>(this: &Resolver<'a, 'tcx>, span: syntax::codemap::Span, formatted: &str) {
resolve_err!(this, span, E0417, "{}", formatted);
pub enum ResolutionError<'b, 'a:'b, 'tcx:'a> {
/// error: static variables cannot be referenced in a pattern
StaticVariableReference(&'b Resolver<'a, 'tcx>, syntax::codemap::Span),
/// error: does not name a struct
DoesNotNameAStruct(&'b Resolver<'a, 'tcx>, syntax::codemap::Span),
/// error: is a struct variant name, but this expression uses it like a function name
StructVariantUsedAsFunction(&'a Resolver<'a, 'tcx>, syntax::codemap::Span),
/// error: unresolved import
UnresolvedImport(&'b Resolver<'a, 'tcx>, syntax::codemap::Span),
/// error: failed to resolve
FailedToResolve(&'b Resolver<'a, 'tcx>, syntax::codemap::Span),
}

fn resolve_err_422<'a, 'tcx>(this: &Resolver<'a, 'tcx>, span: syntax::codemap::Span, formatted: &str) {
resolve_err!(this, span, E0422, "{}", formatted);
}

fn resolve_err_423<'a, 'tcx>(this: &Resolver<'a, 'tcx>, span: syntax::codemap::Span, formatted: &str) {
resolve_err!(this, span, E0423, "{}", formatted);
}

fn resolve_err_432<'a, 'tcx>(this: &Resolver<'a, 'tcx>, span: syntax::codemap::Span, formatted: &str) {
resolve_err!(this, span, E0432, "{}", formatted);
}

fn resolve_err_433<'a, 'tcx>(this: &Resolver<'a, 'tcx>, span: syntax::codemap::Span, formatted: &str) {
resolve_err!(this, span, E0433, "{}", formatted);
fn resolve_error<'b, 'a:'b, 'tcx:'a>(resolution_error: &ResolutionError<'b, 'a, 'tcx>, formatted: &str) {
match resolution_error {
&ResolutionError::StaticVariableReference(resolver, span) => {
resolve_err!(resolver, span, E0417, "{}", formatted);
},
&ResolutionError::DoesNotNameAStruct(resolver, span) => {
resolve_err!(resolver, span, E0422, "{}", formatted);
},
&ResolutionError::StructVariantUsedAsFunction(resolver, span) => {
resolve_err!(resolver, span, E0423, "{}", formatted);
},
&ResolutionError::UnresolvedImport(resolver, span) => {
resolve_err!(resolver, span, E0432, "{}", formatted);
},
&ResolutionError::FailedToResolve(resolver, span) => {
resolve_err!(resolver, span, E0433, "{}", formatted);
},
}
}

#[derive(Copy, Clone)]
Expand Down Expand Up @@ -1330,7 +1343,10 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
PathSearch,
true) {
Failed(Some((span, msg))) => {
resolve_err_433(self, span, &*format!("failed to resolve. {}", msg));
resolve_error(&ResolutionError::FailedToResolve(self, span),
&*format!("failed to resolve. {}",
msg)
);
},
Failed(None) => (), // Continue up the search chain.
Indeterminate => {
Expand Down Expand Up @@ -1588,12 +1604,13 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
.span_to_snippet((*imports)[index].span)
.unwrap();
if sn.contains("::") {
resolve_err_432(self, (*imports)[index].span, "unresolved import");
resolve_error(&ResolutionError::UnresolvedImport(self, (*imports)[index].span),
"unresolved import");
} else {
resolve_err_432(self, (*imports)[index].span,
&*format!("unresolved import (maybe you meant `{}::*`?)",
sn)
);
resolve_error(&ResolutionError::UnresolvedImport(self, (*imports)[index].span),
&*format!("unresolved import (maybe you meant `{}::*`?)",
sn)
);
}
}

Expand Down Expand Up @@ -2549,10 +2566,10 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
self.record_def(pattern.id, path_res);
}
DefStatic(..) => {
resolve_err_417(self, path.span,
"static variables cannot be \
referenced in a pattern, \
use a `const` instead");
resolve_error(&ResolutionError::StaticVariableReference(&self, path.span),
"static variables cannot be \
referenced in a pattern, \
use a `const` instead");
}
_ => {
// If anything ends up here entirely resolved,
Expand Down Expand Up @@ -2630,7 +2647,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
result => {
debug!("(resolving pattern) didn't find struct \
def: {:?}", result);
resolve_err_422(self, path.span,
resolve_error(&ResolutionError::DoesNotNameAStruct(self, path.span),
&*format!("`{}` does not name a structure",
path_names_to_string(path, 0)));
}
Expand Down Expand Up @@ -2678,10 +2695,10 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
return FoundConst(def, LastMod(AllPublic));
}
DefStatic(..) => {
resolve_err_417(self, span,
"static variables cannot be \
referenced in a pattern, \
use a `const` instead");
resolve_error(&ResolutionError::StaticVariableReference(self, span),
"static variables cannot be \
referenced in a pattern, \
use a `const` instead");
return BareIdentifierPatternUnresolved;
}
_ => {
Expand All @@ -2698,9 +2715,10 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
Failed(err) => {
match err {
Some((span, msg)) => {
resolve_err_433(self, span,
&*format!("failed to resolve: {}",
msg));
resolve_error(&ResolutionError::FailedToResolve(self, span),
&*format!("failed to resolve. {}",
msg)
);
}
None => ()
}
Expand Down Expand Up @@ -2929,9 +2947,10 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
}
};

resolve_err_433(self, span,
&*format!("failed to resolve: {}",
msg));
resolve_error(&ResolutionError::FailedToResolve(self, span),
&*format!("failed to resolve. {}",
msg)
);
return None;
}
Indeterminate => panic!("indeterminate unexpected"),
Expand Down Expand Up @@ -2990,11 +3009,10 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
}
};

/*self.resolve_error(span, &format!("failed to resolve. {}",
msg));*/
resolve_err_433(self, span,
&*format!("failed to resolve: {}",
msg));
resolve_error(&ResolutionError::FailedToResolve(self, span),
&*format!("failed to resolve. {}",
msg)
);
return None;
}

Expand Down Expand Up @@ -3090,9 +3108,10 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
failed to resolve {}", name);

if let Some((span, msg)) = err {
resolve_err_433(self, span,
&*format!("failed to resolve: {}",
msg))
resolve_error(&ResolutionError::FailedToResolve(self, span),
&*format!("failed to resolve. {}",
msg)
)
}

return None;
Expand Down Expand Up @@ -3294,11 +3313,12 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
// Check if struct variant
if let DefVariant(_, _, true) = path_res.base_def {
let path_name = path_names_to_string(path, 0);
resolve_err_423(self, expr.span,
&*format!("`{}` is a struct variant name, but \
this expression \
uses it like a function name",
path_name));

resolve_error(&ResolutionError::StructVariantUsedAsFunction(self, expr.span),
&*format!("`{}` is a struct variant name, but \
this expression \
uses it like a function name",
path_name));

let msg = format!("did you mean to write: \
`{} {{ /* fields */ }}`?",
Expand Down Expand Up @@ -3335,11 +3355,11 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
match type_res.map(|r| r.base_def) {
Some(DefTy(struct_id, _))
if self.structs.contains_key(&struct_id) => {
resolve_err_423(self, expr.span,
&*format!("{}` is a structure name, but \
this expression \
uses it like a function name",
path_name));
resolve_error(&ResolutionError::StructVariantUsedAsFunction(self, expr.span),
&*format!("`{}` is a struct variant name, but \
this expression \
uses it like a function name",
path_name));

let msg = format!("did you mean to write: \
`{} {{ /* fields */ }}`?",
Expand Down Expand Up @@ -3414,7 +3434,8 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
Some(definition) => self.record_def(expr.id, definition),
None => {
debug!("(resolving expression) didn't find struct def",);
resolve_err_422(self, path.span,

resolve_error(&ResolutionError::DoesNotNameAStruct(self, path.span),
&*format!("`{}` does not name a structure",
path_names_to_string(path, 0)));
}
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_resolve/resolve_imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,13 +272,13 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
Some((span, msg)) => (span, format!(". {}", msg)),
None => (import_directive.span, String::new())
};
::resolve_err_432(self.resolver, span,
&*format!("unresolved import `{}`{}",
::resolve_error(&::ResolutionError::UnresolvedImport(self.resolver, span),
&*format!("unresolved import `{}`{}",
import_path_to_string(
&import_directive.module_path,
import_directive.subclass),
help)
);
);
}
ResolveResult::Indeterminate => break, // Bail out. We'll come around next time.
ResolveResult::Success(()) => () // Good. Continue.
Expand Down