Commit graph

272739 commits

Author SHA1 Message Date
aaishwarymishra@gmail.com
292fd0ffed Adds new intrinsic declaration
changes old intrinsic to new declaration
2024-12-08 19:46:45 +05:30
bors
f33a8c6426 Auto merge of #134033 - matthiaskrgr:rollup-69fswyh, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #131669 (lint: change help for pointers to dyn types in FFI)
 - #133104 (crashes: add test for #131451)
 - #133767 (Add more info on type/trait mismatches for different crate versions)
 - #133861 (Add allocate_bytes and refactor allocate_str in InterpCx for raw byte…)
 - #133976 (Removed Unnecessary Spaces From RELEASES.md)
 - #133987 (Define acronym for thread local storage)
 - #133992 (Actually walk into lifetimes and attrs in `EarlyContextAndPass`)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-12-08 13:32:19 +00:00
Matthias Krüger
d4b5345248
Rollup merge of #133992 - compiler-errors:walk-fully, r=jieyouxu
Actually walk into lifetimes and attrs in `EarlyContextAndPass`

Visitors that don't also call `walk_*` are kinda a footgun...

I believe all the other early lint functions walk into their types correctly at this point.
2024-12-08 14:28:26 +01:00
Matthias Krüger
a12f3aaf3d
Rollup merge of #133987 - Will-Low:DefineTlsAcronym, r=workingjubilee
Define acronym for thread local storage

There are multiple references in this module's documentation to the acronym "TLS" (meaning "thread local storage"), without defining it. This is confusing for the reader.

I propose that this acronym be defined during the first use of the term.
2024-12-08 14:28:25 +01:00
Matthias Krüger
bf74478bab
Rollup merge of #133976 - rohit141914:master, r=workingjubilee
Removed Unnecessary Spaces From RELEASES.md
2024-12-08 14:28:25 +01:00
Matthias Krüger
0d26662fd3
Rollup merge of #133861 - shamb0:refactor_InterpCx_allocate_str, r=RalfJung
Add allocate_bytes and refactor allocate_str in InterpCx for raw byte…

Fixes https://github.com/rust-lang/miri/issues/4025

This PR introduces a new `allocate_bytes` function in InterpCx and refactors `allocate_str` to use it internally. This change improves memory allocation handling in the interpreter by:

1. Adding `allocate_bytes`:
   - Direct byte slice allocation support
   - Handles both mutable and immutable allocations
   - Maintains proper memory alignment and deduplication

2. Refactoring `allocate_str`:
   - Now uses `allocate_bytes` internally
   - Adds string-specific metadata handling
   - Preserves existing string allocation behavior

This is part 1 of the planned changes to improve timezone string handling in Miri. A follow-up PR will update Miri's timezone logic to use this new allocation mechanism.

Related: https://github.com/rust-lang/miri/pull/4069
2024-12-08 14:28:24 +01:00
Matthias Krüger
a369714a29
Rollup merge of #133767 - estebank:multiple-dep-version-tests, r=Nadrieril
Add more info on type/trait mismatches for different crate versions

When encountering a type or trait mismatch for two types coming from two different crates with the same name, detect if it is either mixing two types/traits from the same crate on different versions:

