about summary refs log tree commit diff
path: root/compiler/rustc_span
AgeCommit message (Collapse)AuthorLines
2022-09-09The `<*const T>::guaranteed_*` methods now return an option for the unknown caseOli Scherer-2/+1
2022-09-09Auto merge of #101603 - matthiaskrgr:rollup-8y6kf20, r=matthiaskrgrbors-1/+0
Rollup of 6 pull requests Successful merges: - #99207 (Enable eager checks for memory sanitizer) - #101253 (fix the suggestion of format for asm_sub_register) - #101450 (Add `const_extern_fn` to 1.62 release notes.) - #101556 (Tweak future opaque ty pretty printing) - #101563 (Link UEFI target documentation from target list) - #101593 (Cleanup themes (tooltip)) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-09-09Rollup merge of #101556 - compiler-errors:tweak-generator-print, r=jackh726Matthias Krüger-1/+0
Tweak future opaque ty pretty printing 1. The `Return` type of a generator doesn't need to be a lang item just for diagnostic printing of types 2. We shouldn't suppress the `Output = Ty` of a opaque future if the type is a int or float var.
2022-09-09Lower RPITIT to ImplTraitPlaceholder itemMichael Goulet-0/+1
2022-09-08Generator return doesn't need to be a lang itemMichael Goulet-1/+0
2022-09-07ssa: implement `#[collapse_debuginfo]`David Wood-12/+24
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. Signed-off-by: David Wood <david.wood@huawei.com>
2022-09-07rustc: Parameterize `ty::Visibility` over used IDVadim Petrochenkov-0/+6
It allows using `LocalDefId` instead of `DefId` when possible, and also encode cheaper `Visibility<DefIndex>` into metadata.
2022-09-05Auto merge of #100759 - fee1-dead-contrib:const_eval_select_real_intrinsic, ↵bors-1/+0
r=oli-obk,RalfJung Make `const_eval_select` a real intrinsic This fixes issues where `track_caller` functions do not have nice panic messages anymore when there is a call to the function, and uses the MIR system to replace the call instead of dispatching via lang items. Fixes #100696.
2022-09-04Auto merge of #101296 - compiler-errors:head-span-for-enclosing-scope, r=oli-obkbors-1/+1
Use head span for `rustc_on_unimplemented`'s `enclosing_scope` attr This may make #101281 slightly easier to understand
2022-09-04Make `const_eval_select` a real intrinsicDeadbeef-1/+0
2022-09-04Auto merge of #100726 - jswrenn:transmute, r=oli-obkbors-0/+5
safe transmute: use `Assume` struct to provide analysis options This task was left as a TODO in #92268; resolving it brings [`BikeshedIntrinsicFrom`](https://doc.rust-lang.org/nightly/core/mem/trait.BikeshedIntrinsicFrom.html) more in line with the API defined in [MCP411](https://github.com/rust-lang/compiler-team/issues/411). **Before:** ```rust pub unsafe trait BikeshedIntrinsicFrom< Src, Context, const ASSUME_ALIGNMENT: bool, const ASSUME_LIFETIMES: bool, const ASSUME_VALIDITY: bool, const ASSUME_VISIBILITY: bool, > where Src: ?Sized, {} ``` **After:** ```rust pub unsafe trait BikeshedIntrinsicFrom<Src, Context, const ASSUME: Assume = { Assume::NOTHING }> where Src: ?Sized, {} ``` `Assume::visibility` has also been renamed to `Assume::safety`, as library safety invariants are what's actually being assumed; visibility is just the mechanism by which it is currently checked (and that may change). r? `@oli-obk` --- Related: - https://github.com/rust-lang/compiler-team/issues/411 - https://github.com/rust-lang/rust/issues/99571
2022-09-04Address nits, rename enclosing_scope => parent_labelMichael Goulet-1/+1
2022-09-02Auto merge of #97802 - Enselic:add-no_ignore_sigkill-feature, r=joshtriplettbors-0/+4
Support `#[unix_sigpipe = "inherit|sig_dfl"]` on `fn main()` to prevent ignoring `SIGPIPE` When enabled, programs don't have to explicitly handle `ErrorKind::BrokenPipe` any longer. Currently, the program ```rust fn main() { loop { println!("hello world"); } } ``` will print an error if used with a short-lived pipe, e.g. % ./main | head -n 1 hello world thread 'main' panicked at 'failed printing to stdout: Broken pipe (os error 32)', library/std/src/io/stdio.rs:1016:9 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace by enabling `#[unix_sigpipe = "sig_dfl"]` like this ```rust #![feature(unix_sigpipe)] #[unix_sigpipe = "sig_dfl"] fn main() { loop { println!("hello world"); } } ``` there is no error, because `SIGPIPE` will not be ignored and thus the program will be killed appropriately: % ./main | head -n 1 hello world The current libstd behaviour of ignoring `SIGPIPE` before `fn main()` can be explicitly requested by using `#[unix_sigpipe = "sig_ign"]`. With `#[unix_sigpipe = "inherit"]`, no change at all is made to `SIGPIPE`, which typically means the behaviour will be the same as `#[unix_sigpipe = "sig_dfl"]`. See https://github.com/rust-lang/rust/issues/62569 and referenced issues for discussions regarding the `SIGPIPE` problem itself See the [this](https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/Proposal.3A.20First.20step.20towards.20solving.20the.20SIGPIPE.20problem) Zulip topic for more discussions, including about this PR. Tracking issue: https://github.com/rust-lang/rust/issues/97889
2022-09-02Rollup merge of #100147 - Bryanskiy:private-in-public, r=petrochenkovGuillaume Gomez-0/+1
optimization of access level table construction Refactoring which was mentioned in #87487
2022-09-02Rollup merge of #97739 - a2aaron:let_underscore, r=estebankGuillaume Gomez-0/+3
Uplift the `let_underscore` lints from clippy into rustc. This PR resolves #97241. This PR adds three lints from clippy--`let_underscore_drop`, `let_underscore_lock`, and `let_underscore_must_use`, which are meant to capture likely-incorrect uses of `let _ = ...` bindings (in particular, doing this on a type with a non-trivial `Drop` causes the `Drop` to occur immediately, instead of at the end of the scope. For a type like `MutexGuard`, this effectively releases the lock immediately, which is almost certainly the wrong behavior) In porting the lints from clippy I had to copy over a bunch of utility functions from `clippy_util` that these lints also relied upon. Is that the right approach? Note that I've set the `must_use` and `drop` lints to Allow by default and set `lock` to Deny by default (this matches the same settings that clippy has). In talking with `@estebank` he informed me to do a Crater run (I am not sure what type of Crater run to request here--I think it's just "check only"?) On the linked issue, there's some discussion about using `must_use` and `Drop` together as a heuristic for when to warn--I did not implement this yet. r? `@estebank`
2022-09-01tracing::instrument cleanupOli Scherer-5/+5
2022-09-01Always import all tracing macros for the entire crate instead of piecemeal ↵Oli Scherer-4/+0
by module
2022-08-31add TestReachabilityVisitorBryanskiy-0/+1
2022-08-29Rollup merge of #100898 - compiler-errors:too-many-expr-fields, r=spastorinoMatthias Krüger-0/+1
Do not report too many expr field candidates When considering "this expressions' field has a {field/method}" suggestions: 1. Don't report methods that are out of scope 2. Use `span_suggestions` instead of reporting each field candidate, which caps the number of suggestions to 4 4. Blacklist some common traits like `Clone` and `Deref` Fixes #100894
2022-08-28Support `#[unix_sigpipe = "inherit|sig_dfl|sig_ign"]` on `fn main()`Martin Nordholts-0/+4
This makes it possible to instruct libstd to never touch the signal handler for `SIGPIPE`, which makes programs pipeable by default (e.g. with `./your-program | head -n 1`) without `ErrorKind::BrokenPipe` errors.
2022-08-28Auto merge of #96946 - WaffleLapkin:ptr_mask, r=scottmcmbors-0/+1
Add pointer masking convenience functions This PR adds the following public API: ```rust impl<T: ?Sized> *const T { fn mask(self, mask: usize) -> *const T; } impl<T: ?Sized> *mut T { fn mask(self, mask: usize) -> *const T; } // mod intrinsics fn mask<T>(ptr: *const T, mask: usize) -> *const T ``` This is equivalent to `ptr.map_addr(|a| a & mask)` but also uses a cool llvm intrinsic. Proposed in https://github.com/rust-lang/rust/pull/95643#issuecomment-1121562352 cc `@Gankra` `@scottmcm` `@RalfJung` r? rust-lang/libs-api
2022-08-26Implementation of import_name_typeDaniel Paoliello-0/+1
2022-08-25Do not report too many expr field candidatesMichael Goulet-0/+1
2022-08-25Rollup merge of #100188 - chenyukang:fix-issue-100165, r=estebankYuki Okushi-0/+1
Parser will not suggest invalid expression when use public Fixes #100165
2022-08-24Auto merge of #100803 - klensy:do-not-encode-preinterned-symbols, r=bjorn3bors-0/+10
Symbols: do not write string values of preinterned symbols into compiled artifacts r? `@bjorn3` Followup for #98851 https://github.com/rust-lang/rust/pull/98851#issuecomment-1215606291
2022-08-23parser will not give wrong help message for 'public'yukang-0/+1
2022-08-23Remove generate_fn_name_span and generate_local_type_param_snippet.Camille GILLOT-87/+0
2022-08-23Improve local generic parameter suggestions.Camille GILLOT-0/+1
2022-08-22safe transmute: use `Assume` struct to provide analysis optionsJack Wrenn-0/+5
This was left as a TODO in #92268, and brings the trait more in line with what was defined in MCP411. `Assume::visibility` has been renamed to `Assume::safety`, as library safety is what's actually being assumed; visibility is just the mechanism by which it is currently checked (this may change). ref: https://github.com/rust-lang/compiler-team/issues/411 ref: https://github.com/rust-lang/rust/issues/99571
2022-08-22Show absolute line numbers if span is outside relative spanNilstrieb-1/+1
In the MIR pretty printing, it can sometimes happen that the span of the statement is outside the span of the body (for example through inlining). In this case, don't display a relative span but an absolute span. This will make the mir-opt-tests a little more prone to diffs again, but the impact should be small.
2022-08-21More docsMichael Goulet-0/+3
2022-08-21Comment a bit, use find_ancestor_in_same_ctxt to suppress some weird macro notesMichael Goulet-0/+7
2022-08-21Add pointer masking convenience functionsMaybe Waffle-0/+1
This commit adds the following functions all of which have a signature `pointer, usize -> pointer`: - `<*mut T>::mask` - `<*const T>::mask` - `intrinsics::ptr_mask` These functions are equivalent to `.map_addr(|a| a & mask)` but they utilize `llvm.ptrmask` llvm intrinsic. *masks your pointers*
2022-08-20rmeta/query cache: don't write string values of preinterned symbolsklensy-0/+5
2022-08-20symbols: add `is_preinterned` fn to check if symbol was preinterned in compilerklensy-0/+5
2022-08-20Rollup merge of #100723 - 5225225:the-easy-ones, r=compiler-errorsMatthias Krüger-0/+2
Add the diagnostic translation lints to crates that don't emit them Some of these have a note saying that they should build on a stable compiler, does that mean they shouldn't get these lints? Or can we cfg them out on those?
2022-08-19Auto merge of #100209 - cjgillot:source-file-index, r=estebankbors-8/+5
Lazily decode SourceFile from metadata Currently, source files from foreign crates are decoded up-front from metadata. Spans from those crates were matched with the corresponding source using binary search among those files. This PR changes the strategy by matching spans to files during encoding. This allows to decode source files on-demand, instead of up-front. The on-disk format for spans becomes: `<tag> <position from start of file> <length> <file index> <crate (if foreign file)>`.
2022-08-18Auto merge of #98851 - klensy:encode_symbols, r=cjgillotbors-2/+2
rustc_metadata: dedupe strings to prevent multiple copies in rmeta/query cache blow file size r? `@cjgillot` Encodes strings in rmeta/query cache so duplicated ones will be encoded as offsets to first strings, reducing file size.
2022-08-18Add diagnostic translation lints to crates that don't emit them5225225-0/+2
2022-08-17Make names more explicit.Camille GILLOT-15/+21
2022-08-17Keep ctxt in encoded span representation.Camille GILLOT-12/+23
2022-08-15Rollup merge of #100031 - GoldsteinE:try-removing-the-field, r=michaelwoeristerMatthias Krüger-1/+1
improve "try ignoring the field" diagnostic Closes #95795
2022-08-15cache strings while encoding/decoding to compiler artifactsklensy-2/+2
2022-08-13fix span_extend_to_next_char docsGoldstein-1/+1
2022-08-09Rollup merge of #96478 - WaffleLapkin:rustc_default_body_unstable, r=Aaron1011Dylan DPC-0/+1
Implement `#[rustc_default_body_unstable]` This PR implements a new stability attribute — `#[rustc_default_body_unstable]`. `#[rustc_default_body_unstable]` controls the stability of default bodies in traits. For example: ```rust pub trait Trait { #[rustc_default_body_unstable(feature = "feat", isssue = "none")] fn item() {} } ``` In order to implement `Trait` user needs to either - implement `item` (even though it has a default implementation) - enable `#![feature(feat)]` This is useful in conjunction with [`#[rustc_must_implement_one_of]`](https://github.com/rust-lang/rust/pull/92164), we may want to relax requirements for a trait, for example allowing implementing either of `PartialEq::{eq, ne}`, but do so in a safe way — making implementation of only `PartialEq::ne` unstable. r? `@Aaron1011` cc `@nrc` (iirc you were interested in this wrt `read_buf`), `@danielhenrymantilla` (you were interested in the related `#[rustc_must_implement_one_of]`) P.S. This is my first time working with stability attributes, so I'm not sure if I did everything right 😅
2022-08-08Remove unused parameter.Camille GILLOT-2/+0
2022-08-07Add Tuple marker traitMichael Goulet-0/+1
2022-08-07Only encode position from start of file.Camille GILLOT-7/+1
2022-08-06Encode index of SourceFile along with span.Camille GILLOT-0/+5
2022-08-05recover require,include instead of use in itemyukang-0/+1