Commit Graph

233901 Commits

Author SHA1 Message Date
Ralf Jung
ec1d04967d don't globally ignore rustc-ice files 2023-09-16 09:44:44 +02:00
bors
790309b102 Auto merge of #115315 - RalfJung:field-capture-packed-alignment, r=oli-obk
closure field capturing: don't depend on alignment of packed fields

This fixes the closure field capture part of https://github.com/rust-lang/rust/issues/115305: field capturing always stops at projections into packed structs, no matter the alignment of the field. This means changing a private field type from `u8` to `u64` can never change how closures capture fields, which is probably what we want.

Here's an example where, before this PR, changing the type of a private field in a repr(Rust) struct can change the output of a program:

```rust
#![allow(dead_code)]

mod m {
    // before patch
    #[derive(Default)]
    pub struct S1(u8);
    // after patch
    #[derive(Default)]
    pub struct S2(u64);
}

struct NoisyDrop;
impl Drop for NoisyDrop {
    fn drop(&mut self) {
        eprintln!("dropped!");
    }
}

#[repr(packed)]
struct MyType {
    field: m::S1, // output changes when this becomes S2
    other_field: NoisyDrop,
    third_field: Vec<()>,
}

fn test(r: MyType) {
    let c = || {
        let _val = std::ptr::addr_of!(r.field);
        let _val = r.third_field;
    };
    drop(c);
    eprintln!("before dropping");
}

fn main() {
    test(MyType {
        field: Default::default(),
        other_field: NoisyDrop,
        third_field: Vec::new(),
    });
}
```

Of course this is a breaking change for the same reason that doing field capturing in the first place was a breaking change. Packed fields are relatively rare and depending on drop order is relatively rare, so I don't expect this to have much impact, but it's hard to be sure and even a crater run will only tell us so much.