```
error[E0308]: mismatched types
  --> replaced
   |
LL |     do_something_type(Type);
   |     ----------------- ^^^^ expected `dependency::Type`, found `dep_2_reexport::Type`
   |     |
   |     arguments to this function are incorrect
   |
note: two different versions of crate `dependency` are being used; two types coming from two different versions of the same crate are different types even if they look the same
  --> replaced
   |
LL | pub struct Type(pub i32);
   | ^^^^^^^^^^^^^^^ this is the expected type `dependency::Type`
   |
  ::: replaced
   |
LL | pub struct Type;
   | ^^^^^^^^^^^^^^^ this is the found type `dep_2_reexport::Type`
   |
  ::: replaced
   |
LL | extern crate dep_2_reexport;
   | ---------------------------- one version of crate `dependency` is used here, as a dependency of crate `foo`
LL | extern crate dependency;
   | ------------------------ one version of crate `dependency` is used here, as a direct dependency of the current crate
   = help: you can use `cargo tree` to explore your dependency tree
note: function defined here
  --> replaced
   |
LL | pub fn do_something_type(_: Type) {}
   |        ^^^^^^^^^^^^^^^^^

error[E0308]: mismatched types
  --> replaced
   |
LL |     do_something_trait(Box::new(Type) as Box<dyn Trait2>);
   |     ------------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected trait `dependency::Trait2`, found trait `dep_2_reexport::Trait2`
   |     |
   |     arguments to this function are incorrect
   |
note: two different versions of crate `dependency` are being used; two types coming from two different versions of the same crate are different types even if they look the same
  --> replaced
   |
LL | pub trait Trait2 {}
   | ^^^^^^^^^^^^^^^^ this is the expected trait `dependency::Trait2`
   |
  ::: replaced
   |
LL | pub trait Trait2 {}
   | ^^^^^^^^^^^^^^^^ this is the found trait `dep_2_reexport::Trait2`
   |
  ::: replaced
   |
LL | extern crate dep_2_reexport;
   | ---------------------------- one version of crate `dependency` is used here, as a dependency of crate `foo`
LL | extern crate dependency;
   | ------------------------ one version of crate `dependency` is used here, as a direct dependency of the current crate
   = help: you can use `cargo tree` to explore your dependency tree
note: function defined here
  --> replaced
   |
LL | pub fn do_something_trait(_: Box<dyn Trait2>) {}
   |        ^^^^^^^^^^^^^^^^^^
```

or if it is different crates that were renamed to the same name:

```
error[E0308]: mismatched types
  --> $DIR/type-mismatch-same-crate-name.rs:21:20
   |
LL |         a::try_foo(foo2);
   |         ---------- ^^^^ expected `main:🅰️:Foo`, found a different `main:🅰️:Foo`
   |         |
   |         arguments to this function are incorrect
   |
note: two types coming from two different crates are different types even if they look the same
  --> $DIR/auxiliary/crate_a2.rs:1:1
   |
LL | pub struct Foo;
   | ^^^^^^^^^^^^^^ this is the found type `crate_a2::Foo`
   |
  ::: $DIR/auxiliary/crate_a1.rs:1:1
   |
LL | pub struct Foo;
   | ^^^^^^^^^^^^^^ this is the expected type `crate_a1::Foo`
   |
  ::: $DIR/type-mismatch-same-crate-name.rs:13:17
   |
LL |     let foo2 = {extern crate crate_a2 as a; a::Foo};
   |                 --------------------------- one type comes from crate `crate_a2` is used here, which is renamed locally to `a`
...
LL |         extern crate crate_a1 as a;
   |         --------------------------- one type comes from crate `crate_a1` is used here, which is renamed locally to `a`
note: function defined here
  --> $DIR/auxiliary/crate_a1.rs:10:8
   |
LL | pub fn try_foo(x: Foo){}
   |        ^^^^^^^

error[E0308]: mismatched types
  --> $DIR/type-mismatch-same-crate-name.rs:27:20
   |
LL |         a::try_bar(bar2);
   |         ---------- ^^^^ expected trait `main:🅰️:Bar`, found a different trait `main:🅰️:Bar`
   |         |
   |         arguments to this function are incorrect
   |
note: two types coming from two different crates are different types even if they look the same
  --> $DIR/auxiliary/crate_a2.rs:3:1
   |
LL | pub trait Bar {}
   | ^^^^^^^^^^^^^ this is the found trait `crate_a2::Bar`
   |
  ::: $DIR/auxiliary/crate_a1.rs:3:1
   |
LL | pub trait Bar {}
   | ^^^^^^^^^^^^^ this is the expected trait `crate_a1::Bar`
   |
  ::: $DIR/type-mismatch-same-crate-name.rs:13:17
   |
LL |     let foo2 = {extern crate crate_a2 as a; a::Foo};
   |                 --------------------------- one trait comes from crate `crate_a2` is used here, which is renamed locally to `a`
...
LL |         extern crate crate_a1 as a;
   |         --------------------------- one trait comes from crate `crate_a1` is used here, which is renamed locally to `a`
note: function defined here
  --> $DIR/auxiliary/crate_a1.rs:11:8
   |
LL | pub fn try_bar(x: Box<Bar>){}
   |        ^^^^^^^
```

