Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove modes from libstd and libcore at least, enable deprecated mode warning by default #3323

Closed
graydon opened this issue Aug 31, 2012 · 8 comments
Labels
A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. C-cleanup Category: PRs that clean code up or issues documenting cleanup.
Milestone

Comments

@graydon
Copy link
Contributor

graydon commented Aug 31, 2012

No description provided.

@ghost ghost assigned graydon Aug 31, 2012
@graydon
Copy link
Contributor Author

graydon commented Aug 31, 2012

Some other components of this bug:

  • Fix main to not take args, just have a sys::get_argv or something
  • Fix the Eq and Cmp traits
  • Add a -Z flag for compiling with the old mode logic; turn old mode logic off by default, only on for rustc (and/or old libraries if they don't get done in time)

@bblum
Copy link
Contributor

bblum commented Sep 4, 2012

why not have main's optional arguments be &[~str] instead of &&~[~str]?

@jdm
Copy link
Contributor

jdm commented Sep 5, 2012

One benefit of a sys::get_argv is that it reduces the "public static void main(String[] args)" factor.

@ghost ghost assigned catamorphism Sep 25, 2012
@brson
Copy link
Contributor

brson commented Sep 29, 2012

I prefer to keep the main argv signature, mostly because sometimes it's useful to call main manually, and not having an argv in the signature means involving global runtime state. For example, the jit is currently tested by building crates and calling main.

@nikomatsakis
Copy link
Contributor

I agree with @brson. We were discussing this the other day and I remembered how much I dislike how Python does it. I always end up making a main(args) fn anyhow. Basically it's bad for all the normal reasons global state is bad—it's unclear what the inputs to the fn are, and it gives the caller no control over them.

@catamorphism
Copy link
Contributor

Current status: serialization and serialization2 cause several mode warnings, and net_tcp causes one warning. Two others (in ptr and extfmt) will go away once I make a new snapshot. This is otherwise done.

@catamorphism
Copy link
Contributor

Still warnings from (in core) stackwalk::frame_address, and (in std) net_tcp and serialization. Otherwise done. Deprecated modes forbidden in all modules except these, AFAIK.

@catamorphism
Copy link
Contributor

I'm closing this because we've done all we're going to do for 0.4; the ones I mentioned in my previous comment have been muted.

flip1995 pushed a commit to flip1995/rust that referenced this issue May 5, 2020
Fix the bugs of `manual_memcpy`, simplify the suggestion and refactor it

While I’m working on the long procrastinated work to expand `manual_memcpy`(rust-lang#1670), I found a few minor bugs and probably unidiomatic or old coding style. There is a brief explanation of changes to the behaviour this PR will make below. And, I have a questoin: do I need to add tests for the first and second fixed bugs? I thought it might be too rare cases to include the tests for those. I added for the last one though.

* Bug fix
  * It negates resulted offsets (`src/dst_offset`) when `offset` is subtraction by 0. This PR will remove any subtraction by 0 as a part of minification.

    ```rust
    for i in 0..5 {
        dst[i - 0] = src[i];
    }
    ```

    ```diff
     warning: it looks like you're manually copying between slices
       --> src/main.rs:2:14
        |
    LL  |     for i in 0..5 {
    -   |              ^^^^ help: try replacing the loop by: `dst[..-5].clone_from_slice(&src[..5])`
    +   |              ^^^^ help: try replacing the loop by: `dst[..5].clone_from_slice(&src[..5])`
        |
    ```
  * It prints `RangeTo` or `RangeFull` when both of `end` and `offset` are 0, which have different meaning. This PR will print 0. I could reject the cases `end` is 0, but I thought I won’t catch other cases `reverse_range_loop` will trigger, and it’s over to catch every such cases.

    ```rust
    for i in 0..0 {
        dst[i] = src[i];
    }
    ```

    ```diff
     warning: it looks like you're manually copying between slices
       --> src/main.rs:2:14
        |
     LL |     for i in 0..0 {
    -   |              ^^^^ help: try replacing the loop by: `dst.clone_from_slice(&src[..])`
    +   |              ^^^^ help: try replacing the loop by: `dst[..0].clone_from_slice(&src[..0])`
        |
    ```
  * it prints four dots when `end` is `None`. This PR will ignore any `for` loops without `end` because a `for` loop that takes `RangeFrom` as its argument and contains indexing without the statements or the expressions that end loops such as `break` will definitely panic, and `manual_memcpy` should ignore the loops with such control flow.

    ```rust
    fn manual_copy(src: &[u32], dst: &mut [u32]) {
        for i in 0.. {
            dst[i] = src[i];
        }
    }
    ```

    ```diff
    -warning: it looks like you're manually copying between slices
    -  --> src/main.rs:2:14
    -   |
    -LL |     for i in 0.. {
    -   |              ^^^ help: try replacing the loop by: `dst[....].clone_from_slice(&src[....])`
    -   |
    ```
* Simplification of the suggestion

  * It prints 0 when `start` or `end` and `offset` are same (from rust-lang#3323). This PR will use `RangeTo`

changelog: fixed the bugs of `manual_memcpy` and also simplify the suggestion.
bors pushed a commit to rust-lang-ci/rust that referenced this issue May 15, 2021
silence testing on the failure repo until it's fixed
jaisnan pushed a commit to jaisnan/rust-dev that referenced this issue Jul 29, 2024
This PR fixes inadvertently exposing some of the unstable Kani
intrinsics.

By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 and MIT licenses.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. C-cleanup Category: PRs that clean code up or issues documenting cleanup.
Projects
None yet
Development

No branches or pull requests

6 participants