about summary refs log tree commit diff
path: root/compiler/rustc_middle/src
AgeCommit message (Collapse)AuthorLines
2022-03-02rename ErrorReported -> ErrorGuaranteedmark-53/+53
2022-03-02Auto merge of #87402 - nagisa:nagisa/request-feature-requests-for-features, ↵bors-0/+9
r=estebank Direct users towards using Rust target feature names in CLI This PR consists of a couple of changes on how we handle target features. In particular there is a bug-fix wherein we avoid passing through features that aren't prefixed by `+` or `-` to LLVM. These appear to be causing LLVM to assert, which is pretty poor a behaviour (and also makes it pretty clear we expect feature names to be prefixed). The other commit, I anticipate to be somewhat more controversial is outputting a warning when users specify a LLVM-specific, or otherwise unknown, feature name on the CLI. In those situations we request users to either replace it with a known Rust feature name (e.g. `bmi` -> `bmi1`) or file a feature request. I've a couple motivations for this: first of all, if users are specifying these features on the command line, I'm pretty confident there is also a need for these features to be usable via `#[cfg(target_feature)]` machinery. And second, we're growing a fair number of backends recently and having ability to provide some sort of unified-ish interface in this place seems pretty useful to me. Sponsored by: standard.ai
2022-03-01Querify `global_backend_features`Simonas Kazlauskas-0/+9
At the very least this serves to deduplicate the diagnostics that are output about unknown target features provided via CLI.
2022-02-28Auto merge of #94299 - oli-obk:stable_hash_ty, r=michaelwoeristerbors-9/+63
Caching the stable hash of Ty within itself Instead of computing stable hashes on types as needed, we compute it during interning. This way we can, when a hash is requested, just hash that hash, which is significantly faster than traversing the type itself. We only do this for incremental for now, as incremental is the only frequent user of stable hashing. As a next step we can try out * moving the hash and TypeFlags to Interner, so projections and regions get the same benefit (tho regions are not nested, so maybe that's not a good idea? Would be nice for dedup tho) * start comparing types via their stable hash instead of their address?
2022-02-27Auto merge of #94157 - erikdesjardins:more-noundef, r=nikicbors-0/+5
Apply noundef attribute to all scalar types which do not permit raw init Beyond `&`/`&mut`/`Box`, this covers `char`, enum discriminants, `NonZero*`, etc. All such types currently cause a Miri error if left uninitialized, and an `invalid_value` lint in cases like `mem::uninitialized::<char>()`. Note that this _does not_ change whether or not it is UB for `u64` (or other integer types with no invalid values) to be undef. Fixes (partially) #74378. r? `@ghost` (blocked on #94127) `@rustbot` label S-blocked
2022-02-27Auto merge of #94084 - Mark-Simulacrum:drop-sharded, r=cjgillotbors-10/+9
Avoid query cache sharding code in single-threaded mode In non-parallel compilers, this is just adding needless overhead at compilation time (since there is only one shard statically anyway). This amounts to roughly ~10 seconds reduction in bootstrap time, with overall neutral (some wins, some losses) performance results. Parallel compiler performance should be largely unaffected by this PR; sharding is kept there.
2022-02-26Apply noundef attribute to all scalar types which do not permit raw initErik Desjardins-0/+5
Beyond `&`/`&mut`/`Box`, this covers `char`, discriminants, `NonZero*`, etc. All such types currently cause a Miri error if left uninitialized, and an `invalid_value` lint in cases like `mem::uninitialized::<char>()` Note that this _does not_ change whether or not it is UB for `u64` (or other integer types with no invalid values) to be undef.
2022-02-26suggest a float literal when dividing a floating-point type by {integer}Takayuki Maeda-0/+5
fix a message implement a rustfix-applicable suggestion implement `suggest_floating_point_literal` add `ObligationCauseCode::BinOp` remove duplicate code fix function names in uitests use `Diagnostic` instead of `DiagnosticBuilder`
2022-02-25Auto merge of #94290 - Mark-Simulacrum:bump-bootstrap, r=pietroalbinibors-6/+12
Bump bootstrap to 1.60 This bumps the bootstrap compiler to 1.60 and cleans up cfgs and Span's rustc_pass_by_value (enabled by the bootstrap bump).
2022-02-25"Reset" the hashing context before stable hashing the typesOli Scherer-2/+6
2022-02-25Auto merge of #94279 - tmiasko:write-print, r=Mark-Simulacrumbors-2/+2
Print `ParamTy` and `ParamConst` instead of displaying them Display for `ParamTy` and `ParamConst` is implemented in terms of print. Using print avoids creating a new `FmtPrinter` just to display the parameter name. r? `@Mark-Simulacrum`
2022-02-25Rollup merge of #93845 - compiler-errors:in-band-lifetimes, r=cjgillotMatthias Krüger-36/+3
Remove in band lifetimes As discussed in t-lang backlog bonanza, the `in_band_lifetimes` FCP closed in favor for the feature not being stabilized. This PR removes `#![feature(in_band_lifetimes)]` in its entirety. Let me know if this PR is too hasty, and if we should instead do something intermediate for deprecate the feature first. r? `@scottmcm` (or feel free to reassign, just saw your last comment on #44524) Closes #44524
2022-02-25Enable rustc_pass_by_value for SpanMark Rousskov-0/+6
2022-02-25Switch bootstrap cfgsMark Rousskov-6/+6
2022-02-25Auto merge of #94130 - erikdesjardins:partially, r=nikicbors-0/+1
Use undef for (some) partially-uninit constants There needs to be some limit to avoid perf regressions on large arrays with undef in each element (see comment in the code). Fixes: #84565 Original PR: #83698 Depends on LLVM 14: #93577
2022-02-25Auto merge of #93878 - Aaron1011:newtype-macro, r=cjgillotbors-0/+1
Convert `newtype_index` to a proc macro The `macro_rules!` implementation was becomng excessively complicated, and difficult to modify. The new proc macro implementation should make it much easier to add new features (e.g. skipping certain `#[derive]`s)
2022-02-24Remove LifetimeDefOriginMichael Goulet-33/+3
2022-02-24Remove in-band lifetimesMichael Goulet-3/+0
2022-02-25Auto merge of #93368 - eddyb:diagbld-guarantee, r=estebankbors-29/+38
rustc_errors: let `DiagnosticBuilder::emit` return a "guarantee of emission". That is, `DiagnosticBuilder` is now generic over the return type of `.emit()`, so we'll now have: * `DiagnosticBuilder<ErrorReported>` for error (incl. fatal/bug) diagnostics * can only be created via a `const L: Level`-generic constructor, that limits allowed variants via a `where` clause, so not even `rustc_errors` can accidentally bypass this limitation * asserts `diagnostic.is_error()` on emission, just in case the construction restriction was bypassed (e.g. by replacing the whole `Diagnostic` inside `DiagnosticBuilder`) * `.emit()` returns `ErrorReported`, as a "proof" token that `.emit()` was called (though note that this isn't a real guarantee until after completing the work on #69426) * `DiagnosticBuilder<()>` for everything else (warnings, notes, etc.) * can also be obtained from other `DiagnosticBuilder`s by calling `.forget_guarantee()` This PR is a companion to other ongoing work, namely: * #69426 and it's ongoing implementation: #93222 the API changes in this PR are needed to get statically-checked "only errors produce `ErrorReported` from `.emit()`", but doesn't itself provide any really strong guarantees without those other `ErrorReported` changes * #93244 would make the choices of API changes (esp. naming) in this PR fit better overall In order to be able to let `.emit()` return anything trustable, several changes had to be made: * `Diagnostic`'s `level` field is now private to `rustc_errors`, to disallow arbitrary "downgrade"s from "some kind of error" to "warning" (or anything else that doesn't cause compilation to fail) * it's still possible to replace the whole `Diagnostic` inside the `DiagnosticBuilder`, sadly, that's harder to fix, but it's unlikely enough that we can paper over it with asserts on `.emit()` * `.cancel()` now consumes `DiagnosticBuilder`, preventing `.emit()` calls on a cancelled diagnostic * it's also now done internally, through `DiagnosticBuilder`-private state, instead of having a `Level::Cancelled` variant that can be read (or worse, written) by the user * this removes a hazard of calling `.cancel()` on an error then continuing to attach details to it, and even expect to be able to `.emit()` it * warnings were switched to *only* `can_emit_warnings` on emission (instead of pre-cancelling early) * `struct_dummy` was removed (as it relied on a pre-`Cancelled` `Diagnostic`) * since `.emit()` doesn't consume the `DiagnosticBuilder` <sub>(I tried and gave up, it's much more work than this PR)</sub>, we have to make `.emit()` idempotent wrt the guarantees it returns * thankfully, `err.emit(); err.emit();` can return `ErrorReported` both times, as the second `.emit()` call has no side-effects *only* because the first one did do the appropriate emission * `&mut Diagnostic` is now used in a lot of function signatures, which used to take `&mut DiagnosticBuilder` (in the interest of not having to make those functions generic) * the APIs were already mostly identical, allowing for low-effort porting to this new setup * only some of the suggestion methods needed some rework, to have the extra `DiagnosticBuilder` functionality on the `Diagnostic` methods themselves (that change is also present in #93259) * `.emit()`/`.cancel()` aren't available, but IMO calling them from an "error decorator/annotator" function isn't a good practice, and can lead to strange behavior (from the caller's perspective) * `.downgrade_to_delayed_bug()` was added, letting you convert any `.is_error()` diagnostic into a `delay_span_bug` one (which works because in both cases the guarantees available are the same) This PR should ideally be reviewed commit-by-commit, since there is a lot of fallout in each. r? `@estebank` cc `@Manishearth` `@nikomatsakis` `@mark-i-m`
2022-02-24Fix intra-doc link issues exposed by new macroAaron Hill-0/+1
These links never worked, but the lint was suppressed due to the fact that the span was pointing into the macro. With the new macro implementation, the span now points directly to the doc comment in the macro invocation, so it's no longer suppressed.
2022-02-24resolve/metadata: Stop encoding macros as reexportsVadim Petrochenkov-0/+2
2022-02-24resolve: Fix incorrect results of `opt_def_kind` query for some built-in macrosVadim Petrochenkov-2/+1
Previously it always returned `MacroKind::Bang` while some of those macros are actually attributes and derives
2022-02-24Auto merge of #94131 - Mark-Simulacrum:fmt-string, r=oli-obkbors-44/+57
Always format to internal String in FmtPrinter This avoids monomorphizing for different parameters, decreasing generic code instantiated downstream from rustc_middle -- locally seeing 7% unoptimized LLVM IR line wins on rustc_borrowck, for example. We likely can't/shouldn't get rid of the Result-ness on most functions, though some further cleanup avoiding fmt::Error where we now know it won't occur may be possible, though somewhat painful -- fmt::Write is a pretty annoying API to work with in practice when you're trying to use it infallibly.
2022-02-24Don't cache stable hashes in types outside of incremental modeOli Scherer-3/+19
2022-02-24Remove redundant hashing configuration logic in type internerOli Scherer-7/+2
2022-02-24Try out caching the stable hash of Ty within itselfOli Scherer-8/+47
2022-02-24Auto merge of #94129 - cjgillot:rmeta-table, r=petrochenkovbors-28/+11
Back more metadata using per-query tables r? `@ghost`
2022-02-24Rollup merge of #94288 - Mark-Simulacrum:ser-opt, r=nnethercoteMatthias Krüger-7/+4
Cleanup a few Decoder methods This is just some simple follow up to #93839. r? `@nnethercote`
2022-02-24Rollup merge of #94267 - pierwill:fast-reject-bound, r=michaelwoeristerMatthias Krüger-4/+4
Remove unused ordering derivations and bounds for `SimplifiedTypeGen` This is another small PR clearing the way for work on #90317.
2022-02-23Rename `region_should_not_be_omitted` to `should_print_region`Tomasz Miąsko-4/+4
to avoid double negation
2022-02-23Print `ParamTy` and `ParamConst` instead of displaying themTomasz Miąsko-2/+2
Display for `ParamTy` and `ParamConst` is implemented in terms of print. Using print avoids creating a new `FmtPrinter` just to display the parameter name.
2022-02-23rustc_errors: let `DiagnosticBuilder::emit` return a "guarantee of emission".Eduard-Mihai Burtescu-4/+7
2022-02-23rustc_errors: handle `force_warn` only through `DiagnosticId::Lint`.Eduard-Mihai Burtescu-4/+2
2022-02-23Replace `&mut DiagnosticBuilder`, in signatures, with `&mut Diagnostic`.Eduard-Mihai Burtescu-21/+29
2022-02-22Remove unused ordering derivations and bounds for `SimplifiedTypeGen`pierwill-4/+4
2022-02-22Delete Decoder::read_unitMark Rousskov-4/+1
2022-02-22Provide copy-free access to raw Decoder bytesMark Rousskov-3/+3
2022-02-22Auto merge of #94254 - matthiaskrgr:rollup-7llbjhd, r=matthiaskrgrbors-1/+5
Rollup of 7 pull requests Successful merges: - #94169 (Fix several asm! related issues) - #94178 (tidy: fire less "ignoring file length unneccessarily" warnings) - #94179 (solarish current_exe using libc call directly) - #94196 (compiletest: Print process output info with less whitespace) - #94208 (Add the let else tests found missing in the stabilization report) - #94237 (Do not suggest wrapping an item if it has ambiguous un-imported methods) - #94246 (ScalarMaybeUninit is explicitly hexadecimal in its formatting) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-02-22Rollup merge of #94246 - RalfJung:hex, r=oli-obkMatthias Krüger-1/+1
ScalarMaybeUninit is explicitly hexadecimal in its formatting This makes `ScalarMaybeUninit` consistent with `Scalar` after the changes in https://github.com/rust-lang/rust/pull/94189. r? ``@oli-obk``
2022-02-22Rollup merge of #94169 - Amanieu:asm_stuff, r=nagisaMatthias Krüger-0/+4
Fix several asm! related issues This is a combination of several fixes, each split into a separate commit. Splitting these into PRs is not practical since they conflict with each other. Fixes #92378 Fixes #85247 r? ``@nagisa``
2022-02-22change `mir::Constant` in mir dumpslcnr-32/+23
2022-02-21ScalarMaybeUninit is explicitly hexadecimal in its formattingRalf Jung-1/+1
2022-02-21Auto merge of #94225 - matthiaskrgr:rollup-0728x8n, r=matthiaskrgrbors-31/+38
Rollup of 10 pull requests Successful merges: - #91192 (Some improvements to the async docs) - #94143 (rustc_const_eval: adopt let else in more places) - #94156 (Gracefully handle non-UTF-8 string slices when pretty printing) - #94186 (Update pin_static_ref stabilization version.) - #94189 (Implement LowerHex on Scalar to clean up their display in rustdoc) - #94190 (Use Metadata::modified instead of FileTime::from_last_modification_ti…) - #94203 (CTFE engine: Scalar: expose size-generic to_(u)int methods) - #94211 (Better error if the user tries to do assignment ... else) - #94215 (trait system: comments and small nonfunctional changes) - #94220 (Correctly handle miniz_oxide extern crate declaration) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-02-21Rollup merge of #94203 - RalfJung:to_sized_int, r=oli-obkMatthias Krüger-21/+25
CTFE engine: Scalar: expose size-generic to_(u)int methods This matches the size-generic constructors `Scalar::from_(u)int`, and it would have helped in https://github.com/rust-lang/miri/pull/1978. r? `@oli-obk`
2022-02-21Rollup merge of #94189 - GuillaumeGomez:scalar-lower-hex, r=RalfJungMatthias Krüger-8/+12
Implement LowerHex on Scalar to clean up their display in rustdoc Follow-up of https://github.com/rust-lang/rust/pull/94091. r? ````@RalfJung````
2022-02-21Rollup merge of #94156 - tmiasko:pp-str, r=petrochenkovMatthias Krüger-2/+1
Gracefully handle non-UTF-8 string slices when pretty printing Fixes #78520.
2022-02-21Take CodegenFnAttrs into account when validating asm! register operandsAmanieu d'Antras-0/+4
Checking of asm! register operands now properly takes function attributes such as #[target_feature] and #[instruction_set] into account.
2022-02-21Auto merge of #93505 - lcnr:substsref-vs-ty-list, r=michaelwoeristerbors-75/+177
safely `transmute<&List<Ty<'tcx>>, &List<GenericArg<'tcx>>>` This PR has 3 relevant steps which are is split in distinct commits. The first commit now interns `List<Ty<'tcx>>` and `List<GenericArg<'tcx>>` together, potentially reusing memory while allowing free conversions between these two using `List<Ty<'tcx>>::as_substs()` and `SubstsRef<'tcx>::try_as_type_list()`. Using this, we then use `&'tcx List<Ty<'tcx>>` instead of a `SubstsRef<'tcx>` for tuple fields, simplifying a bunch of code. Finally, as tuple fields and other generic arguments now use a different `TypeFoldable<'tcx>` impl, we optimize the impl for `List<Ty<'tcx>>` improving perf by slightly less than 1% in tuple heavy benchmarks.
2022-02-21reviewlcnr-1/+10
2022-02-21add comment to `Lift` implslcnr-1/+5