This new output unifies the E0308 errors detail with the pre-existing E0277 errors, and better differentiates the "`extern crate` renamed" and "same crate, different versions" cases.
2024-12-08 14:28:24 +01:00
Matthias Krüger
5101833d7a
Rollup merge of #133104 - matthiaskrgr:crashtest_debugass_131451.rs, r=saethlin
crashes: add test for #131451

r? `@saethlin`
How do I find out which mir opts are involved here? 😅
2024-12-08 14:28:23 +01:00
Matthias Krüger
703bb98230
Rollup merge of #131669 - niacdoial:linting-ptrdyn-ffi, r=workingjubilee
lint: change help for pointers to dyn types in FFI

### Context
while playing around, I encountered the warning for dyn types in `extern "C"` functions, but even after that I assumed that a (rust) raw pointer could be interpreted in C ('s ABI) as a `void *`... to be fair part of why I ignored the warning is because I wanted to poke at the generated assembly, not make useful code.

### Example

```rust
extern "C"
fn caller(callee: *const dyn Fn(i32)->i32){
    // -- snip --
}
```

old warning:
```
warning: `extern` fn uses type `dyn Fn(i32) -> i32`, which is not FFI-safe
 --> file/name.rs:42:19
   |
42 | fn caller(callee: *const dyn Fn(i32)->i32) {
   |                   ^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe
   |
  = note: trait objects have no C equivalent
  = note: `#[warn(improper_ctypes_definitions)]` on by default
  ```

new warning:
```
warning: `extern` fn uses type `dyn Fn(i32) -> i32`, which is not FFI-safe
 --> file/name.rs:42:19
   |
42 | fn caller(callee: *const dyn Fn(i32)->i32) -> (){
   |                   ^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe
   |
  = note: this pointer to an unsized type contains metadata, which makes it incompatible with a C pointer
  = note: `#[warn(improper_ctypes_definitions)]` on by default
```
2024-12-08 14:28:22 +01:00
Prajwal S N
477b722fe1
docs: better examples for std::ops::ControlFlow
Signed-off-by: Prajwal S N <prajwalnadig21@gmail.com>
2024-12-08 18:21:15 +05:30
Matthias Krüger
159ed85d24 crashes: add test for #131451 2024-12-08 13:09:46 +01:00
Zalathar
3a35fb6938 coverage: Unused functions don't need to store CoverageIdsInfo 2024-12-08 21:00:53 +11:00
Zalathar
4d2bfece41 coverage: Remove FunctionCoverageCollector
The information that was being collected by this builder type is now collected
by the `coverage_ids_info` query instead.
2024-12-08 20:53:57 +11:00
Zalathar
2022ef7f12 coverage: Use a query to find counters/expressions that must be zero
This query (`coverage_ids_info`) already determines which counter/expression
IDs are unused, so it only takes a little extra effort to also determine which
counters/expressions must have a value of zero.
2024-12-08 20:53:39 +11:00
bors
f415c07494 Auto merge of #133522 - estebank:dont-suggest-unstable-trait, r=compiler-errors
Don't suggest restricting bound with unstable traits on stable and mention it's unstable on nightly

On nightly, we mention the trait is unstable

```
error[E0277]: the trait bound `T: Unstable` is not satisfied
  --> $DIR/unstable-trait-suggestion.rs:13:9
   |
LL |     foo(t)
   |     --- ^ the trait `Unstable` is not implemented for `T`
   |     |
   |     required by a bound introduced by this call
   |
note: required by a bound in `foo`
  --> $DIR/unstable-trait-suggestion.rs:9:11
   |
LL | fn foo<T: Unstable>(_: T) {}
   |           ^^^^^^^^ required by this bound in `foo`
help: consider restricting type parameter `T` but it is an `unstable` trait
   |
LL | pub fn demo<T: Unstable>(t: T) {
   |              ++++++++++
```

On stable, we don't suggest the trait at all

```
error[E0277]: the trait bound `T: Unstable` is not satisfied
  --> $DIR/unstable-trait-suggestion.rs:13:9
   |
LL |     foo(t)
   |     --- ^ the trait `Unstable` is not implemented for `T`
   |     |
   |     required by a bound introduced by this call
   |
note: required by a bound in `foo`
  --> $DIR/unstable-trait-suggestion.rs:9:11
   |
LL | fn foo<T: Unstable>(_: T) {}
   |           ^^^^^^^^ required by this bound in `foo`
```

Fix #133511.
2024-12-08 09:12:31 +00:00
Ben Kimock
4740b0fda2
Merge pull request #4081 from rust-lang/rustup-2024-12-08
Automatic Rustup
2024-12-08 07:45:35 +00:00
许杰友 Jieyou Xu (Joe)
754dec3fbc Adjust atomic-from-mut-not-available.rs
- Introduce two revisions: one for 32-bit x86 vs one for 64-bit x86_64
  and compare & contrast the errors.
- Document the test intention and note its limitations.
2024-12-08 15:32:04 +08:00
许杰友 Jieyou Xu (Joe)
1247f01a3c Move atomic-from-mut-not-available.rs to tests/ui/stdlib-unit-tests/
This test exercises the combined effect of the
`cfg(target_has_atomic_equal_alignment = "...")` implementation in the
compiler as well as the usage of said
`cfg(target_has_atomic_equal_alignment)` in `core`.
2024-12-08 15:32:04 +08:00
许杰友 Jieyou Xu (Joe)
3a33522ca8 Adjust assoc-oddities-3.rs
- Include the original MCVE as reported in
  <https://github.com/rust-lang/rust/issues/28777>.
- Document the intention of the test.
2024-12-08 15:32:04 +08:00
许杰友 Jieyou Xu (Joe)
b815a93614 Move assoc-oddities-3.rs under tests/ui/parser/assoc/
This is where `assoc-oddities-{1,2}.rs` are located, reunite them!
2024-12-08 15:32:04 +08:00
许杰友 Jieyou Xu (Joe)
6959582ac6 Move assoc-lang-items.rs to tests/ui/lang-items/ 2024-12-08 15:32:04 +08:00
许杰友 Jieyou Xu (Joe)
1e3328dd72 Document assoc-lang-items.rs 2024-12-08 15:32:04 +08:00
许杰友 Jieyou Xu (Joe)
5e07f6e197 Move assign-imm-local-twice.rs to tests/ui/borrowck/ 2024-12-08 15:32:04 +08:00
许杰友 Jieyou Xu (Joe)
62c3160a29 Adjust assign-imm-local-twice.rs
- Document the test intention, including both the language semantics it
  is checking, as well as the borrowck diagnostics that this is
  exercising.
- Tag this test with `//@ run-rustfix` as this ui test exercises a
  suggestion diagnostics to make an immutable local var mutable.
- Minor error annotation reformatting.
2024-12-08 15:32:04 +08:00
许杰友 Jieyou Xu (Joe)
5a79963179 Move assign-assign.rs to tests/ui/codegen/assign-expr-unit-type.rs 2024-12-08 15:32:04 +08:00
许杰友 Jieyou Xu (Joe)
73b00ca8c6 Document assign-assign.rs 2024-12-08 15:31:40 +08:00
Ralf Jung
03c412ead4 fix build 2024-12-08 08:21:20 +01:00
Zalathar
f3f7c20f7b coverage: Move CoverageIdsInfo into mir::coverage 2024-12-08 17:50:42 +11:00
The Miri Cronjob Bot
8cabbc9bd0 Merge from rustc 2024-12-08 05:03:13 +00:00
The Miri Cronjob Bot
7ba5192913 Preparing for merge from rustc 2024-12-08 04:55:19 +00:00
Scott McMurray
18d7b9a12f Remove unnecessary int_type_width_signed function 2024-12-07 19:01:00 -08:00
bors
728f2daab4 Auto merge of #133988 - weihanglo:update-cargo, r=weihanglo
Update cargo

6 commits in 05f54fdc34310f458033af8a63ce1d699fae8bf6..20a443231846b81c7b909691ec3f15eb173f2b18
2024-12-03 03:14:12 +0000 to 2024-12-06 21:56:56 +0000
- fix(fingerprint): Don't throwaway the cache on RUSTFLAGS changes  (rust-lang/cargo#14830)
- fix(build-rs)!: Remove meaningless 'cargo_cfg_debug_assertions' (rust-lang/cargo#14901)
- docs(fingerprint): cargo-rustc extra flags do not affect the metadata  (rust-lang/cargo#14898)
- fix(add): Don't select yanked versions when normalizing names (rust-lang/cargo#14895)
- fix(fix): Migrate workspace dependencies (rust-lang/cargo#14890)
- test(build-std): make mock-std closer to real world (rust-lang/cargo#14896)
2024-12-08 01:44:04 +00:00
Michael Goulet
88669aed22 Don't use AsyncFnOnce::CallOnceFuture bounds for signature deduction 2024-12-08 00:01:21 +00:00
Esteban Küber
25ad0478cb Tweak wording 2024-12-07 22:18:51 +00:00
Esteban Küber
6277fb0a3f Use run-make diff output for stable output test 2024-12-07 21:37:15 +00:00
Esteban Küber
b466405890 Do not talk about "trait <Foo = Bar>"
Pass in an appropriate `Option<DefId>` in more cases from hir ty lowering.
2024-12-07 21:37:15 +00:00
Esteban Küber
af09423967 fix rustdoc test 2024-12-07 21:37:15 +00:00
Esteban Küber
cb4db0a6c6 Account for impl Trait in "add bound" suggestion message 2024-12-07 21:37:15 +00:00
Esteban Küber
d860e5b088 Mention type parameter in more cases and don't suggest ~const bound already there 2024-12-07 21:37:13 +00:00
Esteban Küber
3f2a63a68b Use trait name instead of full constraint in suggestion message
```
help: consider restricting type parameter `T` with traits `Copy` and `Trait`
   |
LL | fn duplicate_custom<T: Copy + Trait>(t: S<T>) -> (S<T>, S<T>) {
   |                      ++++++++++++++
```

```
help: consider restricting type parameter `V` with trait `Copy`
   |
LL | fn index<'a, K, V: std::marker::Copy>(map: &'a HashMap<K, V>, k: K) -> &'a V {
   |                  +++++++++++++++++++
```
2024-12-07 21:29:58 +00:00
Esteban Küber
568b0ac624 Add test for lack of suggestion in stable
This test will break when `Step` gets stabilized, but punt until then.
2024-12-07 21:26:23 +00:00
Esteban Küber
d13c34828e reword trait bound suggestion message to include the bounds 2024-12-07 21:26:20 +00:00
Esteban Küber
68253e14ee Don't suggest restricting bound with unstable traits on stable
On nightly, we mention the trait is unstable

```
error[E0277]: the trait bound `T: Unstable` is not satisfied
  --> $DIR/unstable-trait-suggestion.rs:13:9
   |
LL |     foo(t)
   |     --- ^ the trait `Unstable` is not implemented for `T`
   |     |
   |     required by a bound introduced by this call
   |
note: required by a bound in `foo`
  --> $DIR/unstable-trait-suggestion.rs:9:11
   |
LL | fn foo<T: Unstable>(_: T) {}
   |           ^^^^^^^^ required by this bound in `foo`
help: consider restricting type parameter `T` but it is an `unstable` trait
   |
LL | pub fn demo<T: Unstable>(t: T) {
   |              ++++++++++
```

On stable, we don't suggest the trait at all

```
error[E0277]: the trait bound `T: Unstable` is not satisfied
  --> $DIR/unstable-trait-suggestion.rs:13:9
   |
LL |     foo(t)
   |     --- ^ the trait `Unstable` is not implemented for `T`
   |     |
   |     required by a bound introduced by this call
   |
note: required by a bound in `foo`
  --> $DIR/unstable-trait-suggestion.rs:9:11
   |
LL | fn foo<T: Unstable>(_: T) {}
   |           ^^^^^^^^ required by this bound in `foo`
```
2024-12-07 21:10:44 +00:00
Jack Wrenn
3ce35a4ec5 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
Esteban Küber
16bf7223ea Add more info on type/trait mismatches for different crate versions
When encountering a type or trait mismatch for two types coming from two different crates with the same name, detect if it is either mixing two types/traits from the same crate on different versions:

```
error[E0308]: mismatched types
  --> replaced
   |
LL |     do_something_type(Type);
   |     ----------------- ^^^^ expected `dependency::Type`, found `dep_2_reexport::Type`
   |     |
   |     arguments to this function are incorrect
   |
note: two different versions of crate `dependency` are being used; two types coming from two different versions of the same crate are different types even if they look the same
  --> replaced
   |
LL | pub struct Type(pub i32);
   | ^^^^^^^^^^^^^^^ this is the expected type `dependency::Type`
   |
  ::: replaced
   |
LL | pub struct Type;
   | ^^^^^^^^^^^^^^^ this is the found type `dep_2_reexport::Type`
   |
  ::: replaced
   |
LL | extern crate dep_2_reexport;
   | ---------------------------- one version of crate `dependency` is used here, as a dependency of crate `foo`
LL | extern crate dependency;
   | ------------------------ one version of crate `dependency` is used here, as a direct dependency of the current crate
   = help: you can use `cargo tree` to explore your dependency tree
note: function defined here
  --> replaced
   |
LL | pub fn do_something_type(_: Type) {}
   |        ^^^^^^^^^^^^^^^^^

error[E0308]: mismatched types
  --> replaced
   |
LL |     do_something_trait(Box::new(Type) as Box<dyn Trait2>);
   |     ------------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected trait `dependency::Trait2`, found trait `dep_2_reexport::Trait2`
   |     |
   |     arguments to this function are incorrect
   |
note: two different versions of crate `dependency` are being used; two types coming from two different versions of the same crate are different types even if they look the same
  --> replaced
   |
LL | pub trait Trait2 {}
   | ^^^^^^^^^^^^^^^^ this is the expected trait `dependency::Trait2`
   |
  ::: replaced
   |
LL | pub trait Trait2 {}
   | ^^^^^^^^^^^^^^^^ this is the found trait `dep_2_reexport::Trait2`
   |
  ::: replaced
   |
LL | extern crate dep_2_reexport;
   | ---------------------------- one version of crate `dependency` is used here, as a dependency of crate `foo`
LL | extern crate dependency;
   | ------------------------ one version of crate `dependency` is used here, as a direct dependency of the current crate
   = help: you can use `cargo tree` to explore your dependency tree
note: function defined here
  --> replaced
   |
LL | pub fn do_something_trait(_: Box<dyn Trait2>) {}
   |        ^^^^^^^^^^^^^^^^^^
```

or if it is different crates that were renamed to the same name:

```
error[E0308]: mismatched types
  --> $DIR/type-mismatch-same-crate-name.rs:21:20
   |
LL |         a::try_foo(foo2);
   |         ---------- ^^^^ expected `main:🅰️:Foo`, found a different `main:🅰️:Foo`
   |         |
   |         arguments to this function are incorrect
   |
note: two types coming from two different crates are different types even if they look the same
  --> $DIR/auxiliary/crate_a2.rs:1:1
   |
LL | pub struct Foo;
   | ^^^^^^^^^^^^^^ this is the found type `crate_a2::Foo`
   |
  ::: $DIR/auxiliary/crate_a1.rs:1:1
   |
LL | pub struct Foo;
   | ^^^^^^^^^^^^^^ this is the expected type `crate_a1::Foo`
   |
  ::: $DIR/type-mismatch-same-crate-name.rs:13:17
   |
LL |     let foo2 = {extern crate crate_a2 as a; a::Foo};
   |                 --------------------------- one type comes from crate `crate_a2` is used here, which is renamed locally to `a`
...
LL |         extern crate crate_a1 as a;
   |         --------------------------- one type comes from crate `crate_a1` is used here, which is renamed locally to `a`
note: function defined here
  --> $DIR/auxiliary/crate_a1.rs:10:8
   |
LL | pub fn try_foo(x: Foo){}
   |        ^^^^^^^

error[E0308]: mismatched types
  --> $DIR/type-mismatch-same-crate-name.rs:27:20
   |
LL |         a::try_bar(bar2);
   |         ---------- ^^^^ expected trait `main:🅰️:Bar`, found a different trait `main:🅰️:Bar`
   |         |
   |         arguments to this function are incorrect
   |
note: two types coming from two different crates are different types even if they look the same
  --> $DIR/auxiliary/crate_a2.rs:3:1
   |
LL | pub trait Bar {}
   | ^^^^^^^^^^^^^ this is the found trait `crate_a2::Bar`
   |
  ::: $DIR/auxiliary/crate_a1.rs:3:1
   |
LL | pub trait Bar {}
   | ^^^^^^^^^^^^^ this is the expected trait `crate_a1::Bar`
   |
  ::: $DIR/type-mismatch-same-crate-name.rs:13:17
   |
LL |     let foo2 = {extern crate crate_a2 as a; a::Foo};
   |                 --------------------------- one trait comes from crate `crate_a2` is used here, which is renamed locally to `a`
...
LL |         extern crate crate_a1 as a;
   |         --------------------------- one trait comes from crate `crate_a1` is used here, which is renamed locally to `a`
note: function defined here
  --> $DIR/auxiliary/crate_a1.rs:11:8
   |
LL | pub fn try_bar(x: Box<Bar>){}
   |        ^^^^^^^
```

This new output unifies the E0308 errors detail with the pre-existing E0277 errors, and better differentiates the "`extern crate` renamed" and "same crate, different versions" cases.
2024-12-07 18:18:08 +00:00
Ralf Jung
6956b4165f
Merge pull request #4080 from RalfJung/sc-fence-access-test
add weak memory consistency test for mixing SC accesses and fences
2024-12-07 17:39:58 +00:00
Ralf Jung
854dcbc5d8 add weak memory consistency test for mixing SC accesses and fences 2024-12-07 18:14:17 +01:00
bjorn3
23fda35811 Reduce indentation in run_compiler 2024-12-07 17:13:33 +00:00
Nadrieril
2459dbb4ba Address review comments 2024-12-07 13:37:35 +01:00
shamb0
9b07e75055 Add allocate_bytes and refactor allocate_str in InterpCx for raw byte allocation
Signed-off-by: shamb0 <r.raajey@gmail.com>
2024-12-07 16:36:17 +05:30