summary refs log tree commit diff
path: root/src/librustc_resolve
AgeCommit message (Collapse)AuthorLines
2015-12-09Auto merge of #30145 - petrochenkov:hyg, r=nrcbors-16/+14
Instead of `ast::Ident`, bindings, paths and labels in HIR now keep a new structure called `hir::Ident` containing mtwt-renamed `name` and the original not-renamed `unhygienic_name`. `name` is supposed to be used by default, `unhygienic_name` is rarely used. This is not ideal, but better than the status quo for two reasons: - MTWT tables can be cleared immediately after lowering to HIR - This is less bug-prone, because it is impossible now to forget applying `mtwt::resolve` to a name. It is still possible to use `name` instead of `unhygienic_name` by mistake, but `unhygienic_name`s are used only in few very special circumstances, so it shouldn't be a problem. Besides name resolution `unhygienic_name` is used in some lints and debuginfo. `unhygienic_name` can be very well approximated by "reverse renaming" `token::intern(name.as_str())` or even plain string `name.as_str()`, except that it would break gensyms like `iter` in desugared `for` loops. This approximation is likely good enough for lints and debuginfo, but not for name resolution, unfortunately (see https://github.com/rust-lang/rust/issues/27639), so `unhygienic_name` has to be kept. cc https://github.com/rust-lang/rust/issues/29782 r? @nrc
2015-12-07Remove some unnecessary indirection from HIR structuresVadim Petrochenkov-4/+3
2015-12-05Do MTWT resolution during lowering to HIRVadim Petrochenkov-16/+14
2015-12-01Fixes #30089Jeffrey Seyfried-16/+0
2015-11-28Auto merge of #29383 - petrochenkov:empstr, r=pnkfelixbors-1/+1
Fixes https://github.com/rust-lang/rust/issues/28692 Fixes https://github.com/rust-lang/rust/issues/28992 Fixes some other similar issues (see the tests) [breaking-change], needs crater run (cc @brson or @alexcrichton ) The pattern with parens `UnitVariant(..)` for unit variants seems to be popular in rustc (see the second commit), but mostly used by one person (@nikomatsakis), according to git blame. If it causes breakage on crates.io I'll add an exceptional case for it.
2015-11-27Auto merge of #30064 - fhartwig:macro-suggestions, r=sanxiynbors-6/+2
Fixes #13677 This does the same sort of suggestion for misspelt macros that we already do for misspelt identifiers. Example. Compiling this program: ```rust macro_rules! foo { ($e:expr) => ( $e ) } fn main() { fob!("hello!"); } ``` gives the following error message: ``` /Users/mcp/temp/test.rs:7:5: 7:8 error: macro undefined: 'fob!' /Users/mcp/temp/test.rs:7 fob!("hello!"); ^~~ /Users/mcp/temp/test.rs:7:5: 7:8 help: did you mean `foo`? /Users/mcp/temp/test.rs:7 fob!("hello!"); ``` I had to move the levenshtein distance function into libsyntax for this. Maybe this should live somewhere else (some utility crate?), but I couldn't find a crate to put it in that is imported by libsyntax and the other rustc crates.
2015-11-27Introduce max_suggestion_distance function to avoid duplicating the heuristicFlorian Hartwig-6/+2
2015-11-26split the metadata code into rustc_metadataAriel Ben-Yehuda-2/+2
tests & rustdoc still broken
2015-11-26make CrateStore a trait objectAriel Ben-Yehuda-2/+2
rustdoc still broken
2015-11-26remove csearch from resolve and typeckAriel Ben-Yehuda-48/+28
2015-11-26Add suggestion of similar macro names to `macro undefined` error messageFlorian Hartwig-1/+1
2015-11-25Remove all uses of `#[staged_api]`Vadim Petrochenkov-1/+1
2015-11-23Auto merge of #29530 - jseyfried:resolve, r=nikomatsakisbors-819/+371
Replace `TypeNsDef` and `ValueNsDef` with a more general type `NsDef`. Define a newtype `NameBinding` for `Rc<RefCell<Option<NsDef>>>` and refactor `NameBindings` to be a `NameBinding` for each namespace. Replace uses of `NameBindings` with `NameBinding` where only one binding is being used (in `NamespaceResult`, `Target,` etc). Refactor away `resolve_definition_of_name_in_module` and `NameDefinition`, fixing issue #4952.
2015-11-22Look up macro names as well when suggesting replacements for function ↵Manish Goregaokar-5/+21
resolve errors fixes #5780
2015-11-21Auto merge of #29916 - Manishearth:diag-401, r=steveklabnikbors-1/+71
None
2015-11-19Fix the falloutVadim Petrochenkov-1/+1
2015-11-18Various straight-forward ports that override `visit_nested_items`Niko Matsakis-38/+46
to do "in-situ" visits.
2015-11-18Port a bunch of code new-visitor; all of these ports wereNiko Matsakis-5/+2
straightforward uses of `visit_all_items`. In some cases I had to remove empty `visit_item` calls that were just to suppress visiting nested items.
2015-11-19Add long error diagnostics for E0401Manish Goregaokar-1/+71
2015-11-18Refactor away get_module_if_available and get_module and reformat one-linersJeffrey Seyfried-88/+56
2015-11-17Auto merge of #29766 - oli-obk:impl_item, r=nikomatsakisbors-7/+6
[breaking change] I'm not sure if those renames are ok. [TokenType::Tt* to TokenType::*](https://github.com/rust-lang/rust/pull/29582) was obvious, but for all those Item-enums it's less obvious to me what the right way forward is due to the underscore.
2015-11-17Fix issue #21546 and refactor NsDefJeffrey Seyfried-173/+57
2015-11-16Rollup merge of #29796 - barosl:unresolved-import-extern-crate, r=steveklabnikSteve Klabnik-0/+9
The command-line error message for E0432 does mention the possibility of missing the `extern crate` declaration, but the detailed error message for it doesn't. Fixes #29517.
2015-11-16ImplItem_ -> ImplItemKind renameOliver Schneider-4/+4
2015-11-16rename ImplItem_::*ImplItem to ImplItem_::*Oliver Schneider-7/+6
[breaking change]
2015-11-16Refactor fields def_id and kind of Module into a single field def.Jeffrey Seyfried-183/+125
Change build_reduced_graph.rs so the fields def and module of NsDef are never both Some unless the NsDef represents a duplicate definition (see issue 26421).
2015-11-16Replace `TypeNsDef` and `ValueNsDef` with a more general type `NsDef`.Jeffrey Seyfried-478/+236
Define a newtype `NameBinding` for `Rc<RefCell<Option<NsDef>>>` and refactor `NameBindings` to be a `NameBinding` for each namespace. Replace uses of `NameBindings` with `NameBinding` where only one binding is being used (in `NamespaceResult`, `Target,` etc). Refactor away `resolve_definition_of_name_in_module` and `NameDefinition`.
2015-11-14rustfmt librustc_resolvecorentih-1190/+1220
2015-11-12Improve the detailed error message for E0432Barosl Lee-0/+9
The command-line error message for E0432 does mention the possibility of missing the `extern crate` declaration, but the detailed error message for it doesn't. Fixes #29517.
2015-11-12Fixup tidyManish Goregaokar-3/+7
2015-11-12Add more comprehensive diagnostics for irrefutable pattern error with constantsManish Goregaokar-7/+15
Fixes #7526
2015-11-04Unwrap the RefCell around DefMapJonathan S-2/+2
2015-11-03Remove the RefCell around freevars and freevars_seen in librustc_resolveJonathan S-11/+10
2015-11-04Auto merge of #29547 - arielb1:speculative-upvar, r=eddybbors-151/+149
`resolve_identifier` used to mark a variable as an upvar when used within a closure. However, the function is also used for the "unnecessary qualification" lint, which would mark paths whose last component had the same name as a local as upvars. Fixes #29522 r? @eddyb
2015-11-03resolve: don't speculatively create freevars when resolvingAriel Ben-Yehuda-151/+149
Fixes #29522
2015-10-27Auto merge of #26421 - nham:fix_21546, r=pnkfelixbors-0/+45
Fixes #21546.
2015-10-26Auto merge of #29303 - petrochenkov:unistrimp, r=eddybbors-1/+1
And use `VariantData` instead of `P<VariantData>` in `Item_` and `Variant_` Improvements suggested by @eddyb in https://github.com/rust-lang/rust/pull/28816#discussion_r42483587 and https://github.com/rust-lang/rust/pull/28816#discussion_r42483648 plugin-[breaking-change] r? @eddyb
2015-10-25std: Stabilize library APIs for 1.5Alex Crichton-1/+0
This commit stabilizes and deprecates library APIs whose FCP has closed in the last cycle, specifically: Stabilized APIs: * `fs::canonicalize` * `Path::{metadata, symlink_metadata, canonicalize, read_link, read_dir, exists, is_file, is_dir}` - all moved to inherent methods from the `PathExt` trait. * `Formatter::fill` * `Formatter::width` * `Formatter::precision` * `Formatter::sign_plus` * `Formatter::sign_minus` * `Formatter::alternate` * `Formatter::sign_aware_zero_pad` * `string::ParseError` * `Utf8Error::valid_up_to` * `Iterator::{cmp, partial_cmp, eq, ne, lt, le, gt, ge}` * `<[T]>::split_{first,last}{,_mut}` * `Condvar::wait_timeout` - note that `wait_timeout_ms` is not yet deprecated but will be once 1.5 is released. * `str::{R,}MatchIndices` * `str::{r,}match_indices` * `char::from_u32_unchecked` * `VecDeque::insert` * `VecDeque::shrink_to_fit` * `VecDeque::as_slices` * `VecDeque::as_mut_slices` * `VecDeque::swap_remove_front` - (renamed from `swap_front_remove`) * `VecDeque::swap_remove_back` - (renamed from `swap_back_remove`) * `Vec::resize` * `str::slice_mut_unchecked` * `FileTypeExt` * `FileTypeExt::{is_block_device, is_char_device, is_fifo, is_socket}` * `BinaryHeap::from` - `from_vec` deprecated in favor of this * `BinaryHeap::into_vec` - plus a `Into` impl * `BinaryHeap::into_sorted_vec` Deprecated APIs * `slice::ref_slice` * `slice::mut_ref_slice` * `iter::{range_inclusive, RangeInclusive}` * `std::dynamic_lib` Closes #27706 Closes #27725 cc #27726 (align not stabilized yet) Closes #27734 Closes #27737 Closes #27742 Closes #27743 Closes #27772 Closes #27774 Closes #27777 Closes #27781 cc #27788 (a few remaining methods though) Closes #27790 Closes #27793 Closes #27796 Closes #27810 cc #28147 (not all parts stabilized)
2015-10-25syntax/rustc_front: Simplify VariantData::fieldsVadim Petrochenkov-1/+1
And use VariantData instead of P<VariantData> in Item_ and Variant_
2015-10-22Warn when creating a module and a struct that both have the same name.Nick Hamann-0/+45
Currently it is possible to do the following: - define a module named `Foo` and then a unit or tuple struct also named `Foo` - define any struct named `Foo` and then a module named `Foo` This commit introduces a warning for both of these cases.
2015-10-13Merge VariantData and VariantData_Vadim Petrochenkov-4/+6
2015-10-13Merge struct fields and struct kindVadim Petrochenkov-12/+12
2015-10-13Dict -> Struct, StructDef -> VariantData, def -> dataVadim Petrochenkov-7/+7
2015-10-13Provide span for visit_struct_def + remove some dead codeVadim Petrochenkov-1/+2
2015-10-13Remove now redundant NodeId from VariantVadim Petrochenkov-5/+5
2015-10-13Decouple structure kinds from NodeIdsVadim Petrochenkov-6/+6
2015-10-13Unify structures and enum variants in HIRVadim Petrochenkov-18/+4
2015-10-02Rollup merge of #28554 - christopherdumas:E0422, r=arielb1Manish Goregaokar-1/+23
2015-10-01Convert DefId to use DefIndex, which is an index into a list ofNiko Matsakis-2/+2
paths, and construct paths for all definitions. Also, stop rewriting DefIds for closures, and instead just load the closure data from the original def-id, which may be in another crate.
2015-10-01Introduce semi-duplicate DefIds into DefLocal/DefUpvar to remove useNiko Matsakis-4/+6
of xxx_local.