( LIST )[ LIST ] is called a list slice.
It returns the elements of the first list identified by the indexes returned by the second list.
say for ( 'A'..'Z' )[ 0, 1, 2, 25 ]; # A B C Z
That means that ( stat ... )[0] returns the first value returned by stat.
The builtin stat operator returns information about the file. It returns a number of values, the first is the device id of the file.
So, when using the builtin stat, ( stat $path )[0] returns the device id of the file specified by $path.
But you're not using the built stat. You're using the one from File::stat. In that situation the sub you posted doesn't do anything useful. It effectively does return 0 because it's comparing the memory addresses of two different objects. The following is adjusted for using File:stat's stat:
use File::stat;
sub rootdev { return ( stat readlink )->dev == ( stat "/" )->dev; }
or
use File::stat;
sub rootdev { return stat( readlink )->dev == stat( "/" )->dev; }
Finally, it's really weird that the sub requires that its input be provided using $_ instead of as an argument.