<commit_before>package org.rust.lang.core.resolve

import org.rust.cargo.project.workspace.cargoWorkspace

class RsStdlibResolveTest : RsResolveTestBase() {

    override fun getProjectDescriptor() = WithStdlibRustProjectDescriptor

    fun testHasStdlibSources() {
        val cargoProject = myModule.cargoWorkspace
        cargoProject?.findCrateByName("std")?.crateRoot
            ?: error("No Rust sources found during test.\nTry running `rustup component add rust-src`")
    }

    fun testResolveFs() = stubOnlyResolve("""
    //- main.rs
        use std::fs::File;
                    //^ ...libstd/fs.rs

        fn main() {}
    """)

    fun testResolveCollections() {
        if (is2016_2()) return

        stubOnlyResolve("""
        //- main.rs
            use std::collections::Bound;
                                 //^ ...libcollections/lib.rs

            fn main() {}
        """)
    }

    fun testResolveCore() {
        if (is2016_2()) return

        stubOnlyResolve("""
        //- main.rs
            // FromStr is defined in `core` and reexported in `std`
            use std::str::FromStr;
                            //^ ...libcore/str/mod.rs

            fn main() { }
        """)
    }

    fun testResolvePrelude() {
        if (is2016_2()) return

        stubOnlyResolve("""
        //- main.rs
            fn main() {
                let _ = String::new();
                        //^  ...libcollections/string.rs
            }
        """)
    }

    fun testResolvePreludeInModule() {
        if (is2016_2()) return

        stubOnlyResolve("""
        //- main.rs
            mod tests {
                fn test() {
                    let _ = String::new();
                            //^  ...libcollections/string.rs
                }
            }
        """)
    }

    fun testResolveBox() {
        if (is2016_2()) return

        stubOnlyResolve("""
        //- main.rs
            fn main() {
                let _ = Box::new(92);
                       //^ ...liballoc/boxed.rs
            }
        """)
    }

    fun testDontPutStdInStd() = stubOnlyResolve("""
    //- main.rs
        use std::std;
                //^ unresolved
    """)

    fun testNoCoreExcludesCore() = stubOnlyResolve("""
    //- main.rs
        #![no_std]
        use core::core;
                  //^ unresolved
    """)

    fun testNoCoreExcludesStd() = stubOnlyResolve("""
    //- main.rs
        #![no_std]
        use core::std;
                  //^ unresolved
    """)

    fun testResolveOption() {
        if (is2016_2()) return

        stubOnlyResolve("""
        //- main.rs
            fn f(i: i32) -> Option<i32> {}

            fn bar() {
                if let Some(x) = f() {
                    if let Some(y) = f(x) {
                          //^ ...libcore/option.rs
                        if let Some(z) = f(y) {}
                    }
                }
            }
        """)
    }

    fun testPreludeVisibility1() = stubOnlyResolve("""
    //- main.rs
        mod m { }

        fn main() { m::Some; }
                      //^ unresolved
    """)

    fun testPreludeVisibility2() = stubOnlyResolve("""
    //- main.rs
        mod m { }

        fn main() { use self::m::Some; }
                                //^ unresolved
    """)

    fun `test string slice resolve`()= stubOnlyResolve("""
    //- main.rs
        fn main() { "test".lines(); }
                            //^ ...libcollections/str.rs
    """)

    fun `test slice resolve`()= stubOnlyResolve("""
    //- main.rs
        fn main() {
            let x : [i32];
            x.iter()
             //^ ...libcollections/slice.rs
        }
    """)
}<commit_msg>TY: fix tests<commit_after>package org.rust.lang.core.resolve

import org.rust.cargo.project.workspace.cargoWorkspace

class RsStdlibResolveTest : RsResolveTestBase() {

    override fun getProjectDescriptor() = WithStdlibRustProjectDescriptor

    fun testHasStdlibSources() {
        val cargoProject = myModule.cargoWorkspace
        cargoProject?.findCrateByName("std")?.crateRoot
            ?: error("No Rust sources found during test.\nTry running `rustup component add rust-src`")
    }

    fun testResolveFs() = stubOnlyResolve("""
    //- main.rs
        use std::fs::File;
                    //^ ...libstd/fs.rs

        fn main() {}
    """)

    fun testResolveCollections() {
        if (is2016_2()) return

        stubOnlyResolve("""
        //- main.rs
            use std::collections::Bound;
                                 //^ ...libcollections/lib.rs

            fn main() {}
        """)
    }

    fun testResolveCore() {
        if (is2016_2()) return

        stubOnlyResolve("""
        //- main.rs
            // FromStr is defined in `core` and reexported in `std`
            use std::str::FromStr;
                            //^ ...libcore/str/mod.rs

            fn main() { }
        """)
    }

    fun testResolvePrelude() {
        if (is2016_2()) return

        stubOnlyResolve("""
        //- main.rs
            fn main() {
                let _ = String::new();
                        //^  ...libcollections/string.rs
            }
        """)
    }

    fun testResolvePreludeInModule() {
        if (is2016_2()) return

        stubOnlyResolve("""
        //- main.rs
            mod tests {
                fn test() {
                    let _ = String::new();
                            //^  ...libcollections/string.rs
                }
            }
        """)
    }

    fun testResolveBox() {
        if (is2016_2()) return

        stubOnlyResolve("""
        //- main.rs
            fn main() {
                let _ = Box::new(92);
                       //^ ...liballoc/boxed.rs
            }
        """)
    }

    fun testDontPutStdInStd() = stubOnlyResolve("""
    //- main.rs
        use std::std;
                //^ unresolved
    """)

    fun testNoCoreExcludesCore() = stubOnlyResolve("""
    //- main.rs
        #![no_std]
        use core::core;
                  //^ unresolved
    """)

    fun testNoCoreExcludesStd() = stubOnlyResolve("""
    //- main.rs
        #![no_std]
        use core::std;
                  //^ unresolved
    """)

    fun testResolveOption() {
        if (is2016_2()) return

        stubOnlyResolve("""
        //- main.rs
            fn f(i: i32) -> Option<i32> {}

            fn bar() {
                if let Some(x) = f() {
                    if let Some(y) = f(x) {
                          //^ ...libcore/option.rs
                        if let Some(z) = f(y) {}
                    }
                }
            }
        """)
    }

    fun testPreludeVisibility1() = stubOnlyResolve("""
    //- main.rs
        mod m { }

        fn main() { m::Some; }
                      //^ unresolved
    """)

    fun testPreludeVisibility2() = stubOnlyResolve("""
    //- main.rs
        mod m { }

        fn main() { use self::m::Some; }
                                //^ unresolved
    """)

    fun `test string slice resolve`() {
        if (is2016_2()) return

        stubOnlyResolve("""

        //- main.rs
            fn main() { "test".lines(); }
                                //^ ...libcollections/str.rs
        """)
    }

    fun `test slice resolve`() {
        if (is2016_2()) return

        stubOnlyResolve("""
        //- main.rs
            fn main() {
                let x : [i32];
                x.iter()
                 //^ ...libcollections/slice.rs
            }
        """)
    }
}
{'fraction_non_alphanumeric': 0.14354130637222295, 'fraction_numerical': 0.011972861513901822, 'mean_word_length': 1.1678200692041523, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 5, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2143107', 'n_tokens_mistral': 2282, 'n_tokens_neox': 2182, 'n_words': 412}