about summary refs log tree commit diff
path: root/compiler/rustc_resolve/src
AgeCommit message (Collapse)AuthorLines
2022-01-09Rollup merge of #92510 - inquisitivecrystal:foreign-block, r=cjgillotMatthias Krüger-3/+10
Don't resolve blocks in foreign functions Although it is an error for a foreign function to have a block, it is still possible at the level of the AST. #74204 made AST lowering skip over blocks belonging to foreign functions, since they're invalid. However, resolve still treated these blocks normally, resulting in a mismatch between the HIR and resolve, which could cause an ICE under certain circumstances. This PR changes resolve to skip over blocks belonging to foreign functions, as AST lowering does. Fixes #91370. r? ``@cjgillot``
2022-01-09rustc_middle: Rename `Export` to `ModChild` and add some commentsVadim Petrochenkov-12/+12
Also rename `module_exports`/`export_map` to `module_reexports`/`reexport_map` for clarity.
2022-01-09rustc_metadata: Rename `item_children(_untracked)` to ↵Vadim Petrochenkov-1/+1
`module_children(_untracked)` And `each_child_of_item` to `for_each_module_child`
2022-01-08Simplify error reporting.Camille GILLOT-38/+42
2022-01-08Link impl items to corresponding trait items in late resolver.Camille GILLOT-16/+88
2022-01-06rustc_metadata: Make attribute decoding slightly faster and stricterVadim Petrochenkov-5/+7
Rename `CStore::item_attrs` -> `CStore::item_attrs_untracked` top follow conventions
2022-01-05Do not resolve blocks in foreign functionsinquisitivecrystal-3/+10
2022-01-05ast: Always keep a `NodeId` in `ast::Crate`Vadim Petrochenkov-8/+7
This makes it more uniform with other expanded nodes
2022-01-03Rollup merge of #92402 - pr2502:while-let-typo, r=oli-obkMatthias Krüger-0/+2
Suggest while let x = y when encountering while x = y Extends #75931 to also detect where the `let` might be missing from `while let` expressions.
2021-12-29Suggest while let x = y when encountering while x = yametisf-0/+2
Extends #75931 to also detect where the `let` might be missing from `while let` expressions.
2021-12-29Rollup merge of #92237 - compiler-errors:issue-92100, r=cjgillotMatthias Krüger-1/+4
Visit expressions in-order when resolving pattern bindings [edited:] Visit the pattern's sub-expressions before defining any bindings. Otherwise, we might get into a case where a Lit/Range expression in a pattern has a qpath pointing to a Ident pattern that is defined after it, causing an ICE when lowering to HIR. I have a more detailed explanation in the issue linked. Fixes #92100
2021-12-28Rollup merge of #92333 - compiler-errors:elided-lifetime-spans, r=cjgillotMatthias Krüger-3/+6
Tighten span when suggesting lifetime on path This is kind of a hack. Really the issue here is that we want to suggest the segment's span if the path resolves to something defined outside of the macro, and the macro's span if it resolves to something defined within.. I'll look into seeing if we can do something like that. Fixes #92324 r? `@cjgillot`
2021-12-27Tighten span when suggesting lifetime on pathMichael Goulet-3/+6
2021-12-27Rollup merge of #92161 - petrochenkov:misclean, r=cjgillotMatthias Krüger-20/+14
resolve: Minor miscellaneous cleanups from #89059 `@bors` rollup=always
2021-12-27Visit patterns' literal expressions before binding new identsMichael Goulet-1/+4
2021-12-22rustc_metadata: Merge `get_ctor_def_id` and `get_ctor_kind`Vadim Petrochenkov-4/+1
Also avoid decoding the whole `ty::AssocItem` to get a `has_self` flag
2021-12-21resolve: Minor miscellaneous cleanups from #89059Vadim Petrochenkov-20/+14
2021-12-21Rollup merge of #91770 - TaKO8Ki:suggest-adding-cfg-test, r=joshtriplettMatthias Krüger-2/+20
Suggest adding a `#[cfg(test)]` to to a test module closes #88138
2021-12-19Auto merge of #91957 - nnethercote:rm-SymbolStr, r=oli-obkbors-15/+14
Remove `SymbolStr` This was originally proposed in https://github.com/rust-lang/rust/pull/74554#discussion_r466203544. As well as removing the icky `SymbolStr` type, it allows the removal of a lot of `&` and `*` occurrences. Best reviewed one commit at a time. r? `@oli-obk`
2021-12-18hir: Do not introduce dummy type names for `extern` blocks in def pathsVadim Petrochenkov-1/+1
Use a separate nameless `DefPathData` variant instead
2021-12-16suggest adding a `#[cfg(test)]` to test modulesTakayuki Maeda-2/+20
remove a empty line import `module_to_string` use `contains("test")` show a suggestion in case module starts_with/ends_with "test" replace `parent` with `containing`
2021-12-16Auto merge of #89836 - pierwill:fix-85142-crate-hash, r=wesleywiserbors-4/+1
Include rustc version in `rustc_span::StableCrateId` `rustc_span::def_id::StableCrateId` is a hash of various data about a crate during compilation. This PR includes the version of `rustc` in the input when computing this hash. From a cursory reading of [RFC 2603](https://rust-lang.github.io/rfcs/2603-rust-symbol-name-mangling-v0.html), this appears to be acceptable within that design. In order to pass the `mir-opt` and `ui` test suites, this adds new [normalization for hashes and symbol names in `compiletest`](https://github.com/rust-lang/rust/pull/89836/files#diff-03a0567fa80ca04ed5a55f9ac5c711b4f84659be2d0ac4a984196d581c04f76b). These are enabled by default, but we might prefer it to be configurable. In the UI tests, I had to truncate a significant amount of error annotations in v0 symbols (and maybe some legacy) in order to get the normalization to work correctly. (See https://github.com/rust-lang/rust/issues/90116.) Closes #85142.
2021-12-15Rollup merge of #91888 - BoxyUwU:generic_arg_infer_aaaa, r=lcnrMatthias Krüger-5/+4
Handle unordered const/ty generics for object lifetime defaults *feel like I should have a PR description but cant think of what to put here* r? ```@lcnr```
2021-12-15Remove unnecessary sigils around `Ident::as_str()` calls.Nicholas Nethercote-4/+4
2021-12-15Remove unnecessary sigils around `Symbol::as_str()` calls.Nicholas Nethercote-3/+3
2021-12-15Auto merge of #91945 - matthiaskrgr:rollup-jszf9zp, r=matthiaskrgrbors-1/+0
Rollup of 7 pull requests Successful merges: - #90939 (Tweak errors coming from `for`-loop, `?` and `.await` desugaring) - #91859 (Iterator::cycle() — document empty iterator special case) - #91868 (Use `OutputFilenames` to generate output file for `-Zllvm-time-trace`) - #91870 (Revert setting a default for the MACOSX_DEPLOYMENT_TARGET env var for linking) - #91881 (Stabilize `iter::zip`) - #91882 (Remove `in_band_lifetimes` from `rustc_typeck`) - #91940 (Update cargo) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-12-15Remove `SymbolStr`.Nicholas Nethercote-9/+8
By changing `as_str()` to take `&self` instead of `self`, we can just return `&str`. We're still lying about lifetimes, but it's a smaller lie than before, where `SymbolStr` contained a (fake) `&'static str`!
2021-12-14Stabilize iter::zip.PFPoitras-1/+0
2021-12-14Rollup merge of #91798 - bugadani:issue-91783, r=michaelwoeristerMatthias Krüger-1/+6
Avoid suggest adding `self` in visibility spec Fixes #91783
2021-12-14awdawdawdEllen-5/+4
2021-12-13Include rustc version in `rustc_span::StableCrateId`pierwill-4/+1
Normalize symbol hashes in compiletest. Remove DefId sorting
2021-12-12Avoid suggesting self in visibility specDániel Buga-1/+6
Co-authored-by: Esteban Kuber <estebank@users.noreply.github.com>
2021-12-11Rollup merge of #91764 - cjgillot:elide-anyway, r=jackh726Matthias Krüger-0/+5
Do not ICE when suggesting elided lifetimes on non-existent spans. Fixes https://github.com/rust-lang/rust/issues/91763 r? `@jackh726`
2021-12-11Do not ICE when suggesting elided lifetimes on non-existent spans.Camille GILLOT-0/+5
2021-12-07Store impl_trait_fn inside OpaqueTyOrigin.Camille GILLOT-4/+11
2021-12-03Annotate `derive`d spans and move span suggestion codeEsteban Kuber-2/+2
* Annotate `derive`d spans from the user's code with the appropciate context * Add `Span::can_be_used_for_suggestion` to query if the underlying span at the users' code
2021-12-03Keep spans for generics in `#[derive(_)]` desugaringEsteban Kuber-11/+5
Keep the spans for generics coming from a `derive`d Item, so that errors and suggestions have better detail. Fix #84003.
2021-12-02Rollup merge of #91394 - Mark-Simulacrum:bump-stage0, r=pietroalbiniMatthias Krüger-1/+0
Bump stage0 compiler r? `@pietroalbini` (or anyone else)
2021-12-02Rollup merge of #91045 - mjptree:issue-90702-fix, r=petrochenkovMatthias Krüger-70/+91
Issue 90702 fix: Stop treating some crate loading failures as fatal errors Surface mulitple `extern crate` resolution errors at a time. This is achieved by creating a dummy crate, instead of aborting directly after the resolution error. The `ExternCrateError` has been added to allow propagating the resolution error from `rustc_metadata` crate to the `rustc_resolve` with a minimal public surface. The `import_extern_crate` function is a block that was factored out from `build_reduced_graph_for_item` for better organization. The only added functionality made to it where the added error handling in the `process_extern_crate` call. The remaining bits in this function are the same as before. Resolves #90702 r? `@petrochenkov`
2021-12-01Auto merge of #90446 - cjgillot:late-elided, r=jackh726bors-123/+170
Lint elided lifetimes in path during lifetime resolution. The lifetime elision lint is known to be brittle and can be redundant with later lifetime resolution errors. This PR aims to remove the redundancy by performing the lint after lifetime resolution. This PR proposes to carry the information that an elision should be linted against by using a special `LifetimeName`. I am not certain this is the best solution, but it is certainly the easiest. Fixes https://github.com/rust-lang/rust/issues/60199 Fixes https://github.com/rust-lang/rust/issues/55768 Fixes https://github.com/rust-lang/rust/issues/63110 Fixes https://github.com/rust-lang/rust/issues/71957
2021-12-01Improve suggestion for extern crate self error messageMichael-37/+21
2021-12-01Stop treating extern crate loading failures as fatal errorsMichael-12/+35
2021-12-01Factor out build reduced graph for extern crateMichael-69/+83
2021-12-01Rollup merge of #91313 - petrochenkov:cratexp, r=Aaron1011Matthias Krüger-10/+18
expand: Turn `ast::Crate` into a first class expansion target And stop creating a fake `mod` item for the crate root when expanding a crate, thus addressing FIXMEs left in https://github.com/rust-lang/rust/pull/82238, and making a step towards a proper support for crate-level macro attributes (cc #54726). I haven't added token collection support for the whole crate in this PR, maybe later. r? `@Aaron1011`
2021-12-01Rollup merge of #91404 - nnethercote:fix-bad-NodeId-limit-checking, r=dtolnayMatthias Krüger-6/+3
Fix bad `NodeId` limit checking. `Resolver::next_node_id` converts a `u32` to a `usize` (which is possibly bigger), does a checked add, and then converts the result back to a `u32`. The `usize` conversion completely subverts the checked add! This commit removes the conversion to/from `usize`.
2021-12-01Rollup merge of #91298 - FabianWolff:issue-91028-source-avail, r=cjgillotMatthias Krüger-1/+1
Improve error message for `E0659` if the source is not available Fixes #91028. The fix is similar to those in #89233 and #87088. With this change, instead of the dangling ``` note: `Option` could also refer to the enum defined here ``` I get ``` note: `Option` could also refer to an enum from prelude ``` If the standard library source code _is_ available, the output does not change.
2021-12-01Fix bad `NodeId` limit checking.Nicholas Nethercote-6/+3
`Resolver::next_node_id` converts a `u32` to a `usize` (which is possibly bigger), does a checked add, and then converts the result back to a `u32`. The `usize` conversion completely subverts the checked add! This commit removes the conversion to/from `usize`.
2021-11-30Merge Implicit and ImplicitMissing.Camille GILLOT-7/+4
2021-11-30Handle `allow(elided_lifetimes_in_paths)`.Camille GILLOT-31/+28
2021-11-30Lint elided lifetimes in path during lifetime resolution.Camille GILLOT-9/+57