Commit Graph

48 Commits

Author SHA1 Message Date
Jack Wrenn
691aec2ef3 Make Copy unsafe to implement for ADTs with unsafe fields
As a rule, the application of `unsafe` to a declaration requires that use-sites
of that declaration also require `unsafe`. For example, a field declared
`unsafe` may only be read in the lexical context of an `unsafe` block.

For nearly all safe traits, the safety obligations of fields are explicitly
discharged when they are mentioned in method definitions. For example,
idiomatically implementing `Clone` (a safe trait) for a type with unsafe fields
will require `unsafe` to clone those fields.

Prior to this commit, `Copy` violated this rule. The trait is marked safe, and
although it has no explicit methods, its implementation permits reads of `Self`.

This commit resolves this by making `Copy` conditionally safe to implement. It
remains safe to implement for ADTs without unsafe fields, but unsafe to
implement for ADTs with unsafe fields.

Tracking: #132922
2024-12-07 20:50:00 +00:00
Ralf Jung
f0368983da remove support for rustc_safe_intrinsic attribute; use rustc_intrinsic functions instead 2024-11-08 09:16:00 +01:00
Adrian Taylor
c12fdd2c65 Rename Receiver -> LegacyReceiver
As part of the "arbitrary self types v2" project, we are going to
replace the current `Receiver` trait with a new mechanism based on a
new, different `Receiver` trait.

This PR renames the old trait to get it out the way. Naming is hard.
Options considered included:
* HardCodedReceiver (because it should only be used for things in the
  standard library, and hence is sort-of hard coded)
* LegacyReceiver
* TargetLessReceiver
* OldReceiver

These are all bad names, but fortunately this will be temporary.
Assuming the new mechanism proceeds to stabilization as intended, the
legacy trait will be removed altogether.

Although we expect this trait to be used only in the standard library,
we suspect it may be in use elsehwere, so we're landing this change
separately to identify any surprising breakages.

It's known that this trait is used within the Rust for Linux project; a
patch is in progress to remove their dependency.

This is a part of the arbitrary self types v2 project,
https://github.com/rust-lang/rfcs/pull/3519
https://github.com/rust-lang/rust/issues/44874

r? @wesleywiser
2024-10-22 12:55:16 +00:00
Ralf Jung
9d12735425 stabilize raw_ref_op 2024-08-18 19:46:53 +02:00
Nadrieril
18c7d54993 Fixes in various places 2024-08-10 12:08:46 +02:00
Slanterns
1e117cfb56 stabilize is_sorted 2024-07-28 03:11:54 +08:00
Michael Goulet
9a9d5ec6b6 Remove lang feature for type ascription 2024-07-11 20:40:38 -04:00
Guillaume Gomez
c92f054085 Merge commit '98ed962c7d3eebe12c97588e61245273d265e72f' into master 2024-07-10 12:44:23 +02:00
Mark Rousskov
2b875f0927 Step bootstrap cfgs 2024-05-01 22:19:11 -04:00
Oli Scherer
df0639b6e1 Error on using yield without also using #[coroutine] on the closure
And suggest adding the `#[coroutine]` to the closure
2024-04-24 08:05:29 +00:00
Matthias Krüger
79d217fcf1 Rollup merge of #124003 - WaffleLapkin:dellvmization, r=scottmcm,RalfJung,antoyo
Dellvmize some intrinsics (use `u32` instead of `Self` in some integer intrinsics)

This implements https://github.com/rust-lang/compiler-team/issues/693 minus what was implemented in #123226.

Note: I decided to _not_ change `shl`/... builder methods, as it just doesn't seem worth it.

r? ``@scottmcm``
2024-04-23 20:17:51 +02:00
Maybe Waffle
dd50f454c8 Fixup rustc_codegen_gcc test signature 2024-04-20 12:18:21 +00:00
Ralf Jung
6f36e82594 static_mut_refs: use raw pointers to remove the remaining FIXME 2024-04-15 18:45:56 +02:00
Mark Rousskov
c8cb091e1e Codegen const panic messages as function calls
This skips emitting extra arguments at every callsite (of which there
can be many). For a librustc_driver build with overflow checks enabled,
this cuts 0.7MB from the resulting binary.
2024-03-22 09:55:50 -04:00
Jacob Pratt
a6202e2a77 Rollup merge of #121840 - oli-obk:freeze, r=dtolnay
Expose the Freeze trait again (unstably) and forbid implementing it manually

non-emoji version of https://github.com/rust-lang/rust/pull/121501

cc #60715

This trait is useful for generic constants (associated consts of generic traits). See the test (`tests/ui/associated-consts/freeze.rs`) added in this PR for a usage example. The builtin `Freeze` trait is the only way to do it, users cannot work around this issue.

It's also a useful trait for building some very specific abstrations, as shown by the usage by the `zerocopy` crate: https://github.com/google/zerocopy/issues/941

cc ```@RalfJung```

