summary refs log tree commit diff
path: root/compiler/rustc_resolve/src/late.rs
AgeCommit message (Collapse)AuthorLines
2022-07-30Always create elided lifetimes, even if inferred.Camille GILLOT-23/+20
2022-07-26Move fn parameter ribs outwards.Camille GILLOT-36/+62
2022-07-26Replace LifetimeRes::Anonymous by LifetimeRes::Infer.Camille GILLOT-71/+37
2022-07-26Remove the distinction between LifetimeName::Implicit and ↵Camille GILLOT-38/+12
LifetimeName::Underscore.
2022-07-26Do not produce extra lifetime parameters when not needed.Camille GILLOT-0/+3
2022-07-25Auto merge of #97313 - cjgillot:ast-lifetimes-anon, r=petrochenkovbors-161/+499
Resolve function lifetime elision on the AST ~Based on https://github.com/rust-lang/rust/pull/97720~ Lifetime elision for functions is purely syntactic in nature, so can be resolved on the AST. This PR replicates the elision logic and diagnostics on the AST, and replaces HIR-based resolution by a `delay_span_bug`. This refactor allows for more consistent diagnostics, which don't have to guess the original code from HIR. r? `@petrochenkov`
2022-07-25Report elision failures on the AST.Camille GILLOT-161/+473
2022-07-23Use span_bug in case of unexpected rib kindJordan McQueen-1/+1
Extremely minor QOL change to improve the ICE output in case this default match case is encountered (an unexpected rib kind).
2022-07-20Introduce AnonymousLifetimeRib::Elided and use it for implied 'static.Camille GILLOT-2/+28
2022-07-19Auto merge of #98120 - TaKO8Ki:box-diagnostic-metadata-field, r=estebankbors-2/+2
[Experiment] Box `diagnostic_metadata` field closes #97954 r? `@estebank`
2022-07-14Rollup merge of #98705 - WaffleLapkin:closure_binder, r=cjgillotDylan DPC-8/+45
Implement `for<>` lifetime binder for closures This PR implements RFC 3216 ([TI](https://github.com/rust-lang/rust/issues/97362)) and allows code like the following: ```rust let _f = for<'a, 'b> |a: &'a A, b: &'b B| -> &'b C { b.c(a) }; // ^^^^^^^^^^^--- new! ``` cc ``@Aaron1011`` ``@cjgillot``
2022-07-13Always use CreateParameter mode for function definitions.Camille GILLOT-11/+9
2022-07-12Add `LifetimeBinderKind::Closure`Maybe Waffle-1/+3
2022-07-12Lower closure binders to hir & properly check themMaybe Waffle-7/+42
2022-07-12Parse closure bindersMaybe Waffle-1/+1
This is first step in implementing RFC 3216. - Parse `for<'a>` before closures in ast - Error in lowering - Add `closure_lifetime_binder` feature
2022-07-11Auto merge of #98637 - cjgillot:bare-trait-anon-lt, r=petrochenkovbors-0/+24
Create fresh lifetime parameters for bare fn trait too The current code fails to account for the equivalence between `dyn FnMut(&mut u8)` and bare `FnMut(&mut u8)`, and treated them differently. This PR introduces a special case for `Fn` traits, which are always fully resolved. Fixes #98616 Fixes #98726 This will require a beta-backport, as beta contains that bug. r? `@petrochenkov`
2022-07-08Check if E0530 is `rustc_resolve::late::PatternSource::Match` to emit suggestionObei Sideg-4/+4
2022-07-08Check if E0530 is `tuple variant` or `tuple struct` to emit suggestionObei Sideg-2/+2
2022-07-02Handle fresh lifetimes on bare trait objects.Camille GILLOT-0/+24
2022-06-23Remove excess rib while resolving closuresMaybe Waffle-1/+3
2022-06-21Use CreateParameter mode for closures too.Camille GILLOT-5/+10
2022-06-21Always create parameters for functions-like types.Camille GILLOT-53/+140
2022-06-19Leave the responsibility to create `Fresh` lifetimes to lowering.Camille GILLOT-23/+11
2022-06-19Make matches exhaustive.Camille GILLOT-3/+9
2022-06-19Remove the `region` terminology.Camille GILLOT-9/+9
2022-06-18Separate `AnonymousCreateParameter` and `ReportElidedInPath`.Camille GILLOT-62/+93
2022-06-18Refactor visit_fn.Camille GILLOT-65/+96
2022-06-18Rustfmt resolve_implementation.Camille GILLOT-39/+57
2022-06-18Extract AssocItem handling.Camille GILLOT-166/+131
2022-06-15box `diagnostic_metadata` fieldTakayuki Maeda-2/+2
2022-06-14Make ResolverAstLowering a struct.Camille GILLOT-2/+1
2022-06-11Rollup merge of #97812 - TaKO8Ki:suggest-to-swap-struct-and-trait, r=estebankDylan DPC-1/+8
Suggest to swap a struct and a trait in trait impls closes #89590
2022-06-09Do not introduce bindings for types and consts in HRTB.Camille GILLOT-1/+6
2022-06-07suggest swapping a struct and a traitTakayuki Maeda-1/+8
fmt
2022-06-05Rename `visit_generic_param{_slice => s}`Maybe Waffle-5/+5
2022-06-03Replace `&Vec<_>`s with `&[_]`sMaybe Waffle-6/+6
2022-06-03Use the same message as type & const generics.Camille GILLOT-28/+20
2022-06-03Reuse resolve_label to check lifetime shadowing.Camille GILLOT-33/+20
2022-06-03Do not lower generic lifetime params when AST resolution emitted an error.Camille GILLOT-0/+7
2022-06-02Stop warning against unrelated labels.Camille GILLOT-1/+0
2022-06-02Do not report mixed label/lifetime shadowing.Camille GILLOT-38/+12
2022-06-02Diagnose shadowing on AST.Camille GILLOT-26/+93
2022-05-21Fix broken intra-doc linkMichael Howell-1/+1
2022-05-20Remove `crate` visibility usage in compilerJacob Pratt-9/+9
2022-05-20Lint single-use-lifetimes on the AST.Camille GILLOT-52/+126
2022-05-20Introduce BareFnTy::decl_span and fix generics span.Camille GILLOT-12/+3
2022-05-20Introduce LifetimeCtxt.Camille GILLOT-2/+2
2022-05-07Permit asm_const and asm_sym to reference outer generic paramsGary Guo-0/+23
2022-05-06Rollup merge of #96557 - nbdd0121:const, r=oli-obkGuillaume Gomez-1/+8
Allow inline consts to reference generic params Tracking issue: #76001 The RFC says that inline consts cannot reference to generic parameters (for now), same as array length expressions. And expresses that it's desirable for it to reference in-scope generics, when array length expressions gain that feature as well. However it is possible to implement this for inline consts before doing this for all anon consts, because inline consts are only used as values and they won't be used in the type system. So we can have: ```rust fn foo<T>() { let x = [4i32; std::mem::size_of::<T>()]; // NOT ALLOWED (for now) let x = const { std::mem::size_of::<T>() }; // ALLOWED with this PR! let x = [4i32; const { std::mem::size_of::<T>() }]; // NOT ALLOWED (for now) } ``` This would make inline consts super useful for compile-time checks and assertions: ```rust fn assert_zst<T>() { const { assert!(std::mem::size_of::<T>() == 0) }; } ``` This would create an error during monomorphization when `assert_zst` is instantiated with non-ZST `T`s. A error during mono might sound scary, but this is exactly what a "desugared" inline const would do: ```rust fn assert_zst<T>() { struct F<T>(T); impl<T> F<T> { const V: () = assert!(std::mem::size_of::<T>() == 0); } let _ = F::<T>::V; } ``` It should also be noted that the current inline const implementation can already reference the type params via type inference, so this resolver-level restriction is not any useful either: ```rust fn foo<T>() -> usize { let (_, size): (PhantomData<T>, usize) = const { const fn my_size_of<T>() -> (PhantomData<T>, usize) { (PhantomData, std::mem::size_of::<T>()) } my_size_of() }; size } ``` ```@rustbot``` label: F-inline_const
2022-05-05Rollup merge of #96507 - TaKO8Ki:suggest-calling-associated-function, r=lcnrMatthias Krüger-0/+5
Suggest calling `Self::associated_function()` closes #96453