about summary refs log tree commit diff
path: root/compiler/rustc_span/src
AgeCommit message (Collapse)AuthorLines
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).
2022-10-20fix rust-lang#101880: suggest let for assignment, and some code refactoryukang-0/+20
2022-10-20Auto merge of #103185 - chenyukang:yukang/fix-span-next-point, r=davidtwcobors-8/+61
Fix the bug of next_point in source_map There is a bug in `next_point`, the new span won't move to next position when be called in the first time. For this reason, our current code is working like this: 1. When we really want to move to the next position, we called two times of `next_point` 2. Some code which use `next_point` actually done the same thing with `shrink_to_hi` This fix make sure when `next_point` is called, span will move with the width at least 1, and also work correctly in the scenario of multiple bytes. Ref: https://github.com/rust-lang/rust/pull/103140#discussion_r997710998 r? `@davidtwco`
2022-10-19Add testcase for next_point, fix more trivial issues in ↵yukang-6/+58
find_width_of_character_at_span
2022-10-18Fix the bug of next_point in spanyukang-3/+4
2022-10-17Make diagnostic for unsatisfied Termination bounds more preciseLeón Orell Valerian Liehr-0/+1
2022-10-14Fix line numbers for MIR inlined codeWesley Wiser-1/+7
`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.
2022-10-11rename rustc_allocator_nounwind to rustc_nounwindRalf Jung-1/+1
2022-10-10Rollup merge of #102860 - ↵Yuki Okushi-0/+4
GuillaumeGomez:missing-docs-FileNameDisplayPreference, r=nagisa Add missing documentation for FileNameDisplayPreference variants Took me a while to find the information when I needed it so hopefully it should save some time for the next ones. r? ``@thomcc``
2022-10-09Add missing documentation for FileNameDisplayPreference variantsGuillaume Gomez-0/+4
2022-10-08Split slice part of feature(half_open_range_patterns) to [...]_in_slicesUrgau-0/+1
2022-10-01Shorten the `lookup_line` code slightlyScott McMurray-4/+1
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-09-30Rollup merge of #102382 - cuviper:defid-order, r=fee1-deadMatthias Krüger-1/+19
Manually order `DefId` on 64-bit big-endian `DefId` uses different field orders on 64-bit big-endian vs. others, in order to optimize its `Hash` implementation. However, that also made it derive different lexical ordering for `PartialOrd` and `Ord`. That caused spurious differences wherever `DefId`s are sorted, like the candidate sources list in `report_method_error`. Now we manually implement `PartialOrd` and `Ord` on 64-bit big-endian to match the same lexical ordering as other targets, fixing at least one test, `src/test/ui/methods/method-ambig-two-traits-cross-crate.rs`.
2022-09-30Auto merge of #102387 - nnethercote:inline-Token-PartialEq, r=lqdbors-0/+2
Inline a few functions. r? `@ghost`
2022-09-29Inline two `Ident` methods.Nicholas Nethercote-0/+2
2022-09-28Auto merge of #100719 - CohenArthur:rust-safe-intrinsic-attribute, r=wesleywiserbors-0/+1
Add `#[rustc_safe_intrinsic]` This PR adds the `#[rustc_safe_intrinsic]` attribute as mentionned on Zulip. The goal of this attribute is to avoid keeping a list of symbols as the source for stable intrinsics, and instead rely on an attribute. This is similar to `#[rustc_const_stable]` and `#[rustc_const_unstable]`, which among other things, are used to mark the constness of intrinsic functions.
2022-09-28Auto merge of #102388 - JohnTitor:rollup-mbyw6fl, r=JohnTitorbors-0/+3
Rollup of 8 pull requests Successful merges: - #100747 (Add long description and test for E0311) - #102232 (Stabilize bench_black_box) - #102288 (Suggest unwrapping `???<T>` if a method cannot be found on it but is present on `T`.) - #102338 (Deny associated type bindings within associated type bindings) - #102347 (Unescaping cleanups) - #102348 (Tweak `FulfillProcessor`.) - #102378 (Use already resolved `self_ty` in `confirm_fn_pointer_candidate`) - #102380 (rustdoc: remove redundant mobile `.source > .sidebar` CSS) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-09-27Manually order `DefId` on 64-bit big-endianJosh Stone-1/+19
`DefId` uses different field orders on 64-bit big-endian vs. others, in order to optimize its `Hash` implementation. However, that also made it derive different lexical ordering for `PartialOrd` and `Ord`. That caused spurious differences wherever `DefId`s are sorted, like the candidate sources list in `report_method_error`. Now we manually implement `PartialOrd` and `Ord` on 64-bit big-endian to match the same lexical ordering as other targets, fixing at least one test, `src/test/ui/methods/method-ambig-two-traits-cross-crate.rs`.
2022-09-27Address feedbackmejrs-0/+1
2022-09-27Wrapper suggestionsmejrs-0/+2
2022-09-27attributes: Add #[rustc_safe_intrinsic] builtinArthur Cohen-0/+1
2022-09-27Rewrite and refactor format_args!() builtin macro.Mara Bos-0/+11
2022-09-26remove cfg(bootstrap)Pietro Albini-1/+0
2022-09-23Rollup merge of #100734 - ComputerDruid:afit_feature, r=compiler-errorsMatthias Krüger-0/+1
Split out async_fn_in_trait into a separate feature PR #101224 added support for async fn in trait desuraging behind the `return_position_impl_trait_in_trait` feature. Split this out so that it's behind its own feature gate, since async fn in trait doesn't need to follow the same stabilization schedule.
2022-09-22Auto merge of #98840 - cjgillot:span-inline-ctxt, r=wesleywiserbors-14/+31
Inline SyntaxContext in both encoded span representation. The current interned representation for spans does not use the `ctxt_or_zero: u16` field. This PR proposes to use this field to store the `SyntaxContext` of the interned span instead. When `ctxt_or_zero` and the interned span's `ctxt` don't match, the inlined one takes precedence. This allows to implement `Span::ctxt` and `Span::with_ctxt` with much less probability to access the interner. Those functions are used a lot for hygiene, so this may be worth it.
2022-09-22Auto merge of #101999 - the8472:source-lines-partition-point, r=davidtwcobors-4/+3
use partition_point instead of binary_search when looking up source lines In local benchmarks this results in 0.4% fewer cycles in a critical sequential section when compiling libcore.
2022-09-21Split out async_fn_in_trait into a separate featureDan Johnson-0/+1
PR #101224 added support for async fn in trait desuraging behind the return_position_impl_trait_in_trait feature. Split this out so that it's behind its own feature gate, since async fn in trait doesn't need to follow the same stabilization schedule.
2022-09-21FIX - adopt new Diagnostic naming in newly migrated modulesJhonny Bill Mena-2/+2
FIX - ambiguous Diagnostic link in docs UPDATE - rename diagnostic_items to IntoDiagnostic and AddToDiagnostic [Gardening] FIX - formatting via `x fmt` FIX - rebase conflicts. NOTE: Confirm wheather or not we want to handle TargetDataLayoutErrorsWrapper this way DELETE - unneeded allow attributes in Handler method FIX - broken test FIX - Rebase conflict UPDATE - rename residual _SessionDiagnostic and fix LintDiag link
2022-09-21UPDATE - rename SessionSubdiagnostic macro to SubdiagnosticJhonny Bill Mena-1/+1
Also renames: - sym::AddSubdiagnostic to sym:: Subdiagnostic - rustc_diagnostic_item = "AddSubdiagnostic" to rustc_diagnostic_item = "Subdiagnostic"
2022-09-21UPDATE - rename DiagnosticHandler macro to DiagnosticJhonny Bill Mena-1/+1
2022-09-21UPDATE - rename DiagnosticHandler trait to IntoDiagnosticJhonny Bill Mena-1/+1
2022-09-20Add the `#[derive_const]` attributeDeadbeef-0/+1
2022-09-19use partition_point instead of binary_search when looking up source linesThe 8472-4/+3
In local benchmarks this results in 0.4% fewer cycles in a critical sequential section when compiling libcore.
2022-09-17Rollup merge of #101713 - Bryanskiy:AccessLevels, r=petrochenkovMatthias Krüger-1/+1
change AccessLevels representation Part of RFC (https://github.com/rust-lang/rust/issues/48054). This patch implements effective visibility table with basic methods and change AccessLevels table representation according to it. r? ``@petrochenkov``
2022-09-17Rollup merge of #98441 - calebzulawski:simd_as, r=oli-obkDylan DPC-0/+3
Implement simd_as for pointers Expands `simd_as` (and `simd_cast`) to handle pointer-to-pointer, pointer-to-integer, and integer-to-pointer conversions. cc ``@programmerjake`` ``@thomcc``
2022-09-15Only enable the let_else feature on bootstrapest31-1/+1
On later stages, the feature is already stable. Result of running: rg -l "feature.let_else" compiler/ src/librustdoc/ library/ | xargs sed -s -i "s#\\[feature.let_else#\\[cfg_attr\\(bootstrap, feature\\(let_else\\)#"
2022-09-14Auto merge of #101212 - eholk:dyn-star, r=compiler-errorsbors-0/+1
Initial implementation of dyn* This PR adds extremely basic and incomplete support for [dyn*](https://smallcultfollowing.com/babysteps//blog/2022/03/29/dyn-can-we-make-dyn-sized/). The goal is to get something in tree behind a flag to make collaboration easier, and also to make sure the implementation so far is not unreasonable. This PR does quite a few things: * Introduce `dyn_star` feature flag * Adds parsing for `dyn* Trait` types * Defines `dyn* Trait` as a sized type * Adds support for explicit casts, like `42usize as dyn* Debug` * Including const evaluation of such casts * Adds codegen for drop glue so things are cleaned up properly when a `dyn* Trait` object goes out of scope * Adds codegen for method calls, at least for methods that take `&self` Quite a bit is still missing, but this gives us a starting point. Note that this is never intended to become stable surface syntax for Rust, but rather `dyn*` is planned to be used as an implementation detail for async functions in dyn traits. Joint work with `@nikomatsakis` and `@compiler-errors.` r? `@bjorn3`
2022-09-14change AccessLevels representationBryanskiy-1/+1
2022-09-13Auto merge of #100640 - reitermarkus:socket-display-buffer, r=thomccbors-0/+1
Use `DisplayBuffer` for socket addresses. Continuation of https://github.com/rust-lang/rust/pull/100625 for socket addresses. Renames `net::addr` to `net::addr::socket`, `net::ip` to `net::addr::ip` and `net::ip::display_buffer::IpDisplayBuffer` to `net::addr::display_buffer::DisplayBuffer`.
2022-09-13Auto merge of #99556 - davidtwco:collapse-debuginfo, r=wesleywiserbors-12/+24
ssa: implement `#[collapse_debuginfo]` cc #39153 rust-lang/compiler-team#386 Debuginfo line information for macro invocations are collapsed by default - line information are replaced by the line of the outermost expansion site. Using `-Zdebug-macros` disables this behaviour. When the `collapse_debuginfo` feature is enabled, the default behaviour is reversed so that debuginfo is not collapsed by default. In addition, the `#[collapse_debuginfo]` attribute is available and can be applied to macro definitions which will then have their line information collapsed. r? rust-lang/wg-debugging
2022-09-12Introduce dyn_star feature flagEric Holk-0/+1
The primary purpose of this commit is to introduce the dyn_star flag so we can begin experimenting with implementation. In order to have something to do in the feature gate test, we also add parser support for `dyn* Trait` objects. These are currently treated just like `dyn Trait` objects, but this will change in the future. Note that for now `dyn* Trait` is experimental syntax to enable implementing some of the machinery needed for async fn in dyn traits without fully supporting the feature.
2022-09-12Rollup merge of #101732 - Nemo157:gate-rustdoc-missing-examples, ↵Guillaume Gomez-0/+1
r=GuillaumeGomez Feature gate the `rustdoc::missing_doc_code_examples` lint Moves the lint from being implicitly active on nightly `rustdoc` to requiring a feature to activate, like other unstable lints. Uses the new tracking issue https://github.com/rust-lang/rust/issues/101730