about summary refs log tree commit diff
path: root/compiler/rustc_span
AgeCommit message (Collapse)AuthorLines
2022-12-09Implement allow-by-default multiple_supertrait_upcastable lintGary Guo-0/+1
2022-12-08Add LLVM KCFI support to the Rust compilerRamon de C Valle-0/+1
This commit adds LLVM Kernel Control Flow Integrity (KCFI) support to the Rust compiler. It initially provides forward-edge control flow protection for operating systems kernels for Rust-compiled code only by aggregating function pointers in groups identified by their return and parameter types. (See llvm/llvm-project@cff5bef.) Forward-edge control flow protection for C or C++ and Rust -compiled code "mixed binaries" (i.e., for when C or C++ and Rust -compiled code share the same virtual address space) will be provided in later work as part of this project by identifying C char and integer type uses at the time types are encoded (see Type metadata in the design document in the tracking issue #89653). LLVM KCFI can be enabled with -Zsanitizer=kcfi. Co-authored-by: bjorn3 <17426603+bjorn3@users.noreply.github.com>
2022-12-08Rollup merge of #105423 - oli-obk:symbols, r=jackh726Matthias Krüger-3/+5
Use `Symbol` for the crate name instead of `String`/`str` It always got converted to a symbol anyway
2022-12-07Use `Symbol` for the crate name instead of `String`/`str`Oli Scherer-3/+5
2022-12-06Rollup merge of #105362 - WaffleLapkin:🙅, r=oli-obkMatthias Krüger-1/+1
Cleanup macro-expanded code in `rustc_type_ir` We could of course just leave this as-is, but every time I go-to-def to this file it's painful to see all this `(&A(ref __self_1_0),)` stuff.
2022-12-06Cleanup macro-expanded code in `rustc_type_ir`Maybe Waffle-1/+1
2022-12-06Replace usage of `ResumeTy` in async lowering with `Context`Arpad Borsos-2/+1
Replaces using `ResumeTy` / `get_context` in favor of using `&'static mut Context<'_>`. Usage of the `'static` lifetime here is technically "cheating", and replaces the raw pointer in `ResumeTy` and the `get_context` fn that pulls the correct lifetimes out of thin air.
2022-12-03Rollup merge of #105050 - WaffleLapkin:uselessrefign, r=jyn514Matthias Krüger-6/+6
Remove useless borrows and derefs They are nothing more than noise. <sub>These are not all of them, but my clippy started crashing (stack overflow), so rip :(</sub>
2022-12-02Rollup merge of #104614 - Nilstrieb:type-ascribe!, r=TaKO8KiMatthias Krüger-0/+1
Add `type_ascribe!` macro as placeholder syntax for type ascription This makes it still possible to test the internal semantics of type ascription even once the `:`-syntax is removed from the parser. The macro now gets used in a bunch of UI tests that test the semantics and not syntax of type ascription. I might have forgotten a few tests but this should hopefully be most of them. The remaining ones will certainly be found once type ascription is removed from the parser altogether. Part of #101728
2022-12-01Remove useless borrows and derefsMaybe Waffle-6/+6
2022-11-27Rollup merge of #104976 - WaffleLapkin:move_comments, r=cjgillotMatthias Krüger-20/+20
Prefer doc comments over `//`-comments in compiler Doc comments are generally nicer: they show up in the documentation, they are shown in IDEs when you hover other mentions of items, etc. Thus it makes sense to use them instead of `//`-comments.
2022-11-27Rollup merge of #104934 - ChrisDenton:all-anybody-wants, r=thomccMatthias Krüger-1/+1
Remove redundant `all` in cfg This appears to have been accidentally left in after removing the other branches https://github.com/rust-lang/rust/commit/45bf1ed1a1123122ded05ae2eedaf0f190e52726 (hat tip to kangalioo for the git archaeology)
2022-11-27Prefer doc comments over `//`-comments in compilerMaybe Waffle-20/+20
2022-11-26Remove more redundant `all`sChris Denton-1/+1
2022-11-25Prefer not accessing the private field of newtype_index typesOli Scherer-2/+2
2022-11-24Avoid `GenFuture` shim when compiling async constructsArpad Borsos-1/+2
Previously, async constructs would be lowered to "normal" generators, with an additional `from_generator` / `GenFuture` shim in between to convert from `Generator` to `Future`. The compiler will now special-case these generators internally so that async constructs will *directly* implement `Future` without the need to go through the `from_generator` / `GenFuture` shim. The primary motivation for this change was hiding this implementation detail in stack traces and debuginfo, but it can in theory also help the optimizer as there is less abstractions to see through.
2022-11-24Auto merge of #104507 - WaffleLapkin:asderefsyou, r=wesleywiserbors-3/+1
Use `as_deref` in compiler (but only where it makes sense) This simplifies some code :3 (there are some changes that are not exacly `as_deref`, but more like "clever `Option`/`Result` method use")
2022-11-21Auto merge of #103491 - cjgillot:self-rpit, r=oli-obkbors-0/+1
Support using `Self` or projections inside an RPIT/async fn I reuse the same idea as https://github.com/rust-lang/rust/pull/103449 to use variances to encode whether a lifetime parameter is captured by impl-trait. The current implementation of async and RPIT replace all lifetimes from the parent generics by `'static`. This PR changes the scheme ```rust impl<'a> Foo<'a> { fn foo<'b, T>() -> impl Into<Self> + 'b { ... } } opaque Foo::<'_a>::foo::<'_b, T>::opaque<'b>: Into<Foo<'_a>> + 'b; impl<'a> Foo<'a> { // OLD fn foo<'b, T>() -> Foo::<'static>::foo::<'static, T>::opaque::<'b> { ... } ^^^^^^^ the `Self` becomes `Foo<'static>` // NEW fn foo<'b, T>() -> Foo::<'a>::foo::<'b, T>::opaque::<'b> { ... } ^^ the `Self` stays `Foo<'a>` } ``` There is the same issue with projections. In the example, substitute `Self` by `<T as Trait<'b>>::Assoc` in the sugared version, and `Foo<'_a>` by `<T as Trait<'_b>>::Assoc` in the desugared one. This allows to support `Self` in impl-trait, since we do not replace lifetimes by `'static` any more. The same trick allows to use projections like `T::Assoc` where `Self` is allowed. The feature is gated behind a `impl_trait_projections` feature gate. The implementation relies on 2 tweaking rules for opaques in 2 places: - we only relate substs that correspond to captured lifetimes during TypeRelation; - we only list captured lifetimes in choice region computation. For simplicity, I encoded the "capturedness" of lifetimes as a variance, `Bivariant` vs `Invariant` for unused vs captured lifetimes. The `variances_of` query used to ICE for opaques. Impl-trait that do not reference `Self` or projections will have their variances as: - `o` (invariant) for each parent type or const; - `*` (bivariant) for each parent lifetime --> will not participate in borrowck; - `o` (invariant) for each own lifetime. Impl-trait that does reference `Self` and/or projections will have some parent lifetimes marked as `o` (as the example above), and participate in type relation and borrowck. In the example above, `variances_of(opaque) = ['_a: o, '_b: *, T: o, 'b: o]`. r? types cc `@compiler-errors` , as you asked about the issue with `Self` and projections.
2022-11-20Auto merge of #98914 - fee1-dead-contrib:min-deref-patterns, r=compiler-errorsbors-0/+1
Minimal implementation of implicit deref patterns for Strings cc `@compiler-errors` `@BoxyUwU` https://github.com/rust-lang/lang-team/issues/88 #87121 ~~I forgot to add a feature gate, will do so in a minute~~ Done
2022-11-19Add unstable `type_ascribe` macroNilstrieb-0/+1
This macro serves as a placeholder for future type ascription syntax to make sure that the semantic implementation keeps working.
2022-11-19Rollup merge of #104497 - lyming2007:issue-104379-fix, r=fee1-deadMatthias Krüger-4/+21
detect () to avoid redundant <> suggestion for type fix #104379
2022-11-18Enforce that dyn* casts are actually pointer-sizedMichael Goulet-0/+1
2022-11-18rename to `string_deref_patterns`Deadbeef-1/+1
2022-11-17Readd the matches_macro diag itemPhilipp Krones-0/+1
This is now used by Clippy
2022-11-17detect () to avoid redundant <> suggestion for typeYiming Lei-4/+21
fix #104379
2022-11-17Add feature gateDeadbeef-0/+1
2022-11-16Use `as_deref` in compiler (but only where it makes sense)Maybe Waffle-3/+1
2022-11-15Rollup merge of #104339 - compiler-errors:rustc_deny_explicit_impl, r=cjgillotMatthias Krüger-0/+1
Add `rustc_deny_explicit_impl` Also adjust `E0322` error message to be more general, since it's used for `DiscriminantKind` and `Pointee` as well. Also add `rustc_deny_explicit_impl` on the `Tuple` and `Destruct` marker traits.
2022-11-15Rollup merge of #104383 - WaffleLapkin:rustc_undiagnostic_item, ↵Matthias Krüger-51/+1
r=compiler-errors Remove unused symbols and diagnostic items As the title suggests, this removes unused symbols from `sym::` and `#[rustc_diagnostic_item]` annotations that weren't mentioned anywhere. Originally I tried to use grep, to find symbols and item names that are never mentioned via `sym::name`, however this produced a lot of false positives (?), for example clippy matching on `Symbol::as_str` or macros "implicitly" adding `sym::`. I ended up fixing all these false positives (?) by hand, but tbh I'm not sure if it was worth it...
2022-11-14Add rustc_deny_explicit_implMichael Goulet-0/+1
2022-11-13Fix clippy and rustdocMaybe Waffle-0/+2
please, please, don't match on `Symbol::as_str`s, every time you do, somewhere in the world another waffle becomes sad...
2022-11-13Remove dead NoneError error handlingmejrs-1/+0
2022-11-13Remove unused symbolsMaybe Waffle-37/+0
2022-11-13Remove unused diagnostic itemsMaybe Waffle-15/+0
2022-11-12Make impl_trait_projections a feature gate.Camille GILLOT-0/+1
2022-11-12Rollup merge of #102049 - fee1-dead-contrib:derive_const, r=oli-obkDylan DPC-0/+1
Add the `#[derive_const]` attribute Closes #102371. This is a minimal patchset for the attribute to work. There are no restrictions on what traits this attribute applies to. r? `````@oli-obk`````
2022-11-09Rollup merge of #103675 - lyming2007:issue-103271-fix, r=fee1-deadMichael Goulet-0/+44
remove redundent "<>" for ty::Slice with reference type this fix #103271
2022-11-09remove redundent "<>" for ty::Slice with reference typeYiming Lei-0/+44
this fix #103271
2022-11-09Rollup merge of #103464 - JakobDegen:mir-parsing, r=oli-obkManish Goregaokar-0/+1
Add support for custom mir This implements rust-lang/compiler-team#564 . Details about the design, motivation, etc. can be found in there. r? ```@oli-obk```
2022-11-08Add support for custom MIR parsingJakob Degen-0/+1
2022-11-08Rollup merge of #103521 - chenyukang:yukang/fix-103451-avoid-hang, ↵Manish Goregaokar-10/+9
r=jackh726,wesleywiser Avoid possible infinite loop when next_point reaching the end of file Fixes #103451 If we return a span with `lo` = `hi`, `span_to_snippet` will always get `Ok("")`, which may introduce infinite loop if we don't care. This PR make `find_width_of_character_at_span` return `width` with 1, so that `span_to_snippet` will get an `Err`.
2022-10-30Rollup merge of #97971 - Soveu:varargs, r=jackh726Michael Howell-0/+1
Enable varargs support for calling conventions other than C or cdecl This patch makes it possible to use varargs for calling conventions, which are either based on C (efiapi) or C is based on them (sysv64 and win64). Also pinging ``@phlopsi,`` because he noticed first this oversight when writing a library for UEFI.
2022-10-30Rollup merge of #93582 - WaffleLapkin:rpitirpit, r=compiler-errorsDylan DPC-0/+1
Allow `impl Fn() -> impl Trait` in return position _This was originally proposed as part of #93082 which was [closed](https://github.com/rust-lang/rust/pull/93082#issuecomment-1027225715) due to allowing `impl Fn() -> impl Trait` in argument position._ This allows writing the following function signatures: ```rust fn f0() -> impl Fn() -> impl Trait; fn f3() -> &'static dyn Fn() -> impl Trait; ``` These signatures were already allowed for common traits and associated types, there is no reason why `Fn*` traits should be special in this regard. `impl Trait` in both `f0` and `f3` means "new existential type", just like with `-> impl Iterator<Item = impl Trait>` and such. Arrow in `impl Fn() ->` is right-associative and binds from right to left, it's tested by [this test](https://github.com/WaffleLapkin/rust/blob/a819fecb8dea438fc70488ddec30a61e52942672/src/test/ui/impl-trait/impl_fn_associativity.rs). There even is a test that `f0` compiles: https://github.com/rust-lang/rust/blob/2f004d2d401682e553af3984ebd9a3976885e752/src/test/ui/impl-trait/nested_impl_trait.rs#L25-L28 But it was changed in [PR 48084 (lines)](https://github.com/rust-lang/rust/pull/48084/files#diff-ccecca938872d65ffe8cd1c3ef1956e309fac83bcda547d8b16b89257e53a437R37) to test the opposite, probably unintentionally given [PR 48084 (lines)](https://github.com/rust-lang/rust/pull/48084/files#diff-5a02f1ed43debed1fd24f7aad72490064f795b9420f15d847bac822aa4621a1cR476-R477). r? `@nikomatsakis` ---- This limitation is especially annoying with async code, since it forces one to write this: ```rust trait AsyncFn3<A, B, C>: Fn(A, B, C) -> <Self as AsyncFn3<A, B, C>>::Future { type Future: Future<Output = Self::Out>; type Out; } impl<A, B, C, Fut, F> AsyncFn3<A, B, C> for F where F: Fn(A, B, C) -> Fut, Fut: Future, { type Future = Fut; type Out = Fut::Output; } fn async_closure() -> impl AsyncFn3<i32, i32, i32, Out = u32> { |a, b, c| async move { (a + b + c) as u32 } } ``` Instead of: ```rust fn async_closure() -> impl Fn(i32, i32, i32) -> impl Future<Output = u32> { |a, b, c| async move { (a + b + c) as u32 } } ```
2022-10-29Rollup merge of #103656 - camsteffen:symbol-to-string, r=compiler-errorsMatthias Krüger-0/+7
Specialize ToString for Symbol
2022-10-28Specialize ToString for SymbolCameron Steffen-0/+7
2022-10-28Auto merge of #103071 - wesleywiser:fix_inlined_line_numbers, r=davidtwcobors-1/+7
Fix line numbers for MIR inlined code `should_collapse_debuginfo` detects if the specified span is part of a macro expansion however it does this by checking if the span is anything other than a normal (non-expanded) kind, then the span sequence is walked backwards to the root span. This doesn't work when the MIR inliner inlines code as it creates spans with expansion information set to `ExprKind::Inlined` and results in the line number being attributed to the inline callsite rather than the normal line number of the inlined code. Fixes #103068
2022-10-25Feature gate `impl_trait_in_fn_trait_return`Maybe Waffle-0/+1
2022-10-25Fix #103451, find_width_of_character_at_span return width with 1 when ↵yukang-10/+9
reaching end
2022-10-24Auto merge of #102536 - scottmcm:lookup_line-tweak, r=jackh726bors-4/+1
Shorten the `lookup_line` code slightly The `match` looks like it's exactly the same as `checked_sub(1)`, so we might as well see if perf says we can just do that to save a couple lines.
2022-10-23Enable varargs support for calling conventions other than C or cdeclSoveu-0/+1
This patch makes it possible to use varargs for calling conventions, which are either based on C (like efiapi) or C is based on them (for example sysv64 and win64).