about summary refs log tree commit diff
path: root/compiler/rustc_resolve/src/late
AgeCommit message (Collapse)AuthorLines
2021-07-25clippy::useless_formatMatthias Krüger-1/+1
2021-07-25Merge the BTreeMap in hir::Crate.Camille GILLOT-18/+11
2021-07-25Add generic arg inferkadmin-0/+4
2021-07-09Fix the ICE described in #83693Fabian Wolff-3/+2
2021-06-28Fix garbled suggestion for missing lifetime specifierFabian Wolff-0/+2
2021-06-07Remove lifetime hackCameron Steffen-9/+1
2021-05-13Auto merge of #85041 - mibac138:suggest-generics, r=estebankbors-5/+14
Suggest adding a type parameter for impls Add a new suggestion upon encountering an unknown type in a `impl` that suggests adding a new type parameter. This diagnostic suggests to add a new type parameter even though it may be a const parameter, however after adding the parameter and running rustc again a follow up error steers the user to change the type parameter to a const parameter. ```rust struct X<const C: ()>(); impl X<C> {} ``` suggests ``` error[E0412]: cannot find type `C` in this scope --> bar.rs:2:8 | 1 | struct X<const C: ()>(); | ------------------------ similarly named struct `X` defined here 2 | impl X<C> {} | ^ | help: a struct with a similar name exists | 2 | impl X<X> {} | ^ help: you might be missing a type parameter | 2 | impl<C> X<C> {} | ^^^ ``` After adding a type parameter the code now becomes ```rust struct X<const C: ()>(); impl<C> X<C> {} ``` and the error now fully steers the user towards the correct code ``` error[E0747]: type provided when a constant was expected --> bar.rs:2:11 | 2 | impl<C> X<C> {} | ^ | help: consider changing this type parameter to be a `const` generic | 2 | impl<const C: ()> X<C> {} | ^^^^^^^^^^^ ``` r? `@estebank` Somewhat related #84946
2021-05-13Auto merge of #83759 - SkiFire13:fix-diag, r=estebankbors-6/+28
Handle more span edge cases in generics diagnostics This should fix invalid suggestions that didn't account for empty bracket pairs (`<>`) or type bindings.
2021-05-12Fix diagnostics spans for missing lifetimes in edge casesGiacomo Stevanato-6/+28
2021-05-12Auto merge of #83813 - cbeuw:remap-std, r=michaelwoeristerbors-1/+1
Fix `--remap-path-prefix` not correctly remapping `rust-src` component paths and unify handling of path mapping with virtualized paths This PR fixes #73167 ("Binaries end up containing path to the rust-src component despite `--remap-path-prefix`") by preventing real local filesystem paths from reaching compilation output if the path is supposed to be remapped. `RealFileName::Named` introduced in #72767 is now renamed as `LocalPath`, because this variant wraps a (most likely) valid local filesystem path. `RealFileName::Devirtualized` is renamed as `Remapped` to be used for remapped path from a real path via `--remap-path-prefix` argument, as well as real path inferred from a virtualized (during compiler bootstrapping) `/rustc/...` path. The `local_path` field is now an `Option<PathBuf>`, as it will be set to `None` before serialisation, so it never reaches any build output. Attempting to serialise a non-`None` `local_path` will cause an assertion faliure. When a path is remapped, a `RealFileName::Remapped` variant is created. The original path is preserved in `local_path` field and the remapped path is saved in `virtual_name` field. Previously, the `local_path` is directly modified which goes against its purpose of "suitable for reading from the file system on the local host". `rustc_span::SourceFile`'s fields `unmapped_path` (introduced by #44940) and `name_was_remapped` (introduced by #41508 when `--remap-path-prefix` feature originally added) are removed, as these two pieces of information can be inferred from the `name` field: if it's anything other than a `FileName::Real(_)`, or if it is a `FileName::Real(RealFileName::LocalPath(_))`, then clearly `name_was_remapped` would've been false and `unmapped_path` would've been `None`. If it is a `FileName::Real(RealFileName::Remapped{local_path, virtual_name})`, then `name_was_remapped` would've been true and `unmapped_path` would've been `Some(local_path)`. cc `@eddyb` who implemented `/rustc/...` path devirtualisation
2021-05-11improve diagnosts for GATsb-naber-18/+114
2021-05-11Split span_to_string into span_to_diagnostic/embeddable_stringAndy Wang-1/+1
2021-05-10More minor fixes suggested by @jackh726Fabian Wolff-2/+4
2021-05-09Implement @jackh726's suggestionsFabian Wolff-76/+64
2021-05-07Fix suggestions for missing return type lifetime parametersFabian Wolff-150/+216
2021-05-07Fix impl type parameter suggestion involving constsmibac138-1/+8
2021-05-05Suggest adding a type parameter for implsmibac138-4/+6
2021-05-02add suggestion for unit enum variant when matched with a paternAliénore Bouttefeux-12/+31
2021-04-23Auto merge of #83729 - JohnTitor:issue-43913, r=estebankbors-1/+8
Add a suggestion when using a type alias instead of trait alias Fixes #43913 r? `@estebank`
2021-04-21More review changesJack Huey-85/+59
2021-04-21Review commentsJack Huey-7/+8
2021-04-21Move nested quantification check to ast_validationJack Huey-66/+14
2021-04-20Remove TraitRefHackInner and use the concatenating functionality instead of ↵Jack Huey-245/+176
trait_ref_hack
2021-04-20Add BinderScopeType to replace binder_depth and from_poly_trait_refJack Huey-111/+86
2021-04-20A non-minimal set of TraitRefBoundarys to work on removing from_poly_trait_refJack Huey-84/+93
2021-04-20Precompute inverse binder depthJack Huey-104/+73
2021-04-19fix few typosklensy-2/+2
2021-04-16Rollup merge of #83944 - jackh726:binder-refactor-fix2, r=lcnrDylan DPC-1/+15
Fix a couple resolve bugs from binder refactor Fixes #83753 Fixes #83907
2021-04-09Auto merge of #83870 - jackh726:binder-refactor-fix, r=nikomatsakisbors-61/+132
Don't concatenate binders across types Partially addresses #83737 There's actually two issues that I uncovered in #83737. The first is that we are concatenating bound vars across types, i.e. in ``` F: Fn(&()) -> &mut (dyn Future<Output = ()> + Unpin) ``` the bound vars on `Future` get set as `for<anon>` since those are the binders on `Fn(&()`. This is obviously wrong, since we should only concatenate directly nested trait refs. This is solved here by introducing a new `TraitRefBoundary` scope, that we put around the "syntactical" trait refs and basically don't allow concatenation across. Now, this alone *shouldn't* be a super terrible problem. At least not until you consider the other issue, which is a much more elusive and harder to design a "perfect" fix. A repro can be seen in: ``` use core::future::Future; async fn handle<F>(slf: &F) where F: Fn(&()) -> &mut (dyn for<'a> Future<Output = ()> + Unpin), { (slf)(&()).await; } ``` Notice the `for<'a>` around `Future`. Here, `'a` is unused, so the `for<'a>` Binder gets changed to a `for<>` Binder in the generator witness, but the "local decl" still has it. This has heavy intersections with region anonymization and erasing. Luckily, it's not *super* common to find this unique set of circumstances. It only became apparently because of the first issue mentioned here. However, this *is* still a problem, so I'm leaving #83737 open. r? `@nikomatsakis`
2021-04-08add commentsNiko Matsakis-1/+23
2021-04-07Rollup merge of #83634 - JohnTitor:proc-macro-ice, r=varkorDylan DPC-1/+3
Do not emit the advanced diagnostics on macros Fixes #83510
2021-04-06Fix a couple resolve bugs from binder refactorJack Huey-1/+15
2021-04-05Don't concatenate binders across typesJack Huey-61/+110
2021-04-01Add a suggestion when using a type alias instead of trait aliasYuki Okushi-1/+8
2021-03-31Cleanups and commentsJack Huey-256/+211
2021-03-31Add var to BoundRegion. Add query to get bound vars for applicable items.Jack Huey-87/+634
2021-03-31Make late and late_anon regions track the bound var positionJack Huey-39/+75
2021-03-29Do not emit the advanced diagnostics on macrosJohnTitor-1/+3
2021-03-27Rollup merge of #82917 - cuviper:iter-zip, r=m-ou-seDylan DPC-3/+3
Add function core::iter::zip This makes it a little easier to `zip` iterators: ```rust for (x, y) in zip(xs, ys) {} // vs. for (x, y) in xs.into_iter().zip(ys) {} ``` You can `zip(&mut xs, &ys)` for the conventional `iter_mut()` and `iter()`, respectively. This can also support arbitrary nesting, where it's easier to see the item layout than with arbitrary `zip` chains: ```rust for ((x, y), z) in zip(zip(xs, ys), zs) {} for (x, (y, z)) in zip(xs, zip(ys, zs)) {} // vs. for ((x, y), z) in xs.into_iter().zip(ys).zip(xz) {} for (x, (y, z)) in xs.into_iter().zip((ys.into_iter().zip(xz)) {} ``` It may also format more nicely, especially when the first iterator is a longer chain of methods -- for example: ```rust iter::zip( trait_ref.substs.types().skip(1), impl_trait_ref.substs.types().skip(1), ) // vs. trait_ref .substs .types() .skip(1) .zip(impl_trait_ref.substs.types().skip(1)) ``` This replaces the tuple-pair `IntoIterator` in #78204. There is prior art for the utility of this in [`itertools::zip`]. [`itertools::zip`]: https://docs.rs/itertools/0.10.0/itertools/fn.zip.html
2021-03-27lazily calls some fnsklensy-5/+5
2021-03-26Use iter::zip in compiler/Josh Stone-3/+3
2021-03-25write-up what is happeningNiko Matsakis-0/+28
2021-03-24Review commentsJack Huey-16/+37
2021-03-24resolve late lifetimes by itemJack Huey-157/+269
This reverts commit 22ae20733515d710c1134600bc1e29cdd76f6b9b.
2021-03-23Add has_default to GenericParamDefKind::Constkadmin-1/+3
This currently creates a field which is always false on GenericParamDefKind for future use when consts are permitted to have defaults Update const_generics:default locations Previously just ignored them, now actually do something about them. Fix using type check instead of value Add parsing This adds all the necessary changes to lower const-generics defaults from parsing. Change P<Expr> to AnonConst This matches the arguments passed to instantiations of const generics, and makes it specific to just anonymous constants. Attempt to fix lowering bugs
2021-03-18hir: Preserve used syntax in `TyKind::TraitObject`Vadim Petrochenkov-2/+2
2021-03-15Custom error on literal names from other languagesSmitty-0/+26
This detects all Java literal types and all single word C data types, and suggests the corresponding Rust literal type.
2021-03-10Auto merge of #79519 - cjgillot:noattr, r=wesleywiserbors-1/+2
Store HIR attributes in a side table Same idea as #72015 but for attributes. The objective is to reduce incr-comp invalidations due to modified attributes. Notably, those due to modified doc comments. Implementation: - collect attributes during AST->HIR lowering, in `LocalDefId -> ItemLocalId -> &[Attributes]` nested tables; - access the attributes through a `hir_owner_attrs` query; - local refactorings to use this access; - remove `attrs` from HIR data structures one-by-one. Change in behaviour: - the HIR visitor traverses all attributes at once instead of parent-by-parent; - attribute arrays are sometimes duplicated: for statements and variant constructors; - as a consequence, attributes are marked as used after unused-attribute lint emission to avoid duplicate lints. ~~Current bug: the lint level is not correctly applied in `std::backtrace_rs`, triggering an unused attribute warning on `#![no_std]`. I welcome suggestions.~~
2021-03-10Rollup merge of #82942 - m-ou-se:diagnostics-hardcoded-prelude-v1, r=estebankYuki Okushi-1/+1
Don't hardcode the `v1` prelude in diagnostics, to allow for new preludes. Instead of looking for `std::prelude::v1`, this changes the two places where that was hardcoded to look for `std::prelude::<anything>` instead. This is needed for https://github.com/rust-lang/rust/pull/82217. r? `@estebank`
2021-03-09Don't hardcode the `v1` prelude in diagnostics.Mara Bos-1/+1
Instead of looking for `std::prelude::v1`, this changes it to look for `std::prelude::<anything>`.