Also see the [nomination comment](https://github.com/rust-lang/rust/pull/115315#issuecomment-1702807825).

Cc `@rust-lang/wg-rfc-2229` `@ehuss`
2023-09-16 05:29:23 +00:00
bors
635c4a5e61 Auto merge of #114494 - est31:extend_useless_ptr_null_checks, r=jackh726
Make useless_ptr_null_checks smarter about some std functions

This teaches the `useless_ptr_null_checks` lint that some std functions can't ever return null pointers, because they need to point to valid data, get references as input, etc.

This is achieved by introducing an `#[rustc_never_returns_null_ptr]` attribute and adding it to these std functions (gated behind bootstrap `cfg_attr`).

Later on, the attribute could maybe be used to tell LLVM that the returned pointer is never null. I don't expect much impact of that though, as the functions are pretty shallow and usually the input data is already never null.

Follow-up of PR #113657

Fixes #114442
2023-09-16 03:40:20 +00:00
bors
e81f85fe9e Auto merge of #115520 - Finomnis:const_transmute_copy, r=dtolnay
Stabilize const_transmute_copy

Closes #83165
2023-09-16 01:51:55 +00:00
bors
c48e6ffce5 Auto merge of #115829 - notriddle:notriddle/rustdoc-theme-css-merge, r=GuillaumeGomez
rustdoc: merge theme css into rustdoc.css

Based on https://github.com/rust-lang/rust/pull/115812#issuecomment-1717960119

Having them in separate files used to make more sense, before the migration to CSS variables made the theme files as small as they are nowadays. This is already how docs.rs and mdBook do it.

WebPageTest comparison page:

https://www.webpagetest.org/video/compare.php?tests=230913_AiDc3F_B9E,230913_AiDc7G_B9B

Filmstrip comparison:

![image](https://github.com/rust-lang/rust/assets/1593513/7ccad27b-7497-47ee-94c0-1a701b69c0c2)

Old waterfall:

![image](https://github.com/rust-lang/rust/assets/1593513/7a6e4375-226d-4205-8871-a4d775a70748)

New waterfall:

![image](https://github.com/rust-lang/rust/assets/1593513/e29112e3-84f7-417d-a250-cd6c10fa50f5)
2023-09-16 00:02:41 +00:00
bors
20999de3a2 Auto merge of #115878 - weihanglo:update-cargo, r=weihanglo
Update cargo

11 commits in 2fc85d15a542bfb610aff7682073412cf635352f..d5336f813df39d476e61fc46daabb1446350660a
2023-09-09 01:49:46 +0000 to 2023-09-14 19:55:49 +0000
- fix: emit a warning for `credential-alias` shadowing (rust-lang/cargo#12671)
- refactor: fix lint errors in preparation of `[lints]` table integration (rust-lang/cargo#12669)
- Limit cargo add feature print (rust-lang/cargo#12662)
- Clippy (rust-lang/cargo#12667)
- Prerelease candidates error message (rust-lang/cargo#12659)
- Fix typos: `informations` -&gt; `information` (rust-lang/cargo#12666)
- chore: update globset to 0.4.13 (rust-lang/cargo#12665)
- refactor: Consolidate clap/shell styles (rust-lang/cargo#12655)
- libgit2 fixed upstream (rust-lang/cargo#12657)
- Index summary enum (rust-lang/cargo#12643)
- feat(help): Add styling to help output (rust-lang/cargo#12578)

r? ghost
2023-09-15 20:54:56 +00:00
Weihang Lo
4d4ac94c07
Update cargo 2023-09-16 00:38:45 +08:00
Michael Howell
ab41e2b6dc rustdoc: avoid calling document.write after the page loads 2023-09-15 07:40:17 -07:00
Michael Howell
7e86fd61e8 rustdoc: merge theme css into rustdoc.css
Based on
https://github.com/rust-lang/rust/pull/115812#issuecomment-1717960119

Having them in separate files used to make more sense, before the
migration to CSS variables made the theme files as small as they are
nowadays. This is already how docs.rs and mdBook do it.
2023-09-15 07:40:17 -07:00
bors
33440d7fc6 Auto merge of #115871 - krasimirgg:llvm-18-en, r=durin42
llvm-wrapper: adapt for LLVM API changes

No functional changes intended.

Adapts the wrapper for 0a1aa6cda2.

Found by our experimental rust + llvm @ head CI: https://buildkite.com/llvm-project/rust-llvm-integrate-prototype/builds/22301#018a9926-a810-4e56-8ac2-e6f30b78f433/253-551
2023-09-15 14:36:20 +00:00
Krasimir Georgiev
af401b0ca3 llvm-wrapper: adapt for LLVM API changes
No functional changes intended.

Adapts the wrapper for 0a1aa6cda2.

Found by our experimental rust + llvm @ head CI: https://buildkite.com/llvm-project/rust-llvm-integrate-prototype/builds/22301#018a9926-a810-4e56-8ac2-e6f30b78f433/253-551
2023-09-15 14:31:43 +00:00
bors
e7f9f48d76 Auto merge of #115853 - obeis:hir-analysis-migrate-diagnostics-6, r=compiler-errors
Migrate `rustc_hir_analysis` to session diagnostic [Part 6]

Part 6: Finish `coherence/inherent_impls.rs` file
2023-09-15 11:55:27 +00:00
bors
56e1aaadb3 Auto merge of #115851 - Alexendoo:clippy-doc-hidden-headers, r=flip1995
Ignore `#[doc(hidden)]` functions in clippy doc lints

Fixes https://github.com/rust-lang/rust-clippy/issues/11501

The implementation before #115689 had a check for unsugared doc comments that also happened to catch `#[doc(hidden)]`, this adds the check back in more explicitly

852bf4e51b/src/tools/clippy/clippy_lints/src/doc.rs (L526-L529)

r? `@flip1995`
2023-09-15 09:55:31 +00:00
bors
915c8af550 Auto merge of #115850 - compiler-errors:effect-canon, r=fee1-dead
Canonicalize effect vars in new solver

No good reason not to fix this, we already have all the machinery to make this work.

r? `@fee1-dead`

Fixes #115792
2023-09-15 06:45:56 +00:00
Michael Goulet
280f058560 Canonicalize effect vars in new solver 2023-09-15 05:11:16 +00:00
bors
9cbc90c0ae Auto merge of #115861 - clubby789:migrate-remove-semi-diag, r=compiler-errors
Make 'remove semi to coerce match' diagnostic translatable
2023-09-15 04:56:26 +00:00
clubby789
b663464ea0 Make 'remove semi to coerce match' diagnostic translatable 2023-09-15 00:45:09 +00:00
bors
ae9465fee3 Auto merge of #115859 - compiler-errors:effect-fallback, r=fee1-dead
Fallback effects even if types also fallback

`||` is short circuiting, so if we do ty/int var fallback, we *don't* do effect fallback 😸

r? `@fee1-dead` or `@oli-obk`

Fixes #115791
Fixes #115842
2023-09-15 00:05:28 +00:00
bors
ca2b74f1ae Auto merge of #115857 - notriddle:notriddle/gui-test-themes, r=GuillaumeGomez
rusdoc: add gui test for custom CSS themes

Based on
https://github.com/rust-lang/rust/pull/115829#issuecomment-1720056602
2023-09-14 21:52:34 +00:00
Michael Goulet
5c907a7859 Fallback effects even if types also fall back 2023-09-14 21:08:42 +00:00
Michael Howell
cbccf800b8 rusdoc: add gui test for custom CSS themes
Based on
https://github.com/rust-lang/rust/pull/115829#issuecomment-1720056602
2023-09-14 13:24:23 -07:00
bors
dac91a82e1 Auto merge of #115677 - matthewjasper:let-expr-recovery, r=b-naber
Improve invalid let expression handling

- Move all of the checks for valid let expression positions to parsing.
- Add a field to ExprKind::Let in AST/HIR to mark whether it's in a valid location.
- Suppress some later errors and MIR construction for invalid let expressions.
- Fix a (drop) scope issue that was also responsible for #104172.

Fixes #104172
Fixes #104868
2023-09-14 19:56:55 +00:00
Obei Sideg
8723af5116 Migrate rustc_hir_analysis to session diagnostic
Part 6: Finish `coherence/inherent_impls.rs`
2023-09-14 21:50:22 +03:00
Alex Macleod
88f3f2315c Ignore #[doc(hidden)] functions in clippy doc lints 2023-09-14 17:52:36 +00:00
bors
ccf817b9bb Auto merge of #115848 - matthiaskrgr:rollup-lsul9dz, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 - #115772 (Improve Span in smir)
 - #115832 (Fix the error message for `#![feature(no_coverage)]`)
 - #115834 (Properly consider binder vars in `HasTypeFlagsVisitor`)
 - #115844 (Paper over an accidental regression)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-09-14 17:22:20 +00:00
Matthias Krüger
9362604518
Rollup merge of #115844 - oli-obk:opaque_lifetime_ambiguity, r=jackh726
Paper over an accidental regression

r? types

cc https://github.com/rust-lang/rust/issues/115781 (do not close issue until beta backport has been performed)

The PR reasons are explained with comments in the source.

In order to keep the diff simple, this PR effectively reverts https://github.com/rust-lang/rust/pull/113661, but only for RPITs. I will submit a follow up PR that fixes this correctly instead of just disabling the newly added check for RPITs. This PR should be significantly easier to review for beta backport
2023-09-14 19:12:33 +02:00
Matthias Krüger
57370828b9
Rollup merge of #115834 - compiler-errors:binder-vars, r=jackh726
Properly consider binder vars in `HasTypeFlagsVisitor`

Given a PolyTraitRef like `for<'a> Ty: Trait` (where neither `Ty` nor `Trait` mention `'a`), we do *not* return true for `.has_type_flags(TypeFlags::HAS_LATE_BOUND)`, even though binders are supposed to act as if they have late-bound vars even if they don't mention them in their bound value: 31ae3b2bdb. This is because we use `HasTypeFlagsVisitor`, which only computes the type flags for `Ty`, `Const` and `Region` and `Predicates`, and we consequently skip any binders (and setting flags for their vars) that are not contained in one of these types.

This ends up causing a problem, because when we call `TyCtxt::erase_regions` (which both erases regions *and* anonymizes bound vars), we will skip such a PolyTraitRef, not anonymizing it, and therefore not making it structurally equal to other binders. This breaks vtable computations.

This PR computes the flags for all binders we enter in `HasTypeFlagsVisitor` if we're looking for `TypeFlags::HAS_LATE_BOUND` (or `TypeFlags::HAS_{RE,TY,CT}_LATE_BOUND`).

Fixes #115807
2023-09-14 19:12:32 +02:00
Matthias Krüger
3dbcc28884
Rollup merge of #115832 - Zalathar:fix-no-coverage, r=oli-obk
Fix the error message for `#![feature(no_coverage)]`

When #114656 was written, the feature flag to replace `no_coverage` was originally spelled `coverage`, but it was eventually changed to `coverage_attribute` instead.

That update happened to miss this error message in `removed.rs`, and unfortunately I only noticed just *after* the original PR was approved and merged.

cc ``@bossmc`` (original author) ``@oli-obk`` (original reviewer)
``@rustbot`` label +A-code-coverage
2023-09-14 19:12:32 +02:00
Matthias Krüger
4f90a52ae6
Rollup merge of #115772 - ouz-a:smir_span2, r=oli-obk
Improve Span in smir

Addressing https://github.com/rust-lang/project-stable-mir/issues/31

r? ``@oli-obk``
2023-09-14 19:12:31 +02:00
bors
e437e57954 Auto merge of #115804 - RalfJung:valtree-to-const-val, r=oli-obk
consistently pass ty::Const through valtrees

Some drive-by things extracted from https://github.com/rust-lang/rust/pull/115748.
2023-09-14 15:34:31 +00:00
Oli Scherer
0277184977 Paper over an accidental regression 2023-09-14 15:16:48 +00:00
bors
5e71913156 Auto merge of #115817 - fee1-dead-contrib:fix-codegen, r=oli-obk
treat host effect params as erased in codegen

This fixes the changes brought to codegen tests when effect params are added to libcore, by not attempting to monomorphize functions that get the host param by being `const fn`.

r? `@oli-obk`
2023-09-14 13:42:30 +00:00
bors
df63c5f140 Auto merge of #112038 - Nemo157:edition-2024-unsafe_op_in_unsafe_fn, r=RalfJung
Change `unsafe_op_in_unsafe_fn` to be `warn`-by-default from edition 2024

This was previously FCPed: https://github.com/rust-lang/rust/issues/71668#issuecomment-1189396886

There were two blocking requirements:
* Fix the `unused_unsafe` lint, done in https://github.com/rust-lang/rust/pull/100081
* Have `cargo fix` able to fix the lint, done in https://github.com/rust-lang/rust/pull/112017
2023-09-14 11:52:08 +00:00
bors
d97e04fbfc Auto merge of #115764 - RalfJung:const-by-ref-alloc-id, r=oli-obk
some ConstValue refactoring

In particular, use AllocId instead of Allocation in ConstValue::ByRef. This helps avoid redundant AllocIds when a  `ByRef` constant gets put back into the interpreter.

r? `@oli-obk`

Fixes https://github.com/rust-lang/rust/issues/105536
2023-09-14 10:04:45 +00:00
Ralf Jung
04a4df5f16 add regression test for something we fixed 2023-09-14 11:56:55 +02:00
Ralf Jung
b18c0a8c4e fix clippy (and MIR printing) handling of ConstValue::Indirect slices 2023-09-14 11:56:55 +02:00
Ralf Jung
0a6e263b9f bless all 2023-09-14 11:56:55 +02:00
Ralf Jung
7aa44eee99 don't force all slice-typed ConstValue to be ConstValue::Slice 2023-09-14 11:56:55 +02:00
bors
fea046037f Auto merge of #115828 - clubby789:clubby-off-vacation, r=lqd
Remove `clubby789` from `users_on_vacation`
2023-09-14 08:17:53 +00:00
Deadbeef
a0a801cd38 treat host effect params as erased generics in codegen
This fixes the changes brought to codegen tests when effect params are
added to libcore, by not attempting to monomorphize functions that get
the host param by being `const fn`.
2023-09-14 07:34:35 +00:00
bors
e17235105c Auto merge of #115825 - cjgillot:expr-field-lint, r=compiler-errors
Visit ExprField for lint levels.

Fixes https://github.com/rust-lang/rust/issues/115823
2023-09-14 06:29:23 +00:00
Ralf Jung
19fb2c7ccd found another place where we can eval() a const, and go through valtrees 2023-09-14 07:56:01 +02:00
Ralf Jung
292d5bba86 always evaluate ConstantKind::Ty through valtrees 2023-09-14 07:44:49 +02:00
Ralf Jung
06947be196 valtree_to_const_value: add fast-path for Scalar tuples/structs 2023-09-14 07:40:05 +02:00
Ralf Jung
430c386821 make it more clear which functions create fresh AllocId 2023-09-14 07:27:31 +02:00
Ralf Jung
0f8908da27 cleanup op_to_const a bit; rename ConstValue::ByRef → Indirect 2023-09-14 07:27:30 +02:00
Ralf Jung
551f481ffb use AllocId instead of Allocation in ConstValue::ByRef 2023-09-14 07:26:24 +02:00
Ralf Jung
3aedb85a27 a bit of cleanup in valtree_to_const_value 2023-09-14 07:22:44 +02:00
bors
2394959310 Auto merge of #115751 - lcnr:inspect-cleanup, r=compiler-errors
some inspect improvements

split from #114810 because I still want to experiment a bunch with that PR and these changes are self-contained.

r? `@compiler-errors`
2023-09-14 04:42:07 +00:00
Michael Goulet
7ae301ec47 Properly consider binder vars in HasTypeFlagsVisitor 2023-09-14 03:49:59 +00:00