- 
                Notifications
    You must be signed in to change notification settings 
- Fork 13.9k
          tests/ui: A New Order [13/N]
          #142429
        
          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
          
     Merged
      
      
    
  
     Merged
                    
  
    tests/ui: A New Order [13/N]
  
  #142429
                      Changes from all commits
      Commits
    
    
  File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| //! Test inner attributes (#![...]) behavior in impl blocks with cfg conditions. | ||
| //! | ||
| //! This test verifies that: | ||
| //! - Inner attributes can conditionally exclude entire impl blocks | ||
| //! - Regular attributes within impl blocks work independently | ||
| //! - Attribute parsing doesn't consume too eagerly | ||
|  | ||
| //@ run-pass | ||
|  | ||
| struct Foo; | ||
|  | ||
| impl Foo { | ||
| #![cfg(false)] | ||
|  | ||
| fn method(&self) -> bool { | ||
| false | ||
| } | ||
| } | ||
|  | ||
| impl Foo { | ||
| #![cfg(not(FALSE))] | ||
|  | ||
| // Check that we don't eat attributes too eagerly. | ||
| #[cfg(false)] | ||
| fn method(&self) -> bool { | ||
| false | ||
| } | ||
|  | ||
| fn method(&self) -> bool { | ||
| true | ||
| } | ||
| } | ||
|  | ||
| pub fn main() { | ||
| assert!(Foo.method()); | ||
| } | 
        
          
          
            12 changes: 8 additions & 4 deletions
          
          12 
        
  tests/ui/integral-indexing.rs → tests/ui/indexing/indexing-integral-types.rs
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -1,16 +1,20 @@ | ||
| //! Test that only usize can be used for indexing arrays and slices. | ||
|  | ||
| pub fn main() { | ||
| let v: Vec<isize> = vec![0, 1, 2, 3, 4, 5]; | ||
| let s: String = "abcdef".to_string(); | ||
|  | ||
| // Valid indexing with usize | ||
| v[3_usize]; | ||
| v[3]; | ||
| v[3u8]; //~ ERROR the type `[isize]` cannot be indexed by `u8` | ||
| v[3i8]; //~ ERROR the type `[isize]` cannot be indexed by `i8` | ||
| v[3u8]; //~ ERROR the type `[isize]` cannot be indexed by `u8` | ||
| v[3i8]; //~ ERROR the type `[isize]` cannot be indexed by `i8` | ||
| v[3u32]; //~ ERROR the type `[isize]` cannot be indexed by `u32` | ||
| v[3i32]; //~ ERROR the type `[isize]` cannot be indexed by `i32` | ||
| s.as_bytes()[3_usize]; | ||
| s.as_bytes()[3]; | ||
| s.as_bytes()[3u8]; //~ ERROR the type `[u8]` cannot be indexed by `u8` | ||
| s.as_bytes()[3i8]; //~ ERROR the type `[u8]` cannot be indexed by `i8` | ||
| s.as_bytes()[3u8]; //~ ERROR the type `[u8]` cannot be indexed by `u8` | ||
| s.as_bytes()[3i8]; //~ ERROR the type `[u8]` cannot be indexed by `i8` | ||
| s.as_bytes()[3u32]; //~ ERROR the type `[u8]` cannot be indexed by `u32` | ||
| s.as_bytes()[3i32]; //~ ERROR the type `[u8]` cannot be indexed by `i32` | ||
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              This file was deleted.
      
      Oops, something went wrong.
      
    
  This file was deleted.
      
      Oops, something went wrong.
      
    
  This file was deleted.
      
      Oops, something went wrong.
      
    
  
        
          
          
            3 changes: 3 additions & 0 deletions
          
          3 
        
  ...ui/integral-variable-unification-error.rs → ...smatched_types/int-float-type-mismatch.rs
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
        
          
          
            2 changes: 1 addition & 1 deletion
          
          2 
        
  ...ntegral-variable-unification-error.stderr → ...ched_types/int-float-type-mismatch.stderr
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| //! Basic test for nested module functionality and path resolution | ||
|  | ||
| //@ run-pass | ||
|  | ||
| mod inner { | ||
| pub mod inner2 { | ||
| pub fn hello() { | ||
| println!("hello, modular world"); | ||
| } | ||
| } | ||
| pub fn hello() { | ||
| inner2::hello(); | ||
| } | ||
| } | ||
|  | ||
| pub fn main() { | ||
| inner::hello(); | ||
| inner::inner2::hello(); | ||
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| //! Originally, inner statics in generic functions were generated only once, causing the same | ||
| //! static to be shared across all generic instantiations. This created a soundness hole where | ||
| //! different types could be coerced through thread-local storage in safe code. | ||
| //! | ||
| //! This test checks that generic parameters from outer scopes cannot be used in inner statics, | ||
| //! preventing this soundness issue. | ||
| //! | ||
| //! See https://github.com/rust-lang/rust/issues/9186 | ||
|  | ||
| enum Bar<T> { | ||
| //~^ ERROR parameter `T` is never used | ||
| What, | ||
| } | ||
|  | ||
| fn foo<T>() { | ||
| static a: Bar<T> = Bar::What; | ||
| //~^ ERROR can't use generic parameters from outer item | ||
| } | ||
|  | ||
| fn main() {} | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
        
          
          
            48 changes: 32 additions & 16 deletions
          
          48 
        
  tests/ui/invalid_dispatch_from_dyn_impls.rs → ...traits/dispatch-from-dyn-invalid-impls.rs
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -1,55 +1,71 @@ | ||
| //! Test various invalid implementations of DispatchFromDyn trait. | ||
| //! | ||
| //! DispatchFromDyn is a special trait used by the compiler for dyn-compatible dynamic dispatch. | ||
| //! This checks that the compiler correctly rejects invalid implementations: | ||
| //! - Structs with extra non-coercible fields | ||
| //! - Structs with multiple pointer fields | ||
| //! - Structs with no coercible fields | ||
| //! - Structs with repr(C) or other incompatible representations | ||
| //! - Structs with over-aligned fields | ||
|  | ||
| #![feature(unsize, dispatch_from_dyn)] | ||
|  | ||
| use std::{ | ||
| ops::DispatchFromDyn, | ||
| marker::{Unsize, PhantomData}, | ||
| }; | ||
| use std::marker::{PhantomData, Unsize}; | ||
| use std::ops::DispatchFromDyn; | ||
|  | ||
| // Extra field prevents DispatchFromDyn | ||
| struct WrapperWithExtraField<T>(T, i32); | ||
|  | ||
| impl<T, U> DispatchFromDyn<WrapperWithExtraField<U>> for WrapperWithExtraField<T> | ||
| //~^ ERROR [E0378] | ||
| where | ||
| T: DispatchFromDyn<U>, | ||
| {} | ||
|  | ||
| T: DispatchFromDyn<U> | ||
| { | ||
| } | ||
|  | ||
| struct MultiplePointers<T: ?Sized>{ | ||
| // Multiple pointer fields create ambiguous coercion | ||
| struct MultiplePointers<T: ?Sized> { | ||
| ptr1: *const T, | ||
| ptr2: *const T, | ||
| } | ||
|  | ||
| impl<T: ?Sized, U: ?Sized> DispatchFromDyn<MultiplePointers<U>> for MultiplePointers<T> | ||
| //~^ ERROR implementing `DispatchFromDyn` does not allow multiple fields to be coerced | ||
| where | ||
| T: Unsize<U>, | ||
| {} | ||
|  | ||
| T: Unsize<U> | ||
| { | ||
| } | ||
|  | ||
| // No coercible fields (only PhantomData) | ||
| struct NothingToCoerce<T: ?Sized> { | ||
| data: PhantomData<T>, | ||
| } | ||
|  | ||
| impl<T: ?Sized, U: ?Sized> DispatchFromDyn<NothingToCoerce<T>> for NothingToCoerce<U> {} | ||
| //~^ ERROR implementing `DispatchFromDyn` requires a field to be coerced | ||
|  | ||
| // repr(C) is incompatible with DispatchFromDyn | ||
| #[repr(C)] | ||
| struct HasReprC<T: ?Sized>(Box<T>); | ||
|  | ||
| impl<T: ?Sized, U: ?Sized> DispatchFromDyn<HasReprC<U>> for HasReprC<T> | ||
| //~^ ERROR [E0378] | ||
| where | ||
| T: Unsize<U>, | ||
| {} | ||
| T: Unsize<U> | ||
| { | ||
| } | ||
|  | ||
| // Over-aligned fields are incompatible | ||
| #[repr(align(64))] | ||
| struct OverAlignedZst; | ||
|  | ||
| struct OverAligned<T: ?Sized>(Box<T>, OverAlignedZst); | ||
|  | ||
| impl<T: ?Sized, U: ?Sized> DispatchFromDyn<OverAligned<U>> for OverAligned<T> | ||
| //~^ ERROR [E0378] | ||
| where | ||
| T: Unsize<U>, | ||
| {} | ||
| where | ||
| T: Unsize<U> | ||
| { | ||
| } | ||
|  | ||
| fn main() {} | 
      
      Oops, something went wrong.
        
    
  
      
      Oops, something went wrong.
        
    
  
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Uh oh!
There was an error while loading. Please reload this page.