T-lang signed off on reexposing this unstably: https://github.com/rust-lang/rust/pull/121501#issuecomment-1969827742
2024-03-11 03:47:19 -04:00
Ralf Jung
0975461837 only set noalias on Box with the global allocator 2024-03-05 15:03:33 +01:00
Oli Scherer
3ca0c5913e Forbid implementing Freeze even if the trait is stabilized 2024-02-29 14:10:29 +00:00
Obei Sideg
b959fc1d0a Improve wording of static_mut_ref
Rename `static_mut_ref` lint to `static_mut_refs`.
2024-02-18 06:01:40 +03:00
Ralf Jung
215284a490 remove StructuralEq trait 2024-01-24 07:56:23 +01:00
Obei Sideg
47b06069b3 Update test for E0796 and static_mut_ref lint 2024-01-07 17:29:25 +03:00
Urgau
a72e20d773 Fix rustc codegen gcc tests 2023-12-11 18:48:49 +01:00
Urgau
3cfff05ac7 Allow internal_features in rustc_codegen_gcc examples 2023-12-07 15:26:18 +01:00
Guillaume Gomez
a13408d824 Remove libc dependency in cg_gcc alloc_system example 2023-11-02 21:03:27 +01:00
Guillaume Gomez
34e6386f63 Fix compilation errors in rustc_codegen_gcc examples 2023-11-02 21:03:27 +01:00
Antoni Boucher
9f4f90b19a Merge commit 'e4fe941b11a55c5005630696e9b6d81c65f7bd04' into subtree-update_cg_gcc_2023-10-25 2023-10-26 17:42:02 -04:00
Oli Scherer
a690467938 s/generator/coroutine/ 2023-10-20 21:14:01 +00:00
Oli Scherer
67b28ac34b s/Generator/Coroutine/ 2023-10-20 21:10:38 +00:00
Antoni Boucher
242a482c88 Merge commit '11a0cceab966e5ff1058ddbcab5977e8a1d6d290' into subtree-update_cg_gcc_2023-10-09 2023-10-09 15:53:34 -04:00
Dirreke
814c2e2cea add a csky-unknown-linux-gnuabiv2 target 2023-08-14 23:02:36 +08:00
chenx97
f2dded27f8 support for mips32r6 as a target_arch value 2023-07-18 18:58:18 +08:00
chenx97
5277ea10b5 support for mips64r6 as a target_arch value 2023-07-18 18:58:18 +08:00
Antoni Boucher
38c16e9862 Merge commit '1bbee3e217d75e7bc3bfe5d8c1b35e776fce96e6' into sync-cg_gcc-2023-06-19 2023-06-19 18:51:02 -04:00
DrMeepster
ec100514f8 remove box_free and replace with drop impl 2023-06-16 13:41:06 -07:00
zhaixiaojuan
556ab26283 Define MIN_ALIGN for loongarch64 2023-04-08 00:09:54 +08:00
clubby789
ee38de5155 Remove uses of box_syntax in rustc and tools 2023-03-12 13:19:46 +00:00
Pietro Albini
8652bbb072 replace legacy copyright annotations in submodules 2023-03-09 12:24:47 +01:00
Antoni Boucher
d725cfb6ab Merge commit '08a6d6e16b5efe217123e780398969946266268f' into sync-cg_gcc-2023-03-04 2023-03-05 12:03:19 -05:00
Chris Denton
39511672e7 Remove more redundant alls 2022-11-26 09:54:54 +00:00
Maybe Waffle
928ef372c3 Replace most uses of pointer::offset with add and sub 2022-08-21 02:21:41 +04:00
Yuki Okushi
e4b0d3aff2 Rollup merge of #97675 - nvzqz:unsized-needs-drop, r=dtolnay
Make `std::mem::needs_drop` accept `?Sized`

This change attempts to make `needs_drop` work with types like `[u8]` and `str`.

This enables code in types like `Arc<T>` that was not possible before, such as https://github.com/rust-lang/rust/pull/97676.
2022-06-17 07:16:55 +09:00
Antoni Boucher
fac57d9a06 Merge commit 'e8dca3e87d164d2806098c462c6ce41301341f68' into sync_from_cg_gcc 2022-06-06 22:04:37 -04:00
Nikolai Vazquez
1d3037a107 Fix unsized field order 2022-06-03 12:58:36 -04:00
Nikolai Vazquez
be34cb35c7 Make std::mem::needs_drop accept ?Sized 2022-06-03 03:28:19 -04:00
Yuri Astrakhan
74edcb8bd1 Spellchecking some comments
This PR attempts to clean up some minor spelling mistakes in comments
2022-03-30 01:39:38 -04:00
bjorn3
3888aafe3a Merge commit '39683d8eb7a32a74bea96ecbf1e87675d3338506' into sync_cg_gcc-2022-03-26 2022-03-26 18:29:37 +01:00
Amanieu d'Antras
98f0580cdb Remove alloc::prelude
As per the libs team decision in #58935.

Closes #58935
2021-10-15 01:41:31 +02:00
antoyo
e228f0c16e
Cleanup (#67) 2021-08-15 08:28:46 -04:00
Antoni Boucher
afae271d5d Initial commit 2021-08-12 21:46:50 -04:00